index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-main">
  4. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList" @resert="onRefresh"
  5. @detail="shortBarge" @onRefresh="onRefresh">
  6. </module-view>
  7. </div>
  8. <batchbyOneModal ref="batchbyOneModal" />
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  13. import api from "@/api/currency";
  14. import batchbyOneModal from './components/batchbyOneModal.vue'
  15. @Component({components:{batchbyOneModal}})
  16. export default class Store extends Vue {
  17. timeNum = 0;
  18. skuInfo : any = ''
  19. storeHouseInfo : any = ''
  20. tableInfo : any = ''
  21. timer : any = null
  22. config : any = {
  23. attr: {
  24. calculateH: true
  25. },
  26. search: {
  27. attr: {
  28. size: 'mini',
  29. },
  30. columns: [
  31. [
  32. {
  33. span: 6,
  34. label: '标题',
  35. prop: 'skuTitle',
  36. component: 'by-input',
  37. // labelWidth: '70px',
  38. compConfig: {
  39. attr: {
  40. placeholder: '请输入标题',
  41. clearable: true
  42. }
  43. }
  44. },
  45. {
  46. span: 6,
  47. label: '物料编码',
  48. prop: 'skuCode',
  49. component: 'by-input',
  50. // labelWidth: '70px',
  51. compConfig: {
  52. attr: {
  53. placeholder: '请输入物料编码',
  54. clearable: true
  55. }
  56. }
  57. },
  58. ]
  59. ]
  60. },
  61. tool: {
  62. tools: {
  63. refresh: true,
  64. search: true,
  65. },
  66. customTools:[{
  67. name:'短驳调拨',
  68. icon:'el-icon-discount',
  69. event:{
  70. click: () => {
  71. this.shortBargeHandel()
  72. }
  73. }
  74. }]
  75. },
  76. table: {
  77. attr: {
  78. size: 'mini',
  79. align: 'left',
  80. checkbox: true,
  81. },
  82. columns: [
  83. {
  84. // width: '200px',
  85. title: '标题',
  86. field: 'skuTitle',
  87. // isDetail: true,
  88. fixed: 'left'
  89. },
  90. {
  91. // width: '200px',
  92. title: '副标题',
  93. field: 'skuSubtitle',
  94. },
  95. {
  96. // width: '140px',
  97. title: '物料编码',
  98. field: 'skuCode',
  99. },
  100. ]
  101. },
  102. }
  103. mounted() {
  104. this.timer = setInterval(() => {
  105. this.getDataList()
  106. }, 300)
  107. }
  108. //短驳处理
  109. shortBargeHandel(){
  110. let data = (this.$refs.moduleView as any).getSelectData();
  111. if(!data || data.length == 0) {
  112. this.$message('请选择数据');
  113. return
  114. }
  115. if(this.$refs.batchbyOneModal){
  116. (this.$refs.batchbyOneModal as any).setShow(true);
  117. (this.$refs.batchbyOneModal as any).setValue(data)
  118. }
  119. }
  120. // 获取列表数据
  121. getDataList() {
  122. if (!this.$refs.moduleView) {
  123. if (this.timeNum > 5) {
  124. clearInterval(this.timer)
  125. }
  126. this.timeNum++;
  127. return
  128. }
  129. clearInterval(this.timer)
  130. // this.getPageList(); //旧代码无分页
  131. // 新分页
  132. let query = (this.$refs.moduleView as any).getQuery();
  133. this.newsGetPageList(query)
  134. }
  135. // 新分页
  136. newsGetPageList(query : any) {
  137. let loading = this.$loading({ target: '.main-container' });
  138. api.getMaterialInventory().then((res : any) => {
  139. if (res.code === 200) {
  140. this.skuInfo = res.data;
  141. } else loading.close();
  142. }).then(() => {
  143. api.pageList({}, 'maindataStorehouse').then((res : any) => {
  144. if (res.code === 200) {
  145. this.storeHouseInfo = res.data.records;
  146. } else loading.close();
  147. if (res.code === 200) {
  148. let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
  149. this.storeHouseInfo = res.data.records;
  150. res.data.records.map((v : any, i : any) => {
  151. moduleConfig.columns.push({
  152. // width: '150px',
  153. title: v.name,
  154. field: 'custom' + i,
  155. });
  156. });
  157. (this as any).$refs.moduleView.setTableConfig(moduleConfig);
  158. }
  159. }).then(() => {
  160. api.pageList(query, 'maindataMaterialSku').then((res : any) => {
  161. loading.close();
  162. if (res.code === 200) {
  163. for (let i = 0; i < res.data.records.length; i++) {
  164. for (let j = 0; j < this.storeHouseInfo.length; j++) {
  165. let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
  166. if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
  167. }
  168. }
  169. (this.$refs.moduleView as any).setTableValue(res.data.records);
  170. this.tableInfo = res.data.records;
  171. loading.close();
  172. let page = {
  173. pageNo: res.data.current, //当前页
  174. pageSize: res.data.size, //每页条数
  175. total: res.data.total //总条数
  176. };
  177. (this.$refs.moduleView as any).setPage(page);
  178. } else this.$message.error(res.msg);
  179. }).catch(() => loading.close());
  180. }).catch(() => loading.close());
  181. }).catch(() => loading.close());
  182. }
  183. //旧代码无分页
  184. getPageList() {
  185. let loading = this.$loading({ target: '.main-container' });
  186. api.getMaterialInventory().then((res : any) => {
  187. if (res.code === 200) {
  188. this.skuInfo = res.data;
  189. } else loading.close();
  190. }).then(() => {
  191. api.pageList({}, 'maindataStorehouse').then((res : any) => {
  192. if (res.code === 200) {
  193. this.storeHouseInfo = res.data.records;
  194. } else loading.close();
  195. if (res.code === 200) {
  196. let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
  197. this.storeHouseInfo = res.data.records;
  198. res.data.records.map((v : any, i : any) => {
  199. moduleConfig.columns.push({
  200. width: '120px',
  201. title: v.name,
  202. field: 'custom' + i,
  203. });
  204. });
  205. // moduleConfig.columns.push({
  206. // width: 120,
  207. // title: '操作',
  208. // action: true,
  209. // plugins: [{
  210. // name: '短驳',
  211. // event: {
  212. // click: (item : any) => {
  213. // (this as any).shortBarge(item)
  214. // }
  215. // }
  216. // }, {
  217. // name: '调拨',
  218. // event: {
  219. // click: (item : any) => (this as any).allocate(item)
  220. // }
  221. // }]
  222. // });
  223. (this as any).$refs.moduleView.setTableConfig(moduleConfig);
  224. }
  225. }).then(() => {
  226. api.pageList({
  227. pageNo: 1,
  228. pageSize: 20,
  229. }, 'maindataMaterialSku').then((res : any) => {
  230. if (res.code === 200) {
  231. for (let i = 0; i < res.data.records.length; i++) {
  232. for (let j = 0; j < this.storeHouseInfo.length; j++) {
  233. let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
  234. if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
  235. }
  236. }
  237. (this.$refs.moduleView as any).setTableValue(res.data.records);
  238. this.tableInfo = res.data.records;
  239. loading.close();
  240. // let page = {
  241. // pageNo: res.data.current, //当前页
  242. // pageSize: res.data.size, //每页条数
  243. // total: res.data.total //总条数
  244. // };
  245. // (this.$refs.moduleView as any).setPage(page);
  246. } else loading.close();
  247. }).catch(() => loading.close());
  248. }).catch(() => loading.close());
  249. }).catch(() => loading.close());
  250. }
  251. // 查询
  252. search() {
  253. let searchID : any = (this as any).$refs.moduleView.searchID;
  254. let value = (this as any).$refs.moduleView.$refs[searchID].value;
  255. if (value.skuTitle) {
  256. if (value.skuCode) {
  257. // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode && v.skuTitle == value.skuTitle);
  258. let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1 && v.skuTitle.indexOf(value.skuTitle)>-1);
  259. (this.$refs.moduleView as any).setTableValue(newData);
  260. } else {
  261. // let newData = this.tableInfo.filter((v : any) => v.skuTitle == value.skuTitle);
  262. let newData = this.tableInfo.filter((v : any) => v.skuTitle.indexOf(value.skuTitle)>-1);
  263. (this.$refs.moduleView as any).setTableValue(newData);
  264. }
  265. } else {
  266. if (value.skuCode) {
  267. // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode);
  268. let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1);
  269. (this.$refs.moduleView as any).setTableValue(newData);
  270. } else this.getDataList();
  271. }
  272. }
  273. // 短驳
  274. shortBarge(e : any) {
  275. // console.log(e);
  276. }
  277. // 调拨
  278. allocate(item : any) {
  279. // console.log(item);
  280. }
  281. // 刷新/重置
  282. onRefresh() {
  283. (this as any).$refs.moduleView.clearSearch();
  284. this.getDataList();
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .my-container {
  290. width: 100%;
  291. box-sizing: border-box;
  292. display: flex;
  293. padding: 16px;
  294. height: 100%;
  295. .bill-left {
  296. position: relative;
  297. border-right: solid #EEE 1px;
  298. flex-shrink: 0;
  299. .bill-tab {
  300. width: 150px;
  301. height: 100%;
  302. transition: all .5s;
  303. overflow: hidden;
  304. }
  305. .tab-title {
  306. font-size: 16px;
  307. padding-bottom: 16px;
  308. width: 200px;
  309. }
  310. }
  311. .bill-main {
  312. width: 100%;
  313. box-sizing: border-box;
  314. position: relative;
  315. height: 100%;
  316. overflow-y: hidden;
  317. }
  318. }
  319. </style>