detailsPageEdit.vue 35 KB

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