reTask.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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-item>任务列表</el-breadcrumb-item>
  9. </el-breadcrumb>
  10. </div>
  11. <!-- 头部查询栏 -->
  12. <div class="headSearch">
  13. <el-row :gutter="120" style="margin-right: 0px;">
  14. <el-form :inline="true">
  15. <el-form-item label="年度" class="select" size="small">
  16. <el-date-picker v-model="queryInfo.year" style="width: 110px;" value-format="yyyy" type="year" clearable />
  17. </el-form-item>
  18. <el-form-item label="任务状态" class="select" size="small">
  19. <el-select v-model="queryInfo.ispublic" style="width: 110px;" clearable>
  20. <el-option
  21. v-for="item in taskispublic"
  22. :key="item.value"
  23. :label="item.label"
  24. :value="item.value" >
  25. </el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="任务时间" class="select" size="small">
  29. <el-date-picker v-model="queryInfo.starttime" style="width: 180px;" align="right" type="date"
  30. :picker-options="pickerOptions" clearable value-format="yyyy-MM-dd" />
  31. </el-form-item>
  32. <el-form-item label="--" class="select" style="margin-left: 8px;" size="small">
  33. <el-date-picker v-model="queryInfo.endtime" style="width: 180px;" align="right" type="date"
  34. :picker-options="pickerOptions" clearable />
  35. </el-form-item>
  36. <el-form-item label="任务名称" class="select" size="small">
  37. <el-input v-model="queryInfo.task_name"></el-input>
  38. </el-form-item>
  39. <!-- 查询 -->
  40. <el-button size="mini" style="height: 40px;margin-left: 10px;" type="success" @click="searchData()">查询</el-button>
  41. <!-- 重置 -->
  42. <el-button size="mini" style="height: 40px;margin-left: 5px;" type="success" @click="reset()">重置</el-button>
  43. </el-form>
  44. </el-row>
  45. </div>
  46. <!--头部右侧按钮区域-->
  47. <div class="rightButton">
  48. <el-row :gutter="90" style="margin-right: 0px;">
  49. <div style="display: flex;flex-direction: row;float: right;">
  50. <!-- <el-button type="primary" size="small" plain icon="el-icon-plus" @click="add()">新增</el-button> -->
  51. <el-button type="primary" size="small" plain icon="el-icon-edit-outline" @click="ispublic()">发布
  52. </el-button>
  53. <el-button type="primary" size="small" plain icon="el-icon-scissors" @click="repeal()">废止</el-button>
  54. <el-button type="primary" size="small" plain icon="el-icon-delete" @click="delArray()">删除</el-button>
  55. <!-- <el-button type="primary" size="small" plain icon="el-icon-download">导出</el-button> -->
  56. </div>
  57. </el-row>
  58. </div>
  59. <!-- 表格数据区域-->
  60. <el-table ref="multipleTable"
  61. :data="tableData"
  62. border stripe highlight-current-row
  63. style="width: 100%"
  64. :row-style="rowStyle"
  65. :cell-style="cellStyle"
  66. @selection-change="handleSelectionChange">
  67. <el-table-column type="selection" width="50"></el-table-column>
  68. <el-table-column label="序号" width="50px">
  69. <template slot-scope="scope">
  70. {{ scope.$index+1 }}
  71. </template>
  72. </el-table-column>
  73. <el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop" align="center"
  74. :width="table.width" :fixed="table.fixed" />
  75. <el-table-column prop="status" label="任务状态" width="130" align="center" >
  76. <template slot-scope="scope">
  77. <el-tag v-if="scope.row.ispublic==0">未发布</el-tag>
  78. <el-tag type="warning" v-if="scope.row.ispublic==1">已发布</el-tag>
  79. <el-tag type="danger" v-if="scope.row.ispublic==2">已废止</el-tag>
  80. <el-tag type="info" v-if="scope.row.ispublic==3">已结束,未完成</el-tag>
  81. <el-tag type="success" v-if="scope.row.ispublic==4">已结束,已完成</el-tag>
  82. <el-tag type="success" effect="plain" v-if="scope.row.ispublic==5">执行中</el-tag>
  83. </template>
  84. </el-table-column>
  85. <el-table-column prop="level" label="任务优先级" width="95" align="center">
  86. <template slot-scope="scope">
  87. <el-tag type="success" v-if="scope.row.level==0">一般</el-tag>
  88. <el-tag type="warning" v-if="scope.row.level==1">紧急</el-tag>
  89. <el-tag type="danger" v-if="scope.row.level==2">特急</el-tag>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" fixed="right">
  93. <!-- 操作按钮区域的作用域插槽 -->
  94. <template slot-scope="scope">
  95. <el-col style="margin-bottom: 5px;">
  96. <el-button type="success" size="mini" @click="readDialogVisible1(scope.row)" style="margin-top:5px">查看详情</el-button>
  97. <!-- <el-button type="success" size="mini" @click="sendBack(scope.row)" style="margin-top:5px" >退回</el-button> -->
  98. <el-button type="success" size="mini" @click="editInform(scope.row.id)">编辑</el-button>
  99. </el-col>
  100. <el-col style="margin-bottom: 5px;">
  101. <!-- <el-button type="success" size="mini" plain @click="takeTheLeadReportList(scope.row.id)" style="margin-top:5px">牵头单位报告</el-button> -->
  102. <el-button type="success" size="mini" plain @click="getJcds(scope.row.id)" style="margin-top:5px">检测单</el-button>
  103. <!-- <el-button type="success" size="mini" plain @click="undertakeReport(scope.row.id)">承担单位报告</el-button> -->
  104. <el-button type="success" size="mini" plain @click="sampleList(scope.row.id)">抽样单</el-button>
  105. </el-col>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <!-- 分页器区域-->
  110. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  111. :current-page="queryInfo.pageNum" :page-sizes="[10, 15, 20]" :page-size="queryInfo.pageSize"
  112. layout="total, sizes, prev, pager, next, jumper" :total="total" background />
  113. <!-- 任务详情对话框-->
  114. <el-dialog title="查看" :visible.sync="readDialogVisible" width="30%" :close-on-click-modal="false"
  115. class="dialogItem">
  116. <el-form v-if="readDialogVisible" :model="readForm" label-width="100px">
  117. <el-form-item label="任务名称:" prop="task_name" class="labelItem">
  118. <div>{{readForm.task_name}}</div>
  119. </el-form-item>
  120. <el-form-item label="任务优先级:" prop="level" class="labelItem">
  121. <div v-if="readForm.level=='0'">一般</div>
  122. <div v-else-if="readForm.level=='1'">紧急</div>
  123. <div v-else>特急</div>
  124. </el-form-item>
  125. <el-form-item label="监测类型:" prop="task_class" width="70px" class="labelItem">
  126. <div>{{readForm.task_class}}</div>
  127. </el-form-item>
  128. <el-form-item label="年度:" prop="year" class="labelItem">
  129. <div>{{readForm.year}}</div>
  130. </el-form-item>
  131. <el-form-item label="批次:" prop="batch" width="200px" class="labelItem">
  132. <div>{{readForm.batch}}</div>
  133. </el-form-item>
  134. <el-form-item label="任务时间:" prop="starttime" width="200px" class="labelItem">
  135. <div>{{readForm.starttime}} 至 {{readForm.endtime}}</div>
  136. </el-form-item>
  137. <el-form-item label="发布单位:" prop="creater" class="labelItem">
  138. <div>{{readForm.creater.name}}</div>
  139. </el-form-item>
  140. <!-- <el-form-item label="牵头单位:" prop="main_unit" class="labelItem">
  141. <div>{{readForm.main_unit}}</div>
  142. </el-form-item> -->
  143. <el-form-item label="附件:" prop="file_url" class="labelItem">
  144. <!-- <div>{{readForm.file_url}}</div> -->
  145. <el-link :href="readForm.file_url" type="primary">{{readForm.file_name}}</el-link>
  146. </el-form-item>
  147. <el-form-item label="文件号:" prop="filenum" width="230px" class="labelItem">
  148. <div v-if="readForm.filenum==null">无</div>
  149. <div v-else>{{readForm.filenum}}</div>
  150. </el-form-item>
  151. <el-form-item label="备注:" prop="log" class="labelItem">
  152. <div v-if="readForm.log==null">无</div>
  153. <div v-else>{{readForm.log}}</div>
  154. </el-form-item>
  155. <div class="footer">
  156. <el-button type="success" @click="readDialogVisible = false">返回</el-button>
  157. </div>
  158. </el-form>
  159. </el-dialog>
  160. </div>
  161. </template>
  162. <script>
  163. const token = window.sessionStorage.getItem('token')
  164. const rybh = window.sessionStorage.getItem('rybh')
  165. const rymc = window.sessionStorage.getItem('rymc')
  166. export default {
  167. name: '',
  168. data() {
  169. return {
  170. queryInfo:{
  171. year:'',
  172. task_name:'',
  173. starttime:'',
  174. endtime:'',
  175. ispublic:'',
  176. pageSize:10,
  177. pageNum:1,
  178. task_class:'retask',
  179. task_id:'33',
  180. task_profile_id:''
  181. },
  182. total:0,
  183. cellStyle: {
  184. padding: 2 + 'px'
  185. },
  186. rowStyle: {
  187. height: 35 + 'px'
  188. },
  189. tableHeader: [{
  190. label: '任务名称',
  191. prop: 'task_name',
  192. width: 150
  193. // fixed: 'left'
  194. },
  195. {
  196. label: '开始时间',
  197. prop: 'starttime',
  198. width: 120
  199. },
  200. {
  201. label: '结束时间',
  202. prop: 'endtime',
  203. width: 120
  204. },
  205. {
  206. label: '年度',
  207. prop: 'year',
  208. width: 80
  209. // fixed: 'left'
  210. }, {
  211. label: '文件号',
  212. prop: 'filenum',
  213. width: 180
  214. // fixed: 'left'
  215. },
  216. {
  217. label: '创建者',
  218. prop: 'creater.name',
  219. width: 140
  220. },
  221. {
  222. label: '创建时间',
  223. prop: 'create_time',
  224. width: 180
  225. }
  226. ],
  227. // 数据表格数据
  228. tableData: [],
  229. // 批量删除选中数据
  230. multipleSelection: [],
  231. // 任务状态选项
  232. taskispublic: [{
  233. value: '',
  234. label: '全部'
  235. }, {
  236. value: '0',
  237. label: '未发布'
  238. }, {
  239. value: '1',
  240. label: '已发布'
  241. }, {
  242. value: '2',
  243. label: '废止'
  244. }, {
  245. value: '5',
  246. label: '执行中'
  247. }, {
  248. value: '3',
  249. label: '已结束,未完成'
  250. }, {
  251. value: '4',
  252. label: '已结束,已完成'
  253. }],
  254. // 日期选择器快捷选项
  255. pickerOptions: {
  256. // disabledDate(time) {
  257. // return time.getTime() > Date.now();
  258. // },
  259. shortcuts: [{
  260. text: '今天',
  261. onClick(picker) {
  262. picker.$emit('pick', new Date());
  263. }
  264. }, {
  265. text: '昨天',
  266. onClick(picker) {
  267. const date = new Date();
  268. date.setTime(date.getTime() - 3600 * 1000 * 24);
  269. picker.$emit('pick', date);
  270. }
  271. }, {
  272. text: '一周前',
  273. onClick(picker) {
  274. const date = new Date();
  275. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  276. picker.$emit('pick', date);
  277. }
  278. }]
  279. },
  280. // 查看任务详情
  281. readDialogVisible: false,
  282. readForm: {},
  283. multipleSelection: [],
  284. delarr: [],
  285. pubarr: []
  286. }
  287. },
  288. created() {
  289. this.getTasks()
  290. },
  291. methods: {
  292. //新增
  293. // add() {
  294. // this.$router.push('addTask')
  295. // },
  296. //编辑
  297. editInform(id){
  298. this.$router.push({
  299. name:'editInformation',
  300. params: {
  301. task_id:id,
  302. },
  303. })
  304. },
  305. //查看抽样机构
  306. sampleList(id){
  307. this.$router.push({
  308. name:'setTaskJg',
  309. params: {
  310. task_id:id,
  311. }
  312. })
  313. },
  314. // 搜索
  315. async searchData() {
  316. this.queryInfo.pageNum = 1
  317. this.getTasks()
  318. },
  319. // 重置
  320. reset(){
  321. this.queryInfo={
  322. year:'',
  323. task_name:'',
  324. starttime:'',
  325. endtime:'',
  326. ispublic:'',
  327. pageSize:10,
  328. pageNum:1,
  329. task_class:'例行监测',
  330. task_id
  331. }
  332. this.getTasks()
  333. },
  334. //退回
  335. async sendBack(){
  336. const result = await this.$http.post("postRetask", this.queryInfo);
  337. if (result.data.code == 0) {
  338. this.$message({
  339. type: 'success',
  340. // message: result.data.message
  341. message:'退回成功',
  342. })
  343. } else {
  344. this.$message({
  345. type: 'warning',
  346. // message: result.data.message
  347. message:'退回失败',
  348. })
  349. }
  350. console.log(result.data.code)
  351. },
  352. /** 监听页码的改变 */
  353. handleCurrentChange(newPage) {
  354. this.queryInfo.pageNum = newPage
  355. this.getTasks()
  356. },
  357. /** 监听每页显示多少数据的改变 */
  358. handleSizeChange(newSize) {
  359. this.queryInfo.pageSize = newSize
  360. this.getTasks()
  361. },
  362. // 获取任务列表
  363. async getTasks() {
  364. for (var key in this.queryInfo) {
  365. if (this.queryInfo[key] == '') {
  366. delete this.queryInfo[key]
  367. }
  368. }
  369. const {
  370. data: res
  371. } = await this.$http.post(
  372. "getTasks", this.queryInfo
  373. );
  374. this.tableData = res.data.rows
  375. this.total = res.data.total
  376. },
  377. // 查看任务详情
  378. async readDialogVisible1(row) {
  379. this.readForm.batch = row.batch
  380. this.readForm.task_name = row.task_name
  381. this.readForm.task_class = row.task_class
  382. this.readForm.level = row.level
  383. // console.log(this.readForm.level)
  384. this.readForm.year = row.year
  385. this.readForm.starttime = row.starttime
  386. this.readForm.endtime = row.endtime
  387. this.readForm.releaser = row.releaser
  388. this.readForm.creater = row.creater
  389. this.readForm.main_unit = row.main_unit
  390. this.readForm.file_url = row.file_url
  391. this.readForm.file_name = row.file_name
  392. this.readForm.filenum = row.filenum
  393. this.readForm.log = row.log
  394. this.readDialogVisible = true
  395. },
  396. // 批量删除
  397. handleSelectionChange(val) {
  398. this.multipleSelection = val;
  399. // console.log(this.multipleSelection)
  400. },
  401. // 删除任务
  402. async delArray() {
  403. // 判断任务是否为该创建者创建
  404. // for (let i = 0; i < this.multipleSelection.length; i++) {
  405. // if (rybh != this.multipleSelection[i].releaser) {
  406. // this.$alert('任务仅创建者可以删除!', {
  407. // confirmButtonText: '确定',
  408. // callback: action => {
  409. // }
  410. // });
  411. // }
  412. // }
  413. var that = this;
  414. const length = this.multipleSelection.length;
  415. for (let i = 0; i < length; i++) {
  416. this.delarr.push(this.multipleSelection[i].id);
  417. }
  418. const result = await this.$http.post('deleteTasks', {
  419. delarr: that.delarr,
  420. token: token
  421. })
  422. console.log(that.delarr);
  423. if (result.data.code == 0) {
  424. this.$message({
  425. type: 'success',
  426. message: '删除成功!'
  427. });
  428. that.getTasks()
  429. } else {
  430. this.$message({
  431. type: 'error',
  432. message: '删除失败!'
  433. });
  434. }
  435. // console.log(this.$refs.multipleTable);
  436. this.$refs.multipleTable.clearSelection();
  437. that.delarr = [];
  438. // this.$refs.multipleTable.clearSelectionFun();
  439. },
  440. // 发布任务
  441. async ispublic() {
  442. // 判断任务是否为该创建者创建
  443. // for (let i = 0; i < this.multipleSelection.length; i++) {
  444. // if (rybh != this.multipleSelection[i].releaser) {
  445. // this.$alert('任务仅创建者可以发布!', {
  446. // confirmButtonText: '确定',
  447. // callback: action => {
  448. // }
  449. // });
  450. // }
  451. // }
  452. var that = this;
  453. let canPub = 0
  454. const length = this.multipleSelection.length;
  455. // var val = this.selectedData;
  456. console.log(this.multipleSelection)
  457. // this.pubarr = this.multipleSelection;
  458. for (let i = 0; i < length; i++) {
  459. if (this.multipleSelection[i].ispublic != '0') {
  460. this.$alert('任务不在可发布状态!', {
  461. confirmButtonText: '确定',
  462. callback: action => {
  463. }
  464. });
  465. } else {
  466. this.multipleSelection[i].ispublic = 1
  467. canPub = 1
  468. }
  469. }
  470. if(canPub==1){
  471. const result = await this.$http.post('putTaskPublic', {
  472. pubarr: that.multipleSelection,
  473. token: token,
  474. })
  475. console.log(result.data.code)
  476. if (result.data.code == 0) {
  477. this.$message({
  478. type: 'success',
  479. message: '发布成功!'
  480. });
  481. that.getTasks()
  482. }else{
  483. this.$message({
  484. type: 'error',
  485. message: result.data.message})
  486. }
  487. }
  488. },
  489. // 废止任务
  490. async repeal() {
  491. // 判断任务是否为该创建者创建
  492. for (let i = 0; i < this.multipleSelection.length; i++) {
  493. if (rybh != this.multipleSelection[i].releaser) {
  494. this.$alert('任务仅创建者可以废止!', {
  495. confirmButtonText: '确定',
  496. callback: action => {}
  497. });
  498. }
  499. }
  500. var that = this;
  501. let canPub = 0
  502. const length = this.multipleSelection.length;
  503. // var val = this.selectedData;
  504. this.pubarr = this.multipleSelection;
  505. for (let i = 0; i < length; i++) {
  506. if (this.pubarr[i].ispublic == 1) {
  507. this.pubarr[i].ispublic = 2
  508. canPub = 1
  509. } else {
  510. this.$alert('任务不在可废止状态!', {
  511. confirmButtonText: '确定',
  512. callback: action => {
  513. }
  514. });
  515. }
  516. if(canPub==1){
  517. const result = await this.$http.post('putTaskPublic', {
  518. pubarr: that.pubarr,
  519. token: token
  520. })
  521. if (result.data.code == 0) {
  522. this.$message({
  523. type: 'success',
  524. message: '任务已废止!'
  525. });
  526. that.getTasks()
  527. }
  528. }
  529. }
  530. }
  531. },
  532. }
  533. </script>
  534. <style lang="less" scoped>
  535. .el-breadcrumb {
  536. margin-bottom: 20px;
  537. }
  538. .el-table {
  539. align-items: center;
  540. margin-top: 25px;
  541. }
  542. /deep/ .el-col {
  543. padding-right: 0 !important;
  544. }
  545. /deep/ .el-radio-group label {
  546. width: 180px;
  547. margin-right: 10px;
  548. }
  549. .el-pagination {
  550. margin-top: 25px;
  551. }
  552. // .el-cascader {
  553. // width: 290px;
  554. // }
  555. .el-select {
  556. width: 210px;
  557. height: 100%;
  558. }
  559. .select {
  560. // display: flex;
  561. flex-direction: row;
  562. margin-left: 35px;
  563. }
  564. .dialogItem /deep/ .el-dialog__body {
  565. padding: 15px 12px 0;
  566. color: #606266;
  567. font-size: 14px;
  568. word-break: break-all;
  569. }
  570. .el-form-item {
  571. margin-bottom: 8px;
  572. }
  573. .labelItem /deep/ .el-form-item__label {
  574. // width: 80px;
  575. text-align: center;
  576. vertical-align: middle;
  577. float: left;
  578. font-size: 13px;
  579. color: #606266;
  580. // line-height: 40px;
  581. padding: 0 2px 0 0;
  582. -webkit-box-sizing: border-box;
  583. box-sizing: border-box;
  584. }
  585. .el-dialog__header {
  586. border-bottom: 1px solid #e5e5e5;
  587. }
  588. // .el-form-item__content{
  589. // margin-left: 0;
  590. // }
  591. .footer {
  592. padding: 5px 0;
  593. border-top: 1px solid #e5e5e5;
  594. text-align: center;
  595. }
  596. .rightButton{
  597. margin-top: 20px;
  598. }
  599. .headSearch{
  600. margin-left: 25px;
  601. }
  602. </style>