detailsPageEdit.vue 15 KB

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