index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div>
  3. <Toptitle>
  4. <template #left>
  5. <Button type="primary" @click="is_open = !is_open">{{
  6. is_open ? "收缩" : "展开"
  7. }}</Button>
  8. </template>
  9. <template #right>
  10. <Button type="primary" ghost @click="handleExport">导出</Button>
  11. </template>
  12. </Toptitle>
  13. <div
  14. :style="
  15. is_open
  16. ? 'max-height:200px;transition: all .5s;'
  17. : 'max-height:0px;overflow: hidden;transition: all .5s;'
  18. "
  19. >
  20. <Form :label-width="120" style="display: flex; flex-wrap: wrap">
  21. <FormItem label="入库日期">
  22. <DatePicker
  23. v-model="searchData.crt_time"
  24. clearable
  25. type="daterange"
  26. style="width: 200px"
  27. transfer
  28. placeholder="年/月/日"
  29. />
  30. </FormItem>
  31. <FormItem label="所属集团">
  32. <Select
  33. transfer
  34. filterable
  35. clearable
  36. v-model="searchData.company_id"
  37. style="width: 200px"
  38. >
  39. <Option
  40. v-for="item in companyList"
  41. :key="item.id"
  42. :value="item.id"
  43. :label="item.title"
  44. />
  45. </Select>
  46. </FormItem>
  47. <FormItem label="仓库名称">
  48. <Select
  49. transfer
  50. filterable
  51. clearable
  52. v-model="searchData.storehouse_id"
  53. style="width: 200px"
  54. >
  55. <Option
  56. v-for="item in storehouseList"
  57. :key="item.id"
  58. :value="item.id"
  59. :label="item.title"
  60. />
  61. </Select>
  62. </FormItem>
  63. <FormItem label="卷膜分类">
  64. <Select
  65. v-model="searchData.b_r_f_id"
  66. clearable
  67. filterable
  68. transfer
  69. style="width: 200px"
  70. >
  71. <Option
  72. v-for="item in basicRollFilmList"
  73. :key="item.id"
  74. :value="item.id"
  75. :label="item.title"
  76. />
  77. </Select>
  78. </FormItem>
  79. <FormItem label="卷膜代码">
  80. <Input
  81. clearable
  82. placeholder="请输入"
  83. style="width: 200px"
  84. v-model="searchData.code"
  85. />
  86. </FormItem>
  87. <FormItem label="卷膜型号">
  88. <Select
  89. v-model="searchData.roll_film_id"
  90. clearable
  91. filterable
  92. style="width: 200px"
  93. transfer
  94. >
  95. <Option
  96. v-for="item in rollFilmList"
  97. :key="item.id"
  98. :value="item.id"
  99. :label="item.title"
  100. />
  101. </Select>
  102. </FormItem>
  103. <FormItem label="卷膜编号">
  104. <Input
  105. clearable
  106. placeholder="请输入"
  107. style="width: 200px"
  108. v-model="searchData.roll_film_number"
  109. />
  110. </FormItem>
  111. <FormItem label="在库天数">
  112. <Input
  113. clearable
  114. placeholder="请输入"
  115. style="width: 200px"
  116. v-model="startDay"
  117. />&nbsp;&nbsp;~&nbsp;&nbsp;
  118. <Input
  119. clearable
  120. placeholder="请输入"
  121. style="width: 200px"
  122. v-model="endDay"
  123. />
  124. </FormItem>
  125. <FormItem :label-width="40">
  126. <Button type="primary" @click="handleSearch">查询</Button>
  127. </FormItem>
  128. </Form>
  129. </div>
  130. <div class="table_content">
  131. <vxe-grid v-bind="gridOptions"
  132. :footer-method="footerMethod"
  133. @checkbox-all="selectAllEvent"
  134. @checkbox-change="selectChangeEvent">
  135. </vxe-grid>
  136. </div>
  137. <Footer
  138. :pageSize="pageSize"
  139. :pageIndex="pageIndex"
  140. :total="total"
  141. @changeSize="changeSize"
  142. @changePage="changePage"
  143. ></Footer>
  144. </div>
  145. </template>
  146. <script>
  147. export default {
  148. data() {
  149. return {
  150. startDay:'',
  151. endDay:'',
  152. selectData:[],
  153. basicRollFilmList: [],
  154. rollFilmList: [],
  155. storehouseList: [],
  156. companyList: [],
  157. is_open: true,
  158. pageSize: 10,
  159. pageIndex: 1,
  160. total: 0,
  161. sort: null,
  162. is_show: false,
  163. searchData: {},
  164. proxyData: {},
  165. gridOptions: {
  166. border: true,
  167. resizable: true,
  168. maxHeight: 'auto',
  169. showOverflow: true,
  170. showFooter: true,
  171. align: 'left',
  172. columns: [
  173. { type: 'checkbox', width: 50, fixed: 'left' },
  174. { type: 'seq', title: '序号', width: 80 },
  175. { field: 'company_name', title: '所属集团', showHeaderOverflow: true, minWidth: 100 },
  176. { field: 'storehouse_name', title: '仓库名称', showHeaderOverflow: true, minWidth: 100 },
  177. { field: 'b_r_f_name', title: '卷膜分类', showHeaderOverflow: true, minWidth: 100 },
  178. { field: 'code', title: '卷膜代码', showHeaderOverflow: true, minWidth: 100 },
  179. { field: 'title', title: '卷膜型号', showHeaderOverflow: true, minWidth: 100 },
  180. { field: 'roll_film_number', title: '卷膜编号', showHeaderOverflow: true, minWidth: 100 },
  181. { field: 'unit', title: '计量单位', showHeaderOverflow: true, minWidth: 100 },
  182. { field: 'number', title: '现存数量', showHeaderOverflow: true, minWidth: 100 },
  183. { field: 'crt_time', title: '入库时间', showHeaderOverflow: true, minWidth: 100 },
  184. ],
  185. data: []
  186. },
  187. }
  188. },
  189. created() {
  190. //获取集团
  191. this.axios.post('/api/companyList').then(res => {
  192. this.companyList = res.data.data;
  193. })
  194. //获取仓库
  195. this.axios.post('/api/storehouseList').then(res => {
  196. this.storehouseList = res.data.data;
  197. })
  198. //获取卷膜型号
  199. this.axios.post('/api/rollFilmList').then(res => {
  200. this.rollFilmList = res.data.data
  201. })
  202. //获取卷膜分类
  203. this.axios.post('/api/basicRollFilmList').then(res => {
  204. this.basicRollFilmList = this.getArr(res.data);
  205. })
  206. },
  207. mounted() {
  208. },
  209. methods: {
  210. selectAllEvent(e) {
  211. this.selectData = e.records;
  212. },
  213. selectChangeEvent(e) {
  214. this.selectData = e.records;
  215. },
  216. async handleExport(){
  217. if(this.selectData.length==0){
  218. return this.$Message.warning('请选择需要导出的数据!')
  219. }
  220. let id = this.selectData.map(v=>v.id);
  221. const res = await this.axios.post('/api/exportFileReport',{type:1,id})
  222. if(res.code === 200){
  223. let url = `${this.$store.state.ip}/api/getExport/${res.data.file}`
  224. location.href = url
  225. }
  226. },
  227. footerMethod({ columns, data }) {
  228. return [
  229. columns.map((column, index) => {
  230. if (index === 0) {
  231. return '合计'
  232. } else if (['number'].includes(column.property)) {
  233. return this.sumNum(data, column.property)
  234. }
  235. return null
  236. })
  237. ]
  238. },
  239. sumNum(list, field) {
  240. let count = 0
  241. list.forEach(item => {
  242. count += Number(item[field] ? item[field] : 0)
  243. })
  244. return count.toFixed(2)
  245. },
  246. getArr(arr) {
  247. let data = [];
  248. arr.forEach(ele => {
  249. data.push(ele);
  250. if (ele.children.length != 0) {
  251. data = [...data, ...this.getArr(ele.children)];
  252. }
  253. });
  254. return data;
  255. },
  256. handleSearch() {
  257. this.pageIndex = 1;
  258. this.proxyData = JSON.parse(JSON.stringify(this.searchData));
  259. if(this.startDay&&this.endDay){
  260. this.proxyData.stock_age = [this.startDay,this.endDay]
  261. }
  262. this.proxyData.crt_time = [this.proxyData.crt_time[0] ? Date.parse(this.proxyData.crt_time[0]).toString().slice(0, 10) : '', this.proxyData.crt_time[1] ? (Date.parse(this.proxyData.crt_time[1])+86400000-1).toString().slice(0, 10) : '']
  263. this.initData(this.proxyData);
  264. },
  265. initData(row) {
  266. this.axios.post('/api/RollFilmInventoryList', { ...row, page_size: this.pageSize, page_index: this.pageIndex }).then(res => {
  267. this.gridOptions.data = res.data.data;
  268. this.total = res.data.total;
  269. this.selectData = [];
  270. })
  271. },
  272. changePage(e) {
  273. this.pageIndex = e;
  274. this.initData(this.proxyData);
  275. },
  276. changeSize(e) {
  277. this.pageSize = e;
  278. this.pageIndex = 1;
  279. this.initData(this.proxyData);
  280. },
  281. }
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. .form_item {
  286. margin-bottom: 15px !important;
  287. }
  288. .table_content {
  289. height: calc(100% - 250px);
  290. }
  291. </style>