detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <basic-container class='mt-10'>
  3. <div class='flex flex-align-start flex flex-col'>
  4. <span class='bold'>任务基本信息:</span>
  5. <el-divider/>
  6. <div v-if='taskInfo' class='flex flex-align-start flex-col '>
  7. <div>
  8. <span class='bold'>任务名称:</span>
  9. <span>{{ taskInfo.title }}</span>
  10. </div>
  11. <div class='mt-10'>
  12. <span class='bold'>任务说明:</span>
  13. <span>{{ taskInfo.remark }}</span>
  14. </div>
  15. <div class='mt-10'>
  16. <span class='bold'>任务时间:</span>
  17. <span>{{ taskInfo.startTime }} - {{ taskInfo.endTime }}</span>
  18. </div>
  19. <div class='mt-10'>
  20. <span class='bold'>任务状态:</span>
  21. <el-tag>{{ taskInfo.isCompleted === 0 ? '未完成':'已完成' }}</el-tag>
  22. <el-tag class='ml-10'>{{ taskInfo.isConfirmed === 0 ? '待确认':'已确认' }}</el-tag>
  23. </div>
  24. </div>
  25. </div>
  26. </basic-container>
  27. <basic-container>
  28. <div class='flex flex-align-start flex flex-col full-width '>
  29. <span class='bold'>任务相关文件夹:</span>
  30. <el-divider/>
  31. <div class='full-width flex flex-justify-between'>
  32. <el-button icon='back' type='primary' @click='back'>
  33. 返回上一级
  34. </el-button>
  35. <el-button icon='Check' type='primary' v-if='this.folderList.length === 0 && taskInfo && taskInfo.isCompleted === 0 ' @click='completeTask'>
  36. 完成任务
  37. </el-button>
  38. <el-button icon='Check' type='primary' v-if='taskInfo && taskInfo.isConfirmed === 0 && view' @click='confirmTask'>
  39. 确认任务
  40. </el-button>
  41. </div>
  42. <basic-curd class='full-width' :data='data' :option='taskOption' @row-view='rowDetail' @row-del='rowDel'>
  43. <template #menu='{row}'>
  44. <main-button title='提交文件' v-if='row.type === 2 && view !== true' icon='Position' @click='postFile(row)'/>
  45. </template>
  46. </basic-curd>
  47. </div>
  48. <!-- upload-->
  49. <el-dialog v-model='show' title='上传文件'>
  50. <div>
  51. <el-upload
  52. drag
  53. :action="action"
  54. multiple
  55. accept='.doc,.docx,.pdf,.xls,.xlsx,.png,.jpg,.jpeg,.ppt,pptx'
  56. show-file-list
  57. :headers="{'Authorization':`Basic ${clientId}`}"
  58. :on-success='uploadSuccess'
  59. >
  60. <el-icon class="el-icon--upload">
  61. <upload-filled/>
  62. </el-icon>
  63. <div class="el-upload__text">
  64. 拖拽或者 <em>点击上传文件</em>
  65. </div>
  66. </el-upload>
  67. <el-divider/>
  68. <div class='flex flex-justify-end'>
  69. <el-button @click='show = false'>取 消</el-button>
  70. <el-button type='primary' @click='saveFile'>确 定</el-button>
  71. </div>
  72. </div>
  73. </el-dialog>
  74. <el-image-viewer
  75. v-if='showImage'
  76. :url-list="imgList"
  77. @close='showImage = false'
  78. />
  79. </basic-container>
  80. </template>
  81. <route>
  82. {
  83. name: '任务详情'
  84. }
  85. </route>
  86. <script>
  87. import BasicContainer from '@/components/basic-container/main.vue'
  88. import basicCurd from '@/components/basic-curd/index.vue'
  89. import MainButton from '@/components/main-button.vue'
  90. import api from '@/api/index.js'
  91. import { Base64 } from 'js-base64'
  92. import website from '@/config/website.js'
  93. export default {
  94. name: 'detail',
  95. components: { MainButton, BasicContainer, basicCurd },
  96. data () {
  97. return {
  98. clientId: '',
  99. view: false,
  100. showImage: false,
  101. imgList: [],
  102. show: false,
  103. action: api.uploadPath,
  104. fileList: [],
  105. id: '',
  106. taskId: '',
  107. page: {
  108. pageSize: 10,
  109. currentPage: 1,
  110. total: 10
  111. },
  112. isAccess: 3,
  113. current: null,
  114. currentFolder: null,
  115. taskInfo: null,
  116. folderList: [],
  117. resultFile: [],
  118. data: [],
  119. taskOption: {
  120. viewBtn: true,
  121. editBtn: false,
  122. delBtn: false,
  123. column: [
  124. {
  125. label: '文件夹',
  126. prop: 'folderName'
  127. },
  128. {
  129. label: '更新时间',
  130. prop: 'updateTime'
  131. },
  132. {
  133. label: '创建人',
  134. prop: 'createUserName'
  135. }
  136. ]
  137. }
  138. }
  139. },
  140. created () {
  141. this.id = this.$route.query.id
  142. this.taskId = this.$route.query.taskId
  143. this.clientId = Base64.encode(`${website.clientId}:${website.clientSecret}`)
  144. const viewtemp = this.$route.query.view
  145. if (viewtemp) {
  146. this.view = true
  147. }
  148. if (this.view) {
  149. this.confirmDetail()
  150. } else {
  151. this.detail()
  152. }
  153. },
  154. methods: {
  155. confirmDetail () {
  156. const data = { taskId: this.taskId }
  157. this.$api.task.confirmDetail(Object.assign(data, this.page)).then(res => {
  158. if (res.code === 200) {
  159. this.data = res.data.records.map(sub => {
  160. sub.parentId = 0
  161. sub.type = 2
  162. return sub
  163. })
  164. this.current = this.data[0]
  165. this.isAccess = this.data[0].isAccess
  166. this.taskInfo = this.data[0]
  167. } else {
  168. this.$message.error(res.msg)
  169. }
  170. })
  171. },
  172. detail () {
  173. const data = { taskId: this.taskId }
  174. this.$api.task.detail(Object.assign(data, this.page)).then(res => {
  175. if (res.code === 200) {
  176. this.data = res.data.records.map(sub => {
  177. sub.parentId = 0
  178. sub.type = 2
  179. return sub
  180. })
  181. this.current = this.data[0]
  182. this.isAccess = this.data[0].isAccess
  183. this.taskInfo = this.data[0]
  184. } else {
  185. this.$message.error(res.msg)
  186. }
  187. })
  188. },
  189. rowDel (row) {
  190. this.$api.task.taskRemove({ taskId: this.taskId, ids: row.id }).then(res => {
  191. if (res.code === 200) {
  192. this.$message.success(res.msg)
  193. this.data = this.data.filter(sub => sub.id !== row.id)
  194. } else {
  195. this.$message.error(res.msg)
  196. }
  197. })
  198. },
  199. rowDetail (row, index) {
  200. if (row.type === 2) {
  201. const data = { folderId: row.folderId, taskId: this.taskId }
  202. this.folderList.push(row)
  203. this.current = row
  204. this.current.parentId = row.folderId
  205. this.$api.task.fileList(data).then(res => {
  206. if (res.code === 200) {
  207. this.data = res.data.records.map(sub => {
  208. sub.folderName = sub.title
  209. // 继承上级的权限
  210. sub.isAccess = row.isAccess
  211. // rowDetail 需要folderId
  212. sub.folderId = sub.id
  213. return sub
  214. })
  215. } else {
  216. this.$message.error(res.msg)
  217. }
  218. })
  219. } else {
  220. if (api.offices.includes(row.suffix)) {
  221. const routeData = this.$router.resolve({ path: '/home/file_detail', query: { id: row.fileId } })
  222. window.open(routeData.href, '_blank')
  223. } else {
  224. this.imgList = [row.url]
  225. this.showImage = true
  226. }
  227. }
  228. },
  229. back () {
  230. if (this.folderList.length === 0) {
  231. this.$router.back()
  232. return
  233. }
  234. this.folderList.pop()
  235. this.current = this.folderList[this.folderList.length - 1]
  236. if (this.folderList.length === 0) {
  237. this.detail()
  238. } else {
  239. const data = { folderId: this.current.folderId }
  240. this.$api.task.fileList(data).then(res => {
  241. if (res.code === 200) {
  242. this.data = res.data.records.map(sub => {
  243. sub.folderName = sub.title
  244. // 继承上级的权限
  245. sub.isAccess = this.isAccess
  246. // rowDetail 需要folderId
  247. sub.folderId = sub.id
  248. return sub
  249. })
  250. } else {
  251. this.$message.error(res.msg)
  252. }
  253. })
  254. }
  255. },
  256. postFile (row) {
  257. console.log(row)
  258. this.currentFolder = row
  259. this.show = true
  260. },
  261. completeTask (row) {
  262. this.$api.task.completeTask({ taskId: this.taskId }).then(res => {
  263. if (res.code === 200) {
  264. this.$message.success(res.msg)
  265. this.taskInfo.isCompleted = 1
  266. } else {
  267. this.$message.error(res.msg)
  268. }
  269. })
  270. },
  271. uploadSuccess (res, file, files) {
  272. this.fileList = files.map(sub => sub.response.data)
  273. },
  274. saveFile () {
  275. if (this.fileList.length === 0) {
  276. return
  277. }
  278. this.fileList.forEach(sub => {
  279. if (['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'].includes(sub.suffix)) {
  280. // save Library
  281. const data = {
  282. title: sub.originalFileName,
  283. fileId: sub.id,
  284. suffix: sub.suffix,
  285. volume: sub.volume,
  286. url: sub.filePath,
  287. category: 4,
  288. content: '',
  289. parentId: this.currentFolder.folderId
  290. }
  291. this.$api.common.submit(data).then(res => {
  292. if (res.code === 200) {
  293. console.log(res.msg)
  294. } else {
  295. this.$message.error(res.msg)
  296. }
  297. })
  298. }
  299. })
  300. this.addFile()
  301. },
  302. /**
  303. * 上传文件
  304. */
  305. addFile () {
  306. this.fileList = this.fileList.map(sub => {
  307. sub.parentId = this.currentFolder.folderId
  308. sub.projectId = this.currentFolder.projectId
  309. sub.title = sub.originalFileName
  310. sub.fileId = sub.id
  311. sub.url = sub.filePath
  312. return sub
  313. })
  314. const data = { taskId: this.taskId, dispatcherUser: this.currentFolder.dispatcherUser, folderId: this.currentFolder.folderId, files: this.fileList }
  315. this.$api.task.uploadFile(data).then(res => {
  316. if (res.code === 200) {
  317. this.show = false
  318. } else {
  319. this.$message.error(res.msg)
  320. }
  321. })
  322. },
  323. confirmTask () {
  324. this.$confirm('确认任务,并且向业主发送提醒', {
  325. confirmButtonText: '确定',
  326. cancelButtonText: '取消',
  327. type: 'warning'
  328. }).then(res => {
  329. this.$api.task.taskConfirm({ taskId: this.taskId }).then(res => {
  330. if (res.code === 200) {
  331. this.$message.success(res.msg)
  332. this.taskInfo.isConfirmed = 1
  333. } else {
  334. this.$message.error(res.msg)
  335. }
  336. })
  337. })
  338. }
  339. }
  340. }
  341. </script>
  342. <style scoped>
  343. </style>