index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  5. ref="crud" :key="key" @on-load="onLoad" @search-change="searchChange" @row-del="rowDel"
  6. @expand-change="expandChange" @refresh-change="refreshChange"
  7. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 274.4)"
  8. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 274.4)" :page.sync="page">
  9. <template slot-scope="{ row }" slot="expand">
  10. <avue-crud :data="row.itemData" :option="itemOption" :table-loading="row.itemLoading" :cell-style="cellStyle"
  11. class="itemTable"></avue-crud>
  12. </template>
  13. <template slot-scope="{type,size,row,index}" slot="menu">
  14. <!-- <el-button :size="size" :type="type" @click="check(row)">查看</el-button> -->
  15. <!-- 判断是否一键采购过 然后展示不同的判断按钮-->
  16. <el-button v-if="row.shortcutWarehousingStatus == '1'" :size="size" :type="type"
  17. :disabled="row.status != '录入' && row.item >= 1"
  18. @click="$refs.crud.rowDel(row, index)">删除</el-button>
  19. <el-button v-else :size="size" :type="type"
  20. :disabled="row.status != '录入' && row.status != '待确认' && row.item >= 1 || row.numberRows >= 1"
  21. @click="$refs.crud.rowDel(row, index)">删除</el-button>
  22. </template>
  23. <template slot="corpNameSearch">
  24. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  25. </template>
  26. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  27. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新建订单</el-button>
  28. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  29. </template>
  30. <template slot-scope="{ row, index }" slot="ordNo">
  31. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.ordNo }}
  32. </span>
  33. </template>
  34. <template slot-scope="{ row, index }" slot="srcOrdNo">
  35. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 3)">{{ row.srcOrdNo }}
  36. </span>
  37. </template>
  38. </avue-crud>
  39. </basic-container>
  40. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  41. </div>
  42. </template>
  43. <script>
  44. import { getList, remove, getGoodsInfo } from "@/api/tirePartsMall/salesManagement/saleOrder";
  45. import detailsPage from "./detailsPage"
  46. import { getDetails } from "@/api/tirePartsMall/salesManagement/saleOrder";
  47. import {getToken} from "@/util/auth";
  48. export default {
  49. name: "index",
  50. components: {
  51. detailsPage
  52. },
  53. data() {
  54. return {
  55. detailsOpen: false,
  56. loading: false,
  57. search: {},
  58. form: {},
  59. dataList: [],
  60. detailData: {},
  61. page: {
  62. pageSize: 20,
  63. currentPage: 1,
  64. total: 0,
  65. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  66. },
  67. key: 0,
  68. itemOption: {
  69. align: "center",
  70. header: false,
  71. border: true,
  72. menu: false,
  73. column: [
  74. {
  75. label: '商品名称',
  76. prop: 'goodsId',
  77. width: 200,
  78. disabled: false,
  79. remote: true,
  80. overHidden: true,
  81. type: 'select',
  82. // dicData: [],
  83. props: {
  84. label: 'cname',
  85. value: 'id'
  86. },
  87. dicUrl: "/api/blade-sales-part/goodsDesc/goodsListAll"
  88. }, {
  89. label: '数量',
  90. prop: 'goodsNum',
  91. overHidden: true,
  92. disabled: false,
  93. width: 100,
  94. rules: [{
  95. required: true,
  96. message: " ",
  97. trigger: "blur"
  98. }, {
  99. validator: (rule, value, callback) => {
  100. console.log(this.formContacts.inventory);
  101. if (value < 0) {
  102. callback(new Error("数量不能小于0"));
  103. } else {
  104. callback();
  105. }
  106. },
  107. trigger: "blur"
  108. }]
  109. },
  110. {
  111. label: '价格',
  112. prop: 'price',
  113. overHidden: true,
  114. width: 100,
  115. disabled: false,
  116. rules: [{
  117. required: true,
  118. message: " ",
  119. trigger: "blur"
  120. }, {
  121. validator: (rule, value, callback) => {
  122. if (value < 0) {
  123. callback(new Error("价格不能小于0"));
  124. } else {
  125. callback();
  126. }
  127. },
  128. trigger: "blur"
  129. }]
  130. },
  131. {
  132. label: '库存',
  133. prop: 'inventory',
  134. overHidden: true,
  135. hide: true,
  136. width: 100
  137. }, {
  138. label: '批次号',
  139. prop: 'dot',
  140. type: "select",
  141. disabled: true,
  142. allowCreate: true,
  143. filterable: true,
  144. dicData: [],
  145. props: {
  146. label: "dot",
  147. value: "dot"
  148. },
  149. dicUrl: "/api/blade-sales-part/stockDesc/dotList",
  150. overHidden: true,
  151. }, {
  152. label: '商品编码',
  153. prop: 'goodsNo',
  154. overHidden: true,
  155. disabled: false,
  156. width: 100
  157. },
  158. // {
  159. // label: '品牌',
  160. // prop: 'brandId',
  161. // disabled: false,
  162. // width: 100,
  163. // overHidden: true,
  164. // type: 'select',
  165. // props: {
  166. // label: 'cname',
  167. // value: 'id'
  168. // },
  169. // dicUrl: '/api/blade-sales-part/brandDesc/listAll?type=PP'
  170. // },
  171. {
  172. label: '品牌',
  173. prop: 'brandName',
  174. overHidden: true,
  175. disabled: false,
  176. width: 100
  177. },
  178. {
  179. label: '规格型号',
  180. prop: 'propertyName',
  181. overHidden: true,
  182. disabled: false,
  183. width: 100
  184. }, {
  185. label: '花纹',
  186. prop: 'pattern',
  187. overHidden: true,
  188. disabled: false,
  189. width: 100
  190. }, {
  191. label: '商品描述',
  192. prop: 'goodsDescription',
  193. disabled: false,
  194. overHidden: true,
  195. width: 100
  196. },
  197. {
  198. label: '收货数量',
  199. prop: 'sendNum',
  200. disabled: false,
  201. overHidden: true,
  202. width: 100,
  203. disabled: true,
  204. editDisplay: false,
  205. addDisplay: false
  206. }
  207. ]
  208. },
  209. option: {},
  210. optionList: {
  211. viewBtn: false,
  212. editBtn: false,
  213. delBtn: false,
  214. addBtn: false,
  215. index: true,
  216. span: 8,
  217. border: true,
  218. height: "auto",
  219. searchMenuPosition: "right",
  220. align: "center",
  221. size: "small",
  222. menuWidth: 50,
  223. searchSpan: 8,
  224. searchIcon: true,
  225. searchIndex: 2,
  226. highlightCurrentRow: true,
  227. expand: true,
  228. expandWidth: 60,
  229. dialogWidth: "70%",
  230. summaryText: "合计",
  231. showSummary: true,
  232. sumColumnList: [{
  233. name: 'goodsTotalNum',
  234. type: 'sum',
  235. decimals: 0
  236. }, {
  237. name: 'totalMoney',
  238. type: 'sum',
  239. decimals: 2
  240. },],
  241. column: [{
  242. label: '采购单号',
  243. prop: "ordNo",
  244. search: true,
  245. overHidden: true,
  246. },
  247. // {
  248. // label: '来源单号',
  249. // prop: "srcOrdNo",
  250. // search: true,
  251. // overHidden: true,
  252. // },
  253. // {
  254. // label: "业务来源",
  255. // prop: "businessSource",
  256. // overHidden: true,
  257. // search: true,
  258. // type: 'select',
  259. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=business_Source",
  260. // props: {
  261. // label: "dictValue",
  262. // value: "dictKey"
  263. // }
  264. // },
  265. {
  266. label: '所属公司',
  267. prop: "salesCompanyName",
  268. overHidden: true,
  269. }, {
  270. label: '业务对象',
  271. prop: "customerId",
  272. type: 'select',
  273. remote:true,
  274. search: true,
  275. overHidden: true,
  276. props: {
  277. label: 'cname',
  278. value: 'id'
  279. },
  280. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?cname={{key}}&corpType=GYS',
  281. }, {
  282. label: '仓库',
  283. prop: "storageId",
  284. search: true,
  285. // remote:true,
  286. overHidden: true,
  287. type: 'select',
  288. props: {
  289. label: 'cname',
  290. value: 'id'
  291. },
  292. dicUrl: '/api/blade-sales-part/storageDesc/listAll?cname={{key}}',
  293. }, {
  294. label: '行数',
  295. prop: "numberRows",
  296. overHidden: true,
  297. }, {
  298. label: '数量',
  299. prop: "goodsTotalNum",
  300. overHidden: true,
  301. }, {
  302. label: '金额',
  303. prop: "totalMoney",
  304. overHidden: true,
  305. }, {
  306. label: '已付金额',
  307. prop: "paymentAmountTl",
  308. disabled: true
  309. }, {
  310. label: '状态',
  311. prop: "status",
  312. search: true,
  313. overHidden: true,
  314. type: 'select',
  315. dicUrl: "/api/blade-system/dict-biz/dictionary?code=procurement_Status",
  316. props: {
  317. label: "dictValue",
  318. value: "dictKey"
  319. }
  320. },
  321. {
  322. label: '结算状态',
  323. prop: "actualPaymentStatus",
  324. searchProp:'actualPaymentType',
  325. search: true,
  326. overHidden: true,
  327. type: 'select',
  328. dicData: [
  329. {
  330. label: "待付款",
  331. value: 1,
  332. },
  333. {
  334. label: "已付款",
  335. value: 2,
  336. },
  337. {
  338. label: "尾款",
  339. value: 3,
  340. }
  341. ],
  342. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=settlement_Status",
  343. // props: {
  344. // label: "dictValue",
  345. // value: "dictKey"
  346. // }
  347. },
  348. // {
  349. // label: '应结日期',
  350. // prop: "dueDate",
  351. // overHidden: true,
  352. // },
  353. {
  354. label: "制单人",
  355. prop: "createUserName",
  356. searchProp: "createUser",
  357. overHidden: true,
  358. width: 100,
  359. filterable: true,
  360. remote: true,
  361. type: "select",
  362. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  363. props: {
  364. label: "account",
  365. value: "id",
  366. res: 'data.records'
  367. }
  368. }, {
  369. label: "制单日期",
  370. prop: "createTime",
  371. searchProp: "createTimeList",
  372. type: "date",
  373. overHidden: true,
  374. width: 100,
  375. searchRange: true,
  376. searchDefaultTime: ["00:00:00", "23:59:59"],
  377. format: "yyyy-MM-dd",
  378. valueFormat: "yyyy-MM-dd HH:mm:ss"
  379. }, {
  380. label: '业务日期',
  381. prop: "businesDate",
  382. overHidden: true,
  383. searchProp: "businesDateList",
  384. type: "date",
  385. overHidden: true,
  386. search: true,
  387. width: 100,
  388. searchRange: true,
  389. searchDefaultTime: ["00:00:00", "23:59:59"],
  390. format: "yyyy-MM-dd",
  391. valueFormat: "yyyy-MM-dd HH:mm:ss"
  392. }, {
  393. label: "更新人",
  394. prop: "updateUserName",
  395. searchProp: "updateUser",
  396. overHidden: true,
  397. width: 100,
  398. filterable: true,
  399. remote: true,
  400. type: "select",
  401. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  402. props: {
  403. label: "account",
  404. value: "id",
  405. res: 'data.records'
  406. }
  407. }, {
  408. label: "更新日期",
  409. prop: "updateTime",
  410. searchProp: "updateTimeList",
  411. type: "date",
  412. overHidden: true,
  413. width: 100,
  414. searchRange: true,
  415. searchDefaultTime: ["00:00:00", "23:59:59"],
  416. format: "yyyy-MM-dd",
  417. valueFormat: "yyyy-MM-dd HH:mm:ss"
  418. }]
  419. }
  420. }
  421. },
  422. activated() {
  423. setTimeout(() => {
  424. console.log(this.$route.query,400);
  425. // 主页快捷跳转来的 直接打开新建订单
  426. if (this.$route.query.showTrue) {
  427. this.$store.commit("IN_LTCG_STATUS");
  428. this.detailsOpen = true;
  429. }
  430. if (this.$route.query.check) {
  431. this.editOpen({ id: this.$route.query.check.srcBillId }, 1)
  432. this.$store.commit("IN_LTCG_STATUS");
  433. }
  434. if(this.$route.query.type == 'F'){
  435. this.editOpen({ id: this.$route.query.detail.srcParentId }, 1)
  436. }
  437. this.detailData = {
  438. id: this.$route.query.check.billId,
  439. check: this.$route.query.check,
  440. auditId: this.$route.query.check.id
  441. };
  442. }, 100);
  443. },
  444. async created() {
  445. this.option = await this.getColumnData(this.getColumnName(274.4), this.optionList);
  446. this.key++
  447. let i = 0;
  448. this.option.column.forEach(item => {
  449. if (item.search) i++
  450. })
  451. if (i % 3 !== 0) {
  452. const num = 3 - Number(i % 3)
  453. this.option.searchMenuSpan = num * 8;
  454. this.option.searchMenuPosition = "right";
  455. }
  456. },
  457. methods: {
  458. // 导出
  459. outExport() {
  460. console.log(this.search,412)
  461. let config = { params: { ...this.search } }
  462. if (config.params) {
  463. for (const propName of Object.keys(config.params)) {
  464. const value = config.params[propName];
  465. if (value !== null && typeof (value) !== "undefined") {
  466. if (value instanceof Array) {
  467. for (const key of Object.keys(value)) {
  468. let params = propName + '[' + key + ']';
  469. config.params[params] = value[key]
  470. }
  471. delete config.params[propName]
  472. }
  473. }
  474. }
  475. }
  476. config.params.bsType = 'CG'
  477. console.log(config,427)
  478. const routeData = this.$router.resolve({
  479. path: '/api/blade-sales-part/order/listExport', //跳转目标下载地址
  480. query: {
  481. ...config.params //括号内是要传递给新窗口的参数
  482. }
  483. })
  484. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  485. },
  486. check(row) {
  487. this.form = row
  488. this.detailsOpen = true
  489. },
  490. backToList(type) {
  491. this.form = {}
  492. this.detailsOpen = false
  493. if (type === 0) {
  494. this.detailData = {}
  495. }
  496. this.$store.commit("OUT_LTCG_STATUS");
  497. this.onLoad(this.page, this.search)
  498. },
  499. editOpen(row, status) {
  500. this.form = row
  501. this.detailData = {
  502. id: row.id,
  503. status: status
  504. };
  505. console.log(status);
  506. this.$store.commit("IN_LTCG_STATUS");
  507. this.detailsOpen = true;
  508. },
  509. //刷新
  510. refreshChange() {
  511. this.onLoad(this.page, this.search)
  512. },
  513. rowDel(form, index) {
  514. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  515. confirmButtonText: '确定',
  516. cancelButtonText: '取消',
  517. type: 'warning'
  518. }).then(() => {
  519. remove({ id: form.id }).then(res => {
  520. this.$message({
  521. type: 'success',
  522. message: '删除成功!'
  523. });
  524. this.dataList.splice(index, 1);
  525. this.onLoad(this.page)
  526. })
  527. }).catch(() => {
  528. });
  529. },
  530. // 点击搜索触发
  531. searchChange(params, done) {
  532. this.page.currentPage = 1
  533. done();
  534. this.onLoad(this.page, params)
  535. },
  536. onLoad(page, params = {}) {
  537. params = {
  538. ...params,
  539. current: page.currentPage,
  540. size: page.pageSize,
  541. bsType: "CG",
  542. ...Object.assign(params, this.search)
  543. }
  544. this.loading = true
  545. this.dataList.forEach(item => {
  546. this.$refs.crud.toggleRowExpansion(item, false);
  547. });
  548. getList(params).then(res => {
  549. if (res.data.data.records) {
  550. res.data.data.records.forEach(e => {
  551. e.itemLoading = true;
  552. });
  553. }
  554. this.dataList = res.data.data.records
  555. this.page.total = res.data.data.total
  556. this.$nextTick(() => {
  557. this.$refs.crud.doLayout()
  558. })
  559. this.loading = false
  560. }).finally(() => {
  561. this.loading = false
  562. })
  563. },
  564. expandChange(row) {
  565. if (!row.itemData) {
  566. getDetails({ id: row.id})
  567. .then(res => {
  568. this.dataList[row.$index].itemData = res.data.data.orderItemsList;
  569. })
  570. .finally(() => {
  571. this.dataList[row.$index].itemLoading = false;
  572. });
  573. }
  574. },
  575. //自定义列保存
  576. async saveColumnTwo(ref, option, optionBack, code) {
  577. /**
  578. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  579. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  580. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  581. */
  582. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  583. if (inSave) {
  584. this.$message.success("保存成功");
  585. //关闭窗口
  586. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  587. }
  588. },
  589. //自定义列重置
  590. async resetColumnTwo(ref, option, optionBack, code) {
  591. this[option] = this[optionBack];
  592. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  593. if (inSave) {
  594. this.$message.success("重置成功");
  595. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  596. }
  597. }
  598. }
  599. }
  600. </script>
  601. <style scoped></style>