detailsPageEdit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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" 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. @row-del="rowDel"
  57. >
  58. <template slot-scope="{row}" slot="billNo">
  59. <span v-if="row.$cellEdit" class="required_fields">*</span>
  60. <el-input
  61. v-if="row.$cellEdit"
  62. v-model="row.billNo"
  63. style="width: 90%"
  64. placeholder=" "
  65. size="small"
  66. @change="bingOut(row)"
  67. ></el-input>
  68. <span v-else>{{ row.billNo }}</span>
  69. </template>
  70. <template slot-scope="{row}" slot="contractNumber">
  71. <span v-if="row.$cellEdit" class="required_fields">*</span>
  72. <el-select
  73. v-if="row.$cellEdit"
  74. style="width:90% !important;"
  75. v-model="row.contractNumber"
  76. placeholder=" "
  77. size="small"
  78. clearable
  79. filterable
  80. >
  81. <el-option
  82. style="width:90%"
  83. @change="sumOrderNo()"
  84. v-for="(item,index) in contractDic"
  85. :key="index"
  86. :label="item.orderNo"
  87. :value="item.orderNo"
  88. ></el-option>
  89. </el-select>
  90. <span v-else>{{ row.contractNumber }}</span>
  91. </template>
  92. <template slot="priceCategory" slot-scope="{row,index}">
  93. <span v-if="row.$cellEdit" class="required_fields">*</span>
  94. <el-input
  95. v-if="row.$cellEdit"
  96. v-model="row.priceCategoryNames"
  97. size="small"
  98. placeholder="请点击右侧按钮选择"
  99. :disabled="true"
  100. style="width: 63%"
  101. ></el-input>
  102. <el-button v-if="row.$cellEdit" size="small" icon="el-icon-search" @click="choice(row)"></el-button>
  103. <span v-else>{{ row.priceCategoryNames }}</span>
  104. </template>
  105. <template slot="invoiceWeight" slot-scope="{ row }">
  106. <el-input
  107. v-if="row.$cellEdit"
  108. v-model="row.invoiceWeight"
  109. placeholder="请输入"
  110. size="small"
  111. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  112. @input="totalChange(row.invoiceWeight)"
  113. ></el-input>
  114. <span v-else>{{ row.invoiceWeight }}</span>
  115. </template>
  116. <template slot="billWeight" slot-scope="{ row }">
  117. <el-input
  118. v-if="row.$cellEdit"
  119. v-model="row.billWeight"
  120. placeholder="请输入"
  121. size="small"
  122. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  123. @input="totalChange(row.billWeight)"
  124. ></el-input>
  125. <span v-else>{{ row.billWeight }}</span>
  126. </template>
  127. <template slot="price" slot-scope="{ row }">
  128. <el-input
  129. v-if="row.$cellEdit"
  130. v-model="row.price"
  131. placeholder="请输入"
  132. size="small"
  133. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  134. @input="priceChange(row)"
  135. ></el-input>
  136. <span v-else>{{ row.price }}</span>
  137. </template>
  138. <template slot="actualQuantity" slot-scope="{ row }">
  139. <span v-if="row.$cellEdit" class="required_fields">*</span>
  140. <el-input
  141. v-if="row.$cellEdit"
  142. v-model="row.actualQuantity"
  143. style="width: 90%"
  144. placeholder="请输入"
  145. size="small"
  146. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  147. @input="quantityChange(row)"
  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 _ from "lodash";
  267. export default {
  268. name: "detailsPageEdit",
  269. props: {
  270. detailData: {
  271. type: Object
  272. }
  273. },
  274. components:{
  275. marketDetail,
  276. },
  277. data() {
  278. return {
  279. form: {},
  280. disabled: false,
  281. goodsDisable:false,
  282. marketDialog:false,
  283. customerContact: customerContact,
  284. contactsForm: {},
  285. contactsData: [],
  286. storageIdDic:[],
  287. contractDic:[],
  288. selectKind:-1,
  289. configuration:{
  290. multipleChoices:false,
  291. multiple:false,
  292. disabled:false,
  293. searchShow:true,
  294. collapseTags:false,
  295. placeholder:'请点击右边按钮选择',
  296. dicData:[]
  297. },
  298. basicData: {
  299. column: [
  300. {
  301. label: '系统号',
  302. prop: 'sysNo',
  303. disabled:true,
  304. }, {
  305. label: '合同号',
  306. prop: 'orderNo',
  307. rules: [
  308. {
  309. required: true,
  310. message: ' ',
  311. trigger: 'blur'
  312. }
  313. ]
  314. },{
  315. label: '客户名称',
  316. prop: 'corpId',
  317. type:'component',
  318. rules: [
  319. {
  320. required: true,
  321. message: ' ',
  322. trigger: 'blur'
  323. }
  324. ]
  325. }, {
  326. label: '仓库名称',
  327. prop: 'storageId',
  328. rules: [
  329. {
  330. required: true,
  331. message: ' ',
  332. trigger: 'blur'
  333. }
  334. ]
  335. }, {
  336. label: '发货日期',
  337. prop: 'businessDate',
  338. type:'datetime',
  339. rules: [
  340. {
  341. required: false,
  342. message: ' ',
  343. trigger: 'blur'
  344. }
  345. ]
  346. }, {
  347. label: '业务员',
  348. prop: 'saleman',
  349. dicData: [],
  350. rules: [
  351. {
  352. required: false,
  353. message: ' ',
  354. trigger: 'blur'
  355. }
  356. ]
  357. }, {
  358. label: '发票重量',
  359. prop: 'invoiceWeight',
  360. disabled: true,
  361. rules: [
  362. {
  363. required: false,
  364. message: ' ',
  365. trigger: 'blur'
  366. }
  367. ]
  368. },{
  369. label: '码单重量',
  370. prop: 'billWeight',
  371. disabled: true,
  372. rules: [
  373. {
  374. required: false,
  375. message: ' ',
  376. trigger: 'blur'
  377. }
  378. ]
  379. },{
  380. label: '备注',
  381. prop: 'deliveryRemarks',
  382. span: 24,
  383. mock: {
  384. type: 'county'
  385. }
  386. }
  387. ]
  388. },
  389. //上传文件
  390. upLoadOption: upLoadOption,
  391. upLoadData:[],
  392. upLoadForm:{},
  393. dialogVisible: false,
  394. treeOption: {
  395. nodeKey: 'id',
  396. lazy: true,
  397. treeLoad: function (node, resolve) {
  398. const parentId = (node.level === 0) ? 0 : node.data.id;
  399. getDeptLazyTree(parentId).then(res => {
  400. resolve(res.data.data.map(item => {
  401. return {
  402. ...item,
  403. leaf: !item.hasChildren
  404. }
  405. }))
  406. });
  407. },
  408. treeDeptId: '',
  409. addBtn: false,
  410. menu: false,
  411. size: 'small',
  412. props: {
  413. labelText: '标题',
  414. label: 'title',
  415. value: 'value',
  416. children: 'children'
  417. }
  418. },
  419. optionTwo: commodity,
  420. loading: false,
  421. data: [],
  422. page: {
  423. pageSize: 10,
  424. currentPage: 1,
  425. total: 0
  426. },
  427. commodityData: false,
  428. tableData: [],
  429. //新旧值对比
  430. oldForm:{},
  431. oldContactsData:[],
  432. oldUpLoadData:[],
  433. }
  434. },
  435. created() {
  436. getStorage().then(res =>{
  437. this.storageIdDic = res.data
  438. })
  439. if (this.detailData.id) {
  440. let id = this.detailData.id.replace(/\"/g, "")
  441. detailInvoiceList(id).then(res => {
  442. this.form = res.data.data;
  443. this.oldForm = Object.assign({},res.data.data);
  444. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true :false
  445. this.configuration.dicData = this.form.corpName
  446. if(this.form.deliveryItemsList){
  447. this.contactsData = this.form.deliveryItemsList
  448. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  449. }
  450. if(this.form.deliveryFilesList){
  451. this.upLoadData = this.form.deliveryFilesList
  452. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  453. }
  454. })
  455. }
  456. if (this.detailData.form) {
  457. this.form = JSON.parse(this.detailData.form);
  458. this.form.id = null
  459. this.form.sysNo = null
  460. this.form.orderItemsList.forEach(item =>{
  461. item.srcId = item.id
  462. item.contractNumber = item.orgOrderNo
  463. item.contractAmount = item.amount
  464. if(item.actualQuantity !== 0){ //如果发过货
  465. item.actualQuantity = _.subtract(item.orderQuantity, item.actualQuantity); //发货件数 = 总件数 - 已发件数
  466. }else{
  467. item.actualQuantity = item.orderQuantity;
  468. }
  469. delete item.actualQuantity
  470. delete item.id
  471. })
  472. this.contactsData = this.form.orderItemsList
  473. this.sumOrderNo();
  474. delete this.form.orderItemsList
  475. }
  476. },
  477. methods: {
  478. //合同号合计
  479. sumOrderNo(){
  480. //拿到所有明细合同号 去重加逗号放到主表合同号
  481. const contractNumberList = this.contactsData.map(item =>{item.contractNumber})
  482. this.$set(this.form,'orderNo', Array.from(new Set(contractNumberList)).join(","))
  483. },
  484. //码单合计
  485. totalChange(){
  486. let invoiceList = this.contactsData.map(item => {
  487. if(!item.invoiceWeight){
  488. item.invoiceWeight = 0
  489. }
  490. return parseFloat(item.invoiceWeight);
  491. });
  492. let billList = this.contactsData.map(item => {
  493. if(!item.billWeight){
  494. item.billWeight = 0
  495. }
  496. return parseFloat(item.billWeight);
  497. });
  498. this.$set(this.form,"invoiceWeight", invoiceList.reduce((n,m) => n + m))
  499. this.$set(this.form,"billWeight", billList.reduce((n,m) => n + m))
  500. },
  501. //提单号带出合同号
  502. bingOut(row){
  503. getOrgOrderNo(row.billNo).then(res =>{
  504. if(res.data){
  505. this.contractDic = res.data;
  506. row.contractNumber = res.data[0].orderNo
  507. }
  508. }).catch(()=>{
  509. row.contractNumber = ''
  510. })
  511. },
  512. //单价
  513. priceChange(row) {
  514. if (!row.price) {
  515. row.price = "";
  516. row.contractAmount = 0
  517. } else {
  518. row.contractAmount = _.multiply(row.actualQuantity, row.price).toFixed(2);
  519. }
  520. },
  521. //件数
  522. quantityChange(row) {
  523. if (!row.actualQuantity) {
  524. row.actualQuantity = "";
  525. row.contractAmount = 0
  526. } else {
  527. row.contractAmount = _.multiply(row.actualQuantity, row.price).toFixed(2);
  528. }
  529. },
  530. //导入销售明细
  531. importMarket(list){
  532. list.forEach(item =>{
  533. item.contractNumber = item.orgOrderNo;
  534. item.contractAmount = item.amount;
  535. item.actualQuantity = item.orderQuantity;
  536. delete item.id
  537. this.$refs.crudContact.rowCellAdd(item);
  538. })
  539. this.sumOrderNo();
  540. this.marketDialog = false;
  541. },
  542. //选择货物品种
  543. choice(row){
  544. this.dialogVisible = true;
  545. this.selectKind = row.$index;
  546. },
  547. //选择货品
  548. commodityConfirm(){
  549. if(this.tableData){
  550. this.contactsData[this.selectKind].priceCategory = this.tableData[0].id;
  551. this.$set(this.contactsData[this.selectKind],'priceCategoryNames',this.tableData[0].cname)
  552. this.dialogVisible = !this.dialogVisible
  553. this.selectKind = -1
  554. }
  555. },
  556. //新增商品信息保存触发
  557. rowSave(row, done, loading) {
  558. console.log(row)
  559. console.log(this.contactsData)
  560. // this.contactsData.push(row)
  561. done()
  562. },
  563. //点击行可编辑
  564. handleRowClick(row, event, column) {
  565. console.log(row.$index)
  566. },
  567. //商品编辑
  568. rowCell(row, index) {
  569. console.log(row)
  570. this.$refs.crudContact.rowCell(row, index)
  571. },
  572. //修改商品信息触发
  573. rowUpdate(row, index, done, loading) {
  574. done(row);
  575. },
  576. //删除商品信息触发
  577. rowDel(row, index, donerowDel) {
  578. this.$confirm("确定将选择数据删除?", {
  579. confirmButtonText: "确定",
  580. cancelButtonText: "取消",
  581. type: "warning"
  582. }).then(() => {
  583. //商品判断是否需要调用删除接口
  584. if (row.id) {
  585. removeGoodsItem(row.id).then(res => {
  586. this.$message({
  587. type: "success",
  588. message: "操作成功!"
  589. });
  590. this.contactsData.splice(index, 1);
  591. })
  592. } else {
  593. this.$message({
  594. type: "success",
  595. message: "操作成功!"
  596. });
  597. this.contactsData.splice(index, 1);
  598. }
  599. })
  600. },
  601. confirmGoods(){
  602. if(contrastObj(this.form,this.oldForm) || contrastList(this.contactsData,this.oldContactsData)
  603. || contrastList(this.upLoadData,this.oldUpLoadData)
  604. ){
  605. this.$confirm("请先保存在进行操作!", {
  606. confirmButtonText: "保存",
  607. cancelButtonText: "取消",
  608. type: "warning"
  609. }).then(()=>{
  610. this.editCustomer()
  611. })
  612. }else{
  613. if(!this.goodsDisable){
  614. this.$confirm("是否确认发货?", {
  615. confirmButtonText: "确定",
  616. cancelButtonText: "取消",
  617. type: "warning"
  618. }).then(()=>{
  619. this.form.deliveryItemsList = this.contactsData;
  620. confirmGoods(this.form).then(res =>{
  621. if(res.data.success){
  622. this.$message.success("发货成功!")
  623. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true :false
  624. }
  625. })
  626. })
  627. }else{
  628. this.$confirm("是否撤回发货?", {
  629. confirmButtonText: "确定",
  630. cancelButtonText: "取消",
  631. type: "warning"
  632. }).then(()=>{
  633. this.form.deliveryItemsList = this.contactsData;
  634. cancelGoods(this.form).then(res =>{
  635. if(res.data.success){
  636. this.$message.success("撤销成功!")
  637. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true :false
  638. }
  639. })
  640. })
  641. }
  642. }
  643. },
  644. //修改提交触发
  645. editCustomer(status) {
  646. this.$refs["form"].validate((valid) => {
  647. for (let i = 0; i < this.contactsData.length; i++) {
  648. if (this.contactsData[i].billNo === "") {
  649. return this.$message.error(`请输入第${i + 1}行的提单号`);
  650. }
  651. if (this.contactsData[i].contractNumber === "") {
  652. return this.$message.error(`请输入第${i + 1}行的合同号`);
  653. }
  654. if (this.contactsData[i].priceCategory === "") {
  655. return this.$message.error(`请输入第${i + 1}行的货物品种`);
  656. }
  657. if (this.contactsData[i].actualQuantity === "") {
  658. return this.$message.error(`请输入第${i + 1}行的件数`);
  659. }
  660. if (this.contactsData[i].actualQuantity == 0) {
  661. return this.$message.error(`请输入第${i + 1}行的件数`);
  662. }
  663. }
  664. if (valid) {
  665. let submitDto = {
  666. ...this.form,
  667. deliveryItemsList: this.contactsData
  668. };
  669. submitInvoiceList(submitDto).then(res => {
  670. if(res.data.success){
  671. this.$message.success("操作成功!")
  672. detailInvoiceList(res.data.data.id).then(res => {
  673. this.form = res.data.data;
  674. this.oldForm = Object.assign({},res.data.data);
  675. this.goodsDisable = res.data.data.deliveryStatus === "已发货" ? true :false
  676. // this.configuration.dicData = this.form.companyName
  677. if(this.form.deliveryItemsList){
  678. this.contactsData = this.form.deliveryItemsList
  679. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  680. }
  681. if(this.form.deliveryFilesList){
  682. this.upLoadData = this.form.deliveryFilesList
  683. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  684. }
  685. })
  686. }
  687. })
  688. if(status === true){
  689. this.$emit("goBack");
  690. }
  691. } else {
  692. return false;
  693. }
  694. });
  695. },
  696. //上传文件保存
  697. upLoadSave(row, done, loading){
  698. this.upLoadData.push(row)
  699. done()
  700. },
  701. //修改附件上传触发
  702. upLoadUpdate(row, done){
  703. done(row);
  704. },
  705. //删除附件上传触发
  706. upLoadDel(row, index,){
  707. this.$confirm("确定将选择数据删除?", {
  708. confirmButtonText: "确定",
  709. cancelButtonText: "取消",
  710. type: "warning"
  711. }).then(() => {
  712. if (row.id){
  713. corpsbank(row.id).then(res=>{
  714. if(res.data.success){
  715. this.$message({
  716. type: "success",
  717. message: "操作成功!"
  718. });
  719. this.bankOfDepositData.splice(index, 1);
  720. }
  721. })
  722. }else {
  723. this.$message({
  724. type: "success",
  725. message: "操作成功!"
  726. });
  727. this.bankOfDepositData.splice(index, 1);
  728. }
  729. })
  730. },
  731. //点击商品明细选择触发
  732. commodityChoice(row) {
  733. this.dialogVisible = !this.dialogVisible
  734. this.commodityData = true
  735. this.choiceIndexT = row.$index
  736. },
  737. //商品新增触发
  738. commoditySelection() {
  739. // this.dialogVisible = !this.dialogVisible
  740. // this.commodityData = false
  741. },
  742. //导入页左商品类型查询
  743. nodeClick(data) {
  744. this.treeDeptId = data.id;
  745. this.page.currentPage = 1;
  746. this.onLoad(this.page);
  747. },
  748. //刷新触发
  749. refreshChange() {
  750. this.treeDeptId = '';
  751. this.page.currentPage = 1;
  752. this.onLoad(this.page);
  753. },
  754. //选中触发
  755. selectionChange(list) {
  756. this.tableData = list
  757. },
  758. //确认导入触发
  759. importGoods() {
  760. if (this.tableData.length > 0) {
  761. for (let item in this.tableData) {
  762. const params = {
  763. priceCategory: this.tableData[item].code,
  764. priceCategoryNames: this.tableData[item].cname,
  765. itemId: this.tableData[item].id,
  766. cname: this.tableData[item].cname
  767. }
  768. this.$refs.crudContact.rowCellAdd(params);
  769. this.$refs.crudContact.rowCell(params, this.contactsData.length - 1)
  770. }
  771. }
  772. this.tableData = []
  773. this.dialogVisible = false
  774. },
  775. //导入商品触发
  776. importChoice() {
  777. if (this.tableData.length === 1) {
  778. this.contactsData[this.choiceIndexT].cname = this.tableData[0].cname
  779. this.contactsData[this.choiceIndexT].code = this.tableData[0].code
  780. this.contactsData[this.choiceIndexT].typeno = this.tableData[0].typeno
  781. this.contactsData[this.choiceIndexT].specificationAndModel = this.tableData[0].specificationAndModel
  782. this.contactsData[this.choiceIndexT].itemId = this.tableData[0].id
  783. this.contactsData[this.choiceIndexT].priceCategory = this.tableData[0].goodsTypeName
  784. }
  785. this.dialogVisible = !this.dialogVisible
  786. this.commodityData = false
  787. },
  788. //商品列表查询
  789. onLoad(page, params = {}) {
  790. this.loading = true;
  791. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  792. const data = res.data.data;
  793. this.page.total = data.total;
  794. this.data = data.records;
  795. this.loading = false;
  796. });
  797. },
  798. //返回列表
  799. backToList() {
  800. if(contrastObj(this.form,this.oldForm) || contrastList(this.contactsData,this.oldContactsData)
  801. || contrastList(this.upLoadData,this.oldUpLoadData)
  802. ){
  803. this.$confirm("是否保存当前页面?", "提示", {
  804. confirmButtonText: "保存",
  805. cancelButtonText: "取消",
  806. type: "warning",
  807. }).then(() => {
  808. this.editCustomer(true)
  809. }).catch(()=>{
  810. this.$emit("goBack");
  811. })
  812. }else{
  813. this.$emit("goBack");
  814. }
  815. }
  816. },
  817. }
  818. </script>
  819. <style lang="scss" scoped>
  820. .customer-head {
  821. position: fixed;
  822. top: 105px;
  823. width: 100%;
  824. margin-left: -10px;
  825. height: 62px;
  826. background: #ffffff;
  827. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  828. z-index: 999;
  829. /* display: flex;
  830. justify-content: left; */
  831. }
  832. .customer-back {
  833. cursor: pointer;
  834. line-height: 62px;
  835. font-size: 16px;
  836. color: #323233;
  837. font-weight: 400;
  838. }
  839. .add-customer-btn-two {
  840. position: fixed;
  841. right: 150px;
  842. top: 115px;
  843. }
  844. .back-icon {
  845. line-height: 64px;
  846. font-size: 20px;
  847. margin-right: 8px;
  848. }
  849. .add-customer-btn {
  850. position: fixed;
  851. right: 36px;
  852. top: 115px;
  853. }
  854. ::v-deep .el-form-item {
  855. margin-bottom: 0;
  856. }
  857. .el-dialogDeep {
  858. ::v-deep .el-dialog {
  859. margin: 1vh auto 0 !important;
  860. padding-bottom: 10px !important;
  861. .el-dialog__body, .el-dialog__footer {
  862. padding-bottom: 0 !important;
  863. padding-top: 0 !important;
  864. }
  865. }
  866. }
  867. .required_fields{
  868. color: #F56C6C;
  869. display:inline-block;
  870. width: 7%
  871. }
  872. .add-customer-btn-three {
  873. position: fixed;
  874. right: 266px;
  875. top: 115px;
  876. }
  877. ::v-deep .el-form-item__content{
  878. line-height: 32px;
  879. }
  880. </style>