folder_info.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div class="flex flex-col white-bg">
  3. <div class="flex flex-center ml-20 mb-20 mt-10">
  4. <div class="flex flex-center" style="flex: 3">
  5. <span class="grey-6 bold nowrap mr-10">文件搜索</span>
  6. <el-select
  7. v-model="keyWords" remote filterable clearable
  8. placeholder="输入关键字"
  9. :remote-method="remoteMethod"
  10. :loading="loading"
  11. style="width: 100%"
  12. @change="result"
  13. >
  14. <el-option
  15. v-for="item in findData"
  16. :key="item.value"
  17. :label="item.label"
  18. :value="item.value">
  19. </el-option>
  20. </el-select>
  21. </div>
  22. <div class="flex flex-center ml-10" style="flex: 0.01">
  23. <!-- <base-button icon="Delete" title="清空" type="0" @click="clear"/>-->
  24. <!-- <base-button class="ml-10" @click="filesFind"/>-->
  25. </div>
  26. </div>
  27. <div style="background-color: #E4E4E4;height: 10px;width: 100%;margin-left: -10px"></div>
  28. <!------tab------>
  29. <div class="flex flex-center mt-15">
  30. <div class="flex flex-center" style="flex: 3.8">
  31. <div v-for="(item,index) in folderType" :key='item.id' class="flex flex-center tab">
  32. <el-badge :value='item.fileAmount' :hidden='item.fileAmount === 0'>
  33. <div :class="active === index ? 'tab-active' : ''"
  34. @click="change(index,item.dictKey)">{{ item.dictValue }}
  35. </div>
  36. </el-badge>
  37. </div>
  38. </div>
  39. <div class="flex flex-center mr-5 " style="flex: 1.2">
  40. <base-button v-if='canCreateFolder' class="mr-20" icon="User" title="批量授权"
  41. type="0" @click='authorizeShow = true'/>
  42. <base-button v-if='canCreateFolder' icon="Plus" title="添加文件夹" type="0"
  43. @click="addShow = true"/>
  44. <!-- <base-button v-if='permissions.permissions.home_folders_apply' class="ml-10" icon="User" title="批量授权"/>-->
  45. </div>
  46. </div>
  47. <div class="mt-20">
  48. <!-- <basic-curd-->
  49. <!-- :data='folderList'-->
  50. <!-- :option='option'-->
  51. <!-- />-->
  52. <folder-list :folder="folderList" :total="total" :project-id='id' :owner-id='data.createUser' :dict-key="dictKey"
  53. @delFolder="getFolderList" @change='changePage'/>
  54. </div>
  55. <!-- 新增文件夹-->
  56. <el-dialog v-model='addShow' append-to-body width='40%'>
  57. <div class="flex flex-col">
  58. <el-form ref="ruleFormRef"
  59. :model="folderInfo"
  60. class="demo-ruleForm"
  61. label-width="120px"
  62. status-icon>
  63. <el-form-item label="文件夹名称">
  64. <el-input
  65. v-model="folderInfo.title"
  66. placeholder="填写文件夹名称"
  67. style="width: 100%"
  68. />
  69. </el-form-item>
  70. <el-form-item label="文件夹类型">
  71. <el-select
  72. v-model="dictKey"
  73. clearable
  74. placeholder="输入项目领域"
  75. style="width: 100%">
  76. <el-option
  77. v-for="item in folderType"
  78. :key="item.dictKey"
  79. :label="item.dictValue"
  80. :value="item.dictKey"
  81. />
  82. </el-select>
  83. </el-form-item>
  84. </el-form>
  85. <div class="full-width flex flex-center mt-10">
  86. <base-button icon="Lock" title="保存" type="1" @click="folderAdd"/>
  87. </div>
  88. </div>
  89. </el-dialog>
  90. <el-image-viewer
  91. v-if='showImage'
  92. :url-list="imgList"
  93. @close='viewerClose'
  94. />
  95. <!-- 授权-->
  96. <el-dialog v-model='authorizeShow' append-to-body width='40%'>
  97. <authorize :list='folderList' @close='authorizeShow = false' :project-id='projectId' :extra='{type:1}'/>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import baseButton from '../../../components/base-button.vue'
  103. import folderList from './folder_list.vue'
  104. import permissionStore from '@/store/permission.js'
  105. import authorize from '@/views/home/component/authorize.vue'
  106. import basicCurd from '@/components/basic-curd/index.vue'
  107. export default {
  108. name: 'right2',
  109. components: { baseButton, folderList, authorize },
  110. props: {
  111. data: {
  112. type: Object,
  113. default: null
  114. },
  115. projectStageId: String,
  116. id: String
  117. },
  118. watch: {
  119. projectStageId: {
  120. handler (val) {
  121. if (val) {
  122. this.getDict()
  123. }
  124. },
  125. immediate: true
  126. },
  127. authorizeShow: {
  128. handler (val) {
  129. console.log(val)
  130. },
  131. immediate: true
  132. }
  133. },
  134. setup () {
  135. const permissions = permissionStore()
  136. return { permissions }
  137. },
  138. data () {
  139. return {
  140. projectId: '',
  141. authorizeShow: false,
  142. loading: false,
  143. showImage: false,
  144. imgList: [],
  145. addShow: false,
  146. folderInfo: {
  147. title: '',
  148. stageId: '',
  149. projectId: '',
  150. parentId: '',
  151. dictKey: '',
  152. folderType: 1
  153. },
  154. keyWords: '',
  155. active: 0,
  156. folderType: [],
  157. folderList: [],
  158. total: '',
  159. dictKey: '',
  160. page: {
  161. current: 1,
  162. size: 10
  163. },
  164. findData: [],
  165. option: {
  166. align: 'center',
  167. menuAlign: 'center',
  168. menuWidth: 380,
  169. size: 'mini',
  170. addBtn: false,
  171. viewBtn: true,
  172. editBtn: false,
  173. refreshBtn: false,
  174. columnBtn: false,
  175. labelWidth: 140,
  176. border: true,
  177. column: [
  178. {
  179. label: '文件/文件夹名称',
  180. prop: 'title'
  181. },
  182. {
  183. label: '更新/上传时间',
  184. prop: 'updateTime'
  185. },
  186. {
  187. label: '文件',
  188. prop: 'updateTime'
  189. }
  190. ]
  191. },
  192. canCreateFolder: false
  193. }
  194. },
  195. created () {
  196. this.projectId = this.$route.query.id
  197. this.getFolderList()
  198. this.queryCreateFolder()
  199. this.$bus.on('reFolder', () => {
  200. console.log('reFolder')
  201. this.getFolderList()
  202. })
  203. },
  204. methods: {
  205. queryCreateFolder () {
  206. this.$api.project.queryCreateFolder({ projectId: this.projectId }).then(res => {
  207. if (res.code === 200) {
  208. console.log(res)
  209. this.canCreateFolder = res.data.status === 2
  210. } else {
  211. console.log(res)
  212. }
  213. })
  214. },
  215. getDict () {
  216. this.$api.project.folderType({ stageId: this.projectStageId }).then(res => {
  217. if (res.code === 200) {
  218. this.folderType = res.data
  219. this.change(0, this.folderType[0].dictKey)
  220. }
  221. })
  222. },
  223. change (index, key) {
  224. this.active = index
  225. this.dictKey = key
  226. this.getFolderList()
  227. },
  228. clear () {
  229. this.keyWords = ''
  230. this.getFolderList()
  231. },
  232. getFolderList () {
  233. const data = {
  234. stageId: this.projectStageId,
  235. folderName: this.keyWords,
  236. dictKey: this.dictKey
  237. }
  238. this.$api.project.folderList(Object.assign(data, this.page)).then(res => {
  239. if (res.code === 200) {
  240. this.folderList = res.data.records.map(sub => {
  241. const item = sub
  242. item.title = sub.title
  243. return item
  244. })
  245. this.total = res.data.total
  246. }
  247. })
  248. },
  249. remoteMethod (query) {
  250. if (query !== '') {
  251. this.loading = true
  252. setTimeout(() => {
  253. const data = {
  254. projectId: this.id,
  255. keyword: query
  256. }
  257. this.$api.project.findFiles(Object.assign(data, this.page)).then(res => {
  258. if (res.code === 200) {
  259. this.findData = res.data.map(sub => {
  260. const dataItem = {}
  261. dataItem.label = sub.title
  262. if (['png', 'jpg', 'jpeg'].includes(sub.suffix)) {
  263. dataItem.value = sub.url
  264. } else {
  265. dataItem.value = sub.fileId
  266. }
  267. return dataItem
  268. })
  269. }
  270. this.loading = false
  271. })
  272. }, 200)
  273. } else {
  274. this.findData = []
  275. }
  276. },
  277. result (res) {
  278. if (res.indexOf('http') > -1) {
  279. this.showImage = true
  280. this.imgList.push(res)
  281. } else {
  282. this.$router.push('/home/file_detail?id=' + res)
  283. }
  284. },
  285. viewerClose () {
  286. this.showImage = false
  287. this.imgList = []
  288. },
  289. folderAdd () {
  290. this.folderInfo.projectId = this.id
  291. this.folderInfo.stageId = this.projectStageId
  292. this.folderInfo.dictKey = this.dictKey
  293. this.folderInfo.parentId = 0
  294. this.$api.project.folderAdd(this.folderInfo).then(res => {
  295. if (res.code === 200) {
  296. this.addShow = false
  297. this.$message.success(res.msg)
  298. this.getFolderList()
  299. } else {
  300. this.$message.error(res.msg)
  301. }
  302. })
  303. },
  304. changePage (page) {
  305. console.log(page)
  306. this.page.current = page
  307. this.getFolderList()
  308. }
  309. }
  310. }
  311. </script>
  312. <style lang="scss" scoped>
  313. .tab {
  314. width: 150px;
  315. height: 38px;
  316. background-color: #EDF0F3;
  317. padding: 2px 10px;
  318. color: #707070;
  319. font-size: 13px;
  320. }
  321. .tab:first-child {
  322. border-radius: 20px 0 0 20px;
  323. }
  324. .tab:last-child {
  325. border-radius: 0 20px 20px 0;
  326. }
  327. .tab-active {
  328. width: 130px;
  329. flex-wrap: nowrap;
  330. color: white;
  331. font-size: 15px;
  332. background-color: #AB7630;
  333. font-weight: 500;
  334. padding: 4px 10px;
  335. border-radius: 20px;
  336. }
  337. </style>