index.vue 20 KB

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