reTask copy.vue 17 KB

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