AutoTestTask.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div>
  3. <crumbs title="转化为任务">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="任务名称:">
  6. <el-input size="mini" v-model="filter.missionName" placeholder="任务名称"></el-input>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button size="mini" @click="filterDatas">确认</el-button>
  10. </el-form-item>
  11. </el-form>
  12. </crumbs>
  13. <div class="contents">
  14. <el-table :data="list"
  15. border
  16. style="width: 100%">
  17. <el-table-column
  18. type="index"
  19. :index="indexMethod"
  20. label="编号"
  21. width="60">
  22. </el-table-column>
  23. <el-table-column
  24. prop="missionName"
  25. label="任务名称">
  26. </el-table-column>
  27. <el-table-column
  28. label="操作" width="150">
  29. <template slot-scope="scope"><el-button type="text" size="small" @click="toTaskDetail(scope.row.id)">详情</el-button>
  30. <span style="margin:0 3px;">|</span>
  31. <!--<el-button type="text" size="small" @click="toEditField(scope.row, 'modify')">修改</el-button>
  32. <span style="margin:0 3px;">|</span>-->
  33. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row.id)">删除</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <el-pagination v-if="total>pageSize"
  38. :current-page.sync="currentPage"
  39. @current-change="currentChange"
  40. background
  41. :page-size="pageSize"
  42. layout="total,prev, pager, next, jumper"
  43. :total="total">
  44. </el-pagination>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import api from '@api/qualityControl.js';
  50. export default {
  51. name: 'AutoTestTask',
  52. data: function () {
  53. return {
  54. list: [],
  55. tagType:[1],
  56. currentPage: 1,
  57. pageSize: 10,
  58. total: 0,
  59. fieldTypes:[],
  60. searched:false,
  61. hisTypes:[],
  62. filter: {
  63. missionName: ''
  64. }
  65. }
  66. },
  67. created() {
  68. const _this=this;
  69. setTimeout(function() {
  70. _this.getDataList()
  71. },100);
  72. },
  73. watch:{
  74. 'filter':{
  75. handler:function(){
  76. this.searched = false;
  77. },
  78. deep:true
  79. }
  80. },
  81. beforeRouteEnter(to, from, next){
  82. next(vm => {
  83. //const pm = to.param;
  84. Object.assign(vm,to.params);
  85. vm.inCurrentPage=to.params.currentPage;
  86. })
  87. },
  88. methods: {
  89. toTaskDetail(id){
  90. const pam = this.searched ? {
  91. currentPage: this.currentPage,
  92. filter: this.filter,
  93. id
  94. } : {currentPage: this.currentPage,id};
  95. this.$router.push({
  96. name:'TaskDetail',
  97. params: pam
  98. })
  99. },
  100. filterDatas(){
  101. this.currentPage = 1;
  102. this.getDataList();
  103. },
  104. getDataList() {
  105. const param = this.getFilterItems();
  106. this.searched = true;
  107. api.getTaskList(param).then((res) => {
  108. if (res.data.code == '0') {
  109. const data = res.data.data;
  110. this.list = data.records;
  111. this.total = data.total;
  112. }
  113. }).catch((error) => {
  114. console.log(error);
  115. });
  116. },
  117. getFilterItems() {
  118. const param = Object.assign({
  119. current: this.currentPage,
  120. size: this.pageSize,
  121. },this.filter);
  122. return param;
  123. },
  124. indexMethod(index) {
  125. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  126. },
  127. currentChange(next) {
  128. this.currentPage = next;
  129. this.getDataList();
  130. },
  131. warning(msg,type){
  132. this.$message({
  133. showClose: true,
  134. message:msg,
  135. type:type||'warning'
  136. })
  137. },
  138. showConfirmDialog(msg,resolve){
  139. this.$alert(msg, '提示', {
  140. confirmButtonText: '确定',
  141. type: 'warning'
  142. }).then(() => {
  143. resolve();
  144. }).catch(() => {});
  145. },
  146. showDelDialog(id){
  147. this.showConfirmDialog('是否删除该任务?',()=>{
  148. api.delTask({id:id}).then((res)=>{
  149. if(res.data.code=='0'){
  150. this.warning(res.data.msg||'操作成功','success');
  151. this.getDataList();
  152. }else{
  153. this.warning(res.data.msg);
  154. }
  155. }).catch((error)=>{
  156. this.warning(error);
  157. })
  158. });
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="less">
  164. @import "../../less/admin.less";
  165. .delete{
  166. color: red !important;
  167. }
  168. </style>