detailsPageEdit.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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. export default {
  159. name: "detailsPageEdit",
  160. props: {
  161. detailData: {
  162. type: Object
  163. }
  164. },
  165. data() {
  166. return {
  167. form: {},
  168. disabled: false,
  169. customerContact: customerContact,
  170. contactsForm: {},
  171. contactsData: [],
  172. selectKind:-1,
  173. configuration:{
  174. multipleChoices:false,
  175. multiple:false,
  176. disabled:false,
  177. searchShow:true,
  178. collapseTags:false,
  179. placeholder:'请点击右边按钮选择',
  180. dicData:[]
  181. },
  182. sConfiguration:{
  183. multipleChoices:false,
  184. multiple:false,
  185. disabled:false,
  186. searchShow:true,
  187. collapseTags:false,
  188. placeholder:'请点击右边按钮选择',
  189. dicData:[]
  190. },
  191. basicData: {
  192. column: [
  193. {
  194. label: '系统号',
  195. prop: 'sysNo',
  196. disabled:true,
  197. }, {
  198. label: '合同号',
  199. prop: 'orderNo',
  200. rules: [
  201. {
  202. required: true,
  203. message: ' ',
  204. trigger: 'blur'
  205. }
  206. ]
  207. }, {
  208. label: '发货日期',
  209. prop: 'businessDate',
  210. type:'datetime',
  211. rules: [
  212. {
  213. required: false,
  214. message: ' ',
  215. trigger: 'blur'
  216. }
  217. ]
  218. }, {
  219. label: '业务员',
  220. prop: 'saleman',
  221. dicData: [],
  222. rules: [
  223. {
  224. required: false,
  225. message: ' ',
  226. trigger: 'blur'
  227. }
  228. ]
  229. }, {
  230. label: '销售公司',
  231. prop: 'salesCompany',
  232. type:'component',
  233. dicData: [],
  234. rules: [
  235. {
  236. required: false,
  237. message: ' ',
  238. trigger: 'blur'
  239. }
  240. ]
  241. }, {
  242. label: '工厂/贸易商名称',
  243. prop: 'corpId',
  244. type:'component',
  245. dicData: [],
  246. rules: [
  247. {
  248. required: false,
  249. message: ' ',
  250. trigger: 'blur'
  251. }
  252. ]
  253. }, {
  254. label: '仓库名称',
  255. prop: 'storageId',
  256. dicData: [],
  257. rules: [
  258. {
  259. required: false,
  260. message: ' ',
  261. trigger: 'blur'
  262. }
  263. ]
  264. }, {
  265. label: '发票重量',
  266. prop: 'invoiceWeight',
  267. rules: [
  268. {
  269. required: false,
  270. message: ' ',
  271. trigger: 'blur'
  272. }
  273. ]
  274. }, {
  275. label: '备注',
  276. prop: 'deliveryRemarks',
  277. span: 24,
  278. mock: {
  279. type: 'county'
  280. }
  281. }
  282. ]
  283. },
  284. //上传文件
  285. upLoadOption: upLoadOption,
  286. upLoadData:[],
  287. upLoadForm:{},
  288. dialogVisible: false,
  289. treeOption: {
  290. nodeKey: 'id',
  291. lazy: true,
  292. treeLoad: function (node, resolve) {
  293. const parentId = (node.level === 0) ? 0 : node.data.id;
  294. getDeptLazyTree(parentId).then(res => {
  295. resolve(res.data.data.map(item => {
  296. return {
  297. ...item,
  298. leaf: !item.hasChildren
  299. }
  300. }))
  301. });
  302. },
  303. treeDeptId: '',
  304. addBtn: false,
  305. menu: false,
  306. size: 'small',
  307. props: {
  308. labelText: '标题',
  309. label: 'title',
  310. value: 'value',
  311. children: 'children'
  312. }
  313. },
  314. optionTwo: commodity,
  315. loading: false,
  316. data: [],
  317. page: {
  318. pageSize: 10,
  319. currentPage: 1,
  320. total: 0
  321. },
  322. commodityData: false,
  323. tableData: [],
  324. }
  325. },
  326. created() {
  327. if (this.detailData.id) {
  328. let id = this.detailData.id.replace(/\"/g, "")
  329. detailInvoiceList(id).then(res => {
  330. this.form = res.data.data;
  331. this.configuration.dicData = this.form.companyName
  332. this.sConfiguration.dicData = this.form.salesCompanyNameList
  333. this.contactsData = this.form.deliveryItemsList
  334. })
  335. }else {
  336. getSysNo("JK-FH").then(res => {
  337. this.$set(this.form, "sysNo", res.data.data)
  338. })
  339. }
  340. if (this.detailData.form) {
  341. this.form = JSON.parse(this.detailData.form);
  342. this.form.id = null
  343. this.form.orderItemsList.forEach(item =>{
  344. delete item.id
  345. })
  346. this.contactsData = this.form.orderItemsList
  347. delete this.form.orderItemsList
  348. getSysNo("JK-FH").then(res => {
  349. this.$set(this.form, "sysNo", res.data.data)
  350. })
  351. }
  352. },
  353. methods: {
  354. //单价
  355. priceChange(row) {
  356. if (!row.price) {
  357. row.price = "";
  358. row.contractAmount = 0
  359. } else {
  360. row.contractAmount = (row.actualQuantity * row.price).toFixed(2);
  361. }
  362. },
  363. //件数
  364. quantityChange(row) {
  365. if (!row.actualQuantity) {
  366. row.actualQuantity = "";
  367. row.contractAmount = 0
  368. } else {
  369. row.contractAmount = (row.actualQuantity * row.price).toFixed(2);
  370. }
  371. },
  372. //选择货物品种
  373. choice(row){
  374. this.dialogVisible = true;
  375. this.selectKind = row.$index;
  376. },
  377. //选择货品
  378. commodityConfirm(){
  379. if(this.tableData){
  380. this.contactsData[this.selectKind].priceCategory = this.tableData[0].id;
  381. this.$set(this.contactsData[this.selectKind],'priceCategoryNames',this.tableData[0].cname)
  382. this.dialogVisible = !this.dialogVisible
  383. this.selectKind = -1
  384. }
  385. },
  386. //新增商品信息保存触发
  387. rowSave(row, done, loading) {
  388. console.log(row)
  389. console.log(this.contactsData)
  390. // this.contactsData.push(row)
  391. done()
  392. },
  393. //点击行可编辑
  394. handleRowClick(row, event, column) {
  395. console.log(row.$index)
  396. },
  397. //商品编辑
  398. rowCell(row, index) {
  399. console.log(row)
  400. this.$refs.crudContact.rowCell(row, index)
  401. },
  402. //修改商品信息触发
  403. rowUpdate(row, index, done, loading) {
  404. done(row);
  405. },
  406. //删除商品信息触发
  407. rowDel(row, index, donerowDel) {
  408. this.$confirm("确定将选择数据删除?", {
  409. confirmButtonText: "确定",
  410. cancelButtonText: "取消",
  411. type: "warning"
  412. }).then(() => {
  413. //商品判断是否需要调用删除接口
  414. if (row.id) {
  415. removeGoodsItem(row.id).then(res => {
  416. this.$message({
  417. type: "success",
  418. message: "操作成功!"
  419. });
  420. this.contactsData.splice(index, 1);
  421. })
  422. } else {
  423. this.$message({
  424. type: "success",
  425. message: "操作成功!"
  426. });
  427. this.contactsData.splice(index, 1);
  428. }
  429. })
  430. },
  431. //修改提交触发
  432. editCustomer(status) {
  433. this.$refs["form"].validate((valid) => {
  434. for (let i = 0; i < this.contactsData.length; i++) {
  435. if (this.contactsData[i].billNo == null) {
  436. return this.$message.error(`请输入第${i + 1}行的提单号`);
  437. }
  438. if (this.contactsData[i].contractNumber == null) {
  439. return this.$message.error(`请输入第${i + 1}行的合同号`);
  440. }
  441. }
  442. if (valid) {
  443. let submitDto = {
  444. ...this.form,
  445. deliveryItemsList: this.contactsData
  446. };
  447. submitInvoiceList(submitDto).then(res => {
  448. if(res.data.success){
  449. this.$message.success("操作成功!")
  450. detailInvoiceList(res.data.data.id).then(res => {
  451. this.form = res.data.data;
  452. this.configuration.dicData = this.form.companyName
  453. this.sConfiguration.dicData = this.form.salesCompanyNameList
  454. this.contactsData = this.form.deliveryItemsList
  455. })
  456. }
  457. })
  458. if(status === true){
  459. this.$emit("goBack");
  460. }
  461. } else {
  462. return false;
  463. }
  464. });
  465. },
  466. //上传文件保存
  467. upLoadSave(row, done, loading){
  468. this.upLoadData.push(row)
  469. done()
  470. },
  471. //修改附件上传触发
  472. upLoadUpdate(row, done){
  473. done(row);
  474. },
  475. //删除附件上传触发
  476. upLoadDel(row, index,){
  477. this.$confirm("确定将选择数据删除?", {
  478. confirmButtonText: "确定",
  479. cancelButtonText: "取消",
  480. type: "warning"
  481. }).then(() => {
  482. if (row.id){
  483. corpsbank(row.id).then(res=>{
  484. if(res.data.success){
  485. this.$message({
  486. type: "success",
  487. message: "操作成功!"
  488. });
  489. this.bankOfDepositData.splice(index, 1);
  490. }
  491. })
  492. }else {
  493. this.$message({
  494. type: "success",
  495. message: "操作成功!"
  496. });
  497. this.bankOfDepositData.splice(index, 1);
  498. }
  499. })
  500. },
  501. //点击商品明细选择触发
  502. commodityChoice(row) {
  503. this.dialogVisible = !this.dialogVisible
  504. this.commodityData = true
  505. this.choiceIndexT = row.$index
  506. },
  507. //商品新增触发
  508. commoditySelection() {
  509. this.dialogVisible = !this.dialogVisible
  510. this.commodityData = false
  511. },
  512. //导入页左商品类型查询
  513. nodeClick(data) {
  514. this.treeDeptId = data.id;
  515. this.page.currentPage = 1;
  516. this.onLoad(this.page);
  517. },
  518. //刷新触发
  519. refreshChange() {
  520. this.treeDeptId = '';
  521. this.page.currentPage = 1;
  522. this.onLoad(this.page);
  523. },
  524. //选中触发
  525. selectionChange(list) {
  526. this.tableData = list
  527. },
  528. //确认导入触发
  529. importGoods() {
  530. // this.contactsData = this.contactsData.concat(this.tableData)
  531. if (this.tableData.length > 0) {
  532. for (let item in this.tableData) {
  533. const params = {
  534. priceCategory: this.tableData[item].code,
  535. priceCategoryNames: this.tableData[item].cname,
  536. itemId: this.tableData[item].id,
  537. cname: this.tableData[item].cname
  538. }
  539. this.$refs.crudContact.rowCellAdd(params);
  540. this.$refs.crudContact.rowCell(params, this.contactsData.length - 1)
  541. }
  542. }
  543. this.tableData = []
  544. this.dialogVisible = false
  545. },
  546. //导入商品触发
  547. importChoice() {
  548. if (this.tableData.length === 1) {
  549. this.contactsData[this.choiceIndexT].cname = this.tableData[0].cname
  550. this.contactsData[this.choiceIndexT].code = this.tableData[0].code
  551. this.contactsData[this.choiceIndexT].typeno = this.tableData[0].typeno
  552. this.contactsData[this.choiceIndexT].specificationAndModel = this.tableData[0].specificationAndModel
  553. this.contactsData[this.choiceIndexT].itemId = this.tableData[0].id
  554. this.contactsData[this.choiceIndexT].priceCategory = this.tableData[0].goodsTypeName
  555. }
  556. this.dialogVisible = !this.dialogVisible
  557. this.commodityData = false
  558. },
  559. //商品列表查询
  560. onLoad(page, params = {}) {
  561. this.loading = true;
  562. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  563. const data = res.data.data;
  564. this.page.total = data.total;
  565. this.data = data.records;
  566. this.loading = false;
  567. });
  568. },
  569. //返回列表
  570. backToList() {
  571. this.$confirm("是否保存当前页面?", "提示", {
  572. confirmButtonText: "保存",
  573. cancelButtonText: "取消",
  574. type: "warning",
  575. }).then(() => {
  576. this.editCustomer(true)
  577. }).catch(() => {
  578. this.$emit("goBack");
  579. })
  580. }
  581. },
  582. }
  583. </script>
  584. <style lang="scss" scoped>
  585. .customer-head {
  586. position: fixed;
  587. top: 105px;
  588. width: 100%;
  589. margin-left: -10px;
  590. height: 62px;
  591. background: #ffffff;
  592. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  593. z-index: 999;
  594. /* display: flex;
  595. justify-content: left; */
  596. }
  597. .customer-back {
  598. cursor: pointer;
  599. line-height: 62px;
  600. font-size: 16px;
  601. color: #323233;
  602. font-weight: 400;
  603. }
  604. .add-customer-btn-two {
  605. position: fixed;
  606. right: 150px;
  607. top: 115px;
  608. }
  609. .back-icon {
  610. line-height: 64px;
  611. font-size: 20px;
  612. margin-right: 8px;
  613. }
  614. .add-customer-btn {
  615. position: fixed;
  616. right: 36px;
  617. top: 115px;
  618. }
  619. ::v-deep .el-form-item {
  620. margin-bottom: 0;
  621. }
  622. .el-dialogDeep {
  623. ::v-deep .el-dialog {
  624. margin: 1vh auto 0 !important;
  625. padding-bottom: 10px !important;
  626. .el-dialog__body, .el-dialog__footer {
  627. padding-bottom: 0 !important;
  628. padding-top: 0 !important;
  629. }
  630. }
  631. }
  632. </style>