detailsPageEdit.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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. import {generateShipment} from "@/api/importTrade/salesContract"
  269. export default {
  270. name: "detailsPageEdit",
  271. props: {
  272. detailData: {
  273. type: Object
  274. }
  275. },
  276. components: {
  277. marketDetail,
  278. },
  279. data() {
  280. return {
  281. form: {},
  282. buttonLoading: false,
  283. disabled: false,
  284. goodsDisable: false,
  285. marketDialog: false,
  286. customerContact: customerContact,
  287. contactsForm: {},
  288. contactsData: [],
  289. currencyDic:[],
  290. storageIdDic: [],
  291. contractDic: [],
  292. selectKind: -1,
  293. configuration: {
  294. multipleChoices: false,
  295. multiple: false,
  296. disabled: false,
  297. searchShow: true,
  298. collapseTags: false,
  299. placeholder: '请点击右边按钮选择',
  300. dicData: []
  301. },
  302. sConfiguration: {
  303. multipleChoices: false,
  304. multiple: false,
  305. disabled: false,
  306. searchShow: true,
  307. collapseTags: false,
  308. placeholder: '请点击右边按钮选择',
  309. dicData: []
  310. },
  311. itemConfiguration: {
  312. multipleChoices: false,
  313. multiple: false,
  314. disabled: false,
  315. searchShow: true,
  316. collapseTags: false,
  317. placeholder: '请点击右边按钮选择',
  318. dicData: []
  319. },
  320. basicData: {
  321. column: [
  322. {
  323. label: '系统号',
  324. prop: 'sysNo',
  325. disabled: true,
  326. },
  327. {
  328. label: '客户名称',
  329. prop: 'corpId',
  330. span: 16,
  331. type: 'component',
  332. rules: [
  333. {
  334. required: true,
  335. message: ' ',
  336. trigger: 'blur'
  337. }
  338. ]
  339. },
  340. {
  341. label: '合同号',
  342. prop: 'orderNo',
  343. rules: [
  344. {
  345. required: false,
  346. message: ' ',
  347. trigger: 'blur'
  348. }
  349. ]
  350. }, {
  351. label: '仓库名称',
  352. prop: 'storageId',
  353. rules: [
  354. {
  355. required: true,
  356. message: ' ',
  357. trigger: 'blur'
  358. }
  359. ]
  360. },
  361. {
  362. label: '收货日期',
  363. prop: 'businessDate',
  364. type: 'datetime',
  365. rules: [
  366. {
  367. required: false,
  368. message: ' ',
  369. trigger: 'blur'
  370. }
  371. ]
  372. },
  373. {
  374. label: '收货人',
  375. prop: 'arrivalContact',
  376. rules: [
  377. {
  378. required: false,
  379. message: ' ',
  380. trigger: 'blur'
  381. }
  382. ]
  383. },
  384. {
  385. label: '收货电话',
  386. prop: 'arrivalTel',
  387. rules: [
  388. {
  389. required: false,
  390. message: ' ',
  391. trigger: 'blur'
  392. }
  393. ]
  394. },
  395. {
  396. label: '收货地址',
  397. prop: 'arrivalAddress',
  398. rules: [
  399. {
  400. required: false,
  401. message: ' ',
  402. trigger: 'blur'
  403. }
  404. ]
  405. },
  406. {
  407. label: '业务员',
  408. prop: 'saleman',
  409. dicData: [],
  410. rules: [
  411. {
  412. required: false,
  413. message: ' ',
  414. trigger: 'blur'
  415. }
  416. ]
  417. },
  418. {
  419. label: '发票重量',
  420. prop: 'invoiceWeight',
  421. disabled: true,
  422. rules: [
  423. {
  424. required: false,
  425. message: ' ',
  426. trigger: 'blur'
  427. }
  428. ]
  429. },
  430. {
  431. label: '码单重量',
  432. prop: 'billWeight',
  433. disabled: true,
  434. rules: [
  435. {
  436. required: false,
  437. message: ' ',
  438. trigger: 'blur'
  439. }
  440. ]
  441. },
  442. {
  443. label: '备注',
  444. prop: 'deliveryRemarks',
  445. span: 24,
  446. mock: {
  447. type: 'county'
  448. }
  449. }
  450. ]
  451. },
  452. //上传文件
  453. upLoadOption: upLoadOption,
  454. upLoadData: [],
  455. upLoadForm: {},
  456. commodityData: false,
  457. tableData: [],
  458. //新旧值对比
  459. oldForm: {},
  460. oldContactsData: [],
  461. oldUpLoadData: [],
  462. }
  463. },
  464. async created() {
  465. // this.customerContact = await this.getColumnData(this.getColumnName(44), customerContact);
  466. //币别
  467. this.getWorkDicts("currency").then(res =>{
  468. this.currencyDic = res.data.data
  469. })
  470. getStorage().then(res => {
  471. this.storageIdDic = res.data
  472. })
  473. if (this.detailData.id) {
  474. this.buttonLoading = true;
  475. let id = this.detailData.id.replace(/\"/g, "")
  476. detailInvoiceList(id).then(res => {
  477. this.form = res.data.data;
  478. this.oldForm = Object.assign({}, res.data.data);
  479. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true : false
  480. this.configuration.dicData = this.form.corpName
  481. if (this.form.deliveryItemsList) {
  482. this.contactsData = this.form.deliveryItemsList
  483. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  484. }
  485. if (this.form.deliveryFilesList) {
  486. this.upLoadData = this.form.deliveryFilesList
  487. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  488. }
  489. }).finally(() => {
  490. this.buttonLoading = false
  491. })
  492. }
  493. if (this.detailData.form) {
  494. this.buttonLoading = true;
  495. generateShipment(this.detailData.form).then(res=>{
  496. this.form = res.data.data
  497. this.$set(this.form,"saleman",this.form.salesName)
  498. //是否计算合同号
  499. this.form.id = null
  500. this.form.sysNo = null
  501. console.log(this.form.orderItemsList)
  502. this.form.orderItemsList.forEach((item, index) => {
  503. item.srcId = item.id
  504. item.contractNumber = item.orgOrderNo //合同号
  505. item.orgOrderNo = this.form.orgOrderNo
  506. item.contractAmount = item.amount
  507. item.currency = this.form.currency
  508. item.exRate = this.form.exchangeRate
  509. if (item.actualQuantity !== 0) { //如果发过货
  510. item.actualQuantity = _.subtract(item.orderQuantity, item.actualQuantity); //发货件数 = 总件数 - 已发件数
  511. } else {
  512. item.actualQuantity = item.orderQuantity;
  513. }
  514. delete item.orderQuantity
  515. delete item.id
  516. })
  517. this.contactsData = this.form.orderItemsList
  518. console.log(this.contactsData)
  519. this.sumOrderNo();
  520. delete this.form.orderItemsList
  521. }).finally(()=>{
  522. this.buttonLoading = false
  523. })
  524. }
  525. },
  526. methods: {
  527. //币别选择
  528. currencyChange(row){
  529. if(row.currency == "CNY"){
  530. this.$set(row,"exRate",1)
  531. }else if(row.currency == "USD"){
  532. this.$set(row,"exRate",6.3686)
  533. }else{
  534. this.$set(row,"exRate",7.1749)
  535. }
  536. },
  537. //货品物种
  538. valueName(value, row) {
  539. this.$set(row, "priceCategory", value)
  540. },
  541. // 关闭导入销售弹窗
  542. closeMarkeDialog() {
  543. this.marketDialog = false
  544. },
  545. //选择仓库 带出库存
  546. warehouseChange() {
  547. this.contactsData.forEach(item => {
  548. this.selectInventory(item);
  549. })
  550. },
  551. //合同号合计
  552. sumOrderNo(row) {
  553. //拿到所有明细合同号 去重加逗号放到主表合同号
  554. const contractNumberList = this.contactsData.map(item => {
  555. return item.contractNumber
  556. })
  557. this.$set(this.form, 'orderNo', Array.from(new Set(contractNumberList)).join(","))
  558. if (row) {
  559. this.selectInventory(row)
  560. }
  561. },
  562. //码单合计
  563. totalChange() {
  564. let invoiceList = this.contactsData.map(item => {
  565. if (item.invoiceWeight) {
  566. return parseFloat(item.invoiceWeight);
  567. } else return 0
  568. });
  569. let billList = this.contactsData.map(item => {
  570. if (item.billWeight) {
  571. return parseFloat(item.billWeight);
  572. } else return 0
  573. });
  574. this.$set(this.form, "invoiceWeight", invoiceList.reduce((n, m) => n + m))
  575. this.$set(this.form, "billWeight", billList.reduce((n, m) => n + m))
  576. },
  577. //提单号带出合同号
  578. bingOut(row) {
  579. getOrgOrderNo(row.billNo).then(res => {
  580. if (res.data) {
  581. this.contractDic = res.data;
  582. row.contractNumber = res.data[0].orderNo
  583. }
  584. }).catch(() => {
  585. row.contractNumber = ''
  586. })
  587. this.sumOrderNo(row);
  588. this.selectInventory(row)
  589. },
  590. //查询库存
  591. selectInventory(row) {
  592. if (row.billNo && row.contractNumber && row.priceCategory && row.cntrNo && this.form.storageId) {
  593. const params = {
  594. billNo: row.billNo,
  595. contractNumber: row.contractNumber,
  596. priceCategory: row.priceCategory,
  597. storageId: this.form.storageId,
  598. cntrNo: row.cntrNo
  599. }
  600. selectGoodsNum(params).then(res => {
  601. if(res.data.data){
  602. this.$set(this.contactsData[row.$index],"inventoryNumber",res.data.data.inQuantity)
  603. this.$set(this.contactsData[row.$index],"inWeight",res.data.data.inWeight)
  604. }else {
  605. this.$set(this.contactsData[row.$index],"inventoryNumber",0.00)
  606. this.$set(this.contactsData[row.$index],"inWeight",0.00)
  607. }
  608. })
  609. }
  610. },
  611. // actualQuantityChange(row){
  612. // if(row.singleton){
  613. // const _sing = row.singleton
  614. // if( _sing.BQ !== 0){ //如果有值并且不为空 计算码单与发票
  615. // row.billWeight = _.multiply(_sing.BQ,row.actualQuantity)
  616. // }
  617. // if( _sing.IQ !== 0){
  618. // row.invoiceWeight = _.multiply(_sing.IQ,row.actualQuantity)
  619. // this.invoiceWeightChange(row) //发票改变合同
  620. // }
  621. // this.totalChange()
  622. // }
  623. // },
  624. //单价
  625. priceChange(row) {
  626. if (!row.price) {
  627. row.price = "";
  628. row.contractAmount = 0
  629. } else {
  630. row.contractAmount = _.multiply(row.billWeight, row.price).toFixed(2);
  631. }
  632. },
  633. billWeightChange(row) {
  634. if (!row.invoiceWeight) {
  635. row.billWeight = "";
  636. row.contractAmount = 0
  637. } else {
  638. row.contractAmount = _.multiply(row.billWeight, row.price).toFixed(2);
  639. }
  640. },
  641. //导入销售明细
  642. importMarket(list) {
  643. list.forEach(item => {
  644. item.contractNumber = item.orgOrderNo;
  645. item.contractAmount = item.amount;
  646. item.actualQuantity = item.orderQuantity;
  647. // item.singleton = {
  648. // BQ : item.billWeight && item.orderQuantity?_.divide(item.billWeight, item.orderQuantity):0,
  649. // IQ : item.invoiceWeight && item.orderQuantity?_.divide(item.invoiceWeight, item.orderQuantity):0
  650. // }
  651. this.selectInventory(item);
  652. delete item.id
  653. this.$refs.crudContact.rowCellAdd(item);
  654. })
  655. this.totalChange(); //计算码单 发票
  656. this.sumOrderNo(); //合并合同号
  657. this.marketDialog = false;
  658. },
  659. //选择货物品种
  660. choice(row) {
  661. this.dialogVisible = true;
  662. this.selectKind = row.$index;
  663. },
  664. //新增商品信息保存触发
  665. rowSave(row, done, loading) {
  666. console.log(row)
  667. console.log(this.contactsData)
  668. // this.contactsData.push(row)
  669. done()
  670. },
  671. //点击行可编辑
  672. handleRowClick(row, event, column) {
  673. },
  674. //商品编辑
  675. rowCell(row, index) {
  676. console.log(row)
  677. this.$refs.crudContact.rowCell(row, index)
  678. },
  679. //修改商品信息触发
  680. rowUpdate(row, index, done, loading) {
  681. done(row);
  682. },
  683. //删除商品信息触发
  684. rowDel(row, index, donerowDel) {
  685. this.$confirm("确定将选择数据删除?", {
  686. confirmButtonText: "确定",
  687. cancelButtonText: "取消",
  688. type: "warning"
  689. }).then(() => {
  690. //商品判断是否需要调用删除接口
  691. if (row.id) {
  692. removeGoodsItem(row.id).then(res => {
  693. this.$message({
  694. type: "success",
  695. message: "操作成功!"
  696. });
  697. this.contactsData.splice(index, 1);
  698. })
  699. } else {
  700. this.$message({
  701. type: "success",
  702. message: "操作成功!"
  703. });
  704. this.contactsData.splice(index, 1);
  705. }
  706. }).finally(()=>{
  707. this.totalChange()
  708. })
  709. },
  710. confirmGoods() {
  711. if (contrastObj(this.form, this.oldForm) || contrastList(this.contactsData, this.oldContactsData)
  712. || contrastList(this.upLoadData, this.oldUpLoadData)
  713. ) {
  714. this.$confirm("请先保存在进行操作!", {
  715. confirmButtonText: "保存",
  716. cancelButtonText: "取消",
  717. type: "warning"
  718. }).then(() => {
  719. this.editCustomer()
  720. })
  721. } else {
  722. if (!this.goodsDisable) {
  723. this.$confirm("是否确认发货?", {
  724. confirmButtonText: "确定",
  725. cancelButtonText: "取消",
  726. type: "warning"
  727. }).then(() => {
  728. this.buttonLoading = true;
  729. this.form.deliveryItemsList = this.contactsData;
  730. confirmGoods(this.form).then(res => {
  731. if (res.data.success) {
  732. this.$message.success("发货成功!")
  733. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true : false
  734. }
  735. })
  736. }).finally(() => {
  737. this.buttonLoading = false
  738. })
  739. } else {
  740. this.$confirm("是否撤回发货?", {
  741. confirmButtonText: "确定",
  742. cancelButtonText: "取消",
  743. type: "warning"
  744. }).then(() => {
  745. this.buttonLoading = true;
  746. this.form.deliveryItemsList = this.contactsData;
  747. cancelGoods(this.form).then(res => {
  748. if (res.data.success) {
  749. this.$message.success("撤销成功!")
  750. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true : false
  751. }
  752. })
  753. }).finally(() => {
  754. this.buttonLoading = false
  755. })
  756. }
  757. }
  758. },
  759. //修改提交触发
  760. editCustomer(status) {
  761. this.$refs["form"].validate((valid) => {
  762. for (let i = 0; i < this.contactsData.length; i++) {
  763. if (this.contactsData[i].billNo === "") {
  764. return this.$message.error(`请输入第${i + 1}行的提单号`);
  765. }
  766. if (this.contactsData[i].contractNumber === "") {
  767. return this.$message.error(`请输入第${i + 1}行的合同号`);
  768. }
  769. if (this.contactsData[i].priceCategory === "") {
  770. return this.$message.error(`请输入第${i + 1}行的货物品种`);
  771. }
  772. if (this.contactsData[i].actualQuantity === "") {
  773. return this.$message.error(`请输入第${i + 1}行的件数`);
  774. }
  775. }
  776. this.form.billNo = this.contactsData.map(item => {
  777. return item.billNo
  778. }).join(",")
  779. if (valid) {
  780. let submitDto = {
  781. ...this.form,
  782. deliveryItemsList: this.contactsData
  783. };
  784. this.buttonLoading = true
  785. submitInvoiceList(submitDto).then(res => {
  786. if (res.data.success) {
  787. this.$message.success("操作成功!")
  788. detailInvoiceList(res.data.data.id).then(res => {
  789. this.form = res.data.data;
  790. this.oldForm = Object.assign({}, res.data.data);
  791. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true : false;
  792. if (this.form.deliveryItemsList) {
  793. this.contactsData = this.form.deliveryItemsList
  794. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  795. }
  796. if (this.form.deliveryFilesList) {
  797. this.upLoadData = this.form.deliveryFilesList
  798. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  799. }
  800. })
  801. }
  802. }).finally(() => {
  803. this.buttonLoading = false
  804. })
  805. if (status === true) {
  806. this.$emit("goBack");
  807. }
  808. } else {
  809. return false;
  810. }
  811. });
  812. },
  813. //上传文件保存
  814. upLoadSave(row, done, loading) {
  815. this.upLoadData.push(row)
  816. done()
  817. },
  818. //修改附件上传触发
  819. upLoadUpdate(row, done) {
  820. done(row);
  821. },
  822. //删除附件上传触发
  823. upLoadDel(row, index,) {
  824. this.$confirm("确定将选择数据删除?", {
  825. confirmButtonText: "确定",
  826. cancelButtonText: "取消",
  827. type: "warning"
  828. }).then(() => {
  829. if (row.id) {
  830. corpsbank(row.id).then(res => {
  831. if (res.data.success) {
  832. this.$message({
  833. type: "success",
  834. message: "操作成功!"
  835. });
  836. this.bankOfDepositData.splice(index, 1);
  837. }
  838. })
  839. } else {
  840. this.$message({
  841. type: "success",
  842. message: "操作成功!"
  843. });
  844. this.bankOfDepositData.splice(index, 1);
  845. }
  846. })
  847. },
  848. //点击商品明细选择触发
  849. commodityChoice(row) {
  850. this.dialogVisible = !this.dialogVisible
  851. this.commodityData = true
  852. this.choiceIndexT = row.$index
  853. },
  854. //商品新增触发
  855. commoditySelection() {
  856. // this.dialogVisible = !this.dialogVisible
  857. // this.commodityData = false
  858. },
  859. //返回列表
  860. backToList() {
  861. if (contrastObj(this.form, this.oldForm) || contrastList(this.contactsData, this.oldContactsData)
  862. || contrastList(this.upLoadData, this.oldUpLoadData)
  863. ) {
  864. this.$confirm("是否保存当前页面?", "提示", {
  865. confirmButtonText: "保存",
  866. cancelButtonText: "取消",
  867. type: "warning",
  868. }).then(() => {
  869. this.editCustomer(true)
  870. }).catch(() => {
  871. this.$emit("goBack");
  872. })
  873. } else {
  874. this.$emit("goBack");
  875. }
  876. },
  877. //列保存触发
  878. async saveColumn() {
  879. const inSave = await this.saveColumnData(
  880. this.getColumnName(44),
  881. this.customerContact
  882. );
  883. if (inSave) {
  884. this.$message.success("保存成功");
  885. //关闭窗口
  886. this.$refs.crudContact.$refs.dialogColumn.columnBox = false;
  887. }
  888. },
  889. },
  890. }
  891. </script>
  892. <style lang="scss" scoped>
  893. .back-icon {
  894. line-height: 64px;
  895. font-size: 20px;
  896. margin-right: 8px;
  897. }
  898. ::v-deep .el-form-item {
  899. margin-bottom: 0;
  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. .required_fields{
  912. color: #F56C6C;
  913. display:inline-block;
  914. width: 7%
  915. }
  916. .upper_right_button{
  917. display: flex;
  918. position: fixed;
  919. right: 12px;
  920. top: 47px;
  921. }
  922. ::v-deep .el-form-item__content{
  923. line-height: 32px;
  924. }
  925. </style>