index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud
  5. :option="option"
  6. :search.sync="search"
  7. v-model="form"
  8. :table-loading="loading"
  9. :data="dataList"
  10. ref="crud"
  11. :key="key"
  12. @on-load="onLoad"
  13. @search-change="searchChange"
  14. @refresh-change="refreshChange"
  15. @resetColumn="resetColumnTwo('crud','option','optionList',268)"
  16. @saveColumn="saveColumnTwo('crud','option','optionList',268)"
  17. :page.sync="page">
  18. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  19. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  20. </template>
  21. </avue-crud>
  22. </basic-container>
  23. </div>
  24. </template>
  25. <script>
  26. import {getList} from "@/api/tirePartsMall/inventory";
  27. import {getToken} from "@/util/auth";
  28. export default {
  29. name: "index",
  30. data() {
  31. return {
  32. detailsOpen: false,
  33. loading: false,
  34. search: {},
  35. form: {},
  36. dataList: [],
  37. detailData: {},
  38. page: {
  39. pageSize: 20,
  40. currentPage: 1,
  41. total: 0,
  42. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  43. },
  44. key: 0,
  45. option: {},
  46. optionList: {
  47. viewBtn: false,
  48. editBtn: false,
  49. delBtn: false,
  50. addBtn: false,
  51. index: true,
  52. width:'100%',
  53. span: 8,
  54. border: true,
  55. menu:false,
  56. height: "auto",
  57. searchMenuPosition: "right",
  58. align: "center",
  59. size: "small",
  60. menuWidth: 140,
  61. searchSpan: 8,
  62. searchIcon: true,
  63. searchIndex: 2,
  64. highlightCurrentRow: true,
  65. dialogWidth: "70%",
  66. summaryText: "合计",
  67. showSummary: true,
  68. sumColumnList:[
  69. {
  70. name: 'balanceQuantity',
  71. type: 'sum',
  72. },
  73. {
  74. name: 'storeInventory',
  75. type: 'sum',
  76. },
  77. {
  78. name: 'inventoryAmount',
  79. type: 'sum',
  80. },
  81. ],
  82. column: [{
  83. label: '物料编号',
  84. prop: "code",
  85. search: true,
  86. overHidden: true,
  87. },{
  88. label: '商品名称',
  89. prop: "cname",
  90. search: true,
  91. overHidden: true,
  92. },{
  93. label: '品牌',
  94. prop: "brandName",
  95. searchProp: "brandId",
  96. search: true,
  97. overHidden: true,
  98. type: 'select',
  99. props: {
  100. label: 'cname',
  101. value: 'id'
  102. },
  103. dicUrl: '/api/blade-sales-part/brandDesc/listAll',
  104. width:100
  105. },{
  106. label: '规格型号',
  107. prop: "typeno",
  108. search: true,
  109. overHidden: true,
  110. width:100
  111. },{
  112. label: '花纹',
  113. prop: "brandItem",
  114. overHidden: true,
  115. width:100
  116. },{
  117. label: '商品描述',
  118. prop: "productDescription",
  119. overHidden: true,
  120. width:100
  121. },{
  122. label: '分类',
  123. prop: "goodsTypeName",
  124. overHidden: true,
  125. width:100
  126. },{
  127. label: '仓库',
  128. prop: "storageName",
  129. searchProp: "storageId",
  130. search: true,
  131. overHidden: true,
  132. type: 'select',
  133. props: {
  134. label: 'cname',
  135. value: 'id'
  136. },
  137. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  138. width:100
  139. },{
  140. label: '库存数量',
  141. prop: "balanceQuantity",
  142. overHidden: true,
  143. width:100
  144. },{
  145. label: '批次',
  146. prop: "dot",
  147. overHidden: true,
  148. width:100
  149. },{
  150. label: '上架库存',
  151. prop: "storeInventory",
  152. overHidden: true,
  153. width:100
  154. },{
  155. label: '库存金额',
  156. prop: "inventoryAmount",
  157. overHidden: true,
  158. width:100
  159. },{
  160. label: '库存成本',
  161. prop: "inventoryCostPrice",
  162. overHidden: true,
  163. width:100
  164. },{
  165. label: '库存预警',
  166. prop: "inventoryAlert",
  167. overHidden: true,
  168. width:100
  169. }]
  170. }
  171. }
  172. },
  173. async created() {
  174. this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  175. this.key++
  176. let i = 0;
  177. this.option.column.forEach(item => {
  178. if (item.search) i++
  179. })
  180. if (i % 3 !== 0) {
  181. const num = 3 - Number(i % 3)
  182. this.option.searchMenuSpan = num * 8;
  183. this.option.searchMenuPosition = "right";
  184. }
  185. },
  186. methods: {
  187. outExport() {
  188. let config = {params: {...this.search}}
  189. if (config.params) {
  190. for (const propName of Object.keys(config.params)) {
  191. const value = config.params[propName];
  192. if (value !== null && typeof (value) !== "undefined") {
  193. if (value instanceof Array) {
  194. for (const key of Object.keys(value)) {
  195. let params = propName + '[' + key + ']';
  196. config.params[params] = value[key]
  197. }
  198. delete config.params[propName]
  199. }
  200. }
  201. }
  202. }
  203. const routeData = this.$router.resolve({
  204. path: '/api/blade-sales-part/stockDesc/stockExport', //跳转目标下载地址
  205. query: {
  206. ...config.params //括号内是要传递给新窗口的参数
  207. }
  208. })
  209. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  210. },
  211. check(row) {
  212. this.form = row
  213. this.detailsOpen = true
  214. },
  215. backToList(type) {
  216. this.form = {}
  217. this.detailsOpen = false
  218. if (type === 0) {
  219. this.detailData = {}
  220. }
  221. this.onLoad(this.page, this.search)
  222. },
  223. //刷新
  224. refreshChange() {
  225. this.onLoad(this.page, this.search)
  226. },
  227. searchChange(params, done) {
  228. done();
  229. this.onLoad(this.page, params)
  230. },
  231. onLoad(page, params = {}) {
  232. params = {
  233. current: page.currentPage,
  234. size: page.pageSize,
  235. ...Object.assign(params, this.search)
  236. }
  237. this.loading = true
  238. getList(params).then(res => {
  239. this.dataList = res.data.data.records
  240. this.page.total = res.data.data.total
  241. this.loading = false
  242. }).finally(() => {
  243. this.loading = false
  244. })
  245. },
  246. //自定义列保存
  247. async saveColumnTwo(ref, option, optionBack, code) {
  248. /**
  249. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  250. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  251. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  252. */
  253. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  254. if (inSave) {
  255. this.$message.success("保存成功");
  256. //关闭窗口
  257. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  258. }
  259. },
  260. //自定义列重置
  261. async resetColumnTwo(ref, option, optionBack, code) {
  262. this[option] = this[optionBack];
  263. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  264. if (inSave) {
  265. this.$message.success("重置成功");
  266. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  267. }
  268. }
  269. }
  270. }
  271. </script>
  272. <style scoped>
  273. </style>