index.vue 10.0 KB

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