index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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="table.getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 120px;">
  9. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  10. </el-select>
  11. <el-date-picker
  12. ref="BXinputDatetime"
  13. v-model="table.getdataListParm.parammaps.BXinputDatetime"
  14. class="inputDatetime"
  15. type="datetimerange"
  16. style="width: 270px;top:-3px;"
  17. format="yyyy-MM-dd"
  18. value-format="yyyy-MM-dd"
  19. range-separator="至"
  20. start-placeholder="报修开始时间"
  21. end-placeholder="报修结束时间"
  22. />
  23. <el-date-picker
  24. ref="JDinputDatetime"
  25. v-model="table.getdataListParm.parammaps.JDinputDatetime"
  26. class="inputDatetime"
  27. type="datetimerange"
  28. style="width: 270px;top:-3px;"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd"
  31. range-separator="至"
  32. start-placeholder="接单开始时间"
  33. end-placeholder="接单结束时间"
  34. />
  35. <el-date-picker
  36. ref="useSHinputDatetime"
  37. v-model="table.getdataListParm.parammaps.useSHinputDatetime"
  38. class="inputDatetime"
  39. type="datetimerange"
  40. style="width: 270px;top:-3px;"
  41. format="yyyy-MM-dd"
  42. value-format="yyyy-MM-dd"
  43. range-separator="至"
  44. start-placeholder="维修开始时间"
  45. end-placeholder="维修结束时间"
  46. />
  47. <!-- 等后端接口 -->
  48. <!-- <el-select v-model="table2.getdataListParm.parammaps.typeId" filterable placeholder="类别" class="filter-item" style="width: 120px;" clearable>
  49.         <el-option v-for="item in typeNameList" :key="item.id" :label="item.name" :value="item.id" />
  50.       </el-select> -->
  51. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  52. <el-button class="filter-item" type="success" icon="el-icon-upload2" @click="handleDownload">导出</el-button>
  53. </div>
  54. <el-table v-if="tableShow1"
  55. :key="table.tableKey"
  56. v-loading="table.listLoading"
  57. element-loading-text="给我一点时间"
  58. :data="table.list"
  59. border
  60. fit
  61. highlight-current-row
  62. style="width: 100%;"
  63. :row-style="rowStyle"
  64. :cell-style="cellStyle"
  65. class="elTable"
  66. >
  67. <el-table-column label="序号" align="center" type="index" width="50px">
  68. <template slot-scope="scope">
  69. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="牧场" min-width="90px" align="center" prop="pastureName" />
  73. <el-table-column label="单号" min-width="90px" align="center" prop="repairCode" />
  74. <el-table-column label="设备类别" min-width="90px" align="center" prop="eqClassName" />
  75. <el-table-column label="设备名称" min-width="90px" align="center" prop="eqName" />
  76. <el-table-column label="设备内部编号" min-width="90px" align="center" prop="eqCode" />
  77. <el-table-column label="报修日期" min-width="70px" align="center" prop="BXTime" />
  78. <el-table-column label="接单间隔" min-width="90px" sortable align="center" prop="BxAndJd" />
  79. <el-table-column label="接单日期" min-width="90px" sortable align="center" prop="JDTime" />
  80. <el-table-column label="维修间隔" min-width="70px" sortable align="center" prop="JdAndWx" />
  81. <el-table-column label="维修日期" min-width="90px" sortable align="center" prop="WXTime" />
  82. <el-table-column label="总维修时长" min-width="90px" sortable align="center" prop="WxAndJS" />
  83. <el-table-column label="完成维修日期" min-width="70px" sortable align="center" prop="JSTime" />
  84. <el-table-column label="确认间隔" min-width="70px" sortable align="center" prop="JSAnduseSH" />
  85. <el-table-column label="使用人确认日期" min-width="70px" sortable align="center" prop="useSHTime" />
  86. </el-table>
  87. <pagination v-show="table.total>0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  88. <!-- 等后端接口 -->
  89. <!-- <el-table v-if="tableShow2"
  90. :key="table2.tableKey"
  91. v-loading="table2.listLoading"
  92. element-loading-text="给我一点时间"
  93. :data="table2.list"
  94. border
  95. fit
  96. highlight-current-row
  97. style="width: 100%;"
  98. :row-style="rowStyle"
  99. :cell-style="cellStyle"
  100. class="elTable"
  101. >
  102. <el-table-column label="序号" align="center" type="index" width="50px">
  103. <template slot-scope="scope">
  104. <span>{{ scope.$index + (table2.pageNum-1) * table2.pageSize + 1 }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="牧场" min-width="90px" align="center" prop="pastureName" />
  108. <el-table-column label="月份" min-width="90px" align="center" prop="repairCode" />
  109. <el-table-column label="设备名称" min-width="90px" align="center" prop="eqName" />
  110. <el-table-column label="维修次数" min-width="90px" align="center" prop="eqCode" />
  111. <el-table-column label="平均维修时间" min-width="70px" align="center" prop="BXTime" />
  112. <el-table-column label="无故障时间" min-width="90px" sortable align="center" prop="BxAndJd" />
  113. <el-table-column label="平均故障间隔时间" min-width="90px" sortable align="center" prop="JDTime" />
  114. </el-table> -->
  115. </div>
  116. </template>
  117. <script>
  118. import waves from '@/directive/waves' // waves directive
  119. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  120. import { GetDataByName, GetDataByNames } from '@/api/common'
  121. import { parseTime, json2excel } from '@/utils/index.js'
  122. import Cookies from 'js-cookie'
  123. export default {
  124. name: 'MaintenanceCycle',
  125. components: { Pagination },
  126. directives: { waves },
  127. data() {
  128. return {
  129. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  130. cellStyle: { padding: 0 + 'px' },
  131. tableShow1:true,
  132. tableShow2:false,
  133. table: {
  134. tableKey: 0,
  135. list: [],
  136. total: 0,
  137. listLoading: true,
  138. getdataListParm: {
  139. name: 'getAlleqWX',
  140. page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  141. parammaps: {
  142. BXinputDatetime: '', SGTimeStart: '', SGTimeEnd: '',
  143. JDinputDatetime: '', JDTimeStart: '', JDTimeEnd: '',
  144. useSHinputDatetime: '', useSHTimeStart: '', useSHTimeEnd: '',
  145. pastureName: Cookies.get('pasturename')
  146. }
  147. }
  148. },
  149. table2: {
  150. tableKey: 0,
  151. list: [
  152. {id:1}
  153. ],
  154. total: 0,
  155. listLoading: false,
  156. getdataListParm: {
  157. name: 'getAlleqWX',
  158. page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  159. parammaps: {
  160. typeId:'',
  161. pastureName: Cookies.get('pasturename')
  162. }
  163. }
  164. },
  165. // 下拉框 - 状态
  166. typeNameList: [
  167. {id: "刮粪机", name: "刮粪机"}
  168. ],
  169. downLoadParm: {},
  170. downLoadList: [],
  171. isPercentage: false,
  172. percentage: 1,
  173. findAllPasture: [],
  174. requestParams: [
  175. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }}
  176. ]
  177. }
  178. },
  179. created() {
  180. this.get_select_list()
  181. this.getList()
  182. },
  183. methods: {
  184. get_select_list() {
  185. GetDataByNames(this.requestParams).then(response => {
  186. if (response.data.list !== null) {
  187. this.findAllPasture = response.data.findAllPasture.list
  188. }
  189. })
  190. },
  191. getList() {
  192. this.table.listLoading = true
  193. GetDataByName(this.table.getdataListParm).then(response => {
  194. console.log('table数据', response.data.list)
  195. if (response.data.list !== null) {
  196. for (let i = 0; i < response.data.list.length; i++) {
  197. if (response.data.list[i].BxAndJd !== undefined) {
  198. this.$set(response.data.list[i], 'BxAndJd', parseFloat(response.data.list[i].BxAndJd))
  199. }
  200. if (response.data.list[i].JdAndWx !== undefined) {
  201. this.$set(response.data.list[i], 'JdAndWx', parseFloat(response.data.list[i].JdAndWx))
  202. }
  203. if (response.data.list[i].WxAndJS !== undefined) {
  204. this.$set(response.data.list[i], 'WxAndJS', parseFloat(response.data.list[i].WxAndJS))
  205. }
  206. if (response.data.list[i].JSAnduseSH !== undefined) {
  207. this.$set(response.data.list[i], 'JSAnduseSH', parseFloat(response.data.list[i].JSAnduseSH))
  208. }
  209. }
  210. this.table.list = response.data.list
  211. this.table.pageNum = response.data.pageNum
  212. this.table.pageSize = response.data.pageSize
  213. this.table.total = response.data.total
  214. } else {
  215. this.table.list = []
  216. this.table.total = 0
  217. }
  218. setTimeout(() => {
  219. this.table.listLoading = false
  220. }, 100)
  221. })
  222. },
  223. getList2() {
  224. this.table2.listLoading = true
  225. GetDataByName(this.table.getdataListParm).then(response => {
  226. console.log('table数据', response.data.list)
  227. if (response.data.list !== null) {
  228. this.table2.list = response.data.list
  229. this.table2.pageNum = response.data.pageNum
  230. this.table2.pageSize = response.data.pageSize
  231. this.table2.total = response.data.total
  232. } else {
  233. this.table2.list = []
  234. this.table2.total = 0
  235. }
  236. setTimeout(() => {
  237. this.table2.listLoading = false
  238. }, 100)
  239. })
  240. },
  241. form_search() {
  242. this.table.listLoading = true
  243. this.table.getdataListParm.offset = 1
  244. if (this.table.getdataListParm.parammaps.BXinputDatetime !== [] && this.table.getdataListParm.parammaps.BXinputDatetime !== '' && this.table.getdataListParm.parammaps.BXinputDatetime !== null) {
  245. if (this.table.getdataListParm.parammaps.BXinputDatetime.length !== 0) {
  246. this.table.getdataListParm.parammaps.BXTimeStart = parseTime(this.table.getdataListParm.parammaps.BXinputDatetime[0], '{y}-{m}-{d}')
  247. this.table.getdataListParm.parammaps.BXTimeEnd = parseTime(this.table.getdataListParm.parammaps.BXinputDatetime[1], '{y}-{m}-{d}')
  248. }
  249. } else {
  250. this.table.getdataListParm.parammaps.BXinputDatetime = []
  251. this.table.getdataListParm.parammaps.BXTimeStart = ''
  252. this.table.getdataListParm.parammaps.BXTimeEnd = ''
  253. }
  254. if (this.table.getdataListParm.parammaps.JDinputDatetime !== [] && this.table.getdataListParm.parammaps.JDinputDatetime !== '' && this.table.getdataListParm.parammaps.JDinputDatetime !== null) {
  255. if (this.table.getdataListParm.parammaps.JDinputDatetime.length !== 0) {
  256. this.table.getdataListParm.parammaps.JDTimeStart = parseTime(this.table.getdataListParm.parammaps.JDinputDatetime[0], '{y}-{m}-{d}')
  257. this.table.getdataListParm.parammaps.JDTimeEnd = parseTime(this.table.getdataListParm.parammaps.JDinputDatetime[1], '{y}-{m}-{d}')
  258. }
  259. } else {
  260. this.table.getdataListParm.parammaps.JDinputDatetime = []
  261. this.table.getdataListParm.parammaps.JDTimeStart = ''
  262. this.table.getdataListParm.parammaps.JDTimeEnd = ''
  263. }
  264. if (this.table.getdataListParm.parammaps.useSHinputDatetime !== [] && this.table.getdataListParm.parammaps.useSHinputDatetime !== '' && this.table.getdataListParm.parammaps.useSHinputDatetime !== null) {
  265. if (this.table.getdataListParm.parammaps.useSHinputDatetime.length !== 0) {
  266. this.table.getdataListParm.parammaps.useSHTimeStart = parseTime(this.table.getdataListParm.parammaps.useSHinputDatetime[0], '{y}-{m}-{d}')
  267. this.table.getdataListParm.parammaps.useSHTimeEnd = parseTime(this.table.getdataListParm.parammaps.useSHinputDatetime[1], '{y}-{m}-{d}')
  268. }
  269. } else {
  270. this.table.getdataListParm.parammaps.useSHinputDatetime = []
  271. this.table.getdataListParm.parammaps.useSHTimeStart = ''
  272. this.table.getdataListParm.parammaps.useSHTimeEnd = ''
  273. }
  274. this.getList()
  275. //选了类别,就执行第二个表格
  276. //等后端接口
  277. // if(this.table2.getdataListParm.parammaps.typeId != ""){
  278. // this.tableShow2 = true
  279. // this.tableShow1 = false
  280. // this.getList2()
  281. // } else {
  282. // this.tableShow2 = false
  283. // this.tableShow1 = true
  284. // this.getList()
  285. // }
  286. },
  287. handleDownload() {
  288. this.$alert('维修周期效率统计正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  289. this.isPercentage = true
  290. this.percentage = 1
  291. var timer = setInterval(() => {
  292. this.percentage += 5
  293. if (this.percentage > 95) {
  294. this.percentage = 99
  295. clearInterval(timer)
  296. }
  297. this.percentage = this.percentage
  298. }, 1000)
  299. this.form_search()
  300. this.downLoadParm.getdataListParm = {}
  301. this.downLoadParm.getdataListParm.name = 'getAlleqWX'
  302. this.downLoadParm.getdataListParm.pagecount = 0
  303. this.downLoadParm.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  304. GetDataByName(this.downLoadParm.getdataListParm).then(response => {
  305. if (response.data.list !== '') {
  306. this.percentage = 99
  307. setTimeout(() => {
  308. this.isPercentage = false
  309. }, 2000)
  310. }
  311. this.$nextTick(() => {
  312. this.downLoadParm.list = response.data.list
  313. var excelDatas = [
  314. {
  315. tHeader: ['牧场', '单号', '设备类别', '设备名称', '设备内部编号', '报修日期', '接单间隔', '接单日期', '维修间隔', '维修日期', '总维修时长', '完成维修日期', '确认间隔', '使用人确认时间'],
  316. filterVal: ['pastureName', 'repairCode', 'eqClassName', 'eqName', 'eqCode', 'BXTime', 'BxAndJd', 'JDTime', 'JdAndWx', 'WXTime', 'WxAndJS', 'JSTime', 'JSAnduseSH', 'useSHTime'],
  317. tableDatas: this.downLoadParm.list,
  318. sheetName: 'Sheet'
  319. }
  320. ]
  321. json2excel(excelDatas, '维修周期效率统计', true, 'xlsx')
  322. })
  323. })
  324. }
  325. }
  326. }
  327. </script>