index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-main">
  4. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="search" @resert="onRefresh"
  5. @detail="shortBarge" @onRefresh="onRefresh">
  6. </module-view>
  7. </div>
  8. </div>
  9. </template>
  10. <script lang="ts">
  11. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  12. import api from "@/api/currency";
  13. @Component
  14. export default class Store extends Vue {
  15. timeNum = 0;
  16. skuInfo : any = ''
  17. storeHouseInfo : any = ''
  18. tableInfo : any = ''
  19. timer : any = null
  20. config : any = {
  21. attr: {
  22. calculateH: true
  23. },
  24. search: {
  25. attr: {
  26. size: 'mini',
  27. },
  28. columns: [
  29. [
  30. {
  31. span: 6,
  32. label: '物料编码',
  33. prop: 'skuCode',
  34. component: 'by-input',
  35. labelWidth: '70px',
  36. compConfig: {
  37. attr: {
  38. placeholder: '请输入物料编码',
  39. clearable: true
  40. }
  41. }
  42. },
  43. ]
  44. ]
  45. },
  46. tool: {
  47. tools: {
  48. refresh: true,
  49. search: true,
  50. }
  51. },
  52. table: {
  53. attr: {
  54. size: 'mini',
  55. align: 'left',
  56. // checkbox: true,
  57. },
  58. columns: [
  59. {
  60. width: '200px',
  61. title: '标题',
  62. field: 'skuTitle',
  63. // isDetail: true,
  64. fixed: 'left'
  65. },
  66. {
  67. width: '200px',
  68. title: '副标题',
  69. field: 'skuSubtitle',
  70. },
  71. {
  72. width: '140px',
  73. title: '物料编码',
  74. field: 'skuCode',
  75. },
  76. ]
  77. },
  78. }
  79. mounted() {
  80. this.timer = setInterval(() => {
  81. this.getDataList()
  82. }, 300)
  83. }
  84. // 获取列表数据
  85. getDataList() {
  86. if (!this.$refs.moduleView) {
  87. if (this.timeNum > 5) {
  88. clearInterval(this.timer)
  89. }
  90. this.timeNum++;
  91. return
  92. }
  93. clearInterval(this.timer)
  94. this.getPageList();
  95. }
  96. getPageList() {
  97. let loading = this.$loading({ target: '.main-container' });
  98. api.getMaterialInventory().then((res : any) => {
  99. if (res.code === 200) {
  100. this.skuInfo = res.data;
  101. } else loading.close();
  102. }).then(() => {
  103. api.pageList({
  104. pageNum: 1,
  105. pageSize: 9999,
  106. }, 'maindataStorehouse').then((res : any) => {
  107. if (res.code === 200) {
  108. this.storeHouseInfo = res.data.records;
  109. } else loading.close();
  110. if (res.code === 200) {
  111. let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
  112. this.storeHouseInfo = res.data.records;
  113. res.data.records.map((v : any, i : any) => {
  114. moduleConfig.columns.push({
  115. width: '140px',
  116. title: v.name,
  117. field: 'custom' + i,
  118. });
  119. });
  120. moduleConfig.columns.push({
  121. width: 120,
  122. title: '操作',
  123. action: true,
  124. plugins: [{
  125. name: '短驳',
  126. event: {
  127. click: (item : any) => {
  128. (this as any).shortBarge(item)
  129. }
  130. }
  131. }, {
  132. name: '调拨',
  133. event: {
  134. click: (item : any) => (this as any).allocate(item)
  135. }
  136. }]
  137. });
  138. (this as any).$refs.moduleView.setTableConfig(moduleConfig);
  139. }
  140. }).then(() => {
  141. api.pageList({
  142. pageNum: 1,
  143. pageSize: 9999
  144. }, 'maindataMaterialSku').then((res : any) => {
  145. if (res.code === 200) {
  146. for (let i = 0; i < res.data.records.length; i++) {
  147. for (let j = 0; j < this.storeHouseInfo.length; j++) {
  148. let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
  149. if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
  150. }
  151. }
  152. (this.$refs.moduleView as any).setTableValue(res.data.records);
  153. this.tableInfo = res.data.records;
  154. loading.close();
  155. // let page = {
  156. // pageNo: res.data.current, //当前页
  157. // pageSize: res.data.size, //每页条数
  158. // total: res.data.total //总条数
  159. // };
  160. // (this.$refs.moduleView as any).setPage(page);
  161. } else loading.close();
  162. }).catch(() => loading.close());
  163. }).catch(() => loading.close());
  164. }).catch(() => loading.close());
  165. }
  166. // 查询
  167. search() {
  168. let searchID : any = (this as any).$refs.moduleView.searchID;
  169. let value = (this as any).$refs.moduleView.$refs[searchID].value;
  170. if (value.skuCode) {
  171. let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode);
  172. (this.$refs.moduleView as any).setTableValue(newData);
  173. } else this.getDataList();
  174. }
  175. // 短驳
  176. shortBarge(e : any) {
  177. console.log(e);
  178. }
  179. // 调拨
  180. allocate(item : any) {
  181. console.log(item);
  182. }
  183. // 刷新/重置
  184. onRefresh() {
  185. (this as any).$refs.moduleView.clearSearch();
  186. this.getDataList();
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .my-container {
  192. width: 100%;
  193. box-sizing: border-box;
  194. display: flex;
  195. padding: 16px;
  196. height: 100%;
  197. .bill-left {
  198. position: relative;
  199. border-right: solid #EEE 1px;
  200. flex-shrink: 0;
  201. .bill-tab {
  202. width: 150px;
  203. height: 100%;
  204. transition: all .5s;
  205. overflow: hidden;
  206. }
  207. .tab-title {
  208. font-size: 16px;
  209. padding-bottom: 16px;
  210. width: 200px;
  211. }
  212. }
  213. .bill-main {
  214. width: 100%;
  215. box-sizing: border-box;
  216. position: relative;
  217. height: 100%;
  218. overflow-y: hidden;
  219. }
  220. }
  221. </style>