detailsPageEdit.vue 16 KB

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