detailsPageEdit.vue 37 KB

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