detailsPageEdit.vue 33 KB

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