current.vue 6.5 KB

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