detailsPageEdit.vue 33 KB

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