detailsPageEdit.vue 32 KB

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