index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. <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. getPageList() {
  133. let loading = this.$loading({ target: '.main-container' });
  134. api.getMaterialInventory().then((res : any) => {
  135. if (res.code === 200) {
  136. this.skuInfo = res.data;
  137. } else loading.close();
  138. }).then(() => {
  139. api.pageList({
  140. pageNum: 1,
  141. pageSize: 9999,
  142. }, 'maindataStorehouse').then((res : any) => {
  143. if (res.code === 200) {
  144. this.storeHouseInfo = res.data.records;
  145. } else loading.close();
  146. if (res.code === 200) {
  147. let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
  148. this.storeHouseInfo = res.data.records;
  149. res.data.records.map((v : any, i : any) => {
  150. moduleConfig.columns.push({
  151. width: '120px',
  152. title: v.name,
  153. field: 'custom' + i,
  154. });
  155. });
  156. // moduleConfig.columns.push({
  157. // width: 120,
  158. // title: '操作',
  159. // action: true,
  160. // plugins: [{
  161. // name: '短驳',
  162. // event: {
  163. // click: (item : any) => {
  164. // (this as any).shortBarge(item)
  165. // }
  166. // }
  167. // }, {
  168. // name: '调拨',
  169. // event: {
  170. // click: (item : any) => (this as any).allocate(item)
  171. // }
  172. // }]
  173. // });
  174. (this as any).$refs.moduleView.setTableConfig(moduleConfig);
  175. }
  176. }).then(() => {
  177. api.pageList({
  178. pageNum: 1,
  179. pageSize: 9999
  180. }, 'maindataMaterialSku').then((res : any) => {
  181. if (res.code === 200) {
  182. for (let i = 0; i < res.data.records.length; i++) {
  183. for (let j = 0; j < this.storeHouseInfo.length; j++) {
  184. let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
  185. if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
  186. }
  187. }
  188. (this.$refs.moduleView as any).setTableValue(res.data.records);
  189. this.tableInfo = res.data.records;
  190. loading.close();
  191. // let page = {
  192. // pageNo: res.data.current, //当前页
  193. // pageSize: res.data.size, //每页条数
  194. // total: res.data.total //总条数
  195. // };
  196. // (this.$refs.moduleView as any).setPage(page);
  197. } else loading.close();
  198. }).catch(() => loading.close());
  199. }).catch(() => loading.close());
  200. }).catch(() => loading.close());
  201. }
  202. // 查询
  203. search() {
  204. let searchID : any = (this as any).$refs.moduleView.searchID;
  205. let value = (this as any).$refs.moduleView.$refs[searchID].value;
  206. if (value.skuTitle) {
  207. if (value.skuCode) {
  208. // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode && v.skuTitle == value.skuTitle);
  209. let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1 && v.skuTitle.indexOf(value.skuTitle)>-1);
  210. (this.$refs.moduleView as any).setTableValue(newData);
  211. } else {
  212. // let newData = this.tableInfo.filter((v : any) => v.skuTitle == value.skuTitle);
  213. let newData = this.tableInfo.filter((v : any) => v.skuTitle.indexOf(value.skuTitle)>-1);
  214. (this.$refs.moduleView as any).setTableValue(newData);
  215. }
  216. } else {
  217. if (value.skuCode) {
  218. // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode);
  219. let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1);
  220. (this.$refs.moduleView as any).setTableValue(newData);
  221. } else this.getDataList();
  222. }
  223. }
  224. // 短驳
  225. shortBarge(e : any) {
  226. console.log(e);
  227. }
  228. // 调拨
  229. allocate(item : any) {
  230. console.log(item);
  231. }
  232. // 刷新/重置
  233. onRefresh() {
  234. (this as any).$refs.moduleView.clearSearch();
  235. this.getDataList();
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .my-container {
  241. width: 100%;
  242. box-sizing: border-box;
  243. display: flex;
  244. padding: 16px;
  245. height: 100%;
  246. .bill-left {
  247. position: relative;
  248. border-right: solid #EEE 1px;
  249. flex-shrink: 0;
  250. .bill-tab {
  251. width: 150px;
  252. height: 100%;
  253. transition: all .5s;
  254. overflow: hidden;
  255. }
  256. .tab-title {
  257. font-size: 16px;
  258. padding-bottom: 16px;
  259. width: 200px;
  260. }
  261. }
  262. .bill-main {
  263. width: 100%;
  264. box-sizing: border-box;
  265. position: relative;
  266. height: 100%;
  267. overflow-y: hidden;
  268. }
  269. }
  270. </style>