detailsPageEdit.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <div class="borderless">
  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">返回列表
  7. </el-button>
  8. </div>
  9. <div class="upper_right_button">
  10. <el-button type="primary"
  11. size="small"
  12. v-if="viewDisabled"
  13. class="el-button--small-yh "
  14. :loading="buttonLoading"
  15. @click.stop="openEdit()">编辑
  16. </el-button>
  17. <el-button type="primary"
  18. size="small"
  19. :loading="buttonLoading"
  20. class="el-button--small-yh"
  21. :disabled="!form.id || viewDisabled"
  22. @click.stop="confirmGoods">
  23. {{goodsDisable ? "撤回发货":"确认发货"}}
  24. </el-button>
  25. <el-dropdown style="padding: 0 8px;line-height: 0">
  26. <el-button
  27. type="success"
  28. :loading="buttonLoading"
  29. :disabled="!form.id || viewDisabled"
  30. size="small"
  31. >
  32. 业务处理<i class="el-icon-arrow-down el-icon--right"></i>
  33. </el-button>
  34. <el-dropdown-menu slot="dropdown">
  35. <el-dropdown-item
  36. :loading="buttonLoading"
  37. :disabled="!form.id || viewDisabled"
  38. @click.native="createData()">创建单据
  39. </el-dropdown-item>
  40. <el-dropdown-item
  41. :loading="buttonLoading"
  42. :disabled="!form.id || viewDisabled"
  43. @click.native="copyData()">复制单据
  44. </el-dropdown-item>
  45. </el-dropdown-menu>
  46. </el-dropdown>
  47. <el-button
  48. class="el-button--small-yh"
  49. type="primary"
  50. size="small"
  51. :loading="buttonLoading"
  52. :disabled="disabled || goodsDisable || viewDisabled"
  53. @click="editCustomer"
  54. >保存数据
  55. </el-button>
  56. </div>
  57. </div>
  58. <div class="customer-main">
  59. <el-form :model="form" ref="form" label-width="130px" class="demo-ruleForm">
  60. <containerTitle title="基础信息"></containerTitle>
  61. <basic-container style="margin-bottom: 10px">
  62. <el-row>
  63. <el-col v-for="(item,index) in basicData.column" :key="index" :span="item.span?item.span:8">
  64. <el-form-item :label="item.label" :prop="item.prop" :rules="item.rules">
  65. <el-date-picker v-if="item.type === 'datetime'" style="width: 100%;" v-model="form[item.prop]" :disabled="goodsDisable || viewDisabled" size="small" type="date" placeholder="请选择日期" value-format="yyyy-MM-dd HH:mm:ss"/>
  66. <crop-select
  67. v-else-if="item.prop === 'corpId'"
  68. v-model="form[item.prop]"
  69. corpType="KH"
  70. :disabled="viewDisabled || goodsDisable"
  71. style="width: 100%"
  72. ></crop-select>
  73. <el-select v-else-if="item.prop === 'storageId'" style="width: 100%" :disabled="goodsDisable || viewDisabled" @change="warehouseChange" v-model="form[item.prop]" size="small" placeholder="请选择" clearable filterable>
  74. <el-option v-for="(item,index) in storageList" :key="index" :label="item.stockName" :value="item.storageId"></el-option>
  75. </el-select>
  76. <el-input type="textarea" v-else-if="(item.prop === 'deliveryRemarks')" :disabled="goodsDisable || viewDisabled" v-model="form[item.prop]" size="small" autocomplete="off" placeholder="请输入"></el-input>
  77. <el-input type="age" v-else v-model="form[item.prop]" :disabled="item.disabled?true:false || goodsDisable || viewDisabled" placeholder="请输入" size="small" autocomplete="off"></el-input>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </basic-container>
  82. <containerTitle title="发货明细"></containerTitle>
  83. <basic-container style="margin-bottom: 10px">
  84. <avue-crud
  85. :option="customerContact"
  86. v-model="contactsForm"
  87. :data="contactsData"
  88. ref="crudContact"
  89. @row-save="rowSave"
  90. @row-click="handleRowClick"
  91. @row-update="rowUpdate"
  92. @saveColumn="saveColumn"
  93. @resetColumn="resetColumn"
  94. @row-del="rowDel"
  95. >
  96. <template slot-scope="{row}" slot="billNo">
  97. <span v-if="row.$cellEdit" class="required_fields">*</span>
  98. <el-input
  99. v-if="row.$cellEdit"
  100. v-model="row.billNo"
  101. style="width: 90%"
  102. placeholder=" "
  103. size="small"
  104. @change="bingOut(row)"
  105. ></el-input>
  106. <span v-else>{{ row.billNo }}</span>
  107. </template>
  108. <template slot-scope="{row}" slot="contractNumber">
  109. <span v-if="row.$cellEdit" class="required_fields">*</span>
  110. <el-select
  111. v-if="row.$cellEdit"
  112. style="width:90% !important;"
  113. v-model="row.contractNumber"
  114. placeholder=" "
  115. size="small"
  116. clearable
  117. filterable
  118. >
  119. <el-option
  120. style="width:90%"
  121. @change="sumOrderNo(row)"
  122. v-for="(item,index) in contractDic"
  123. :key="index"
  124. :label="item.orderNo"
  125. :value="item.orderNo"
  126. ></el-option>
  127. </el-select>
  128. <span v-else>{{ row.contractNumber }}</span>
  129. </template>
  130. <template slot="priceCategory" slot-scope="{row,index}">
  131. <span v-if="row.$cellEdit" class="required_fields">*</span>
  132. <goods-select
  133. v-if="row.$cellEdit"
  134. style="width:90%"
  135. v-model="row.priceCategoryNames"
  136. @valueName="(value) => valueName(value,row)"
  137. :configuration="itemConfiguration"
  138. >
  139. </goods-select>
  140. <span v-else>{{ row.priceCategoryNames }}</span>
  141. </template>
  142. <template slot="invoiceWeight" slot-scope="{ row }">
  143. <span v-if="row.$cellEdit" class="required_fields">*</span>
  144. <el-input
  145. style="width:90%"
  146. v-if="row.$cellEdit"
  147. v-model="row.invoiceWeight"
  148. placeholder="请输入"
  149. size="small"
  150. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  151. @change="totalChange(row.invoiceWeight)"
  152. ></el-input>
  153. <span v-else>{{ row.invoiceWeight }}</span>
  154. </template>
  155. <template slot="billWeight" slot-scope="{ row }">
  156. <el-input
  157. v-if="row.$cellEdit"
  158. v-model="row.billWeight"
  159. placeholder="请输入"
  160. size="small"
  161. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  162. @input="billWeightChange(row)"
  163. @change="totalChange(row.billWeight)"
  164. ></el-input>
  165. <span v-else>{{ row.billWeight }}</span>
  166. </template>
  167. <template slot="price" slot-scope="{ row }">
  168. <el-input
  169. v-if="row.$cellEdit"
  170. v-model="row.price"
  171. placeholder="请输入"
  172. size="small"
  173. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  174. @input="priceChange(row)"
  175. ></el-input>
  176. <span v-else>{{ row.price }}</span>
  177. </template>
  178. <template slot="actualQuantity" slot-scope="{ row }">
  179. <span v-if="row.$cellEdit" class="required_fields">*</span>
  180. <el-input
  181. v-if="row.$cellEdit"
  182. v-model="row.actualQuantity"
  183. style="width: 90%"
  184. placeholder="请输入"
  185. size="small"
  186. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  187. ></el-input>
  188. <span v-else>{{ row.actualQuantity | roundNumbers}}</span>
  189. </template>
  190. <template slot="contractAmount" slot-scope="{ row }">
  191. <el-input
  192. v-if="row.$cellEdit"
  193. v-model="row.contractAmount"
  194. placeholder="请输入"
  195. size="small"
  196. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  197. ></el-input>
  198. <span v-else>{{ row.contractAmount }}</span>
  199. </template>
  200. <template slot="cntrNo" slot-scope="{ row }">
  201. <span v-if="row.$cellEdit" class="required_fields">*</span>
  202. <el-select v-if="row.$cellEdit"
  203. v-model="row.cntrNo"
  204. style="width:90% !important;"
  205. size="small"
  206. placeholder="请选择"
  207. @change="selectInventory(row)"
  208. clearable
  209. filterable>
  210. <el-option v-for="(item,index) in cntrNoList"
  211. :key="index"
  212. :label="item.cntrNo"
  213. :value="item.cntrNo"
  214. >
  215. </el-option>
  216. </el-select>
  217. <span v-else>{{ row.cntrNo }}</span>
  218. </template>
  219. <template slot-scope="{row,index}" slot="menu">
  220. <el-button
  221. type="text"
  222. size="small"
  223. :disabled="goodsDisable || viewDisabled"
  224. @click="rowCell(row,index)"
  225. >{{ row.$cellEdit ? '保存' : '修改' }}
  226. </el-button>
  227. <el-button
  228. type="text"
  229. size="small"
  230. :disabled="goodsDisable || viewDisabled"
  231. @click="rowDel(row,index)"
  232. >删除
  233. </el-button>
  234. </template>
  235. <template slot="menuLeft" slot-scope="{size}">
  236. <el-button type="primary"
  237. icon="el-icon-plus"
  238. size="small"
  239. :disabled="goodsDisable || viewDisabled"
  240. @click="openMarketDialog"
  241. >录入明细
  242. </el-button>
  243. </template>
  244. </avue-crud>
  245. </basic-container>
  246. <containerTitle title="附件上传"></containerTitle>
  247. <basic-container style="margin-bottom: 40px">
  248. <avue-crud
  249. :option="upLoadOption"
  250. v-model="upLoadForm"
  251. :data="upLoadData"
  252. @row-save="upLoadSave"
  253. @row-update="upLoadUpdate"
  254. @row-del="upLoadDel"
  255. ></avue-crud>
  256. </basic-container>
  257. </el-form>
  258. </div>
  259. <el-dialog
  260. title="导入销售"
  261. append-to-body
  262. class="el-dialogDeep"
  263. :visible.sync="marketDialog"
  264. width="60%"
  265. :close-on-click-modal="false"
  266. :destroy-on-close="true"
  267. :modal-append-to-body='false'
  268. :close-on-press-escape="false"
  269. v-dialog-drag>
  270. <market-detail
  271. :marketParams="marketParams"
  272. @closeFun="!marketDialog"
  273. @importMarket="importMarket"
  274. @close="closeMarkeDialog"
  275. systemType="JK"
  276. >
  277. </market-detail>
  278. </el-dialog>
  279. </div>
  280. </template>
  281. <script>
  282. import customerContact from "./config/customerContact.json"
  283. import {detailInvoiceList,
  284. submitInvoiceList,
  285. removeGoodsItem,
  286. confirmGoods,
  287. cancelGoods
  288. } from "@/api/importTrade/invoice"
  289. import { isPercentage,roundNumbers } from "@/util/validate";
  290. import upLoadOption from "../../exportTrade/purchaseContract/config/uploadList.json";
  291. import { contrastObj,contrastList } from "@/util/contrastData";
  292. import {getStorage} from "@/api/importTrade/receipt"
  293. import { getListOrgOrderNo } from "@/api/importTrade/salesContract"
  294. import marketDetail from "@/components/procurement/market";
  295. import {selectJKGoodsNum} from "@/api/basicData/inventoryAccount"
  296. import _ from "lodash";
  297. import {generateShipment} from "@/api/importTrade/salesContract"
  298. import { getOrgOrderNo } from "@/api/importTrade/salesContract"
  299. export default {
  300. name: "detailsPageEdit",
  301. props: {
  302. detailData: {
  303. type: Object
  304. }
  305. },
  306. components: {
  307. marketDetail,
  308. },
  309. filters: {
  310. isPercentage(val) {
  311. return isPercentage(val);
  312. },
  313. roundNumbers(val){
  314. return roundNumbers(val);
  315. }
  316. },
  317. data() {
  318. return {
  319. form: {},
  320. buttonLoading: false,
  321. disabled: false,
  322. goodsDisable: false,
  323. marketDialog: false,
  324. viewDisabled:false,
  325. customerContact: customerContact,
  326. contactsForm: {},
  327. marketParams:{},
  328. contactsData: [],
  329. currencyDic:[],
  330. storageIdDic: [],
  331. contractDic: [],
  332. creditList:[],
  333. cntrNoList:[],
  334. storageList:[],
  335. selectKind: -1,
  336. sConfiguration: {
  337. multipleChoices: false,
  338. multiple: false,
  339. disabled: false,
  340. searchShow: true,
  341. collapseTags: false,
  342. placeholder: '请点击右边按钮选择',
  343. dicData: []
  344. },
  345. itemConfiguration: {
  346. multipleChoices: false,
  347. multiple: false,
  348. disabled: false,
  349. searchShow: true,
  350. collapseTags: false,
  351. placeholder: '请点击右边按钮选择',
  352. dicData: []
  353. },
  354. basicData: {
  355. column: [
  356. {
  357. label: '系统号',
  358. prop: 'sysNo',
  359. disabled: true,
  360. },
  361. {
  362. label: '客户名称',
  363. prop: 'corpId',
  364. span: 16,
  365. type: 'component',
  366. rules: [
  367. {
  368. required: true,
  369. message: ' ',
  370. trigger: 'blur'
  371. }
  372. ]
  373. },
  374. {
  375. label: '合同号',
  376. prop: 'orderNo',
  377. rules: [
  378. {
  379. required: false,
  380. message: ' ',
  381. trigger: 'blur'
  382. }
  383. ]
  384. }, {
  385. label: '仓库名称',
  386. prop: 'storageId',
  387. rules: [
  388. {
  389. required: false,
  390. message: ' ',
  391. trigger: 'blur'
  392. }
  393. ]
  394. },
  395. {
  396. label: '收货日期',
  397. prop: 'businessDate',
  398. type: 'datetime',
  399. rules: [
  400. {
  401. required: false,
  402. message: ' ',
  403. trigger: 'blur'
  404. }
  405. ]
  406. },
  407. {
  408. label: '收货人',
  409. prop: 'arrivalContact',
  410. rules: [
  411. {
  412. required: false,
  413. message: ' ',
  414. trigger: 'blur'
  415. }
  416. ]
  417. },
  418. {
  419. label: '收货电话',
  420. prop: 'arrivalTel',
  421. rules: [
  422. {
  423. required: false,
  424. message: ' ',
  425. trigger: 'blur'
  426. }
  427. ]
  428. },
  429. {
  430. label: '收货地址',
  431. prop: 'arrivalAddress',
  432. rules: [
  433. {
  434. required: false,
  435. message: ' ',
  436. trigger: 'blur'
  437. }
  438. ]
  439. },
  440. {
  441. label: '业务员',
  442. prop: 'saleman',
  443. dicData: [],
  444. rules: [
  445. {
  446. required: false,
  447. message: ' ',
  448. trigger: 'blur'
  449. }
  450. ]
  451. },
  452. {
  453. label: '发票重量',
  454. prop: 'invoiceWeight',
  455. disabled: true,
  456. rules: [
  457. {
  458. required: false,
  459. message: ' ',
  460. trigger: 'blur'
  461. }
  462. ]
  463. },
  464. {
  465. label: '码单重量',
  466. prop: 'billWeight',
  467. disabled: true,
  468. rules: [
  469. {
  470. required: false,
  471. message: ' ',
  472. trigger: 'blur'
  473. }
  474. ]
  475. },
  476. {
  477. label: '备注',
  478. prop: 'deliveryRemarks',
  479. span: 24,
  480. mock: {
  481. type: 'county'
  482. }
  483. }
  484. ]
  485. },
  486. //上传文件
  487. upLoadOption: upLoadOption,
  488. upLoadData: [],
  489. upLoadForm: {},
  490. commodityData: false,
  491. tableData: [],
  492. //新旧值对比
  493. oldForm: {},
  494. oldContactsData: [],
  495. oldUpLoadData: [],
  496. }
  497. },
  498. async created() {
  499. this.customerContact = await this.getColumnData(this.getColumnName(44), customerContact);
  500. //币别
  501. this.getWorkDicts("currency").then(res =>{
  502. this.currencyDic = res.data.data
  503. })
  504. getStorage().then(res => {
  505. this.storageIdDic = res.data
  506. })
  507. if(this.detailData.view){
  508. this.viewDisabled = true
  509. }
  510. if (this.detailData.id) {
  511. this.buttonLoading = true;
  512. let id = this.detailData.id.replace(/\"/g, "")
  513. detailInvoiceList(id).then(res => {
  514. this.afterData(res.data.data)
  515. }).finally(() => {
  516. this.buttonLoading = false
  517. })
  518. }
  519. if (this.detailData.form) {
  520. this.buttonLoading = true;
  521. generateShipment(this.detailData.form).then(res=>{
  522. this.form = res.data.data
  523. this.$set(this.form,"saleman",this.form.salesName)
  524. //是否计算合同号
  525. this.form.id = null
  526. this.form.sysNo = null
  527. this.form.orderItemsList.forEach((item, index) => {
  528. item.srcOrgNo = this.form.orderNo
  529. item.srcOrderNo = this.form.orderNo
  530. item.srcId = item.id
  531. item.contractNumber = item.orgOrderNo //合同号
  532. item.orgOrderNo = this.form.orgOrderNo
  533. item.contractAmount = item.amount
  534. item.currency = this.form.currency
  535. item.exRate = this.form.exchangeRate
  536. if (item.actualQuantity !== 0) { //如果发过货
  537. item.actualQuantity = _.subtract(item.orderQuantity, item.actualQuantity); //发货件数 = 总件数 - 已发件数
  538. } else {
  539. item.actualQuantity = item.orderQuantity;
  540. }
  541. //生成时 将合同号放到 明细合同下拉列表里 去重
  542. this.contractDic.push({orderNo:item.contractNumber})
  543. this.checkCntrNoList(item)
  544. delete item.orderQuantity
  545. delete item.id
  546. })
  547. this.contactsData = this.form.orderItemsList
  548. this.contractDicList() //合同下拉列
  549. this.sumOrderNo();
  550. delete this.form.orderItemsList
  551. }).finally(()=>{
  552. this.buttonLoading = false
  553. })
  554. }
  555. },
  556. methods: {
  557. //币别选择
  558. // currencyChange(row){
  559. // if(row.currency == "CNY"){
  560. // this.$set(row,"exRate",1)
  561. // }else if(row.currency == "USD"){
  562. // this.$set(row,"exRate",6.3686)
  563. // }else{
  564. // this.$set(row,"exRate",7.1749)
  565. // }
  566. // },
  567. //货品物种
  568. valueName(value, row) {
  569. this.$set(row, "priceCategory", value)
  570. },
  571. // 关闭导入销售弹窗
  572. closeMarkeDialog() {
  573. this.marketDialog = false
  574. },
  575. //选择仓库 带出库存
  576. warehouseChange() {
  577. this.contactsData.forEach(item => {
  578. this.selectInventory(item);
  579. })
  580. },
  581. //合同号合计
  582. sumOrderNo(row) {
  583. //拿到所有明细合同号 去重加逗号放到主表合同号
  584. const contractNumberList = this.contactsData.map(item => {
  585. return item.contractNumber
  586. })
  587. this.$set(this.form, 'orderNo', Array.from(new Set(contractNumberList)).join(","))
  588. if (row) {
  589. //查询库存
  590. this.selectInventory(row)
  591. //查询箱号
  592. this.checkCntrNoList(row)
  593. }
  594. },
  595. //码单合计
  596. totalChange() {
  597. let invoiceList = this.contactsData.map(item => {
  598. if (item.invoiceWeight) {
  599. return parseFloat(item.invoiceWeight);
  600. } else return 0
  601. });
  602. let billList = this.contactsData.map(item => {
  603. if (item.billWeight) {
  604. return parseFloat(item.billWeight);
  605. } else return 0
  606. });
  607. this.$set(this.form, "invoiceWeight", invoiceList.reduce((n, m) => n + m))
  608. this.$set(this.form, "billWeight", billList.reduce((n, m) => n + m))
  609. },
  610. //提单号带出合同号
  611. bingOut(row) {
  612. getOrgOrderNo(row.billNo).then(res => {
  613. this.contractDic.push(res.data)
  614. if(res.data.length !== 0){
  615. row.contractNumber = res.data[0].orderNo
  616. }else{
  617. row.contractNumber = ''
  618. }
  619. })
  620. this.contractDicList() //合同下拉列
  621. this.sumOrderNo(row); //明细列表合成主表合同
  622. this.checkCntrNoList(row) //箱号 仓库下拉列表
  623. this.selectInventory(row) //查询库存
  624. },
  625. //合同号下拉合计
  626. contractDicList(){
  627. this.contractDic = this.contractDic.reduce((all, next) => all.some((atom) => atom['orderNo'] == next['orderNo']) ? all : [...all, next],[]);
  628. },
  629. //查询 箱号 仓库list
  630. checkCntrNoList(item){
  631. if(item.billNo && item.contractNumber && item.priceCategory){
  632. getListOrgOrderNo(item.billNo,item.contractNumber,item.priceCategory).then(res => {
  633. this.creditList = res.data
  634. let storageList = this.creditList.reduce((all, next) => all.some((atom) => atom['storageId'] == next['storageId']) ? all : [...all, next],[]);
  635. let cntrNoList = this.creditList.reduce((all, next) => all.some((atom) => atom['cntrNo'] == next['cntrNo']) ? all : [...all, next],[]);
  636. storageList.map(item=>{
  637. let param ={
  638. storageId:item.storageId,
  639. stockName:item.stockName
  640. }
  641. this.storageList.push(param)
  642. })
  643. cntrNoList.map(item=>{
  644. let params ={
  645. cntrNo:item.cntrNo,
  646. }
  647. this.cntrNoList.push(params)
  648. })
  649. }).finally(()=>{
  650. //再次去重
  651. this.storageList = this.storageList.reduce((all, next) => all.some((atom) => atom['storageId'] == next['storageId']) ? all : [...all, next],[]);
  652. this.cntrNoList = this.cntrNoList.reduce((all, next) => all.some((atom) => atom['cntrNo'] == next['cntrNo']) ? all : [...all, next],[]);
  653. })
  654. }
  655. },
  656. //查询库存
  657. selectInventory(row) {
  658. if (row.billNo && row.contractNumber && row.priceCategory && row.cntrNo && this.form.storageId) {
  659. const params = {
  660. billNo: row.billNo,
  661. contractNumber: row.contractNumber,
  662. priceCategory: row.priceCategory,
  663. storageId: this.form.storageId,
  664. cntrNo: row.cntrNo
  665. }
  666. selectJKGoodsNum(params).then(res => {
  667. if(res.data.data){
  668. this.$set(this.contactsData[row.$index],"inventoryNumber",res.data.data.inQuantity)
  669. this.$set(this.contactsData[row.$index],"inWeight",res.data.data.inWeight)
  670. }else {
  671. this.$set(this.contactsData[row.$index],"inventoryNumber",0.00)
  672. this.$set(this.contactsData[row.$index],"inWeight",0.00)
  673. }
  674. })
  675. }
  676. },
  677. //单价
  678. priceChange(row) {
  679. if (row.price && row.billWeight) {
  680. row.contractAmount = _.multiply(row.billWeight, row.price).toFixed(2);
  681. }
  682. },
  683. billWeightChange(row) {
  684. if (row.billWeight && row.price) {
  685. row.contractAmount = _.multiply(row.billWeight, row.price).toFixed(2);
  686. }
  687. },
  688. //导入销售明细
  689. importMarket(list) {
  690. list.forEach(item => {
  691. item.contractNumber = item.orgOrderNo;
  692. item.contractAmount = item.amount;
  693. item.actualQuantity = item.orderQuantity;
  694. item.srcOrgNo = item.orderNo;
  695. item.srcOrderNo = item.orderNo;
  696. item.srcId = item.id;
  697. //根据提单 合同 货品 查询箱号库存list
  698. this.contractDic.push({orderNo:item.contractNumber})
  699. this.checkCntrNoList(item)
  700. this.selectInventory(item);
  701. delete item.id
  702. this.$refs.crudContact.rowCellAdd(item);
  703. })
  704. this.totalChange(); //计算码单 发票
  705. this.sumOrderNo(); //合并合同号
  706. this.contractDicList() //合同下拉列
  707. this.marketDialog = false;
  708. },
  709. //选择货物品种
  710. choice(row) {
  711. this.dialogVisible = true;
  712. this.selectKind = row.$index;
  713. },
  714. //打开导入销售
  715. openMarketDialog(){
  716. this.marketDialog = true
  717. if(this.contactsData.length !=0){
  718. this.marketParams = {
  719. billNo:this.contactsData[0].billNo,
  720. contractNumber:this.contactsData[0].contractNumber
  721. }
  722. }
  723. },
  724. //新增商品信息保存触发
  725. rowSave(row, done, loading) {
  726. done()
  727. },
  728. //点击行可编辑
  729. handleRowClick(row, event, column) {
  730. },
  731. //商品编辑
  732. rowCell(row, index) {
  733. this.$refs.crudContact.rowCell(row, index)
  734. },
  735. //修改商品信息触发
  736. rowUpdate(row, index, done, loading) {
  737. done(row);
  738. },
  739. //删除商品信息触发
  740. rowDel(row, index, donerowDel) {
  741. this.$confirm("确定将选择数据删除?", {
  742. confirmButtonText: "确定",
  743. cancelButtonText: "取消",
  744. type: "warning"
  745. }).then(() => {
  746. //商品判断是否需要调用删除接口
  747. if (row.id) {
  748. removeGoodsItem(row.id).then(res => {
  749. this.$message({
  750. type: "success",
  751. message: "操作成功!"
  752. });
  753. this.contactsData.splice(index, 1);
  754. })
  755. } else {
  756. this.$message({
  757. type: "success",
  758. message: "操作成功!"
  759. });
  760. this.contactsData.splice(index, 1);
  761. }
  762. }).finally(()=>{
  763. this.totalChange()
  764. })
  765. },
  766. //上传文件保存
  767. upLoadSave(row, done, loading) {
  768. this.upLoadData.push(row)
  769. done()
  770. },
  771. //修改附件上传触发
  772. upLoadUpdate(row, done) {
  773. done(row);
  774. },
  775. //删除附件上传触发
  776. upLoadDel(row, index,) {
  777. this.$confirm("确定将选择数据删除?", {
  778. confirmButtonText: "确定",
  779. cancelButtonText: "取消",
  780. type: "warning"
  781. }).then(() => {
  782. this.$message({
  783. type: "success",
  784. message: "操作成功!"
  785. });
  786. this.bankOfDepositData.splice(index, 1);
  787. })
  788. },
  789. //发货
  790. confirmGoods() {
  791. if(this.verificationData()){
  792. if (!this.goodsDisable) {
  793. this.$confirm("是否确认发货?", {
  794. confirmButtonText: "确定",
  795. cancelButtonText: "取消",
  796. type: "warning"
  797. }).then(() => {
  798. if(!this.form.storageId){
  799. return this.$message.error(`发货时仓库名称不能为空!`);
  800. }
  801. this.buttonLoading = true;
  802. this.form.deliveryItemsList = this.contactsData;
  803. confirmGoods(this.form).then(res => {
  804. if (res.data.success) {
  805. this.$message.success("发货成功!")
  806. this.afterData(res.data.data)
  807. }
  808. }).finally(() => {
  809. this.buttonLoading = false
  810. })
  811. })
  812. } else {
  813. this.$confirm("是否撤回发货?", {
  814. confirmButtonText: "确定",
  815. cancelButtonText: "取消",
  816. type: "warning"
  817. }).then(() => {
  818. this.buttonLoading = true;
  819. this.form.deliveryItemsList = this.contactsData;
  820. cancelGoods(this.form).then(res => {
  821. if (res.data.success) {
  822. this.$message.success("撤销成功!")
  823. this.afterData(res.data.data)
  824. }
  825. }).finally(() => {
  826. this.buttonLoading = false
  827. })
  828. })
  829. }
  830. }
  831. },
  832. //修改提交触发
  833. editCustomer(status) {
  834. this.$refs["form"].validate((valid) => {
  835. for (let i = 0; i < this.contactsData.length; i++) {
  836. if (this.contactsData[i].billNo === "") {
  837. return this.$message.error(`请输入第${i + 1}行的提单号`);
  838. }
  839. if (this.contactsData[i].contractNumber === "") {
  840. return this.$message.error(`请输入第${i + 1}行的合同号`);
  841. }
  842. if (this.contactsData[i].priceCategory === "") {
  843. return this.$message.error(`请输入第${i + 1}行的货物品种`);
  844. }
  845. if (this.contactsData[i].actualQuantity === "") {
  846. return this.$message.error(`请输入第${i + 1}行的件数`);
  847. }
  848. if (this.contactsData[i].invoiceWeight === (null || "" )) {
  849. return this.$message.error(`请输入第${i + 1}行的发票重量`);
  850. }
  851. }
  852. for (let i = 0; i < this.contactsData.length; i++) {
  853. if (this.contactsData[i].billNo === (null || "" )) {
  854. return this.$message.error(`请输入第${i + 1}行的提单号`);
  855. }
  856. if (this.contactsData[i].contractNumber === (null || "" )) {
  857. return this.$message.error(`请输入第${i + 1}行的合同号`);
  858. }
  859. if (this.contactsData[i].priceCategory === (null || "" )) {
  860. return this.$message.error(`请输入第${i + 1}行的货物品种`);
  861. }
  862. if (this.contactsData[i].cntrNo === (null || "" )) {
  863. return this.$message.error(`请输入第${i + 1}行的箱号`);
  864. }
  865. if (this.contactsData[i].actualQuantity === (null || "" )) {
  866. return this.$message.error(`请输入第${i + 1}行的件数`);
  867. }
  868. }
  869. //提单号合体
  870. this.form.billNo =Array.from(new Set(this.contactsData.map(item =>{return item.billNo}))).join(",")
  871. if (valid) {
  872. let submitDto = {
  873. ...this.form,
  874. deliveryItemsList: this.contactsData
  875. };
  876. this.buttonLoading = true
  877. submitInvoiceList(submitDto).then(res => {
  878. if (res.data.success) {
  879. this.$message.success("操作成功!")
  880. detailInvoiceList(res.data.data.id).then(res => {
  881. this.afterData(res.data.data)
  882. })
  883. }
  884. }).finally(() => {
  885. this.buttonLoading = false
  886. })
  887. if (status === true) {
  888. this.$emit("goBack");
  889. }
  890. } else {
  891. return false;
  892. }
  893. });
  894. },
  895. //数据回显
  896. afterData(data){
  897. this.form = data;
  898. this.oldForm = Object.assign({},data);
  899. this.goodsDisable = data.deliveryStatus === "已发货" ? true :false
  900. if (data.deliveryItemsList) {
  901. this.contactsData = this.form.deliveryItemsList
  902. this.contactsData.map(item=>{
  903. this.contractDic.push({orderNo:item.contractNumber})
  904. this.checkCntrNoList(item)
  905. this.contractDicList() //合同下拉列
  906. })
  907. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  908. }
  909. if(data.deliveryFilesList){
  910. this.upLoadData = data.deliveryFilesList
  911. this.oldUpLoadData = this.deepClone(data.deliveryFilesList)
  912. }
  913. if(this.detailData.status === 'copy'){
  914. this.copyData()
  915. }
  916. },
  917. //验证
  918. verificationData(){
  919. if(contrastObj(this.form,this.oldForm) || contrastList(this.contactsData,this.oldContactsData)
  920. || contrastList(this.upLoadData,this.oldUpLoadData)
  921. ){
  922. this.$confirm("数据发生变化,请先提交保存!", "提示", {
  923. confirmButtonText: "保存",
  924. cancelButtonText: "取消",
  925. type: "warning",
  926. }).then(() => {
  927. this.editCustomer()
  928. }).catch(()=>{
  929. return false
  930. })
  931. }else{
  932. return true
  933. }
  934. },
  935. createData(){
  936. if(this.verificationData()){
  937. this.$confirm("确定创建新的单据吗?", "提示", {
  938. confirmButtonText: "保存",
  939. cancelButtonText: "取消",
  940. type: "warning",
  941. }).then(() => {
  942. this.form = {}
  943. this.oldForm = {}
  944. this.contactsData = []
  945. this.oldContactsData = []
  946. this.upLoadData = []
  947. this.oldUpLoadData = []
  948. })
  949. }
  950. },
  951. copyData(){
  952. if(this.verificationData()){
  953. this.goodsDisable = false
  954. delete this.form.id //删除id
  955. delete this.form.deliveryStatus
  956. this.$set(this.form,"sysNo","")//系统编号
  957. this.contactsData.forEach(item =>{
  958. delete item.id //删除id
  959. })
  960. this.upLoadData.forEach(item =>{
  961. delete item.id //删除id
  962. })
  963. this.oldForm = {}
  964. this.oldContactsData = []
  965. this.oldUpLoadData = []
  966. this.$message.success("复制成功!")
  967. }
  968. },
  969. async openEdit() {
  970. //标签页保存key
  971. this.inDetailsKey(this.$route.name,this.detailData.lockData);
  972. //单据是否锁定
  973. if(!await this.checkLocks(this.detailData.lockData)){
  974. this.onLock(this.detailData.lockData); //上锁
  975. this.viewDisabled = false
  976. }else{
  977. this.$message.warning('此单据已被锁定,请稍后再进行操作!')
  978. }
  979. },
  980. //返回列表
  981. async backToList() {
  982. //如果单据已被锁定 并且编辑按钮存在 则直接返回
  983. if(this.viewDisabled || !this.detailData.lockData){
  984. this.$emit("goBack");
  985. return
  986. }
  987. if (contrastObj(this.form, this.oldForm) || contrastList(this.contactsData, this.oldContactsData)
  988. || contrastList(this.upLoadData, this.oldUpLoadData)
  989. ) {
  990. this.$confirm("是否保存当前页面?", "提示", {
  991. confirmButtonText: "保存",
  992. cancelButtonText: "取消",
  993. type: "warning",
  994. }).then(() => {
  995. this.editCustomer(true)
  996. }).catch(() => {
  997. this.$emit("goBack");
  998. }).finally(()=>{
  999. if(this.form.id){
  1000. this.unLock(this.detailData.lockData);
  1001. this.leaveDetailsKey(this.$route.name);
  1002. }
  1003. })
  1004. }else {
  1005. this.$emit("goBack");
  1006. if (this.form.id) {
  1007. this.unLock(this.detailData.lockData);
  1008. this.leaveDetailsKey(this.$route.name);
  1009. }
  1010. }
  1011. },
  1012. //列保存触发
  1013. async saveColumn() {
  1014. const inSave = await this.saveColumnData(
  1015. this.getColumnName(44),
  1016. this.customerContact
  1017. );
  1018. if (inSave) {
  1019. this.$message.success("保存成功");
  1020. //关闭窗口
  1021. this.$refs.crudContact.$refs.dialogColumn.columnBox = false;
  1022. }
  1023. },
  1024. async resetColumn() {
  1025. const inSave = await this.delColumnData(
  1026. this.getColumnName(44),
  1027. customerContact
  1028. );
  1029. if (inSave) {
  1030. this.$message.success("重置成功");
  1031. this.customerContact = customerContact;
  1032. //关闭窗口
  1033. this.$refs.crudContact.$refs.dialogColumn.columnBox = false;
  1034. }
  1035. },
  1036. },
  1037. }
  1038. </script>
  1039. <style lang="scss" scoped>
  1040. .back-icon {
  1041. line-height: 64px;
  1042. font-size: 20px;
  1043. margin-right: 8px;
  1044. }
  1045. ::v-deep .el-form-item {
  1046. margin-bottom: 0;
  1047. }
  1048. .el-dialogDeep {
  1049. ::v-deep .el-dialog {
  1050. margin: 1vh auto 0 !important;
  1051. padding-bottom: 10px !important;
  1052. .el-dialog__body, .el-dialog__footer {
  1053. padding-bottom: 0 !important;
  1054. padding-top: 0 !important;
  1055. }
  1056. }
  1057. }
  1058. .required_fields{
  1059. color: #F56C6C;
  1060. display:inline-block;
  1061. width: 7%
  1062. }
  1063. .upper_right_button{
  1064. display: flex;
  1065. position: fixed;
  1066. right: 12px;
  1067. top: 47px;
  1068. }
  1069. ::v-deep .el-form-item__content{
  1070. line-height: 32px;
  1071. }
  1072. </style>