detailsPageEdit.vue 31 KB

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