current.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="flex flex-col padding">
  3. <div class="flex flex-center mt-20">
  4. <div class="bold font-16 grey flex-child-average text-left" style="margin-left: 50px">
  5. <div>
  6. <el-button type='primary' class='mr-20' icon='el-icon-back' @click='this.$router.go(-1) '>返回上一层
  7. </el-button>
  8. <span>{{ folderName }}({{ folderNumber }})</span>
  9. </div>
  10. </div>
  11. <div class="flex flex-center flex-child-average flex-justify-end" style="margin-right: 50px">
  12. <base-button v-if='permissions && permissions.permissions.home_folder_authorize' class="mr-5" icon="User"
  13. title="授权"
  14. type="0" @click='showClick'/>
  15. <base-button v-if="permissions && permissions.permissions.floder_detail_add && isAccess === '2'" icon="Plus"
  16. title="添加文件夹"
  17. class="mr-5"
  18. type="0" @click="addShow = true"/>
  19. <base-button v-if="isAccess === '2'" icon="Upload" title="上传文件" @click="show = true"/>
  20. </div>
  21. </div>
  22. <files-list :data="data" class="mt-20" @change='changePage'/>
  23. <el-dialog v-model="show"
  24. append-to-body
  25. center
  26. title="附件上传(可批量)">
  27. <div class="flex flex-col" style="margin-top: -20px">
  28. <span class="font-16 main-color bold mb-10">{{ folderName }}</span>
  29. <uploadFile :data='{type:1,toStatus:0}' :max='20'
  30. @close='show = false'
  31. accept='.doc,.docx,.pdf,.xls,.xlsx,.png,.jpg,.jpeg,.ppt,pptx'
  32. @success='success'/>
  33. </div>
  34. </el-dialog>
  35. <el-dialog v-model='authorizeShow' :show-close='false' append-to-body center>
  36. <template #header="{ close, titleId, titleClass }">
  37. <div class="flex flex-justify-between">
  38. <h4 :id="titleId" :class="titleClass">{{ data.folderName }}</h4>
  39. <el-button text type="danger" @click="close">
  40. <el-icon class="el-icon--left">
  41. <CircleCloseFilled/>
  42. </el-icon>
  43. </el-button>
  44. </div>
  45. </template>
  46. <authorize :list='data.records' :folder-id='id' :project-id='projectId' @close='authorizeShow = false'/>
  47. </el-dialog>
  48. <el-dialog v-model='addShow' append-to-body width='40%'>
  49. <div class="flex flex-col">
  50. <el-form ref="ruleFormRef"
  51. :model="folderInfo"
  52. class="demo-ruleForm"
  53. label-width="120px"
  54. status-icon>
  55. <el-form-item label="文件夹名称">
  56. <el-input
  57. v-model="folderInfo.title"
  58. placeholder="填写文件夹名称"
  59. style="width: 100%"
  60. />
  61. </el-form-item>
  62. </el-form>
  63. <div class="full-width flex flex-center mt-10">
  64. <base-button icon="Lock" title="保存" type="1" @click="folderAdd"/>
  65. </div>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import filesList from './files_list.vue'
  72. import baseButton from '../../../components/base-button.vue'
  73. import uploadFile from '../../../components/upload-file.vue'
  74. import authorize from '@/views/home/component/authorize.vue'
  75. import permissionStore from '@/store/permission.js'
  76. import { useStore } from '@/store/user.js'
  77. export default {
  78. name: 'current',
  79. components: { filesList, baseButton, uploadFile, authorize },
  80. props: {
  81. id: String,
  82. data: Object
  83. },
  84. data () {
  85. return {
  86. authorizeShow: false,
  87. addShow: false,
  88. show: false,
  89. folderInfo: {
  90. title: '',
  91. projectStageId: '',
  92. projectId: '',
  93. parentId: '',
  94. dictKey: ''
  95. },
  96. fileList: [],
  97. saveCount: 0,
  98. libraryList: [],
  99. projectId: '',
  100. sendParams: {
  101. ids: '',
  102. ownerId: '',
  103. projectId: ''
  104. },
  105. isAccess: '',
  106. folderName: '',
  107. folderNumber: 0
  108. }
  109. },
  110. setup () {
  111. const permissions = permissionStore()
  112. const user = useStore()
  113. return { permissions, user }
  114. },
  115. created () {
  116. this.folderName = this.$route.query.folderName
  117. this.folderNumber = this.$route.query.folderNumber
  118. this.isAccess = this.$route.query.isAccess
  119. this.projectId = this.$route.query.projectId
  120. this.folderInfo.dictKey = this.$route.query.dictKey
  121. this.folderInfo.projectStageId = this.$route.query.projectStageId
  122. },
  123. methods: {
  124. showClick () {
  125. this.authorizeShow = true
  126. },
  127. success (res) {
  128. this.fileList = res.fileList.map(res => {
  129. const item = {}
  130. item.title = res.response.data.originalFileName
  131. item.suffix = res.response.data.suffix
  132. item.volume = res.response.data.volume
  133. item.fileId = res.response.data.id
  134. item.url = res.response.data.filePath
  135. item.fileFolderId = this.id
  136. item.projectId = this.$route.query.projectId
  137. return item
  138. })
  139. this.fileList.forEach(sub => {
  140. this.saveCount++
  141. if (['pdf', 'doc'].includes(sub.suffix)) {
  142. this.saveLibrary(sub)
  143. }
  144. if (this.saveCount === this.fileList.length) {
  145. this.saveCount = 0
  146. this.addFile()
  147. }
  148. })
  149. },
  150. saveLibrary (sub) {
  151. const data = { category: 4, content: '' }
  152. this.$api.common.submit(Object.assign(sub, data)).then(res => {
  153. if (res.code === 200) {
  154. this.saveCount++
  155. this.libraryList.push(res.data.id)
  156. } else {
  157. this.$message.error(res.msg)
  158. }
  159. })
  160. },
  161. addFile () {
  162. this.$api.project.fileAdd(this.fileList).then(res => {
  163. if (res.code === 200) {
  164. this.show = false
  165. this.$emit('reFiles')
  166. this.$message.success(res.msg)
  167. if (this.user.info.type !== 3) {
  168. this.$confirm('文件上传成功,是否给业主发送提醒消息?', {
  169. confirmButtonText: '确定',
  170. cancelButtonText: '取消',
  171. type: 'warning'
  172. })
  173. .then(() => {
  174. this.SendMsg()
  175. })
  176. }
  177. } else {
  178. this.show = false
  179. this.$message.error(res.msg)
  180. }
  181. })
  182. },
  183. SendMsg () {
  184. this.sendParams.ids = this.fileList.map(e => e.fileId).join(',')
  185. this.sendParams.projectId = this.$route.query.projectId
  186. this.sendParams.ownerId = this.$route.query.ownerId
  187. console.log(this.sendParams)
  188. this.$api.project.send(this.sendParams).then(res => {
  189. if (res.code === 200) {
  190. this.$message.success('消息已经发送成功!')
  191. this.$bus.emit('reFolder')
  192. this.sendMsg = false
  193. } else {
  194. this.$message.error(res.msg)
  195. }
  196. })
  197. },
  198. folderAdd () {
  199. this.folderInfo.projectId = this.projectId
  200. this.folderInfo.parentId = this.id
  201. this.$api.project.folderAdd(this.folderInfo).then(res => {
  202. if (res.code === 200) {
  203. this.addShow = false
  204. this.$message.success(res.msg)
  205. this.$emit('reFiles')
  206. } else {
  207. this.$message.error(res.msg)
  208. }
  209. })
  210. },
  211. changePage (page) {
  212. this.$emit('change', page)
  213. }
  214. }
  215. }
  216. </script>
  217. <style scoped>
  218. </style>