detailsPageEdit.vue 30 KB

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