detailsPageEdit.vue 30 KB

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