index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <el-row :gutter="8" class='mt-10'>
  3. <el-col :span="4">
  4. <basic-container style='min-height: 720px;padding-left: 0'>
  5. <div class='full-width flex flex-center flex-justify-between'>
  6. <span class='bold'>文件柜分类</span>
  7. <el-button type='primary' @click='addFolder'>新 增</el-button>
  8. </div>
  9. <el-divider/>
  10. <div class='flex flex-col flex-justify-start flex-align-start padding' style='min-height: 900px'>
  11. <span class=' full-width' v-for='(item,index) in folders' :key='item.id'>
  12. <div class='item full-width flex flex-col pointer' :class='active === index ? "item-selected":"" '
  13. @click='changeFolder(index)'>
  14. {{ item.title }}
  15. </div>
  16. </span>
  17. </div>
  18. </basic-container>
  19. </el-col>
  20. <el-col :span="20">
  21. <basic-container class="grid-content bg-purple">
  22. <div class='flex flex-center flex-justify-between'>
  23. <div class='flex flex-center'>
  24. <base-button class="ml-20 " icon="Plus" title="上传文件"
  25. @click="show = true"/>
  26. <base-button class="ml-20 " icon="Back" title="返回上一层"
  27. v-if='currentFolder && currentFolder.parentId !== "0"'
  28. @click="backFolder"/>
  29. </div>
  30. <div class='flex flex-center'>
  31. <base-button class="ml-20 " icon="Plus" title="授权"
  32. @click="authorShow = true"/>
  33. <base-button class="ml-20 " icon="Plus" title="新建文件夹"
  34. @click="addSubFolder"/>
  35. </div>
  36. </div>
  37. <basic-curd
  38. :option="option"
  39. :data="data"
  40. @row-view='rowDetail'
  41. @row-del="rowDel"
  42. ></basic-curd>
  43. </basic-container>
  44. </el-col>
  45. <!-- dialog-->
  46. <el-dialog v-model='show' title='上传文件'>
  47. <div>
  48. <el-upload
  49. drag
  50. :action="action"
  51. multiple
  52. accept='.doc,.docx,.pdf,.xls,.xlsx,.png,.jpg,.jpeg,.ppt,pptx'
  53. show-file-list
  54. :headers="{'Authorization':`Basic ${clientId}`}"
  55. :on-success='uploadSuccess'
  56. >
  57. <el-icon class="el-icon--upload">
  58. <upload-filled/>
  59. </el-icon>
  60. <div class="el-upload__text">
  61. 拖拽或者 <em>点击上传文件</em>
  62. </div>
  63. </el-upload>
  64. <el-divider/>
  65. <div class='flex flex-justify-end'>
  66. <el-button @click='show = false'>取 消</el-button>
  67. <el-button type='primary' @click='saveFile'>确 定</el-button>
  68. </div>
  69. </div>
  70. </el-dialog>
  71. <el-image-viewer
  72. v-if='showImage'
  73. :url-list="imgList"
  74. @close='showImage = false'
  75. />
  76. <el-dialog v-model='authorShow' title='批量授权'>
  77. <authorize :list='data' :folder-id='currentFolder.id' :extra='{type:2}' :author-type='false' @close='authorShow = false'/>
  78. </el-dialog>
  79. </el-row>
  80. </template>
  81. <route>
  82. {
  83. name: '公司资料'
  84. }
  85. </route>
  86. <script>
  87. import BasicContainer from '@/components/basic-container/main.vue'
  88. import baseButton from '@/components/base-button.vue'
  89. import basicCurd from '@/components/basic-curd/index.vue'
  90. import api from '@/api'
  91. import authorize from '@/views/home/component/authorize.vue'
  92. import { Base64 } from 'js-base64'
  93. import website from '@/config/website.js'
  94. export default {
  95. name: 'index',
  96. components: { BasicContainer, baseButton, basicCurd, authorize },
  97. data () {
  98. return {
  99. clientId: '',
  100. authorShow: false,
  101. showImage: false,
  102. imgList: [],
  103. folders: [],
  104. show: false,
  105. active: 0,
  106. form: {},
  107. data: [],
  108. action: api.uploadPath,
  109. option: {
  110. align: 'center',
  111. menuAlign: 'center',
  112. menuWidth: 380,
  113. size: 'mini',
  114. addBtn: false,
  115. viewBtn: true,
  116. editBtn: false,
  117. refreshBtn: false,
  118. columnBtn: false,
  119. labelWidth: 140,
  120. border: true,
  121. column: [
  122. {
  123. label: '文件/文件夹名称',
  124. prop: 'title'
  125. },
  126. {
  127. label: '更新/上传时间',
  128. prop: 'updateTime'
  129. },
  130. {
  131. label: '文件',
  132. prop: 'updateTime'
  133. }
  134. ]
  135. },
  136. currentFolder: null,
  137. lastParentFolder: [],
  138. page: {
  139. size: 10,
  140. current: 1,
  141. total: 0
  142. },
  143. fileList: []
  144. }
  145. },
  146. created () {
  147. this.clientId = Base64.encode(`${website.clientId}:${website.clientSecret}`)
  148. this.list()
  149. },
  150. methods: {
  151. list () {
  152. this.$api.company.list({ current: 1, size: 100, parentId: '' }).then(res => {
  153. if (res.code === 200) {
  154. this.folders = res.data.records
  155. if (this.folders.length > 0) {
  156. this.currentFolder = this.folders[0]
  157. }
  158. this.onLoad()
  159. } else {
  160. this.$message.error(res.msg)
  161. }
  162. })
  163. },
  164. addFolder () {
  165. this.$prompt('请输入分类名称', '提示', {
  166. confirmButtonText: '确定',
  167. cancelButtonText: '取消'
  168. }).then(({ value }) => {
  169. this.$api.company.submint({ title: value, type: 2 }).then(res => {
  170. if (res.code === 200) {
  171. this.$message.success(res.msg)
  172. this.list()
  173. } else {
  174. this.$message.error(res.msg)
  175. }
  176. })
  177. })
  178. },
  179. changeFolder (index) {
  180. this.active = index
  181. this.currentFolder = this.folders[index]
  182. this.page.current = 1
  183. this.onLoad()
  184. },
  185. onLoad () {
  186. const data = { parentId: this.currentFolder.id }
  187. this.$api.company.list(Object.assign(data, this.page)).then(res => {
  188. if (res.code === 200) {
  189. this.data = res.data.records
  190. this.page.total = res.data.total
  191. } else {
  192. this.$message.error(res.msg)
  193. }
  194. }).finally(() => {
  195. this.loading = false
  196. })
  197. },
  198. rowSave (row, done, loading) {
  199. const data = {
  200. projectInfoId: this.info.id
  201. }
  202. this.$api.projects.meeting.save(Object.assign(row, data)).then((res) => {
  203. if (res.code === 200) {
  204. this.$message.success(res.msg)
  205. } else {
  206. this.$message.error(res.msg)
  207. }
  208. done(row)
  209. this.onLoad()
  210. }, error => {
  211. window.console.log(error)
  212. loading()
  213. })
  214. },
  215. rowUpdate (row, index, done, loading) {
  216. const data = {
  217. projectInfoId: this.info.id
  218. }
  219. this.$api.projects.meeting.update(Object.assign(row, data)).then((res) => {
  220. if (res.code === 200) {
  221. this.$message.success(res.msg)
  222. } else {
  223. this.$message.error(res.msg)
  224. }
  225. done(row)
  226. this.onLoad()
  227. }, error => {
  228. window.console.log(error)
  229. loading()
  230. })
  231. },
  232. rowDetail (row, index) {
  233. if (row.type === 1) {
  234. if (['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'].includes(row.suffix)) {
  235. const routeData = this.$router.resolve({ path: '/home/file_detail', query: { id: row.fileId } })
  236. window.open(routeData.href, '_blank')
  237. } else {
  238. this.imgList = [row.url]
  239. this.showImage = true
  240. }
  241. } else {
  242. this.lastParentFolder = this.lastParentFolder.filter(sub => sub.id !== this.currentFolder.id)
  243. this.lastParentFolder.push(this.currentFolder)
  244. this.currentFolder = row
  245. this.onLoad()
  246. }
  247. },
  248. rowDel (row, index, done) {
  249. console.log(row, index, done)
  250. this.$confirm('确定将选择数据删除?', {
  251. confirmButtonText: '确定',
  252. cancelButtonText: '取消',
  253. type: 'warning'
  254. }).then(() => {
  255. return this.$api.company.removeList({ ids: row.id })
  256. }).then(() => {
  257. this.$message({
  258. type: 'success',
  259. message: '操作成功!'
  260. })
  261. // 数据回调进行刷新
  262. this.onLoad()
  263. }).catch(() => {
  264. })
  265. },
  266. uploadSuccess (res, file, files) {
  267. this.fileList = files.map(sub => sub.response.data)
  268. },
  269. saveFile () {
  270. if (this.fileList.length === 0) {
  271. return
  272. }
  273. this.fileList.forEach(sub => {
  274. if (api.offices.includes(sub.suffix)) {
  275. // save Library
  276. const data = {
  277. title: sub.originalFileName,
  278. fileId: sub.id,
  279. suffix: sub.suffix,
  280. volume: sub.volume,
  281. url: sub.filePath,
  282. category: 4,
  283. content: '',
  284. parentId: this.currentFolder.id
  285. }
  286. this.$api.common.submit(data).then(res => {
  287. if (res.code === 200) {
  288. this.addFile(this.currentFolder.id, sub, 1)
  289. } else {
  290. this.$message.error(res.msg)
  291. }
  292. })
  293. } else {
  294. this.addFile(this.currentFolder.id, sub, 1)
  295. }
  296. })
  297. },
  298. /**
  299. * 保存文件
  300. * @param parentId
  301. * @param item
  302. * @param type 1 图片 2 文件夹
  303. */
  304. addFile (parentId, item, type) {
  305. const data = {
  306. title: item.originalFileName,
  307. parentId,
  308. fileId: item.id,
  309. suffix: item.suffix,
  310. volume: item.volume,
  311. url: item.filePath,
  312. type
  313. }
  314. this.$api.company.submint(data).then(res => {
  315. if (res.code === 200) {
  316. this.show = false
  317. this.onLoad()
  318. } else {
  319. this.$message.error(res.msg)
  320. }
  321. })
  322. },
  323. addSubFolder () {
  324. this.$prompt('请输入文件夹名称', '提示', {
  325. confirmButtonText: '确定',
  326. cancelButtonText: '取消'
  327. }).then(({ value }) => {
  328. const data = { parentId: this.currentFolder.id, title: value, type: 2 }
  329. this.$api.company.submint(data).then(res => {
  330. if (res.code === 200) {
  331. this.$message.success(res.msg)
  332. this.onLoad()
  333. } else {
  334. this.$message.error(res.msg)
  335. }
  336. })
  337. })
  338. },
  339. backFolder () {
  340. this.currentFolder = this.lastParentFolder[this.lastParentFolder.length - 1]
  341. this.lastParentFolder = this.lastParentFolder.filter(sub => sub.id !== this.currentFolder.id)
  342. this.onLoad()
  343. }
  344. }
  345. }
  346. </script>
  347. <style scoped>
  348. .item {
  349. padding: 10px 5px;
  350. margin-bottom: 10px;
  351. border-radius: 8px;
  352. text-align: left;
  353. background-color: #E4E4E4;
  354. }
  355. .item:hover {
  356. background-color: #AB7630;
  357. color: white;
  358. }
  359. .item-selected {
  360. background-color: #AB7630;
  361. color: white;
  362. }
  363. .icon {
  364. width: 80px;
  365. height: 66px;
  366. }
  367. </style>