detailsPageEdit.vue 31 KB

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