index.vue 20 KB

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