detailsPageEdit.vue 31 KB

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