detailsPageEdit.vue 37 KB

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