task.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <avue-crud
  3. :option="option"
  4. :data="data"
  5. ref="crud"
  6. v-model="form"
  7. :before-open="beforeOpen"
  8. @row-del="rowDel"
  9. @row-save="rowSave"
  10. @row-update="rowUpdate"
  11. @on-load="onLoad">
  12. <template #menu-left="{}">
  13. <el-button-group>
  14. <el-button type='primary' :plain='query.type !== "0" ' @click='changeQueryType("0")'>待完成</el-button>
  15. <el-button type='primary' :plain='query.type !== "1" ' @click='changeQueryType("1")'>已完成</el-button>
  16. <el-button type='primary' :plain='query.type !== "" ' @click='changeQueryType("")'>全部</el-button>
  17. </el-button-group>
  18. </template>
  19. <template #menu="{row}">
  20. <el-button type='primary' text icon='Position' @click='changeQueryType("0")'>提交</el-button>
  21. </template>
  22. </avue-crud>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'my-task',
  27. data () {
  28. return {
  29. query: {
  30. type: '0'
  31. },
  32. page: {
  33. pageSize: 10,
  34. currentPage: 1,
  35. total: 10
  36. },
  37. data: [],
  38. form: {},
  39. option: {
  40. align: 'center',
  41. menuAlign: 'center',
  42. menuWidth: 380,
  43. size: 'mini',
  44. addBtn: false,
  45. viewBtn: true,
  46. editBtn: false,
  47. delBtn: false,
  48. refreshBtn: false,
  49. columnBtn: false,
  50. labelWidth: 140,
  51. border: true,
  52. column: [
  53. {
  54. label: '任务名称',
  55. prop: 'title'
  56. },
  57. {
  58. label: '任务要求',
  59. prop: 'remark'
  60. },
  61. {
  62. label: '所属项目',
  63. prop: 'projectName'
  64. },
  65. {
  66. label: '下发人',
  67. prop: 'dispatcherUserName'
  68. },
  69. {
  70. label: '下发时间',
  71. prop: 'createTime'
  72. },
  73. {
  74. label: '任务状态',
  75. prop: 'isCompleted',
  76. type: 'select',
  77. dicData: [
  78. {
  79. label: '待完成',
  80. value: 0
  81. },
  82. {
  83. label: '已完成',
  84. value: 1
  85. }
  86. ]
  87. }
  88. ]
  89. }
  90. }
  91. },
  92. methods: {
  93. onLoad () {
  94. this.loading = true
  95. this.page.current = this.page.currentPage
  96. this.page.size = this.page.pageSize
  97. this.$api.task.taskList(Object.assign(this.page, this.query)).then(res => {
  98. this.loading = false
  99. if (res.code === 200) {
  100. this.data = res.data.records
  101. this.page.total = res.data.total
  102. }
  103. })
  104. },
  105. beforeOpen (done, type) {
  106. if (type === 'view') {
  107. this.$router.push({ path: '/task/detail', query: { id: this.form.id, taskId: this.form.taskId } })
  108. } else {
  109. done()
  110. }
  111. },
  112. currentChange (currentPage) {
  113. this.page.currentPage = currentPage
  114. },
  115. sizeChange (pageSize) {
  116. this.page.size = pageSize
  117. },
  118. refreshChange () {
  119. this.onLoad()
  120. },
  121. rowDel (row) {
  122. this.$confirm('确定彻底删除所选择的文件?', {
  123. confirmButtonText: '确定',
  124. cancelButtonText: '取消',
  125. type: 'warning'
  126. })
  127. .then(() => {
  128. this.$api.recycle.recycleRemove({ ids: row.id }).then(res => {
  129. if (res.code === 200) {
  130. this.$message.success(res.msg)
  131. this.onLoad()
  132. } else {
  133. this.$message.error(res.msg)
  134. }
  135. })
  136. })
  137. },
  138. changeQueryType (type) {
  139. this.query.type = type
  140. this.onLoad()
  141. }
  142. }
  143. }
  144. </script>
  145. <style scoped>
  146. </style>