detailsPageEdit.vue 34 KB

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