index.vue 22 KB

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