task.vue 7.8 KB

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