detailsPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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: 'dot',
  335. overHidden: true,
  336. width: 100
  337. }, {
  338. label: '价格',
  339. prop: 'price',
  340. overHidden: true,
  341. width: 100
  342. }, {
  343. label: '发货数量',
  344. prop: 'sendNum',
  345. overHidden: true,
  346. width: 100
  347. }, {
  348. label: '毛利',
  349. prop: 'grossProfit',
  350. overHidden: true,
  351. width: 100
  352. }
  353. // , {
  354. // label: '利润',
  355. // prop: 'profit',
  356. // overHidden: true,
  357. // width: 100
  358. // }
  359. , {
  360. label: '小计',
  361. prop: 'subTotalMoney',
  362. overHidden: true,
  363. width: 100
  364. }, {
  365. label: '返利',
  366. prop: 'thisAmount',
  367. overHidden: true,
  368. width: 100
  369. }, {
  370. label: '成本',
  371. prop: 'costprie',
  372. overHidden: true,
  373. width: 100
  374. }]
  375. },
  376. optionPaymentDetails: {},
  377. optionPaymentDetailsBack: {
  378. align: 'center',
  379. index: true,
  380. addBtnText: "录入明细",
  381. refreshBtn: false,
  382. dialogDrag: true,
  383. addBtn: false,
  384. span: 8,
  385. height: 600,
  386. addRowBtn: false,
  387. editBtn: false,
  388. delBtn: false,
  389. menuWidth: 140,
  390. dialogTop: 25,
  391. dialogWidth: "80%",
  392. column: [{
  393. label: '支付编号',
  394. prop: 'paymentNumber'
  395. }, {
  396. label: '金额',
  397. prop: 'amount'
  398. }, {
  399. label: '类型',
  400. prop: 'paymentType'
  401. }, {
  402. label: '支付时间',
  403. prop: 'paymentTime'
  404. }]
  405. },
  406. optionOutboundRecords: {},
  407. optionOutboundRecordsBack: {
  408. align: 'center',
  409. index: true,
  410. addBtnText: "录入明细",
  411. refreshBtn: false,
  412. dialogDrag: true,
  413. addBtn: false,
  414. span: 8,
  415. height: 600,
  416. addRowBtn: false,
  417. editBtn: false,
  418. delBtn: false,
  419. menuWidth: 140,
  420. dialogTop: 25,
  421. dialogWidth: "80%",
  422. column: [{
  423. label: '出库单号',
  424. prop: 'billno'
  425. }, {
  426. label: '来源单号',
  427. prop: 'ordNo'
  428. }, {
  429. label: '数量',
  430. prop: 'goodsTotalNum'
  431. }, {
  432. label: '状态',
  433. prop: 'statusName'
  434. }, {
  435. label: '业务时间',
  436. prop: 'createTime'
  437. }]
  438. }
  439. }
  440. },
  441. props: {
  442. onLoad: Object,
  443. detailData: Object
  444. },
  445. async created() {
  446. this.optionContacts = await this.getColumnData(this.getColumnName(269.1), this.optionContactsBack);
  447. this.optionPaymentDetails = await this.getColumnData(this.getColumnName(269.2), this.optionPaymentDetailsBack);
  448. this.optionOutboundRecords = await this.getColumnData(this.getColumnName(269.3), this.optionOutboundRecordsBack);
  449. this.key++
  450. if (this.onLoad.id && this.detailData.id) {
  451. this.refresh(this.onLoad.id, true)
  452. } else if (this.onLoad.id) {
  453. this.refresh(this.onLoad.id, true)
  454. }
  455. },
  456. methods: {
  457. generateOutbound() {
  458. this.$refs["form"].validate((valid, done) => {
  459. done();
  460. if (valid) {
  461. const loading = this.$loading({
  462. lock: true,
  463. text: '加载中',
  464. spinner: 'el-icon-loading',
  465. background: 'rgba(255,255,255,0.7)'
  466. });
  467. generateShipTask(this.form).then(res=>{
  468. this.$message.success("生成出库任务成功");
  469. loading.close();
  470. }).finally(() => {
  471. loading.close();
  472. });
  473. }
  474. })
  475. },
  476. //修改提交触发
  477. editCustomer() {
  478. this.$refs["form"].validate((valid, done) => {
  479. done();
  480. if (valid) {
  481. const loading = this.$loading({
  482. lock: true,
  483. text: '加载中',
  484. spinner: 'el-icon-loading',
  485. background: 'rgba(255,255,255,0.7)'
  486. });
  487. submit({
  488. bsType: "XS",
  489. ...this.form
  490. }).then(res => {
  491. this.$message.success("保存成功");
  492. this.refresh(res.data.data.id)
  493. loading.close();
  494. }).finally(() => {
  495. loading.close();
  496. });
  497. } else {
  498. return false;
  499. }
  500. });
  501. },
  502. refresh(id, type) {
  503. const loading = this.$loading({
  504. lock: true,
  505. text: '加载中',
  506. spinner: 'el-icon-loading',
  507. background: 'rgba(255,255,255,0.7)'
  508. })
  509. getDetails({id: id}).then(res => {
  510. this.form = res.data.data
  511. loading.close();
  512. }).catch(() => {
  513. loading.close();
  514. })
  515. },
  516. rowDelBox(row, index, type) {
  517. this.$confirm("确定将选择数据删除?", {
  518. confirmButtonText: "确定",
  519. cancelButtonText: "取消",
  520. type: "warning"
  521. }).then(() => {
  522. if (row.id) {
  523. tradingBox(row.id).then(res => {
  524. this.form.contactsList.splice(index, 1);
  525. this.$message.success("操作成功!");
  526. });
  527. } else {
  528. this.form[type].splice(index, 1);
  529. this.$message.success("操作成功!");
  530. }
  531. }
  532. );
  533. },
  534. rowSave(form, done, loading) {
  535. done(form)
  536. },
  537. rowUpdate(form, index, done, loading) {
  538. done(form)
  539. },
  540. //自定义列保存
  541. async saveColumnTwo(ref, option, optionBack, code) {
  542. /**
  543. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  544. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  545. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  546. */
  547. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  548. if (inSave) {
  549. this.$message.success("保存成功");
  550. //关闭窗口
  551. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  552. }
  553. },
  554. //自定义列重置
  555. async resetColumnTwo(ref, option, optionBack, code) {
  556. this[option] = this[optionBack];
  557. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  558. if (inSave) {
  559. this.$message.success("重置成功");
  560. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  561. }
  562. },
  563. backToList(type) {
  564. this.$emit("backToList", type);
  565. }
  566. }
  567. }
  568. </script>
  569. <style lang="scss" scoped>
  570. ::v-deep .el-form-item {
  571. margin-bottom: 8px !important;
  572. }
  573. </style>