task.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <el-dialog v-model="showDialog" width="800">
  3. <template #header>
  4. <div class="full-width flex flex-center flex-justify-between">
  5. <h4>任务详情</h4>
  6. </div>
  7. </template>
  8. <div>
  9. <el-input v-model="form.title" placeholder="请输入任务名称"></el-input>
  10. <div class="mt-10">
  11. <div class="flex flex-center flex-justify-start">
  12. <span class="mr-10 title flex flex-justify-start">状态:</span>
  13. <wt-tag :data="status" @change="changeStatus($event, 1)" />
  14. </div>
  15. <div class="mt-10 flex flex-center flex-justify-start">
  16. <span class="mr-10 title flex flex-justify-start">优先级:</span>
  17. <wt-tag :data="level" @change="changeStatus($event, 2)" />
  18. </div>
  19. <div class="mt-10 flex flex-center flex-justify-start">
  20. <span class="mr-10 title flex flex-justify-start">时间:</span>
  21. <div class="flex flex-center">
  22. <el-date-picker
  23. v-model="form.startTime"
  24. type="date"
  25. placeholder="设置开始日期"
  26. format="YYYY-MM-DD"
  27. value-format="YYYY-MM-DD"
  28. >
  29. </el-date-picker>
  30. <div class="ml-5 mr-5">至</div>
  31. <el-date-picker
  32. v-model="form.endTime"
  33. type="date"
  34. placeholder="设置截止日期"
  35. format="YYYY-MM-DD"
  36. value-format="YYYY-MM-DD"
  37. >
  38. </el-date-picker>
  39. </div>
  40. </div>
  41. <div class="mt-10 flex lex-align-start flex-justify-start">
  42. <span class="mr-10 title flex flex-justify-start">标签:</span>
  43. <div>
  44. <wt-label @submit="handleTags" />
  45. </div>
  46. </div>
  47. <div class="mt-10 flex lex-align-start flex-justify-start">
  48. <span class="mr-10 title flex flex-justify-start">执行者:</span>
  49. <div>
  50. <tasker :data="task.users" @success="selected" />
  51. </div>
  52. </div>
  53. <div class="mt-10 flex flex-align-start flex-justify-start">
  54. <span class="mr-10 title flex flex-justify-start">备注:</span>
  55. <el-input type="textarea" :rows="5" v-model="form.remark"></el-input>
  56. </div>
  57. <div class="mt-10 flex flex-align-start flex-justify-start flex-col">
  58. <div class="flex flex-center flex-justify-start">
  59. <span class="mr-10 title flex flex-justify-start">关联附件:</span>
  60. <filepicker :project-id="projectId" @submit="selection" />
  61. </div>
  62. <div class="flex flex-center flex-justify-start full-width mt-10">
  63. <div class="title mr-10"></div>
  64. <div>
  65. <div v-for="item in fileList" :key="item.id">
  66. {{ item.title }}
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="flex flex-justify-start full-width flex-col">
  72. <div class="mt-10 flex flex-align-start flex-justify-start">
  73. <span class="mr-10 title flex flex-justify-start">任务进展:</span>
  74. <el-input
  75. type="textarea"
  76. :rows="5"
  77. v-model="form.taskProcess"
  78. ></el-input>
  79. </div>
  80. <div class="flex flex-justify-start flex-center mt-10 full-width">
  81. <div class="title mr-10" />
  82. <el-icon>
  83. <Paperclip />
  84. </el-icon>
  85. <div>附件</div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="flex flex-justify-end full-width">
  90. <el-button type="primary" plain @click="showDialog = false"
  91. >取 消
  92. </el-button>
  93. <el-button type="primary" @click="submit">确 定</el-button>
  94. </div>
  95. </div>
  96. </el-dialog>
  97. </template>
  98. <script>
  99. import WtTag from '@/views/task/component/wt-tag.vue'
  100. import Tasker from '@/views/task/component/tasker.vue'
  101. import filepicker from '@/components/filepicker/index.vue'
  102. import WtLabel from '@/views/task/component/wt-label.vue'
  103. export default {
  104. components: { WtLabel, Tasker, WtTag, filepicker },
  105. props: {
  106. projectId: {
  107. type: String,
  108. default: ''
  109. },
  110. task: {
  111. type: Object,
  112. default: () => {
  113. return null
  114. }
  115. }
  116. },
  117. watch: {
  118. task: {
  119. handler(val) {
  120. if (val) {
  121. this.form = val
  122. this.status = this.fetchIndex(this.status, this.form.taskStatus)
  123. this.level = this.fetchIndex(this.level, this.form.level)
  124. if (val.files !== undefined && val.files.length > 0) {
  125. this.fileList = val.files.map(ele => {
  126. return {
  127. fileId: ele.id,
  128. title: ele.title
  129. }
  130. })
  131. }
  132. }
  133. },
  134. immediate: true
  135. }
  136. },
  137. data() {
  138. return {
  139. showDialog: false,
  140. fileList: [],
  141. form: {
  142. title: '',
  143. taskStatus: '',
  144. level: '',
  145. remark: '',
  146. startTime: '',
  147. endTime: '',
  148. executeUser: '',
  149. tags: '',
  150. taskProcess: ''
  151. },
  152. status: [
  153. {
  154. title: '待确认',
  155. value: 0,
  156. color: '#D7D7D7',
  157. checked: true
  158. },
  159. {
  160. title: '进行中',
  161. value: 1,
  162. color: '#47A6EA',
  163. checked: false
  164. },
  165. {
  166. title: '已完成',
  167. value: 2,
  168. color: '#80B336',
  169. checked: false
  170. },
  171. {
  172. title: '已关闭',
  173. value: 3,
  174. color: '#ECAB56',
  175. checked: false
  176. },
  177. {
  178. title: '已取消',
  179. value: 4,
  180. color: '#C72A29',
  181. checked: false
  182. }
  183. ],
  184. level: [
  185. {
  186. title: 'P1',
  187. value: 0,
  188. color: '#C72A29',
  189. checked: true
  190. },
  191. {
  192. title: 'P2',
  193. value: 1,
  194. color: '#E89D42',
  195. checked: false
  196. },
  197. {
  198. title: 'P3',
  199. value: 2,
  200. color: '#47A6EA',
  201. checked: false
  202. },
  203. {
  204. title: 'P4',
  205. value: 3,
  206. color: '#A0A0A0',
  207. checked: false
  208. }
  209. ]
  210. }
  211. },
  212. methods: {
  213. fetchIndex(list, key) {
  214. const index = list.findIndex(ele => ele.value === key)
  215. if (index > -1) {
  216. list.map(ele => {
  217. ele.checked = false
  218. return ele
  219. })
  220. list[index].checked = true
  221. }
  222. return list
  223. },
  224. show() {
  225. this.showDialog = true
  226. },
  227. changeStatus(res, type) {
  228. if (type === 1) {
  229. this.form.taskStatus = res.value
  230. } else {
  231. this.form.level = res.value
  232. }
  233. },
  234. submit() {
  235. this.form.projectId = this.projectId
  236. this.form.relatedIds = this.fileList.map(ele => ele.fileId).join(',')
  237. this.$api.task.addTask(this.form).then(res => {
  238. this.showDialog = false
  239. if (res.code === 200) {
  240. this.$message.success(res.msg)
  241. } else {
  242. this.$message.error(res.msg)
  243. }
  244. })
  245. },
  246. selection(list) {
  247. this.fileList = list.map(ele => {
  248. return {
  249. fileId: ele.id,
  250. title: ele.title
  251. }
  252. })
  253. },
  254. selected(list) {
  255. this.form.executeUser = list.map(ele => ele.id).join(',')
  256. },
  257. handleTags(tags) {
  258. this.form.tags = tags
  259. },
  260. close() {
  261. this.form = {}
  262. this.showDialog = false
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .title {
  269. min-width: 60px;
  270. }
  271. :deep(.el-input__wrapper) {
  272. box-shadow: none;
  273. font-weight: bold;
  274. font-size: 16px;
  275. background-color: #eeeeee;
  276. }
  277. :deep(.el-input__wrapper:hover) {
  278. box-shadow: none;
  279. background-color: #eeeeee;
  280. }
  281. </style>