specialMonitorqt.vue 12 KB

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