detailsPageEdit.vue 32 KB

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