detailsPageEdit.vue 37 KB

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