routineMonitor.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div style="width: 100%">
  3. <div slot="header" class="clearfix">
  4. <el-breadcrumb separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item>首页</el-breadcrumb-item>
  6. <el-breadcrumb-item>承担单位</el-breadcrumb-item>
  7. <el-breadcrumb-item>任务列表</el-breadcrumb-item>
  8. </el-breadcrumb>
  9. </div>
  10. <!-- 头部搜索栏 -->
  11. <el-row :gutter="50" style="margin-right: 0px;">
  12. <el-form style="display: flex; flex-direction: row;" size="mini">
  13. <el-form-item label="年度" class="select">
  14. <el-date-picker v-model="queryInfo.year" style="width: 110px;" value-format="yyyy"
  15. type="year" clearable />
  16. </el-form-item>
  17. <el-form-item label="任务状态" class="select">
  18. <el-select v-model="queryInfo.ispublic" style="width: 110px;">
  19. <el-option v-for="item in taskstatus" :key="item.value" :label="item.label"
  20. :value="item.value">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="任务时间" class="select">
  25. <el-date-picker v-model="queryInfo.starttime" style="width: 180px;" align="right" type="date"
  26. :picker-options="pickerOptions" clearable />
  27. </el-form-item>
  28. <el-form-item label="--" class="select" style="margin-left: 10px; padding-left: 0px;">
  29. <el-date-picker v-model="queryInfo.endtime" style="width: 180px;" align="right" type="date"
  30. :picker-options="pickerOptions" clearable />
  31. </el-form-item>
  32. <el-form-item label="任务名称" class="select">
  33. <el-input v-model="queryInfo.task_name"></el-input>
  34. </el-form-item>
  35. <!-- 查询 -->
  36. <el-button style="height: 28px;margin-left: 10px;" size="mini" type="success" @click="searchData()">查询</el-button>
  37. <!-- 重置 -->
  38. <el-button style="height: 28px;margin-left: 5px;" size="mini" type="success" @click="reset()">重置</el-button>
  39. </el-form>
  40. </el-row>
  41. <!-- 头部钮区域-->
  42. <el-row :gutter="90" style="margin-right: 0px;">
  43. <div style="display: flex;flex-direction: row;float: right;">
  44. <!-- <el-button type="primary" size="small" plain icon="el-icon-plus" @click="add">新增</el-button>
  45. <el-button type="primary" size="small" plain icon="el-icon-edit-outline" >发布</el-button>
  46. <el-button type="primary" size="small" plain icon="el-icon-scissors" >废止</el-button>
  47. <el-button type="primary" size="small" plain icon="el-icon-delete" >删除</el-button> -->
  48. <el-button type="primary" size="small" plain icon="el-icon-download" @click="exportData">导出Excel</el-button>
  49. </div>
  50. </el-row>
  51. <!-- 表格数据区域-->
  52. <el-table ref="multipleTable" :data="tableData" border stripe highlight-current-row style="width: 100%"
  53. :row-style="rowStyle" :cell-style="cellStyle">
  54. <el-table-column type="selection" width="50" align="center"></el-table-column>
  55. <el-table-column label="序号" width="50px" align="center">
  56. <template slot-scope="scope">
  57. {{ scope.$index+1 }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop"
  61. align="center" :width="table.width" :fixed="table.fixed" />
  62. <el-table-column prop="ispublic" label="任务状态" align="center">
  63. <template slot-scope="scope">
  64. <el-tag type="danger" v-if="scope.row.ispublic==2">废止</el-tag>
  65. <el-tag type="info" v-if="scope.row.ispublic==3">已结束,未完成</el-tag>
  66. <el-tag type="success" v-if="scope.row.ispublic==4">已结束,已完成</el-tag>
  67. <el-tag type="warning" v-if="scope.row.ispublic==5">执行中</el-tag>
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="level" label="任务优先级" width="100" align="center">
  71. <template slot-scope="scope">
  72. <el-tag type="success" v-if="scope.row.level==0">一般</el-tag>
  73. <el-tag type="warning" v-if="scope.row.level==1">紧急</el-tag>
  74. <el-tag type="danger" v-if="scope.row.level==2">特急</el-tag>
  75. </template>
  76. </el-table-column>
  77. <el-table-column prop="file_url" label="附件" width="80" align="center">
  78. <template slot-scope="scope">
  79. <el-link type="primary" :href="scope.row.file_url">下载</el-link>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="操作" align="center" fixed="right">
  83. <!-- 操作按钮区域的作用域插槽 -->
  84. <template slot-scope="scope">
  85. <el-button type="success" size="mini" @click="runtask(scope.row.id)">执行检测</el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  90. :current-page="queryInfo.currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="queryInfo.pageSize"
  91. layout="total, sizes, prev, pager, next, jumper" :total="total">
  92. </el-pagination>
  93. </div>
  94. </template>
  95. <script>
  96. const qee = require('qf-export-excel')
  97. const HeadersList = [{
  98. title: '任务名称',
  99. key: 'task_name',
  100. },
  101. {
  102. title: '年度',
  103. key: 'year',
  104. }, {
  105. title: '文件号',
  106. key: 'filenum',
  107. },
  108. {
  109. title: '开始时间',
  110. key: 'starttime',
  111. },
  112. {
  113. title: '结束时间',
  114. key: 'endtime',
  115. },
  116. {
  117. title: '发布单位',
  118. key: 'releaser',
  119. },
  120. {
  121. title: '创建时间',
  122. key: 'createtime',
  123. },{
  124. title: '任务状态',
  125. key: 'ispublic'
  126. },{
  127. title: '任务优先级',
  128. key: 'level'
  129. }
  130. ]
  131. export default {
  132. name: '',
  133. data() {
  134. return {
  135. total: 0,
  136. cellStyle: {
  137. padding: 2 + 'px'
  138. },
  139. rowStyle: {
  140. height: 35 + 'px'
  141. },
  142. tableHeader: [{
  143. label: '任务名称',
  144. prop: 'task_name',
  145. // fixed: 'left'
  146. },
  147. {
  148. label: '年度',
  149. prop: 'year',
  150. // fixed: 'left'
  151. }, {
  152. label: '文件号',
  153. prop: 'filenum',
  154. // fixed: 'left'
  155. },
  156. {
  157. label: '开始时间',
  158. prop: 'starttime',
  159. },
  160. {
  161. label: '结束时间',
  162. prop: 'endtime',
  163. },
  164. {
  165. label: '发布单位',
  166. prop: 'releaser',
  167. },
  168. {
  169. label: '创建时间',
  170. prop: 'createtime',
  171. // width: 180
  172. },
  173. ],
  174. total:'',
  175. // 数据表格数据
  176. tableData: [],
  177. // 批量删除选中数据
  178. multipleSelection: [],
  179. queryInfo:{
  180. pageSize:10,
  181. pageNum:1,
  182. currentPage:1,
  183. year:'',
  184. ispublic:'',
  185. starttime:'',
  186. endtime:'',
  187. task_name:'',
  188. task_class:'例行监测'
  189. },
  190. // 任务状态选项
  191. taskstatus: [{
  192. value: '',
  193. label: '全部'
  194. },{
  195. value: '2',
  196. label: '已废止'
  197. }, {
  198. value: '3',
  199. label: '已结束,未完成'
  200. }, {
  201. value: '4',
  202. label: '已结束,已完成'
  203. }, {
  204. value: '5',
  205. label: '执行中'
  206. }],
  207. // 日期选择器快捷选项
  208. pickerOptions: {
  209. disabledDate(time) {
  210. return time.getTime() > Date.now();
  211. },
  212. shortcuts: [{
  213. text: '今天',
  214. onClick(picker) {
  215. picker.$emit('pick', new Date());
  216. }
  217. }, {
  218. text: '昨天',
  219. onClick(picker) {
  220. const date = new Date();
  221. date.setTime(date.getTime() - 3600 * 1000 * 24);
  222. picker.$emit('pick', date);
  223. }
  224. }, {
  225. text: '一周前',
  226. onClick(picker) {
  227. const date = new Date();
  228. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  229. picker.$emit('pick', date);
  230. }
  231. }]
  232. },
  233. }
  234. },
  235. mounted: function() {
  236. this.gettaskList()
  237. },
  238. methods: {
  239. handleSizeChange(val) {
  240. this.queryInfo.pageSize = val;
  241. console.log(`每页 ${val} 条`);
  242. },
  243. handleCurrentChange(val) {
  244. this.queryInfo.pageNum = val;
  245. console.log(`当前页: ${val}`);
  246. this.gettaskList()
  247. },
  248. add() {
  249. // this.$router.push('')
  250. },
  251. async gettaskList() {
  252. for (var key in this.queryInfo) {
  253. if (this.queryInfo[key] == '') {
  254. delete this.queryInfo[key]
  255. }
  256. }
  257. const {
  258. data: res
  259. } = await this.$http.post(
  260. "getTaskcd", this.queryInfo
  261. );
  262. console.log(res)
  263. this.tableData = res.data.rows
  264. this.total = res.data.total
  265. },
  266. // 搜索
  267. async searchData() {
  268. console.log(this.queryInfo)
  269. this.queryInfo.pageNum = 1
  270. this.gettaskList()
  271. },
  272. // 重置
  273. reset(){
  274. this.queryInfo={
  275. year:'',
  276. task_name:'',
  277. starttime:'',
  278. endtime:'',
  279. ispublic:'',
  280. pageSize:'',
  281. pageNum:1,
  282. task_class:'例行监测'
  283. }
  284. this.gettaskList()
  285. },
  286. runtask(id) {
  287. console.log(id)
  288. this.$router.push({
  289. name: 'setTaskcd',
  290. params: {
  291. id: id
  292. }
  293. })
  294. },
  295. // 导出Excel
  296. async exportData() {
  297. // for (var key in this.exportInfo) {
  298. // if (this.exportInfo[key] == '') {
  299. // delete this.exportInfo[key]
  300. // }
  301. // }
  302. console.log(this.tableData)
  303. let exportList = []
  304. exportList = this.tableData
  305. for (let i = 0; i < exportList.length; i++) {
  306. if (exportList[i].level == '0') {
  307. exportList[i].level = '一般'
  308. } else if (exportList[i].level == '1') {
  309. exportList[i].level = '紧急'
  310. }else{
  311. exportList[i].level = '特急'
  312. }
  313. if (exportList[i].ispublic == '1') {
  314. exportList[i].ispublic = '已发布'
  315. } else if(exportList[i].ispublic == '2') {
  316. exportList[i].ispublic = '废止'
  317. }else if(exportList[i].ispublic == '3') {
  318. exportList[i].ispublic = '已结束,未完成'
  319. }else if(exportList[i].ispublic == '4') {
  320. exportList[i].ispublic = '已结束,已完成'
  321. }else if(exportList[i].ispublic == '5') {
  322. exportList[i].ispublic = '执行中'
  323. }
  324. }
  325. // 导出表格的表头设置
  326. // let allColumns = exportList
  327. var columnNames = []
  328. var columnValues = []
  329. // var columns = []
  330. require.ensure([], () => {
  331. const {
  332. export_json_to_excel
  333. } = require('@/vendor/Export2Excel.js')
  334. for (var i = 0; i < HeadersList.length; i++) {
  335. columnNames[i] = HeadersList[i].title
  336. columnValues[i] = HeadersList[i].key
  337. }
  338. const tHeader = columnNames
  339. const filterVal = columnValues
  340. // console.log(columns)
  341. const list = exportList
  342. const data = this.formatJson(filterVal, list)
  343. export_json_to_excel(tHeader, data, '例行监测任务')
  344. })
  345. },
  346. formatJson(filterVal, jsonData) {
  347. return jsonData.map(v => filterVal.map(j => v[j]))
  348. },
  349. },
  350. }
  351. </script>
  352. <style lang="less" scoped>
  353. .el-breadcrumb {
  354. margin-bottom: 20px;
  355. }
  356. .el-table {
  357. align-items: center;
  358. margin-top: 25px;
  359. }
  360. /deep/ .el-col {
  361. padding-right: 0 !important;
  362. }
  363. /deep/ .el-radio-group label {
  364. width: 180px;
  365. margin-right: 10px;
  366. }
  367. .el-pagination {
  368. margin-top: 25px;
  369. }
  370. // .el-cascader {
  371. // width: 290px;
  372. // }
  373. .el-select {
  374. width: 210px;
  375. height: 100%;
  376. }
  377. .select {
  378. display: flex;
  379. flex-direction: row;
  380. margin-left: 10px;
  381. }
  382. .dialogItem /deep/ .el-dialog__body {
  383. padding: 15px 12px 0;
  384. color: #606266;
  385. font-size: 14px;
  386. word-break: break-all;
  387. }
  388. .el-form-item {
  389. margin-bottom: 8px;
  390. padding-left: 18px;
  391. }
  392. .labelItem /deep/ .el-form-item__label {
  393. // width: 80px;
  394. text-align: center;
  395. vertical-align: middle;
  396. float: left;
  397. font-size: 13px;
  398. color: #606266;
  399. // line-height: 40px;
  400. padding: 0 2px 0 0;
  401. -webkit-box-sizing: border-box;
  402. box-sizing: border-box;
  403. }
  404. // .el-form-item__content{
  405. // margin-left: 0;
  406. // }
  407. </style>