index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
  4. <h4 style="padding-left: 10px;line-height: 0;">导出进度:</h4>
  5. <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
  6. </div>
  7. <div class="filter-container">
  8. <el-select v-model="getdataListParm.parammaps.pastureName" style="width: 140px;" placeholder="牧场" class="filter-item">
  9. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  10. </el-select>
  11. <el-date-picker v-model="getdataListParm.parammaps.checkDate" type="month" style="width: 250px;top:-3px;" placeholder="选择月份" format="yyyy-MM" value-format="yyyy-MM" />
  12. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  13. <el-button class="filter-item" style="position:absolute;right:10px" type="success" icon="el-icon-edit" @click="handleDownload">导出</el-button>
  14. <el-table
  15. :key="tableKey"
  16. v-loading="listLoading"
  17. element-loading-text="给我一点时间"
  18. :data="list"
  19. border
  20. fit
  21. highlight-current-row
  22. style="width: 100%;"
  23. :row-style="rowStyle"
  24. :cell-style="cellStyle"
  25. class="elTable table-fixed"
  26. @sort-change="tableSort"
  27. >
  28. <el-table-column label="序号" align="center" type="index" width="50px">
  29. <template slot-scope="scope">
  30. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="月份" sortable prop="checkDate" align="center" min-width="150px" />
  34. <el-table-column label="牧场" prop="pastureName" min-width="130px" align="center" />
  35. <el-table-column label="盘盈数量" min-width="130px" align="center" sortable prop="moreAount" />
  36. <el-table-column label="盘盈金额" align="center" min-width="150px" sortable prop="moreSum" />
  37. <el-table-column label="盘亏数量" min-width="130px" align="center" sortable prop="lessAount" />
  38. <el-table-column label="盘亏金额" min-width="130px" align="center" sortable prop="lessSum" />
  39. <el-table-column label="盈亏净额" min-width="130px" align="center" sortable prop="sums" />
  40. <el-table-column label="盘点状态" min-width="130px" align="center">
  41. <template slot-scope="scope">
  42. <span>{{ scope.row.sumStatue }}</span><br>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. // 引入
  52. import { GetDataByName, GetDataByNames, GetAccount } from '@/api/common'
  53. import Pagination from '@/components/Pagination'
  54. import waves from '@/directive/waves' // waves directive
  55. import Cookies from 'js-cookie'
  56. import { parseTime, json2excel, sortChange } from '@/utils/index.js'
  57. import { } from '@/utils/index.js'
  58. export default {
  59. name: 'InventorySpareParts',
  60. components: { Pagination },
  61. directives: { waves },
  62. data() {
  63. return {
  64. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  65. cellStyle: { padding: 0 + 'px' },
  66. rules: {},
  67. findAllPasture: [],
  68. requestParams: [
  69. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }}
  70. ],
  71. getdataListParm: {
  72. name: 'getcheckpartReportList',
  73. page: 1,
  74. offset: 1,
  75. pagecount: 10,
  76. returntype: 'Map',
  77. parammaps: {
  78. pastureName: Cookies.get('pasturename'),
  79. checkDate: ''
  80. }
  81. },
  82. listLoading: false,
  83. total: 0,
  84. tableKey: 0,
  85. list: [],
  86. downLoadParm: {},
  87. downLoadList: [],
  88. isPercentage: false,
  89. percentage: 1
  90. }
  91. },
  92. created() {
  93. this.get_select_list()
  94. this.getList()
  95. },
  96. methods: {
  97. tableSort(column) {
  98. sortChange(column, this.list)
  99. },
  100. get_select_list() {
  101. GetDataByNames(this.requestParams).then(response => {
  102. this.findAllPasture = response.data.findAllPasture.list
  103. })
  104. },
  105. getList() {
  106. this.listLoading = true
  107. GetDataByName(this.getdataListParm).then(response => {
  108. console.log('table数据', response.data.list)
  109. this.list = response.data.list
  110. this.pageNum = response.data.pageNum
  111. this.pageSize = response.data.pageSize
  112. if (response.data.total) {
  113. this.total = response.data.total
  114. }
  115. // Just to simulate the time of the request
  116. setTimeout(() => {
  117. this.listLoading = false
  118. }, 100)
  119. })
  120. },
  121. form_search() {
  122. console.log('点击了table搜索')
  123. if (this.getdataListParm.parammaps.checkDate == null) {
  124. this.getdataListParm.parammaps.checkDate = ''
  125. }
  126. this.getdataListParm.offset = 1
  127. this.getList()
  128. },
  129. handleDownload() {
  130. this.$alert('备件盘点报表正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  131. this.isPercentage = true
  132. this.percentage = 1
  133. var timer = setInterval(() => {
  134. this.percentage += 5
  135. if (this.percentage > 95) {
  136. this.percentage = 99
  137. clearInterval(timer)
  138. }
  139. this.percentage = this.percentage
  140. }, 1000)
  141. this.downLoadParm.name = 'getcheckpartReportList'
  142. this.downLoadParm.returntype = 'Map'
  143. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  144. GetAccount(this.downLoadParm).then(response => {
  145. if (response.data.list !== '') {
  146. this.percentage = 99
  147. setTimeout(() => {
  148. this.isPercentage = false
  149. }, 2000)
  150. }
  151. this.$nextTick(() => {
  152. this.downLoadList = response.data.list
  153. console.log(this.downLoadList)
  154. const ExcelDatas = [
  155. {
  156. tHeader: ['月份', '牧场', '盘盈数量', '盘亏数量', '盘亏金额', '盈亏净额', '盘点状态'],
  157. filterVal: ['checkDate', 'pastureName', 'moreAount', 'lessAount', 'lessSum', 'sums', 'sumStatue'],
  158. tableDatas: this.downLoadList,
  159. sheetName: '备件盘点报表'
  160. }
  161. ]
  162. json2excel(ExcelDatas, '备件盘点报表', true, 'xlsx')
  163. })
  164. })
  165. }
  166. }
  167. }
  168. </script>