index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen" class="page-crad">
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree ref="treeRef" :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"
  7. @save="corpTypeVisible = true">
  8. </avue-tree>
  9. </el-col>
  10. <el-col :span="20">
  11. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  12. ref="crud" :key="key" @on-load="onLoad" @search-change="searchChange" @refresh-change="refreshChange"
  13. :cell-style="cellStyle"
  14. @search-criteria-switch="searchCriteriaSwitch"
  15. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 268)"
  16. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 268)" :page.sync="page">
  17. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  18. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  19. </template>
  20. </avue-crud>
  21. </el-col>
  22. </el-row>
  23. </basic-container>
  24. </div>
  25. </template>
  26. <script>
  27. import { getList } from "@/api/tirePartsMall/inventory";
  28. import { getToken } from "@/util/auth";
  29. import { getCorpType } from "@/api/tirePartsMall/basicData/commodityInformation";
  30. export default {
  31. name: "index",
  32. data() {
  33. return {
  34. detailsOpen: false,
  35. treeData: [],
  36. loading: false,
  37. corpTypeVisible: false,
  38. search: {},
  39. form: {},
  40. dataList: [],
  41. detailData: {},
  42. page: {
  43. pageSize: 20,
  44. currentPage: 1,
  45. total: 0,
  46. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  47. },
  48. key: 0,
  49. treeOption: {
  50. addBtn: false,
  51. menu: false,
  52. size: "small",
  53. props: {
  54. labelText: "标题",
  55. label: "title",
  56. value: "value",
  57. }
  58. },
  59. option: {},
  60. optionList: {
  61. viewBtn: false,
  62. editBtn: false,
  63. delBtn: false,
  64. addBtn: false,
  65. index: true,
  66. width: '100%',
  67. span: 8,
  68. border: true,
  69. menu: false,
  70. height: "auto",
  71. searchMenuPosition: "right",
  72. align: "center",
  73. size: "small",
  74. menuWidth: 140,
  75. searchSpan: 8,
  76. searchIcon: true,
  77. searchIndex: 2,
  78. highlightCurrentRow: true,
  79. dialogWidth: "70%",
  80. summaryText: "合计",
  81. showSummary: true,
  82. sumColumnList: [
  83. {
  84. name: 'balanceQuantity',
  85. type: 'sum',
  86. },
  87. {
  88. name: 'storeInventory',
  89. type: 'sum',
  90. },
  91. {
  92. name: 'inventoryAmount',
  93. type: 'sum',
  94. },
  95. ],
  96. column: [
  97. {
  98. label: '轮胎名称',
  99. prop: "cname",
  100. search: true,
  101. overHidden: true,
  102. },
  103. {
  104. label: '轮胎编码',
  105. prop: "code",
  106. search: true,
  107. overHidden: true,
  108. }, {
  109. label: '品牌',
  110. prop: "brandName",
  111. searchProp: "brandId",
  112. search: true,
  113. overHidden: true,
  114. type: 'select',
  115. props: {
  116. label: 'cname',
  117. value: 'id'
  118. },
  119. dicUrl: '/api/blade-sales-part/brandDesc/listAll',
  120. width: 100
  121. }, {
  122. label: '规格型号',
  123. prop: "typeno",
  124. search: true,
  125. overHidden: true,
  126. width: 100
  127. }, {
  128. label: '花纹',
  129. prop: "brandItem",
  130. overHidden: true,
  131. width: 100
  132. }, {
  133. label: '轮胎描述',
  134. prop: "productDescription",
  135. overHidden: true,
  136. width: 100
  137. }, {
  138. label: '分类',
  139. prop: "goodsTypeName",
  140. overHidden: true,
  141. width: 100
  142. }, {
  143. label: '仓库',
  144. prop: "storageName",
  145. searchProp: "storageId",
  146. search: true,
  147. overHidden: true,
  148. type: 'select',
  149. props: {
  150. label: 'cname',
  151. value: 'id'
  152. },
  153. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  154. width: 100
  155. }, {
  156. label: '库存数量',
  157. prop: "balanceQuantity",
  158. overHidden: true,
  159. width: 100
  160. }, {
  161. label: '库存单价',
  162. prop: "inventoryCostPrice",
  163. overHidden: true,
  164. width: 100
  165. }, {
  166. label: '批次',
  167. prop: "dot",
  168. overHidden: true,
  169. width: 100
  170. }, {
  171. label: '上架库存',
  172. prop: "storeInventory",
  173. overHidden: true,
  174. width: 100
  175. }, {
  176. label: '库存金额',
  177. prop: "inventoryAmount",
  178. overHidden: true,
  179. width: 100
  180. }, {
  181. label: '库存预警',
  182. prop: "inventoryAlert",
  183. overHidden: true,
  184. width: 100
  185. }, {
  186. label: '存在库存',
  187. prop: "whether",
  188. overHidden: true,
  189. search: true,
  190. type:'select',
  191. showColumn:false,
  192. hide:true,
  193. width: 100,
  194. dicData: [{
  195. "label": "是",
  196. "value": 1
  197. }, {
  198. "label": "否",
  199. "value": 0
  200. }]
  201. }]
  202. }
  203. }
  204. },
  205. async created() {
  206. this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  207. this.key++
  208. let i = 0;
  209. this.option.column.forEach(item => {
  210. if (item.search) i++
  211. })
  212. if (i % 3 !== 0) {
  213. const num = 3 - Number(i % 3)
  214. this.option.searchMenuSpan = num * 8;
  215. this.option.searchMenuPosition = "right";
  216. }
  217. this.getAllWorkDicts()
  218. },
  219. methods: {
  220. outExport() {
  221. let config = { params: { ...this.search } }
  222. if (config.params) {
  223. for (const propName of Object.keys(config.params)) {
  224. const value = config.params[propName];
  225. if (value !== null && typeof (value) !== "undefined") {
  226. if (value instanceof Array) {
  227. for (const key of Object.keys(value)) {
  228. let params = propName + '[' + key + ']';
  229. config.params[params] = value[key]
  230. }
  231. delete config.params[propName]
  232. }
  233. }
  234. }
  235. }
  236. const routeData = this.$router.resolve({
  237. path: '/api/blade-sales-part/stockDesc/stockExport', //跳转目标下载地址
  238. query: {
  239. ...config.params //括号内是要传递给新窗口的参数
  240. }
  241. })
  242. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  243. },
  244. check(row) {
  245. this.form = row
  246. this.detailsOpen = true
  247. },
  248. backToList(type) {
  249. this.form = {}
  250. this.detailsOpen = false
  251. if (type === 0) {
  252. this.detailData = {}
  253. }
  254. this.onLoad(this.page, this.search)
  255. },
  256. getAllWorkDicts() {
  257. getCorpType({ corpType: 'SP' }).then(res => {
  258. this.treeData = res.data.data;
  259. // this.findObject(this.option2.column, "parentId").dicData = res.data.data;
  260. });
  261. },
  262. nodeClick(data) {
  263. this.search.goodsTypeId = data.value
  264. this.page.currentPage = 1;
  265. this.onLoad(this.page, this.search);
  266. },
  267. //刷新
  268. refreshChange() {
  269. this.onLoad(this.page, this.search)
  270. },
  271. searchChange(params, done) {
  272. done();
  273. this.onLoad(this.page, params)
  274. },
  275. onLoad(page, params = {}) {
  276. params = {
  277. current: page.currentPage,
  278. size: page.pageSize,
  279. ...Object.assign(params, this.search)
  280. }
  281. this.loading = true
  282. getList(params).then(res => {
  283. this.dataList = res.data.data.records
  284. this.page.total = res.data.data.total
  285. this.loading = false
  286. }).finally(() => {
  287. this.loading = false
  288. })
  289. },
  290. searchCriteriaSwitch(){
  291. this.$refs.crud.getTableHeight();
  292. },
  293. cellStyle() {
  294. return "padding:0;height:40px;";
  295. },
  296. //自定义列保存
  297. async saveColumnTwo(ref, option, optionBack, code) {
  298. /**
  299. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  300. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  301. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  302. */
  303. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  304. if (inSave) {
  305. this.$message.success("保存成功");
  306. //关闭窗口
  307. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  308. }
  309. },
  310. //自定义列重置
  311. async resetColumnTwo(ref, option, optionBack, code) {
  312. this[option] = this[optionBack];
  313. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  314. if (inSave) {
  315. this.$message.success("重置成功");
  316. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  317. }
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .page-crad ::v-deep .basic-container__card {
  324. height: 94.2vh;
  325. }
  326. ::v-deep .el-form-item__error {
  327. display: none !important;
  328. }
  329. ::v-deep .el-input-group__append {
  330. padding: 0 0px !important;
  331. }
  332. .el-dialog ::v-deep .el-form-item__error {
  333. display: none !important;
  334. }
  335. .stat-td {
  336. text-align: center;
  337. position: relative;
  338. }
  339. .stat-img {
  340. width: 95%;
  341. height: 100px;
  342. }
  343. .stat-tip {
  344. position: absolute;
  345. left: 15px;
  346. top: 5px;
  347. .money {
  348. color: #fff;
  349. font-size: 28px;
  350. text-align: left;
  351. font-weight: 600;
  352. }
  353. .title {
  354. color: #fff;
  355. font-size: 14px;
  356. text-align: left;
  357. margin-top: 5px;
  358. margin-bottom: 0px;
  359. }
  360. }
  361. </style>