detailsPageEdit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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="success"
  10. class="el-button--small-yh add-customer-btn-two"
  11. :disabled="true"
  12. @click.stop="">复制新单
  13. </el-button>
  14. <el-button
  15. class="el-button--small-yh add-customer-btn"
  16. type="primary"
  17. :disabled="disabled"
  18. @click="editCustomer"
  19. >{{ form.id ? '确认修改' : '确认新增' }}
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 60px">
  23. <el-form :model="form" ref="form" label-width="130px" class="demo-ruleForm">
  24. <containerTitle title="基础信息"></containerTitle>
  25. <basic-container style="margin-bottom: 10px">
  26. <el-row>
  27. <el-col v-for="(item,index) in basicData.column" :key="index" :span="item.span?item.span:8">
  28. <el-form-item :label="item.label" :prop="item.prop" :rules="item.rules">
  29. <el-date-picker v-if="item.type === 'datetime'" style="width: 100%;" v-model="form[item.prop]" size="small" type="date" placeholder="请选择日期" value-format="yyyy-MM-dd HH:mm:ss"/>
  30. <selectComponent v-else-if="item.prop === 'corpId'" v-model="form[item.prop]" :configuration="configuration"/>
  31. <selectComponent v-else-if="item.prop === 'salesCompany'" v-model="form[item.prop]" :configuration="sConfiguration"/>
  32. <el-input type="age" v-else v-model="form[item.prop]" :disabled="item.disabled?true:false" placeholder="请输入" size="small" autocomplete="off"></el-input>
  33. </el-form-item>
  34. </el-col>
  35. </el-row>
  36. </basic-container>
  37. <containerTitle title="收货明细"></containerTitle>
  38. <basic-container style="margin-bottom: 10px">
  39. <avue-crud
  40. :option="customerContact"
  41. v-model="contactsForm"
  42. :data="contactsData"
  43. ref="crudContact"
  44. @row-save="rowSave"
  45. @row-click="handleRowClick"
  46. @row-update="rowUpdate"
  47. @row-del="rowDel"
  48. >
  49. <template slot="price" slot-scope="{ row }">
  50. <el-input
  51. v-if="row.$cellEdit"
  52. v-model="row.price"
  53. placeholder="请输入"
  54. size="small"
  55. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  56. @input="priceChange(row)"
  57. ></el-input>
  58. <span v-else>{{ row.price }}</span>
  59. </template>
  60. <template slot="actualQuantity" slot-scope="{ row }">
  61. <el-input
  62. v-if="row.$cellEdit"
  63. v-model="row.actualQuantity"
  64. placeholder="请输入"
  65. size="small"
  66. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  67. @input="quantityChange(row)"
  68. ></el-input>
  69. <span v-else>{{ row.actualQuantity }}</span>
  70. </template>
  71. <template slot="priceCategory" slot-scope="{row,index}">
  72. <span style="margin-left: 12px;padding-top: 2px">{{ row.priceCategoryNames }}</span>
  73. <el-button v-if="row.$cellEdit" type="text" size="mini" style="float: right" @click="choice(row)">选择</el-button>
  74. </template>
  75. <template slot-scope="{row,index}" slot="menu">
  76. <el-button
  77. type="text"
  78. size="small"
  79. @click="rowCell(row,index)"
  80. >{{ row.$cellEdit ? '保存' : '修改' }}
  81. </el-button>
  82. </template>
  83. <template slot="menuLeft" slot-scope="{size}">
  84. <el-button type="primary"
  85. icon="el-icon-plus"
  86. size="small"
  87. @click="commoditySelection"
  88. >新增
  89. </el-button>
  90. </template>
  91. </avue-crud>
  92. </basic-container>
  93. <containerTitle title="附件上传"></containerTitle>
  94. <basic-container style="margin-bottom: 40px">
  95. <avue-crud
  96. :option="upLoadOption"
  97. v-model="upLoadForm"
  98. :data="upLoadData"
  99. @row-save="upLoadSave"
  100. @row-update="upLoadUpdate"
  101. @row-del="upLoadDel"
  102. ></avue-crud>
  103. </basic-container>
  104. </el-form>
  105. </div>
  106. <el-dialog
  107. title="导入商品"
  108. append-to-body
  109. class="el-dialogDeep"
  110. :visible.sync="dialogVisible"
  111. width="80%"
  112. :close-on-click-modal="false"
  113. :destroy-on-close="true"
  114. :close-on-press-escape="false">
  115. <el-row style="height: 0;">
  116. <el-col :span="5">
  117. <div>
  118. <el-scrollbar>
  119. <basic-container>
  120. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  121. </basic-container>
  122. </el-scrollbar>
  123. </div>
  124. </el-col>
  125. <el-col :span="19">
  126. <basic-container>
  127. <avue-crud :option="optionTwo"
  128. :table-loading="loading"
  129. :data="data"
  130. ref="crud"
  131. @refresh-change="refreshChange"
  132. @selection-change="selectionChange"
  133. :page.sync="page"
  134. @on-load="onLoad"></avue-crud>
  135. </basic-container>
  136. </el-col>
  137. </el-row>
  138. <span slot="footer" class="dialog-footer">
  139. <el-button @click="dialogVisible = false">取 消</el-button>
  140. <el-button type="primary" @click="commodityConfirm" v-if="selectKind != -1" :disabled="tableData.length !== 1">确定</el-button>
  141. <el-button type="primary" @click="importGoods" v-if="commodityData !== true && selectKind == -1" :disabled="tableData.length !== 1" >导入</el-button>
  142. <el-button type="primary" @click="importChoice" v-if="commodityData === true && selectKind == -1"
  143. :disabled="tableData.length !== 1">导入</el-button>
  144. </span>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import customerContact from "./config/customerContact.json"
  150. import {detailInvoiceList,
  151. submitInvoiceList,
  152. removeGoodsItem,} from "@/api/importTrade/invoice"
  153. import {getDeptLazyTree } from "@/api/basicData/basicFeesDesc";
  154. import commodity from "./config/commodity.json"
  155. import {corpsbank, getList} from "@/api/basicData/deliveryNotice"
  156. import upLoadOption from "../../exportTrade/purchaseContract/config/uploadList.json";
  157. import {getSysNo} from "@/api/importTrade/purchase";
  158. import { contrastObj,contrastList } from "@/util/contrastData";
  159. export default {
  160. name: "detailsPageEdit",
  161. props: {
  162. detailData: {
  163. type: Object
  164. }
  165. },
  166. data() {
  167. return {
  168. form: {},
  169. disabled: false,
  170. customerContact: customerContact,
  171. contactsForm: {},
  172. contactsData: [],
  173. selectKind:-1,
  174. configuration:{
  175. multipleChoices:false,
  176. multiple:false,
  177. disabled:false,
  178. searchShow:true,
  179. collapseTags:false,
  180. placeholder:'请点击右边按钮选择',
  181. dicData:[]
  182. },
  183. sConfiguration:{
  184. multipleChoices:false,
  185. multiple:false,
  186. disabled:false,
  187. searchShow:true,
  188. collapseTags:false,
  189. placeholder:'请点击右边按钮选择',
  190. dicData:[]
  191. },
  192. basicData: {
  193. column: [
  194. {
  195. label: '系统号',
  196. prop: 'sysNo',
  197. disabled:true,
  198. }, {
  199. label: '合同号',
  200. prop: 'orderNo',
  201. rules: [
  202. {
  203. required: true,
  204. message: ' ',
  205. trigger: 'blur'
  206. }
  207. ]
  208. }, {
  209. label: '发货日期',
  210. prop: 'businessDate',
  211. type:'datetime',
  212. rules: [
  213. {
  214. required: false,
  215. message: ' ',
  216. trigger: 'blur'
  217. }
  218. ]
  219. }, {
  220. label: '业务员',
  221. prop: 'saleman',
  222. dicData: [],
  223. rules: [
  224. {
  225. required: false,
  226. message: ' ',
  227. trigger: 'blur'
  228. }
  229. ]
  230. }, {
  231. label: '销售公司',
  232. prop: 'salesCompany',
  233. type:'component',
  234. dicData: [],
  235. rules: [
  236. {
  237. required: false,
  238. message: ' ',
  239. trigger: 'blur'
  240. }
  241. ]
  242. }, {
  243. label: '工厂/贸易商名称',
  244. prop: 'corpId',
  245. type:'component',
  246. dicData: [],
  247. rules: [
  248. {
  249. required: false,
  250. message: ' ',
  251. trigger: 'blur'
  252. }
  253. ]
  254. }, {
  255. label: '仓库名称',
  256. prop: 'storageId',
  257. dicData: [],
  258. rules: [
  259. {
  260. required: false,
  261. message: ' ',
  262. trigger: 'blur'
  263. }
  264. ]
  265. }, {
  266. label: '发票重量',
  267. prop: 'invoiceWeight',
  268. rules: [
  269. {
  270. required: false,
  271. message: ' ',
  272. trigger: 'blur'
  273. }
  274. ]
  275. }, {
  276. label: '备注',
  277. prop: 'deliveryRemarks',
  278. span: 24,
  279. mock: {
  280. type: 'county'
  281. }
  282. }
  283. ]
  284. },
  285. //上传文件
  286. upLoadOption: upLoadOption,
  287. upLoadData:[],
  288. upLoadForm:{},
  289. dialogVisible: false,
  290. treeOption: {
  291. nodeKey: 'id',
  292. lazy: true,
  293. treeLoad: function (node, resolve) {
  294. const parentId = (node.level === 0) ? 0 : node.data.id;
  295. getDeptLazyTree(parentId).then(res => {
  296. resolve(res.data.data.map(item => {
  297. return {
  298. ...item,
  299. leaf: !item.hasChildren
  300. }
  301. }))
  302. });
  303. },
  304. treeDeptId: '',
  305. addBtn: false,
  306. menu: false,
  307. size: 'small',
  308. props: {
  309. labelText: '标题',
  310. label: 'title',
  311. value: 'value',
  312. children: 'children'
  313. }
  314. },
  315. optionTwo: commodity,
  316. loading: false,
  317. data: [],
  318. page: {
  319. pageSize: 10,
  320. currentPage: 1,
  321. total: 0
  322. },
  323. commodityData: false,
  324. tableData: [],
  325. //新旧值对比
  326. oldForm:{},
  327. oldContactsData:[],
  328. oldUpLoadData:[],
  329. }
  330. },
  331. created() {
  332. if (this.detailData.id) {
  333. let id = this.detailData.id.replace(/\"/g, "")
  334. detailInvoiceList(id).then(res => {
  335. this.form = res.data.data;
  336. this.oldForm = Object.assign({},res.data.data);
  337. this.configuration.dicData = this.form.companyName
  338. this.sConfiguration.dicData = this.form.salesCompanyNameList
  339. if(this.form.deliveryItemsList){
  340. this.contactsData = this.form.deliveryItemsList
  341. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  342. }
  343. if(this.form.deliveryFilesList){
  344. this.upLoadData = this.form.deliveryFilesList
  345. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  346. }
  347. })
  348. }else {
  349. getSysNo("JK-FH").then(res => {
  350. this.$set(this.form, "sysNo", res.data.data)
  351. })
  352. }
  353. if (this.detailData.form) {
  354. this.form = JSON.parse(this.detailData.form);
  355. this.form.id = null
  356. this.form.orderItemsList.forEach(item =>{
  357. delete item.id
  358. })
  359. this.contactsData = this.form.orderItemsList
  360. delete this.form.orderItemsList
  361. getSysNo("JK-FH").then(res => {
  362. this.$set(this.form, "sysNo", res.data.data)
  363. })
  364. }
  365. },
  366. methods: {
  367. //单价
  368. priceChange(row) {
  369. if (!row.price) {
  370. row.price = "";
  371. row.contractAmount = 0
  372. } else {
  373. row.contractAmount = (row.actualQuantity * row.price).toFixed(2);
  374. }
  375. },
  376. //件数
  377. quantityChange(row) {
  378. if (!row.actualQuantity) {
  379. row.actualQuantity = "";
  380. row.contractAmount = 0
  381. } else {
  382. row.contractAmount = (row.actualQuantity * row.price).toFixed(2);
  383. }
  384. },
  385. //选择货物品种
  386. choice(row){
  387. this.dialogVisible = true;
  388. this.selectKind = row.$index;
  389. },
  390. //选择货品
  391. commodityConfirm(){
  392. if(this.tableData){
  393. this.contactsData[this.selectKind].priceCategory = this.tableData[0].id;
  394. this.$set(this.contactsData[this.selectKind],'priceCategoryNames',this.tableData[0].cname)
  395. this.dialogVisible = !this.dialogVisible
  396. this.selectKind = -1
  397. }
  398. },
  399. //新增商品信息保存触发
  400. rowSave(row, done, loading) {
  401. console.log(row)
  402. console.log(this.contactsData)
  403. // this.contactsData.push(row)
  404. done()
  405. },
  406. //点击行可编辑
  407. handleRowClick(row, event, column) {
  408. console.log(row.$index)
  409. },
  410. //商品编辑
  411. rowCell(row, index) {
  412. console.log(row)
  413. this.$refs.crudContact.rowCell(row, index)
  414. },
  415. //修改商品信息触发
  416. rowUpdate(row, index, done, loading) {
  417. done(row);
  418. },
  419. //删除商品信息触发
  420. rowDel(row, index, donerowDel) {
  421. this.$confirm("确定将选择数据删除?", {
  422. confirmButtonText: "确定",
  423. cancelButtonText: "取消",
  424. type: "warning"
  425. }).then(() => {
  426. //商品判断是否需要调用删除接口
  427. if (row.id) {
  428. removeGoodsItem(row.id).then(res => {
  429. this.$message({
  430. type: "success",
  431. message: "操作成功!"
  432. });
  433. this.contactsData.splice(index, 1);
  434. })
  435. } else {
  436. this.$message({
  437. type: "success",
  438. message: "操作成功!"
  439. });
  440. this.contactsData.splice(index, 1);
  441. }
  442. })
  443. },
  444. //修改提交触发
  445. editCustomer(status) {
  446. this.$refs["form"].validate((valid) => {
  447. for (let i = 0; i < this.contactsData.length; i++) {
  448. if (this.contactsData[i].billNo == null) {
  449. return this.$message.error(`请输入第${i + 1}行的提单号`);
  450. }
  451. if (this.contactsData[i].contractNumber == null) {
  452. return this.$message.error(`请输入第${i + 1}行的合同号`);
  453. }
  454. }
  455. if (valid) {
  456. let submitDto = {
  457. ...this.form,
  458. deliveryItemsList: this.contactsData
  459. };
  460. submitInvoiceList(submitDto).then(res => {
  461. if(res.data.success){
  462. this.$message.success("操作成功!")
  463. detailInvoiceList(res.data.data.id).then(res => {
  464. this.form = res.data.data;
  465. this.oldForm = Object.assign({},res.data.data);
  466. this.configuration.dicData = this.form.companyName
  467. this.sConfiguration.dicData = this.form.salesCompanyNameList
  468. if(this.form.deliveryItemsList){
  469. this.contactsData = this.form.deliveryItemsList
  470. this.oldContactsData = this.deepClone(this.form.deliveryItemsList)
  471. }
  472. if(this.form.deliveryFilesList){
  473. this.upLoadData = this.form.deliveryFilesList
  474. this.oldUpLoadData = this.deepClone(this.form.deliveryFilesList)
  475. }
  476. })
  477. }
  478. })
  479. if(status === true){
  480. this.$emit("goBack");
  481. }
  482. } else {
  483. return false;
  484. }
  485. });
  486. },
  487. //上传文件保存
  488. upLoadSave(row, done, loading){
  489. this.upLoadData.push(row)
  490. done()
  491. },
  492. //修改附件上传触发
  493. upLoadUpdate(row, done){
  494. done(row);
  495. },
  496. //删除附件上传触发
  497. upLoadDel(row, index,){
  498. this.$confirm("确定将选择数据删除?", {
  499. confirmButtonText: "确定",
  500. cancelButtonText: "取消",
  501. type: "warning"
  502. }).then(() => {
  503. if (row.id){
  504. corpsbank(row.id).then(res=>{
  505. if(res.data.success){
  506. this.$message({
  507. type: "success",
  508. message: "操作成功!"
  509. });
  510. this.bankOfDepositData.splice(index, 1);
  511. }
  512. })
  513. }else {
  514. this.$message({
  515. type: "success",
  516. message: "操作成功!"
  517. });
  518. this.bankOfDepositData.splice(index, 1);
  519. }
  520. })
  521. },
  522. //点击商品明细选择触发
  523. commodityChoice(row) {
  524. this.dialogVisible = !this.dialogVisible
  525. this.commodityData = true
  526. this.choiceIndexT = row.$index
  527. },
  528. //商品新增触发
  529. commoditySelection() {
  530. this.dialogVisible = !this.dialogVisible
  531. this.commodityData = false
  532. },
  533. //导入页左商品类型查询
  534. nodeClick(data) {
  535. this.treeDeptId = data.id;
  536. this.page.currentPage = 1;
  537. this.onLoad(this.page);
  538. },
  539. //刷新触发
  540. refreshChange() {
  541. this.treeDeptId = '';
  542. this.page.currentPage = 1;
  543. this.onLoad(this.page);
  544. },
  545. //选中触发
  546. selectionChange(list) {
  547. this.tableData = list
  548. },
  549. //确认导入触发
  550. importGoods() {
  551. // this.contactsData = this.contactsData.concat(this.tableData)
  552. if (this.tableData.length > 0) {
  553. for (let item in this.tableData) {
  554. const params = {
  555. priceCategory: this.tableData[item].code,
  556. priceCategoryNames: this.tableData[item].cname,
  557. itemId: this.tableData[item].id,
  558. cname: this.tableData[item].cname
  559. }
  560. this.$refs.crudContact.rowCellAdd(params);
  561. this.$refs.crudContact.rowCell(params, this.contactsData.length - 1)
  562. }
  563. }
  564. this.tableData = []
  565. this.dialogVisible = false
  566. },
  567. //导入商品触发
  568. importChoice() {
  569. if (this.tableData.length === 1) {
  570. this.contactsData[this.choiceIndexT].cname = this.tableData[0].cname
  571. this.contactsData[this.choiceIndexT].code = this.tableData[0].code
  572. this.contactsData[this.choiceIndexT].typeno = this.tableData[0].typeno
  573. this.contactsData[this.choiceIndexT].specificationAndModel = this.tableData[0].specificationAndModel
  574. this.contactsData[this.choiceIndexT].itemId = this.tableData[0].id
  575. this.contactsData[this.choiceIndexT].priceCategory = this.tableData[0].goodsTypeName
  576. }
  577. this.dialogVisible = !this.dialogVisible
  578. this.commodityData = false
  579. },
  580. //商品列表查询
  581. onLoad(page, params = {}) {
  582. this.loading = true;
  583. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  584. const data = res.data.data;
  585. this.page.total = data.total;
  586. this.data = data.records;
  587. this.loading = false;
  588. });
  589. },
  590. //返回列表
  591. backToList() {
  592. if(contrastObj(this.form,this.oldForm) || contrastList(this.contactsData,this.oldContactsData)
  593. || contrastList(this.upLoadData,this.oldUpLoadData)
  594. ){
  595. this.$confirm("是否保存当前页面?", "提示", {
  596. confirmButtonText: "保存",
  597. cancelButtonText: "取消",
  598. type: "warning",
  599. }).then(() => {
  600. this.editCustomer(true)
  601. }).catch(()=>{
  602. this.$emit("goBack");
  603. })
  604. }else{
  605. this.$emit("goBack");
  606. }
  607. }
  608. },
  609. }
  610. </script>
  611. <style lang="scss" scoped>
  612. .customer-head {
  613. position: fixed;
  614. top: 105px;
  615. width: 100%;
  616. margin-left: -10px;
  617. height: 62px;
  618. background: #ffffff;
  619. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  620. z-index: 999;
  621. /* display: flex;
  622. justify-content: left; */
  623. }
  624. .customer-back {
  625. cursor: pointer;
  626. line-height: 62px;
  627. font-size: 16px;
  628. color: #323233;
  629. font-weight: 400;
  630. }
  631. .add-customer-btn-two {
  632. position: fixed;
  633. right: 150px;
  634. top: 115px;
  635. }
  636. .back-icon {
  637. line-height: 64px;
  638. font-size: 20px;
  639. margin-right: 8px;
  640. }
  641. .add-customer-btn {
  642. position: fixed;
  643. right: 36px;
  644. top: 115px;
  645. }
  646. ::v-deep .el-form-item {
  647. margin-bottom: 0;
  648. }
  649. .el-dialogDeep {
  650. ::v-deep .el-dialog {
  651. margin: 1vh auto 0 !important;
  652. padding-bottom: 10px !important;
  653. .el-dialog__body, .el-dialog__footer {
  654. padding-bottom: 0 !important;
  655. padding-top: 0 !important;
  656. }
  657. }
  658. }
  659. </style>