index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen" class="page-crad">
  4. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  5. <el-tab-pane label="明细" name="first">
  6. <el-row>
  7. <el-col :span="4">
  8. <avue-tree ref="treeRef" :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"
  9. @save="corpTypeVisible = true">
  10. </avue-tree>
  11. </el-col>
  12. <el-col :span="20">
  13. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  14. ref="crud" :key="key" @on-load="onLoad" @search-change="searchChange" @refresh-change="refreshChange"
  15. :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch"
  16. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 268)"
  17. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 268)" :page.sync="page">
  18. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  19. <div style="display: flex;align-items: center;">
  20. <div style="display: flex;align-items: center;">
  21. <div class="buttonBox">
  22. <span>库存数量总计:</span>
  23. <span>{{ stockSum.balanceQuantity }}</span>
  24. </div>
  25. <div class="buttonBox">
  26. <span>库存金额总计:</span>
  27. <span>{{ stockSum.inventoryAmount }}</span>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <template slot-scope="{ row }" slot="balanceQuantity">
  33. <span style="color: #409EFF;cursor: pointer" @click.stop="storeInventoryOpen(row)">
  34. {{ row.balanceQuantity }}
  35. </span>
  36. </template>
  37. </avue-crud>
  38. </el-col>
  39. </el-row>
  40. </el-tab-pane>
  41. <el-tab-pane label="品牌" name="second">
  42. <avue-crud :option="brandOption" :table-loading="loading" :data="brandList" ref="crudBrand"
  43. :search.sync="brandSearch" @on-load="onbrandLoad" @search-change="brandsearchChange"
  44. @refresh-change="brandrefreshChange" :cell-style="cellStyle">
  45. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  46. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  47. </template>
  48. </avue-crud>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </basic-container>
  52. <report-dialog :switchDialog="switchDialog" reportName="轮胎商城--盘库单" :reportId="form.id"
  53. @onClose="onClose()"></report-dialog>
  54. </div>
  55. </template>
  56. <script>
  57. import { getList, stockDescStockSum, stockBrandList } from "@/api/tirePartsMall/inventory";
  58. import { getToken } from "@/util/auth";
  59. import { getCorpType } from "@/api/tirePartsMall/basicData/commodityInformation";
  60. import reportDialog from "@/components/report-dialog/main.vue";
  61. export default {
  62. name: "index",
  63. components: { reportDialog },
  64. data() {
  65. return {
  66. activeName: "first",
  67. switchDialog: false, // 打印弹窗
  68. detailsOpen: false,
  69. treeData: [],
  70. loading: false,
  71. corpTypeVisible: false,
  72. search: { whether: '0', ifGrounding: '1' },
  73. form: {},
  74. dataList: [],
  75. stockSum: {}, // 合计数据
  76. detailData: {},
  77. params: {
  78. corpId: null,
  79. itemId: null
  80. },
  81. page: {
  82. pageSize: 20,
  83. currentPage: 1,
  84. total: 0,
  85. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 1000]
  86. },
  87. key: 0,
  88. treeOption: {
  89. addBtn: false,
  90. menu: false,
  91. size: "small",
  92. props: {
  93. labelText: "标题",
  94. label: "title",
  95. value: "value",
  96. }
  97. },
  98. option: {},
  99. optionList: {
  100. viewBtn: false,
  101. editBtn: false,
  102. delBtn: false,
  103. addBtn: false,
  104. index: true,
  105. width: '100%',
  106. span: 8,
  107. border: true,
  108. menu: false,
  109. // height: "auto",
  110. searchMenuPosition: "right",
  111. align: "center",
  112. size: "small",
  113. menuWidth: 140,
  114. searchSpan: 8,
  115. searchIcon: true,
  116. searchIndex: 2,
  117. highlightCurrentRow: true,
  118. dialogWidth: "70%",
  119. summaryText: "合计",
  120. showSummary: true,
  121. sumColumnList: [
  122. {
  123. name: 'balanceQuantity',
  124. type: 'sum',
  125. decimals: 0
  126. },
  127. {
  128. name: 'storeInventory',
  129. type: 'sum',
  130. },
  131. {
  132. name: 'inventoryAmount',
  133. type: 'sum',
  134. },
  135. ],
  136. column: [
  137. {
  138. label: '商品名称',
  139. prop: "cname",
  140. search: true,
  141. overHidden: true,
  142. },
  143. {
  144. label: '商品编码',
  145. prop: "code",
  146. search: true,
  147. overHidden: true,
  148. }, {
  149. label: '品牌',
  150. prop: "brandName",
  151. // searchProp: "brandId",
  152. search: true,
  153. overHidden: true,
  154. type: 'select',
  155. props: {
  156. label: 'cname',
  157. value: 'cname'
  158. },
  159. dicUrl: '/api/blade-sales-part/brandDesc/listAllV1?type=PP&enableOrNot=1',
  160. width: 100
  161. }, {
  162. label: '规格型号',
  163. prop: "typeno",
  164. search: true,
  165. overHidden: true,
  166. width: 100
  167. }, {
  168. label: '花纹',
  169. prop: "brandItem",
  170. overHidden: true,
  171. width: 100
  172. }, {
  173. label: '商品描述',
  174. prop: "productDescription",
  175. overHidden: true,
  176. width: 100
  177. }, {
  178. label: '分类',
  179. prop: "goodsTypeId",
  180. overHidden: true,
  181. props: {
  182. label: 'title',
  183. value: 'value',
  184. children: 'children'
  185. },
  186. dicUrl: '/api/blade-sales-part/goodsType/tree?corpType=SP',
  187. width: 100
  188. }, {
  189. label: '仓库',
  190. prop: "storageId",
  191. // searchProp: "storageId",
  192. search: true,
  193. overHidden: true,
  194. hide: true,
  195. type: 'select',
  196. props: {
  197. label: 'cname',
  198. value: 'id'
  199. },
  200. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  201. width: 100
  202. },
  203. {
  204. label: '仓库',
  205. prop: "storageName",
  206. overHidden: true,
  207. width: 100
  208. },
  209. {
  210. label: '库存数量',
  211. prop: "balanceQuantity",
  212. overHidden: true,
  213. width: 100
  214. }, {
  215. label: '库存单价',
  216. prop: "inventoryCostPrice",
  217. overHidden: true,
  218. width: 100
  219. }, {
  220. label: '批次',
  221. search: true,
  222. prop: "dot",
  223. overHidden: true,
  224. width: 100
  225. },
  226. // {
  227. // label: '上架库存',
  228. // prop: "storeInventory",
  229. // overHidden: true,
  230. // width: 100
  231. // },
  232. {
  233. label: '库存金额',
  234. prop: "inventoryAmount",
  235. overHidden: true,
  236. width: 100
  237. }, {
  238. label: '库存预警',
  239. prop: "inventoryAlert",
  240. overHidden: true,
  241. width: 100
  242. }, {
  243. label: '是否显示零库存',
  244. prop: "whether",
  245. overHidden: true,
  246. search: true,
  247. type: 'select',
  248. showColumn: false,
  249. hide: true,
  250. width: 120,
  251. searchLabelWidth: 120,
  252. searchValue: '0',
  253. dicData: [{
  254. label: '是',
  255. value: '1'
  256. }, {
  257. label: '否',
  258. value: '0'
  259. }],
  260. }, {
  261. label: '是否上架',
  262. prop: "ifGrounding",
  263. overHidden: true,
  264. search: true,
  265. type: 'select',
  266. dicData: [{
  267. label: '未上架',
  268. value: '0'
  269. }, {
  270. label: '已上架',
  271. value: '1'
  272. }],
  273. searchValue: '1',
  274. }]
  275. },
  276. brandOption: {
  277. addBtn: false,
  278. menu: false,
  279. align: "center",
  280. searchMenuSpan: 12,
  281. height: "700",
  282. column: [
  283. {
  284. label: '仓库',
  285. prop: "storageId",
  286. search: true,
  287. overHidden: true,
  288. hide: true,
  289. showColumn: false,
  290. type: 'select',
  291. filterable: true,
  292. props: {
  293. label: 'cname',
  294. value: 'id'
  295. },
  296. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  297. },
  298. {
  299. label: '品牌',
  300. prop: "brandId",
  301. search: true,
  302. overHidden: true,
  303. hide: true,
  304. showColumn: false,
  305. type: 'select',
  306. filterable: true,
  307. props: {
  308. label: 'cname',
  309. value: 'id'
  310. },
  311. dicUrl: '/api/blade-sales-part/brandDesc/listAll?type=PP&enableOrNot=1'
  312. },
  313. {
  314. label: '品牌',
  315. prop: 'brandName'
  316. }, {
  317. label: '合计',
  318. prop: 'goodsSizeTotal'
  319. }, {
  320. label: '12',
  321. prop: 'goodsSize12'
  322. }, {
  323. label: '13',
  324. prop: 'goodsSize13'
  325. }, {
  326. label: '14',
  327. prop: 'goodsSize14'
  328. }, {
  329. label: '15',
  330. prop: 'goodsSize15'
  331. }, {
  332. label: '16',
  333. prop: 'goodsSize16'
  334. }, {
  335. label: '17',
  336. prop: 'goodsSize17'
  337. }, {
  338. label: '18',
  339. prop: 'goodsSize18'
  340. }, {
  341. label: '19',
  342. prop: 'goodsSize19'
  343. }, {
  344. label: '20',
  345. prop: 'goodsSize20'
  346. }, {
  347. label: '21',
  348. prop: 'goodsSize21'
  349. }, {
  350. label: '22',
  351. prop: 'goodsSize22'
  352. }, {
  353. label: '23',
  354. prop: 'goodsSize23'
  355. }, {
  356. label: '24',
  357. prop: 'goodsSize24'
  358. }, {
  359. label: '25',
  360. prop: 'goodsSize25'
  361. }, {
  362. label: '26',
  363. prop: 'goodsSize26'
  364. }, {
  365. label: '27',
  366. prop: 'goodsSize27'
  367. }, {
  368. label: '28',
  369. prop: 'goodsSize28'
  370. }, {
  371. label: '其它',
  372. prop: 'goodsSizeOther'
  373. }
  374. ]
  375. },
  376. brandList: [],
  377. brandSearch: {}
  378. }
  379. },
  380. async created() {
  381. // this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  382. this.option = this.optionList
  383. this.key++
  384. let i = 0;
  385. this.option.column.forEach(item => {
  386. if (item.search) i++
  387. })
  388. if (i % 3 !== 0) {
  389. const num = 3 - Number(i % 3)
  390. this.option.searchMenuSpan = num * 8;
  391. this.option.searchMenuPosition = "right";
  392. }
  393. this.option.height = window.innerHeight - 260;
  394. this.getAllWorkDicts()
  395. },
  396. methods: {
  397. // 导出
  398. outExport() {
  399. let config = { params: { ...this.brandSearch } }
  400. if (config.params) {
  401. for (const propName of Object.keys(config.params)) {
  402. const value = config.params[propName];
  403. if (value !== null && typeof (value) !== "undefined") {
  404. if (value instanceof Array) {
  405. for (const key of Object.keys(value)) {
  406. let params = propName + '[' + key + ']';
  407. config.params[params] = value[key]
  408. }
  409. delete config.params[propName]
  410. }
  411. }
  412. }
  413. }
  414. const routeData = this.$router.resolve({
  415. path: '/api/blade-sales-part/stockDesc/stockBrandExport', //跳转目标下载地址
  416. query: {
  417. ...config.params
  418. }
  419. })
  420. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  421. },
  422. handleClick() {
  423. if (this.activeName == 'second') {
  424. this.onbrandLoad()
  425. }
  426. },
  427. brandsearchChange(params, done) {
  428. this.page.currentPage = 1
  429. this.brandSearch = params;
  430. done();
  431. this.onbrandLoad()
  432. },
  433. brandrefreshChange() {
  434. this.onLoad()
  435. },
  436. onbrandLoad() {
  437. this.loading = true
  438. stockBrandList(this.brandSearch).then(res => {
  439. this.brandList = res.data.data
  440. }).finally(() => {
  441. this.loading = false
  442. })
  443. },
  444. // 打印
  445. handlePrint() {
  446. this.switchDialog = !this.switchDialog;
  447. },
  448. onClose(val) {
  449. this.switchDialog = val;
  450. },
  451. check(row) {
  452. this.form = row
  453. this.detailsOpen = true
  454. },
  455. backToList(type) {
  456. this.form = {}
  457. this.detailsOpen = false
  458. if (type === 0) {
  459. this.detailData = {}
  460. }
  461. this.onLoad(this.page, this.search)
  462. },
  463. getAllWorkDicts() {
  464. getCorpType({ corpType: 'SP' }).then(res => {
  465. this.treeData = res.data.data;
  466. // this.findObject(this.option2.column, "parentId").dicData = res.data.data;
  467. });
  468. },
  469. nodeClick(data) {
  470. this.search.goodsTypeId = data.value
  471. this.page.currentPage = 1;
  472. this.onLoad(this.page, this.search);
  473. },
  474. //刷新
  475. refreshChange() {
  476. this.onLoad(this.page, this.search)
  477. },
  478. searchChange(params, done) {
  479. this.page.currentPage = 1
  480. done();
  481. this.onLoad(this.page, params)
  482. },
  483. onLoad(page, params = {}) {
  484. console.log(params);
  485. params = {
  486. storageId: params.storageId,
  487. current: page.currentPage,
  488. size: page.pageSize,
  489. ...Object.assign(params, this.search)
  490. }
  491. this.loading = true
  492. getList(params).then(res => {
  493. this.dataList = res.data.data.records
  494. this.page.total = res.data.data.total
  495. stockDescStockSum(params).then(re => {
  496. this.stockSum = re.data.data
  497. })
  498. this.$nextTick(() => {
  499. this.$refs.crud.doLayout()
  500. })
  501. this.loading = false
  502. }).finally(() => {
  503. this.loading = false
  504. })
  505. },
  506. searchCriteriaSwitch(type) {
  507. if (type) {
  508. this.option.height = this.option.height - 104;
  509. } else {
  510. this.option.height = this.option.height + 104;
  511. }
  512. this.$refs.crud.getTableHeight();
  513. },
  514. cellStyle() {
  515. return "padding:0;height:40px;";
  516. },
  517. //点击可用库存打开
  518. storeInventoryOpen(row) {
  519. console.log(this.$store.getters.inventoryAccount);
  520. if (this.$store.getters.inventoryAccount) {
  521. this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
  522. confirmButtonText: "确定",
  523. type: "warning",
  524. callback: action => {
  525. console.log(action);
  526. }
  527. });
  528. } else {
  529. console.log(row)
  530. this.params.corpId = row.corpId
  531. this.params.itemId = row.goodsId
  532. this.params.storageId = row.storageId
  533. this.$router.$avueRouter.closeTag("/tirePartsMall/inventory/detail");
  534. this.$router.push({
  535. path: "/tirePartsMall/inventory/detail",
  536. query: {
  537. stockId: row.storageId,
  538. goodsId: row.goodsId,
  539. dot: row.dot
  540. },
  541. });
  542. }
  543. },
  544. //自定义列保存
  545. async saveColumnTwo(ref, option, optionBack, code) {
  546. /**
  547. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  548. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  549. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  550. */
  551. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  552. if (inSave) {
  553. this.$message.success("保存成功");
  554. //关闭窗口
  555. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  556. }
  557. },
  558. //自定义列重置
  559. async resetColumnTwo(ref, option, optionBack, code) {
  560. this[option] = this[optionBack];
  561. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  562. if (inSave) {
  563. this.$message.success("重置成功");
  564. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  565. }
  566. }
  567. }
  568. }
  569. </script>
  570. <style lang="scss" scoped>
  571. .buttonBox {
  572. font-size: 12px;
  573. color: #909399;
  574. margin-left: 10px;
  575. border: 1px solid #d3d4d6;
  576. border-radius: 3px;
  577. padding: 6px 10px;
  578. background: #f4f4f5;
  579. }
  580. .page-crad ::v-deep .basic-container__card {
  581. height: 94.2vh;
  582. }
  583. ::v-deep .el-form-item__error {
  584. display: none !important;
  585. }
  586. ::v-deep .el-input-group__append {
  587. padding: 0 0px !important;
  588. }
  589. .el-dialog ::v-deep .el-form-item__error {
  590. display: none !important;
  591. }
  592. .stat-td {
  593. text-align: center;
  594. position: relative;
  595. }
  596. .stat-img {
  597. width: 95%;
  598. height: 100px;
  599. }
  600. .stat-tip {
  601. position: absolute;
  602. left: 15px;
  603. top: 5px;
  604. .money {
  605. color: #fff;
  606. font-size: 28px;
  607. text-align: left;
  608. font-weight: 600;
  609. }
  610. .title {
  611. color: #fff;
  612. font-size: 14px;
  613. text-align: left;
  614. margin-top: 5px;
  615. margin-bottom: 0px;
  616. }
  617. }
  618. </style>