attachmentSalesOrderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="s-page">
  3. <el-page-header @back="goBack" :content="title"></el-page-header>
  4. <el-divider></el-divider>
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>单据信息</span>
  8. </div>
  9. <div class="mymain-container">
  10. <el-form ref="formData" :rules="rules" :model="formData" label-width="110px" size="small" label-position="left">
  11. <el-row :gutter="20" justify="start">
  12. <el-col :span="8" v-if="id">
  13. <el-form-item label="单据状态">
  14. <el-input type="text" :value="formData.flag == 'SAVE'?'已保存':formData.flag == 'SUBMIT'?'已提交':formData.flag == 'CANCEL'?'取消订单':formData.flag == 'PAY_NOT_TAKE'?'已支付,未提货':formData.flag == 'PAY_TAKE'?'已支付,已提货':''" disabled></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="8" v-if="id">
  18. <el-form-item label="单据编号">
  19. <el-input type="text" :value="formData.salesId" disabled></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="所属商户" :required="true" >
  24. <el-input type="text" :value="companyName" disabled></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="12">
  28. <el-form-item label="网点名称" prop="websitId" :required="true">
  29. <el-select v-model="formData.websit" :disabled="formType == 2" value-key="websitId" @change="changeWebsit" placeholder="请选择" style="width: 100%;">
  30. <el-option
  31. v-for="item in websitList"
  32. :key="item.websitId"
  33. :label="item.name"
  34. :value="item">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="师傅姓名" prop="worker" :required="true">
  41. <el-select v-model="formData.worker" :disabled="formType == 2" value-key="nickName" @focus="()=>{
  42. if(!this.formData.websitId){return this.$message.warning('请先选择网点名称!');}
  43. }" filterable @change="changeWorker" @blur="workerBlur" placeholder="请选择" style="width: 100%;">
  44. <el-option
  45. v-for="item in workerList"
  46. :key="item.id"
  47. :label="item.nickName"
  48. :value="item">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="师傅身份证" prop="identity" :required="true">
  55. <el-input type="text" v-model="formData.identity" :disabled="formType == 2" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="师傅联系电话" prop="workerMobile" :required="true">
  60. <el-input type="text" v-model="formData.workerMobile" :disabled="formType == 2" placeholder="请输入"></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6" v-if="id">
  64. <el-form-item label="单据金额">
  65. <el-input type="text" :value="formData.totalAmount" disabled></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6" v-if="id">
  69. <el-form-item label="制单人">
  70. <el-input type="text" :value="formData.createBy" disabled></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6" v-if="id">
  74. <el-form-item label="制单时间">
  75. <el-input type="text" :value="formData.createTime" disabled></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6" v-if="id">
  79. <el-form-item label="审核人">
  80. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="6" v-if="id">
  84. <el-form-item label="审核时间">
  85. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12">
  89. <el-form-item label="订单来源" prop="source" :required="true">
  90. <el-select v-model="formData.source" :disabled="true" placeholder="请选择" style="width: 100%;">
  91. <el-option
  92. v-for="item in [{name: '在线订单',id: 'ONLINE'},{name: '自建订单',id: 'SELF'}]"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="9">
  101. <el-form-item label="支付方式" prop="payType" :required="true">
  102. <el-select v-model="formData.payType" :disabled="formType == 2" placeholder="请选择" style="width: 100%;">
  103. <el-option
  104. v-for="item in [{name: '现金',id: 'CASH'},{name: '微信',id: 'WECHAT'}]"
  105. :key="item.id"
  106. :label="item.name"
  107. :value="item.id">
  108. </el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="3" v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'">
  113. <div style="height: 32px;display: flex;align-items: center;cursor: pointer;" @click="wxPay()">微信支付<i class="el-icon-full-screen"></i></div>
  114. </el-col>
  115. <el-col :span="24">
  116. <el-form-item label="备注">
  117. <el-input type="textarea" :rows="4" v-model="formData.remark" :disabled="formType == 2" placeholder="请输入"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </el-form>
  122. </div>
  123. </el-card>
  124. <el-card class="box-card">
  125. <div slot="header" class="clearfix">
  126. <span>配件信息</span>
  127. </div>
  128. <el-button size="small" v-if="formData.flag == 'SAVE' || formType==0" type="primary" @click="add()">添加</el-button>
  129. <div class="table">
  130. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  131. <el-table-column label="配件名称" align="center">
  132. <template slot-scope="scope">
  133. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  134. <el-option
  135. v-for="item in scope.row.goodsList"
  136. :key="item.goodsId"
  137. :label="item.goodsName"
  138. :value="item">
  139. </el-option>
  140. </el-select>
  141. </template>
  142. </el-table-column>
  143. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  144. <el-table-column prop="" align="center" label="数量" >
  145. <template slot-scope="scope">
  146. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  147. </template>
  148. </el-table-column>
  149. <el-table-column prop="goods.goodsCode" align="center" label="配件编码"></el-table-column>
  150. <el-table-column prop="goods.brandRelaName" align="center" label="适用品牌"></el-table-column>
  151. <el-table-column prop="goods.productRelaName" align="center" label="适用产品大类"></el-table-column>
  152. <el-table-column prop="goods.price" align="center" label="销售价格"></el-table-column>
  153. <el-table-column prop="goods.saleAmount" align="center" label="销售金额" >
  154. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.goods && scope.row.goods.price">
  155. {{(scope.row.goods.price * 100) * scope.row.salesQty / 100}}
  156. </template>
  157. </el-table-column>
  158. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  159. <el-table-column label="操作" align="right" width="140">
  160. <template slot-scope="scope" v-if="formType != 2">
  161. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  162. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. </div>
  167. </el-card>
  168. <div class="page-footer">
  169. <div class="footer">
  170. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  171. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  172. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  173. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  174. <el-button size="small" type="info" @click="goBack">返回</el-button>
  175. </div>
  176. </div>
  177. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  178. <h3 style="text-align: center;">扫二维码支付</h3>
  179. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  180. <div
  181. ref="payQRCode"
  182. style="display: flex; justify-content: center;"
  183. />
  184. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  185. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  186. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  187. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  188. </div>
  189. </el-dialog>
  190. </div>
  191. </template>
  192. <script>
  193. import { getWebsit } from "@/api/customerManagement";
  194. import QRCode from "qrcodejs2";
  195. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  196. export default {
  197. props: ['id','title','formType'],
  198. data() {
  199. return {
  200. dataList: [],
  201. websitList: [],
  202. workerList: [],
  203. isPay: false,
  204. is_submit: true,
  205. payCodeUrl: '',
  206. formData: {
  207. websit: {},
  208. websitId: '',
  209. websitName: '',
  210. file_url: [],
  211. salesId: '',
  212. flag: '',
  213. createBy: '',
  214. createTime: '',
  215. confirmBy: '',
  216. confirmTime: '',
  217. worker: {},
  218. workerName: '',
  219. workerId: '',
  220. identity: '',
  221. workerMobile: '',
  222. source: 'SELF',
  223. payType: '',
  224. totalAmount: '',
  225. remark: ''
  226. },
  227. isEdit: 0,
  228. timer: '',
  229. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  230. rules: {
  231. websitId: [
  232. { required: true, message: '请选择网点', trigger: 'change' }
  233. ],
  234. worker: [
  235. { required: true, message: '请选择师傅', trigger: 'change' }
  236. ],
  237. source: [
  238. { required: true, message: '请选择订单来源', trigger: 'change' }
  239. ],
  240. payType: [
  241. { required: true, message: '请选择订单来源', trigger: 'change' }
  242. ],
  243. identity: [
  244. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  245. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  246. ],
  247. workerMobile: [
  248. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  249. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  250. ],
  251. }
  252. };
  253. },
  254. computed: {},
  255. created() {
  256. if(this.id){
  257. this.getDetail()
  258. }
  259. this.getWebsit()
  260. },
  261. methods: {
  262. // 返回
  263. goBack() {
  264. this.$emit('back');
  265. },
  266. async getDetail(){
  267. const that = this
  268. getDetail({salesId: this.id}).then(async res => {
  269. Object.assign(this.formData, res.data, {
  270. websit: {websitId: res.data.websitId,name: res.data.websitName},
  271. worker: {nickName: res.data.workerName,userId: res.data.workerId}
  272. })
  273. this.getWorker()
  274. for(var item of res.data.items){
  275. var ress = await that.getGoods(item.goodsName, 1)
  276. item.goods = {...ress.data,oldPrice:ress.data.price}
  277. item.goodsList = ress.data ? [{...ress.data,oldPrice:ress.data.price}] : []
  278. }
  279. this.dataList = res.data.items
  280. })
  281. },
  282. getWebsit(){
  283. getWebsit({type: 'C'}).then(res => {
  284. this.websitList = res.data
  285. })
  286. },
  287. changeWebsit(e){
  288. this.formData.websitId = e.websitId
  289. this.formData.websitName = e.name
  290. this.getWorker()
  291. },
  292. async getGoods(goodsName,type){
  293. const that = this
  294. if(type == 1){
  295. return new Promise((resolve, reject) => {
  296. getGoods({websitId: this.formData.websitId,type: 'P',goodsName: goodsName}).then(res => {
  297. resolve({
  298. data: res.data[0]
  299. })
  300. })
  301. })
  302. }else{
  303. getGoods({websitId: this.formData.websitId,type: 'P'}).then(res => {
  304. that.dataList[that.isEdit].goodsList = res.data
  305. console.log(this.dataList)
  306. })
  307. }
  308. },
  309. getWorker(){
  310. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  311. this.workerList = res.data.records
  312. })
  313. },
  314. changeWorker(e){
  315. this.formData.identity = e.idCard
  316. this.formData.workerMobile = e.mobile
  317. this.formData.workerId = e.userId
  318. this.formData.workerName = e.nickName
  319. },
  320. workerBlur(e){
  321. this.formData.worker = e.target.value
  322. this.$forceUpdate()
  323. },
  324. changeGoods(e){
  325. console.log(e)
  326. this.dataList[this.isEdit].goodsId = e.goodsId
  327. this.dataList[this.isEdit].goodsName = e.goodsName
  328. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  329. this.dataList[this.isEdit].brandRelaName = e.brandRelaName
  330. this.dataList[this.isEdit].productRelaName = e.productRelaName
  331. this.dataList[this.isEdit].price = e.price
  332. this.dataList[this.isEdit].goodsCode = e. goodsCode
  333. this.dataList[this.isEdit].qty = e.qty
  334. },
  335. add(){
  336. if(this.dataList.length != 0){this.isEdit += 1}
  337. this.dataList.push({
  338. goodsList: [],
  339. goods: {},
  340. goodsId: '',
  341. goodsName: '',
  342. goodsSalesUnit: '',
  343. brandRelaName: '',
  344. productRelaName: '',
  345. goodsCode: '',
  346. price: '',
  347. saleAmount: '',
  348. salesQty: 1,
  349. qty: '',
  350. goodsType: 'P'
  351. })
  352. this.getGoods()
  353. },
  354. submit(){
  355. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  356. confirmButtonText: '确定',
  357. cancelButtonText: '取消',
  358. type: 'warning'
  359. }).then(() => {
  360. submit({
  361. salesId: this.formData.salesId
  362. }).then(res => {
  363. if(res.code == 200){
  364. this.$message.success('提交成功!')
  365. if(this.formData.payType == 'WECHAT'){
  366. this.wxPay()
  367. }else{
  368. this.goBack()
  369. }
  370. }
  371. })
  372. });
  373. },
  374. confirm(){
  375. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  376. confirmButtonText: '确定',
  377. cancelButtonText: '取消',
  378. type: 'warning'
  379. }).then(() => {
  380. confirm({
  381. salesId: this.formData.salesId
  382. }).then(res => {
  383. if(res.code == 200){
  384. this.$message.success('审核成功!')
  385. this.goBack()
  386. }
  387. })
  388. });
  389. },
  390. checkPay(){
  391. this.timer = setInterval(()=>{
  392. getDetail({salesId: this.id}).then(res => {
  393. if(res.data.payFlag == 'YES'){
  394. this.clear()
  395. this.$message.success('支付成功!')
  396. this.goBack()
  397. }
  398. })
  399. },3000)
  400. },
  401. clear(){
  402. clearInterval(this.timer)
  403. },
  404. wxPay(){
  405. if(!this.is_submit){
  406. return false
  407. }
  408. this.is_submit = false
  409. setTimeout(()=>{
  410. this.is_submit = true
  411. },3000)
  412. getCode({
  413. salesId: this.formData.salesId
  414. }).then(res => {
  415. if(res.code == 200){
  416. this.payCodeUrl = res.data.codeUrl
  417. this.isPay = true
  418. this.$nextTick(() => {
  419. this.payUrl = res.data.codeUrl;
  420. new QRCode(this.$refs.payQRCode, {
  421. text: res.data.codeUrl,
  422. width: 200,
  423. height: 200,
  424. colorDark: "#333333", // 二维码颜色
  425. colorLight: "#ffffff", // 二维码背景色
  426. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  427. });
  428. this.checkPay()
  429. });
  430. }
  431. })
  432. },
  433. save(){
  434. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  435. if (valid) {
  436. if(this.formType == 0){
  437. add({
  438. goodsType: 'P',
  439. source: this.formData.source,
  440. payType: this.formData.payType,
  441. remark: this.formData.remark,
  442. websitId: this.formData.websitId,
  443. websitName: this.formData.websitName,
  444. workerName: this.formData.workerName,
  445. workerId: this.formData.workerId,
  446. identity: this.formData.identity,
  447. workerMobile: this.formData.workerMobile,
  448. items: this.dataList
  449. }).then(res => {
  450. if(res.code == 200){
  451. this.$message.success('提交成功!')
  452. this.goBack()
  453. }
  454. })
  455. }else if(this.formType == 1){
  456. edit({
  457. salesId: this.formData.salesId,
  458. goodsType: 'P',
  459. source: this.formData.source,
  460. payType: this.formData.payType,
  461. remark: this.formData.remark,
  462. websitId: this.formData.websitId,
  463. websitName: this.formData.websitName,
  464. workerName: this.formData.workerName,
  465. workerId: this.formData.workerId,
  466. identity: this.formData.identity,
  467. workerMobile: this.formData.workerMobile,
  468. items: this.dataList
  469. }).then(res => {
  470. if(res.code == 200){
  471. this.dataList = []
  472. this.$message.success('提交成功!')
  473. this.goBack()
  474. }
  475. })
  476. }
  477. }
  478. })
  479. }
  480. }
  481. };
  482. </script>
  483. <style scoped="scoped" lang="scss">
  484. .s-page {
  485. padding: 20px;
  486. background-color: #ffffff;
  487. }
  488. .page-footer {
  489. height: 70px;
  490. }
  491. .footer {
  492. position: fixed;
  493. bottom: 0;
  494. left: 0;
  495. z-index: 1;
  496. width: 100%;
  497. background: #fff;
  498. padding: 15px 40px;
  499. box-sizing: border-box;
  500. transition: all 0.28s;
  501. text-align: right;
  502. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  503. &.hideSidebar {
  504. margin-left: 54px;
  505. width: calc(100vw - 54px);
  506. }
  507. &.openSidebar {
  508. margin-left: 210px;
  509. width: calc(100vw - 210px);
  510. }
  511. .tips {
  512. font-size: 12px;
  513. color: red;
  514. margin-top: 10px;
  515. }
  516. }
  517. </style>