index.vue 10 KB

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