detailsPageEdit.vue 32 KB

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