detailsPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList(0)">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <!-- <el-button class="el-button&#45;&#45;small-yh" style="margin-right: 10px" type="primary" size="small" v-if="!editButton"-->
  11. <!-- @click="confirmEditing">编辑-->
  12. <!-- </el-button>-->
  13. <el-button
  14. class="el-button--small-yh"
  15. type="primary"
  16. size="small"
  17. @click="editCustomer">保存数据
  18. </el-button>
  19. <el-button
  20. class="el-button--small-yh"
  21. type="primary"
  22. size="small"
  23. @click="generateOutbound">生成出库任务
  24. </el-button>
  25. </div>
  26. </div>
  27. <div style="margin-top: 50px">
  28. <trade-card title="基础信息">
  29. <avue-form :option="optionForm" v-model="form" ref="form"></avue-form>
  30. </trade-card>
  31. <trade-card title="明细信息">
  32. <el-tabs v-model="activeName" type="card">
  33. <el-tab-pane label="销售明细" name="sale_detail">
  34. <avue-crud :option="optionContacts"
  35. v-model="formContacts"
  36. ref="formContacts"
  37. :data="form.orderItemsList"
  38. :key="key"
  39. @row-save="rowSave"
  40. @row-update="rowUpdate"
  41. @resetColumn="resetColumnTwo('formContacts','optionContacts','optionContactsBack',269.1)"
  42. @saveColumn="saveColumnTwo('formContacts','optionContacts','optionContactsBack',269.1)">
  43. <template slot-scope="{type,size,row,index,disabled}" slot="menu">
  44. <el-button
  45. :size="size" :disabled="disabled" :type="type"
  46. :icon="row.$cellEdit?'el-icon-plus':'el-icon-edit'"
  47. @click="$refs.formContacts.rowEdit(row,index)"
  48. >编辑
  49. </el-button>
  50. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type"
  51. @click="rowDelBox(row,index,'orderItemsList')">删除
  52. </el-button>
  53. </template>
  54. </avue-crud>
  55. </el-tab-pane>
  56. <el-tab-pane label="支付明细" name="payment_details">
  57. <avue-crud :option="optionPaymentDetails" v-model="formContacts" ref="payment_details"
  58. :data="form.paymentRecordsList"
  59. @row-save="rowSave"
  60. @row-update="rowUpdate"
  61. @resetColumn="resetColumnTwo('payment_details','optionPaymentDetails','optionPaymentDetailsBack',269.2)"
  62. @saveColumn="saveColumnTwo('payment_details','optionPaymentDetails','optionPaymentDetailsBack',269.2)">
  63. <template slot-scope="{type,size,row,index,disabled}" slot="menu">
  64. <el-button
  65. :size="size" :disabled="disabled" :type="type"
  66. :icon="row.$cellEdit?'el-icon-plus':'el-icon-edit'"
  67. @click="$refs.formContacts.rowCell(row,index)"
  68. >{{ row.$cellEdit ? '确认' : '修改' }}
  69. </el-button>
  70. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type"
  71. @click="rowDelBox(row,index,'paymentRecordsList')">删除
  72. </el-button>
  73. </template>
  74. </avue-crud>
  75. </el-tab-pane>
  76. <el-tab-pane label="出库记录" name="outbound_records">
  77. <avue-crud :option="optionOutboundRecords" v-model="formContacts" ref="outbound_records"
  78. :data="form.outboundRecordsList"
  79. @row-save="rowSave"
  80. @row-update="rowUpdate"
  81. @resetColumn="resetColumnTwo('outbound_records','optionOutboundRecords','optionOutboundRecordsBack',269.3)"
  82. @saveColumn="saveColumnTwo('outbound_records','optionOutboundRecords','optionOutboundRecordsBack',269.3)">
  83. <template slot-scope="{type,size,row,index,disabled}" slot="menu">
  84. <el-button
  85. :size="size" :disabled="disabled" :type="type"
  86. :icon="row.$cellEdit?'el-icon-plus':'el-icon-edit'"
  87. @click="$refs.formContacts.rowCell(row,index)"
  88. >{{ row.$cellEdit ? '确认' : '修改' }}
  89. </el-button>
  90. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type"
  91. @click="rowDelBox(row,index)">删除
  92. </el-button>
  93. </template>
  94. </avue-crud>
  95. </el-tab-pane>
  96. </el-tabs>
  97. </trade-card>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import {getDetails, submit, generateShipTask, tradingBox} from "@/api/tirePartsMall/salesManagement/saleOrder";
  103. export default {
  104. name: "detailsPage",
  105. data() {
  106. return {
  107. activeName: "sale_detail",
  108. disabled: false,
  109. key: 0,
  110. form: {
  111. orderItemsList: [],
  112. paymentRecordsList: [],
  113. outboundRecordsList: []
  114. },
  115. optionForm: {
  116. menuBtn: false,
  117. span: 8,
  118. column: [{
  119. label: '客户',
  120. prop: "customerId",
  121. type: 'select',
  122. props: {
  123. label: 'cname',
  124. value: 'id'
  125. },
  126. cascader: ['recAddress'],
  127. change:(data)=>{
  128. if (this.$refs.form.DIC.customerId || data.value){
  129. for (let item of this.$refs.form.DIC.customerId){
  130. if (item.id == data.value){
  131. // 后端返回数据暂无联系人、地址等数据,无法下拉默认
  132. }
  133. }
  134. }
  135. },
  136. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?corpType=KH',
  137. rules: [{
  138. required: true,
  139. message: " ",
  140. trigger: "blur"
  141. }]
  142. }, {
  143. label: '仓库',
  144. prop: "storageId",
  145. type: 'select',
  146. props: {
  147. label: 'cname',
  148. value: 'id'
  149. },
  150. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  151. rules: [{
  152. required: true,
  153. message: " ",
  154. trigger: "blur"
  155. }]
  156. }, {
  157. label: '单据编号',
  158. prop: "ordNo",
  159. }, {
  160. label: '来源单号',
  161. prop: "srcOrdNo",
  162. disabled: true
  163. }, {
  164. label: '业务来源',
  165. prop: "businessSource",
  166. disabled: true
  167. }, {
  168. label: '应收类别',
  169. prop: "receivableType",
  170. type: "select",
  171. dicUrl: "/api/blade-system/dict-biz/dictionary?code=receivableType",
  172. props: {
  173. label: "dictValue",
  174. value: "dictValue"
  175. }
  176. }, {
  177. label: '联系人',
  178. prop: "contacts",
  179. }, {
  180. label: '电话',
  181. prop: "phone",
  182. }, {
  183. label: '收货地址',
  184. prop: "recAddress",
  185. type: 'select',
  186. props: {
  187. label: 'address',
  188. value: 'id'
  189. },
  190. dicUrl: '/api/blade-sales-part/corpsAddr/corpIdByAddr?pid={{key}}',
  191. rules: [{
  192. required: true,
  193. message: " ",
  194. trigger: "blur"
  195. }]
  196. }, {
  197. label: '配送方式',
  198. prop: "shipType",
  199. }, {
  200. label: '物流公司',
  201. prop: "logisticsCorpName"
  202. }, {
  203. label: '成本',
  204. prop: "cost"
  205. }, {
  206. label: '毛利',
  207. prop: "grossProfit"
  208. }, {
  209. label: '销售金额',
  210. prop: "salesAmount"
  211. }, {
  212. label: '运费',
  213. prop: "freight"
  214. }, {
  215. label: '总金额',
  216. prop: "totalMoney"
  217. }, {
  218. label: '备注',
  219. prop: "remarks",
  220. type: 'textarea',
  221. span: 16,
  222. minRows: 1
  223. }]
  224. },
  225. formContacts: {},
  226. optionContacts: {},
  227. optionContactsBack: {
  228. border: true,
  229. align: 'center',
  230. index: true,
  231. addBtnText: "录入明细",
  232. refreshBtn: false,
  233. dialogDrag: true,
  234. addBtn: true,
  235. span: 8,
  236. height: 500,
  237. addRowBtn: false,
  238. editBtn: false,
  239. delBtn: false,
  240. menuWidth: 140,
  241. dialogTop: 25,
  242. dialogWidth: "80%",
  243. // summaryText: "合计",
  244. // showSummary: true,
  245. // sumColumnList:[{
  246. // name: "goodsNum",
  247. // type: "sum",
  248. // decimals: 2
  249. // },{
  250. // name: "sendNum",
  251. // type: "sum",
  252. // decimals: 2
  253. // },{
  254. // name: "profit",
  255. // type: "sum",
  256. // decimals: 2
  257. // },{
  258. // name: "subTotalMoney",
  259. // type: "sum",
  260. // decimals: 2
  261. // },{
  262. // name: "thisAmount",
  263. // type: "sum",
  264. // decimals: 2
  265. // },{
  266. // name: "costprie",
  267. // type: "sum",
  268. // decimals: 2
  269. // },{
  270. // name: "grossProfit",
  271. // type: "sum",
  272. // decimals: 2
  273. // }],
  274. column: [{
  275. label: '物料编码',
  276. prop: 'goodsNo',
  277. overHidden: true,
  278. width: 100
  279. }, {
  280. label: '商品名称',
  281. prop: 'goodsId',
  282. width: 200,
  283. overHidden: true,
  284. type: 'select',
  285. props: {
  286. label: 'cname',
  287. value: 'id'
  288. },
  289. dicUrl: '/api/blade-sales-part/goodsDesc/goodsListAll'
  290. }, {
  291. label: '品牌',
  292. prop: 'brandId',
  293. width: 100,
  294. overHidden: true,
  295. type: 'select',
  296. props: {
  297. label: 'cname',
  298. value: 'id'
  299. },
  300. dicUrl: '/api/blade-sales-part/brandDesc/listAll'
  301. }, {
  302. label: '规格型号',
  303. prop: 'propertyName',
  304. overHidden: true,
  305. width: 100
  306. }, {
  307. label: '花纹',
  308. prop: 'pattern',
  309. overHidden: true,
  310. width: 100
  311. }, {
  312. label: '商品描述',
  313. prop: 'goodsDescription',
  314. overHidden: true,
  315. width: 100
  316. }, {
  317. label: '数量',
  318. prop: 'goodsNum',
  319. overHidden: true,
  320. width: 100
  321. }, {
  322. label: '单位',
  323. prop: 'units',
  324. type: "select",
  325. props: {
  326. label: "dictValue",
  327. value: "dictValue"
  328. },
  329. dicUrl: "/api/blade-system/dict-biz/dictionary?code=unit",
  330. overHidden: true,
  331. width: 100
  332. }, {
  333. label: '价格',
  334. prop: 'price',
  335. overHidden: true,
  336. width: 100
  337. }, {
  338. label: '发货数量',
  339. prop: 'sendNum',
  340. overHidden: true,
  341. width: 100
  342. }, {
  343. label: '毛利',
  344. prop: 'grossProfit',
  345. overHidden: true,
  346. width: 100
  347. }
  348. // , {
  349. // label: '利润',
  350. // prop: 'profit',
  351. // overHidden: true,
  352. // width: 100
  353. // }
  354. , {
  355. label: '小计',
  356. prop: 'subTotalMoney',
  357. overHidden: true,
  358. width: 100
  359. }, {
  360. label: '返利',
  361. prop: 'thisAmount',
  362. overHidden: true,
  363. width: 100
  364. }, {
  365. label: '成本',
  366. prop: 'costprie',
  367. overHidden: true,
  368. width: 100
  369. }]
  370. },
  371. optionPaymentDetails: {},
  372. optionPaymentDetailsBack: {
  373. align: 'center',
  374. index: true,
  375. addBtnText: "录入明细",
  376. refreshBtn: false,
  377. dialogDrag: true,
  378. addBtn: false,
  379. span: 8,
  380. height: 600,
  381. addRowBtn: false,
  382. editBtn: false,
  383. delBtn: false,
  384. menuWidth: 140,
  385. dialogTop: 25,
  386. dialogWidth: "80%",
  387. column: [{
  388. label: '支付编号',
  389. prop: 'paymentNumber',
  390. cell: true
  391. }, {
  392. label: '金额',
  393. prop: 'amount',
  394. cell: true
  395. }, {
  396. label: '类型',
  397. prop: 'paymentType',
  398. cell: true
  399. }, {
  400. label: '支付时间',
  401. prop: 'paymentTime',
  402. cell: true
  403. }]
  404. },
  405. optionOutboundRecords: {},
  406. optionOutboundRecordsBack: {
  407. align: 'center',
  408. index: true,
  409. addBtnText: "录入明细",
  410. refreshBtn: false,
  411. dialogDrag: true,
  412. addBtn: false,
  413. span: 8,
  414. height: 600,
  415. addRowBtn: false,
  416. editBtn: false,
  417. delBtn: false,
  418. menuWidth: 140,
  419. dialogTop: 25,
  420. dialogWidth: "80%",
  421. column: [{
  422. label: '出库单号',
  423. prop: 'attn',
  424. cell: true
  425. }, {
  426. label: '来源单号',
  427. prop: 'contractNumber',
  428. cell: true
  429. }, {
  430. label: '数量',
  431. prop: 'accountsAmount',
  432. cell: true
  433. }, {
  434. label: '状态',
  435. prop: 'settlmentAmount',
  436. cell: true
  437. }, {
  438. label: '业务时间',
  439. prop: 'settlmentAmount',
  440. cell: true
  441. }]
  442. }
  443. }
  444. },
  445. props: {
  446. onLoad: Object,
  447. detailData: Object
  448. },
  449. async created() {
  450. this.optionContacts = await this.getColumnData(this.getColumnName(269.1), this.optionContactsBack);
  451. this.optionPaymentDetails = await this.getColumnData(this.getColumnName(269.2), this.optionPaymentDetailsBack);
  452. this.optionOutboundRecords = await this.getColumnData(this.getColumnName(269.2), this.optionOutboundRecordsBack);
  453. this.key++
  454. if (this.onLoad.id && this.detailData.id) {
  455. this.refresh(this.onLoad.id, true)
  456. } else if (this.onLoad.id) {
  457. this.refresh(this.onLoad.id, true)
  458. }
  459. },
  460. methods: {
  461. generateOutbound() {
  462. this.$refs["form"].validate((valid, done) => {
  463. done();
  464. if (valid) {
  465. const loading = this.$loading({
  466. lock: true,
  467. text: '加载中',
  468. spinner: 'el-icon-loading',
  469. background: 'rgba(255,255,255,0.7)'
  470. });
  471. generateShipTask(this.form).then(res=>{
  472. this.$message.success("生成出库任务成功");
  473. loading.close();
  474. }).finally(() => {
  475. loading.close();
  476. });
  477. }
  478. })
  479. },
  480. //修改提交触发
  481. editCustomer() {
  482. this.$refs["form"].validate((valid, done) => {
  483. done();
  484. if (valid) {
  485. const loading = this.$loading({
  486. lock: true,
  487. text: '加载中',
  488. spinner: 'el-icon-loading',
  489. background: 'rgba(255,255,255,0.7)'
  490. });
  491. submit({
  492. bsType: "XS",
  493. ...this.form
  494. }).then(res => {
  495. this.$message.success("保存成功");
  496. this.refresh(res.data.data.id)
  497. loading.close();
  498. }).finally(() => {
  499. loading.close();
  500. });
  501. } else {
  502. return false;
  503. }
  504. });
  505. },
  506. refresh(id, type) {
  507. const loading = this.$loading({
  508. lock: true,
  509. text: '加载中',
  510. spinner: 'el-icon-loading',
  511. background: 'rgba(255,255,255,0.7)'
  512. })
  513. getDetails({id: id}).then(res => {
  514. this.form = res.data.data
  515. loading.close();
  516. }).catch(() => {
  517. loading.close();
  518. })
  519. },
  520. rowDelBox(row, index, type) {
  521. this.$confirm("确定将选择数据删除?", {
  522. confirmButtonText: "确定",
  523. cancelButtonText: "取消",
  524. type: "warning"
  525. }).then(() => {
  526. if (row.id) {
  527. tradingBox(row.id).then(res => {
  528. this.form.contactsList.splice(index, 1);
  529. this.$message.success("操作成功!");
  530. });
  531. } else {
  532. this.form[type].splice(index, 1);
  533. this.$message.success("操作成功!");
  534. }
  535. }
  536. );
  537. },
  538. rowSave(form, done, loading) {
  539. done(form)
  540. },
  541. rowUpdate(form, index, done, loading) {
  542. done(form)
  543. },
  544. //自定义列保存
  545. async saveColumnTwo(ref, option, optionBack, code) {
  546. /**
  547. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  548. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  549. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  550. */
  551. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  552. if (inSave) {
  553. this.$message.success("保存成功");
  554. //关闭窗口
  555. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  556. }
  557. },
  558. //自定义列重置
  559. async resetColumnTwo(ref, option, optionBack, code) {
  560. this[option] = this[optionBack];
  561. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  562. if (inSave) {
  563. this.$message.success("重置成功");
  564. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  565. }
  566. },
  567. backToList(type) {
  568. this.$emit("backToList", type);
  569. }
  570. }
  571. }
  572. </script>
  573. <style lang="scss" scoped>
  574. ::v-deep .el-form-item {
  575. margin-bottom: 8px !important;
  576. }
  577. </style>