index.vue 11 KB

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