detailsPageEdit.vue 19 KB

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