reTask.vue 18 KB

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