index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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="balanceQuantity">
  20. <span style="color: #409EFF;cursor: pointer" @click.stop="storeInventoryOpen(row)">{{ row.balanceQuantity }}
  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: {whether:'0'},
  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: "brandId",
  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. search: true,
  175. prop: "dot",
  176. overHidden: true,
  177. width: 100
  178. }, {
  179. label: '上架库存',
  180. prop: "storeInventory",
  181. overHidden: true,
  182. width: 100
  183. }, {
  184. label: '库存金额',
  185. prop: "inventoryAmount",
  186. overHidden: true,
  187. width: 100
  188. }, {
  189. label: '库存预警',
  190. prop: "inventoryAlert",
  191. overHidden: true,
  192. width: 100
  193. }, {
  194. label: '是否显示库存',
  195. prop: "whether",
  196. overHidden: true,
  197. search: true,
  198. type: 'select',
  199. showColumn: false,
  200. hide: true,
  201. width: 120,
  202. searchLabelWidth: 120,
  203. searchValue:'0',
  204. dicData: [{
  205. label: '是',
  206. value: '1'
  207. }, {
  208. label: '否',
  209. value: '0'
  210. }],
  211. }]
  212. }
  213. }
  214. },
  215. async created() {
  216. // this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  217. this.option = this.optionList
  218. this.key++
  219. let i = 0;
  220. this.option.column.forEach(item => {
  221. if (item.search) i++
  222. })
  223. if (i % 3 !== 0) {
  224. const num = 3 - Number(i % 3)
  225. this.option.searchMenuSpan = num * 8;
  226. this.option.searchMenuPosition = "right";
  227. }
  228. this.getAllWorkDicts()
  229. },
  230. methods: {
  231. outExport() {
  232. let config = { params: { ...this.search } }
  233. if (config.params) {
  234. for (const propName of Object.keys(config.params)) {
  235. const value = config.params[propName];
  236. if (value !== null && typeof (value) !== "undefined") {
  237. if (value instanceof Array) {
  238. for (const key of Object.keys(value)) {
  239. let params = propName + '[' + key + ']';
  240. config.params[params] = value[key]
  241. }
  242. delete config.params[propName]
  243. }
  244. }
  245. }
  246. }
  247. const routeData = this.$router.resolve({
  248. path: '/api/blade-sales-part/stockDesc/stockExport', //跳转目标下载地址
  249. query: {
  250. ...config.params //括号内是要传递给新窗口的参数
  251. }
  252. })
  253. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  254. },
  255. check(row) {
  256. this.form = row
  257. this.detailsOpen = true
  258. },
  259. backToList(type) {
  260. this.form = {}
  261. this.detailsOpen = false
  262. if (type === 0) {
  263. this.detailData = {}
  264. }
  265. this.onLoad(this.page, this.search)
  266. },
  267. getAllWorkDicts() {
  268. getCorpType({ corpType: 'SP' }).then(res => {
  269. this.treeData = res.data.data;
  270. // this.findObject(this.option2.column, "parentId").dicData = res.data.data;
  271. });
  272. },
  273. nodeClick(data) {
  274. this.search.goodsTypeId = data.value
  275. this.page.currentPage = 1;
  276. this.onLoad(this.page, this.search);
  277. },
  278. //刷新
  279. refreshChange() {
  280. this.onLoad(this.page, this.search)
  281. },
  282. searchChange(params, done) {
  283. done();
  284. this.onLoad(this.page, params)
  285. },
  286. onLoad(page, params = {}) {
  287. console.log(params);
  288. params = {
  289. storageId:params.storageName,
  290. current: page.currentPage,
  291. size: page.pageSize,
  292. ...Object.assign(params, this.search)
  293. }
  294. this.loading = true
  295. getList(params).then(res => {
  296. this.dataList = res.data.data.records
  297. this.page.total = res.data.data.total
  298. this.$nextTick(() => {
  299. this.$refs.crud.doLayout()
  300. })
  301. this.loading = false
  302. }).finally(() => {
  303. this.loading = false
  304. })
  305. },
  306. searchCriteriaSwitch() {
  307. this.$refs.crud.getTableHeight();
  308. },
  309. cellStyle() {
  310. return "padding:0;height:40px;";
  311. },
  312. //点击可用库存打开
  313. storeInventoryOpen(row) {
  314. console.log(this.$store.getters.inventoryAccount);
  315. if (this.$store.getters.inventoryAccount) {
  316. this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
  317. confirmButtonText: "确定",
  318. type: "warning",
  319. callback: action => {
  320. console.log(action);
  321. }
  322. });
  323. } else {
  324. console.log(row)
  325. this.params.corpId = row.corpId
  326. this.params.itemId = row.goodsId
  327. this.params.storageId = row.storageId
  328. this.$router.$avueRouter.closeTag("/tirePartsMall/inventory/detail");
  329. this.$router.push({
  330. path: "/tirePartsMall/inventory/detail",
  331. query: {
  332. stockId: row.storageId,
  333. goodsId: row.goodsId,
  334. dot:row.dot
  335. },
  336. });
  337. }
  338. },
  339. //自定义列保存
  340. async saveColumnTwo(ref, option, optionBack, code) {
  341. /**
  342. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  343. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  344. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  345. */
  346. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  347. if (inSave) {
  348. this.$message.success("保存成功");
  349. //关闭窗口
  350. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  351. }
  352. },
  353. //自定义列重置
  354. async resetColumnTwo(ref, option, optionBack, code) {
  355. this[option] = this[optionBack];
  356. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  357. if (inSave) {
  358. this.$message.success("重置成功");
  359. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  360. }
  361. }
  362. }
  363. }
  364. </script>
  365. <style lang="scss" scoped>
  366. .page-crad ::v-deep .basic-container__card {
  367. height: 94.2vh;
  368. }
  369. ::v-deep .el-form-item__error {
  370. display: none !important;
  371. }
  372. ::v-deep .el-input-group__append {
  373. padding: 0 0px !important;
  374. }
  375. .el-dialog ::v-deep .el-form-item__error {
  376. display: none !important;
  377. }
  378. .stat-td {
  379. text-align: center;
  380. position: relative;
  381. }
  382. .stat-img {
  383. width: 95%;
  384. height: 100px;
  385. }
  386. .stat-tip {
  387. position: absolute;
  388. left: 15px;
  389. top: 5px;
  390. .money {
  391. color: #fff;
  392. font-size: 28px;
  393. text-align: left;
  394. font-weight: 600;
  395. }
  396. .title {
  397. color: #fff;
  398. font-size: 14px;
  399. text-align: left;
  400. margin-top: 5px;
  401. margin-bottom: 0px;
  402. }
  403. }
  404. </style>