specialMonitorqt.vue 12 KB

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