detailsPageEdit.vue 37 KB

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