detailsPageEdit.vue 30 KB

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