returnTaskcd.vue 11 KB

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