index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div>
  3. <tips-custom>
  4. <template #default>
  5. <div class="flex flex-center">
  6. <span class="mr-10 nowrap">项目阶段</span>
  7. <el-select
  8. v-model="folderInfo.stageId"
  9. remote
  10. filterable
  11. style="width: 200px"
  12. clearable
  13. placeholder="筛选项目阶段"
  14. :disabled="!top"
  15. @change="folderResult"
  16. >
  17. <el-option
  18. v-for="item in stage"
  19. :key="item.id"
  20. :label="item.name"
  21. :value="item.id"
  22. >
  23. </el-option>
  24. </el-select>
  25. </div>
  26. </template>
  27. </tips-custom>
  28. <!-- content-->
  29. <el-card shadow="hover" class="content">
  30. <div>
  31. <div class="full-width flex flex-center flex-justify-between">
  32. <div class="full-width flex flex-justify-start flex-center">
  33. <upload-file
  34. v-if="!top && currentFolder.fileStatus !== 1"
  35. @on-success="uploadSuccess"
  36. :data="{ type: 1 }"
  37. :project-id="folderInfo.projectId"
  38. :stage-id="folderInfo.stageId"
  39. :parent-id="currentFolder.id"
  40. />
  41. <el-button
  42. class="ml-10"
  43. type="primary"
  44. icon="Folder"
  45. :plain="!top"
  46. @click="showDialog(1)"
  47. v-if="
  48. canCreateFolder &&
  49. (currentFolder ? currentFolder.fileStatus !== 1 : true)
  50. "
  51. >新建文件夹
  52. </el-button>
  53. <authorize
  54. class="ml-10"
  55. :list="selectedList"
  56. v-if="canCreateFolder"
  57. />
  58. </div>
  59. <div class="flex flex-center main-color mr-10">
  60. <search
  61. :stage-id="folderInfo.stageId"
  62. :folder-id="currentFolder ? currentFolder.id : ''"
  63. />
  64. </div>
  65. </div>
  66. <file-way
  67. :next="currentFolder"
  68. :refresh-btn="true"
  69. @before="goBefore"
  70. @goHome="getFolderList"
  71. @refresh="refreshData"
  72. class="mt-20"
  73. />
  74. <xtable
  75. :data="data"
  76. :option="option"
  77. :loading="loading"
  78. :page="page"
  79. :top-folder="top"
  80. @selected="selected"
  81. @row-click="getFileList"
  82. @current-change="currentChange"
  83. @refresh="refreshData"
  84. @selection="selectAll"
  85. >
  86. <template #menu="{ row }">
  87. <el-button
  88. v-if="row.type === 2 && row.fileStatus === 0"
  89. type="primary"
  90. text
  91. @click="renameFolder(row)"
  92. >重命名
  93. </el-button>
  94. </template>
  95. </xtable>
  96. </div>
  97. </el-card>
  98. <el-dialog
  99. v-model="show"
  100. :title="title"
  101. :width="width"
  102. @close="closeDialog"
  103. >
  104. <floder
  105. v-if="showType === 1"
  106. :info="folderInfo"
  107. :rename="rename"
  108. @close="closeDialog"
  109. ></floder>
  110. </el-dialog>
  111. </div>
  112. </template>
  113. <route>
  114. {
  115. name: '资料管理',
  116. meta: { 'show': false, layout: 'empty'}
  117. }
  118. </route>
  119. <script>
  120. import tipsCustom from '@/components/tips-custom/index.vue'
  121. import xtable from '@/views/resource/component/xtable.vue'
  122. import floder from '@/views/resource/component/floder.vue'
  123. import uploadFile from '@/components/upload-file/index.vue'
  124. import fileWay from '@/components/file-way/index.vue'
  125. import authorize from '@/views/resource/component/authorize.vue'
  126. import search from '@/views/resource/component/search.vue'
  127. export default {
  128. components: {
  129. tipsCustom,
  130. xtable,
  131. floder,
  132. uploadFile,
  133. fileWay,
  134. authorize,
  135. search
  136. },
  137. data() {
  138. return {
  139. show: false,
  140. showType: 1,
  141. width: 380,
  142. title: '新建文件夹',
  143. rename: false,
  144. top: true,
  145. loading: false,
  146. currentFolder: null,
  147. selectedList: [],
  148. data: [],
  149. canCreateFolder: false,
  150. option: {
  151. showCheckBox: false,
  152. folderChecked: true,
  153. column: [
  154. {
  155. label: '名称',
  156. prop: 'title',
  157. display: false,
  158. width: 270
  159. },
  160. {
  161. label: '创建人',
  162. prop: 'createUserName'
  163. },
  164. {
  165. label: '创建时间',
  166. prop: 'createTime'
  167. }
  168. ]
  169. },
  170. option2: {
  171. column: [
  172. {
  173. label: '名称2',
  174. prop: 'title',
  175. display: false
  176. },
  177. {
  178. label: '创建人',
  179. prop: 'createUserName'
  180. }
  181. ]
  182. },
  183. stage: [],
  184. folderInfo: {
  185. projectId: '',
  186. stageId: ''
  187. },
  188. page: {
  189. current: 1,
  190. size: 10,
  191. total: 0
  192. },
  193. total: ''
  194. }
  195. },
  196. created() {
  197. this.folderInfo.projectId = this.$route.query.id
  198. this.getStage()
  199. this.queryCreateFolder()
  200. },
  201. methods: {
  202. queryCreateFolder() {
  203. this.$api.project
  204. .queryCreateFolder({ projectId: this.folderInfo.projectId })
  205. .then(res => {
  206. if (res.code === 200) {
  207. this.canCreateFolder = res.data.status === 2
  208. } else {
  209. console.log(res)
  210. }
  211. })
  212. },
  213. showDialog(type) {
  214. this.showType = type
  215. this.show = true
  216. this.title = '新建文件夹'
  217. },
  218. folderAdd() {
  219. this.$api.resource.folderAddUpdate().then(res => {
  220. if (res.code === 200) {
  221. this.refreshData()
  222. }
  223. })
  224. },
  225. closeDialog() {
  226. this.show = false
  227. if (this.top) {
  228. this.getFolderList()
  229. } else {
  230. this.getFileList(this.currentFolder)
  231. }
  232. },
  233. /**
  234. * 获取阶段对应的一级文件夹
  235. */
  236. getFolderList() {
  237. const data = {
  238. projectId: this.folderInfo.projectId,
  239. stageId: this.folderInfo.stageId,
  240. dictKey: 1,
  241. current: this.page.current,
  242. size: this.page.size
  243. }
  244. this.currentFolder = null
  245. this.loading = true
  246. this.top = true
  247. this.$api.resource.folderList(data).then(res => {
  248. this.loading = false
  249. if (res.code === 200) {
  250. this.data = res.data.records
  251. this.page.total = res.data.total
  252. }
  253. })
  254. },
  255. /**
  256. * 获取二级文件
  257. * @param row
  258. */
  259. getFileList(row) {
  260. this.data.length = 0
  261. this.currentFolder = row
  262. this.folderInfo = Object.assign(this.folderInfo, row)
  263. this.top = false
  264. const data = {
  265. id: row.id,
  266. current: this.page.current,
  267. size: this.page.size
  268. }
  269. this.loading = true
  270. this.$api.resource.fileList(data).then(res => {
  271. this.loading = false
  272. if (res.code === 200) {
  273. this.data = res.data.records
  274. this.page.total = res.data.total
  275. } else {
  276. this.$message.error(res.msg)
  277. }
  278. })
  279. },
  280. /**
  281. * 获取项目阶段
  282. */
  283. getStage() {
  284. this.$api.project
  285. .includeStage({ projectId: this.folderInfo.projectId })
  286. .then(res => {
  287. if (res.code === 200) {
  288. this.stage = res.data
  289. const tmp = this.stage.find(ele => ele.isLastSelect === 1)
  290. if (tmp) {
  291. this.folderInfo.stageId = tmp.id
  292. } else {
  293. this.folderInfo.stageId = this.stage[0].id
  294. }
  295. this.getFolderList()
  296. }
  297. })
  298. },
  299. folderResult(res) {
  300. this.loading = true
  301. this.stageId = res
  302. this.getFolderList()
  303. },
  304. /**
  305. * 文件上传成功侯刷新文件列表,上传文件的按钮,不出现在顶级目录,所以刷新下级就行
  306. * @param files
  307. */
  308. uploadSuccess(files) {
  309. this.getFileList(this.currentFolder)
  310. },
  311. refreshData() {
  312. if (this.top) {
  313. this.getFolderList()
  314. } else {
  315. this.getFileList(this.currentFolder)
  316. }
  317. },
  318. currentChange(current) {
  319. this.page.current = current
  320. this.refreshData()
  321. },
  322. goBefore(res) {
  323. this.currentFolder = res
  324. this.refreshData()
  325. },
  326. renameFolder(res) {
  327. this.rename = true
  328. this.title = '重命名文件夹'
  329. this.show = true
  330. this.showType = 1
  331. this.folderInfo = res
  332. },
  333. selectAll(res) {
  334. this.option.showCheckBox = res
  335. },
  336. selected(list) {
  337. this.selectedList = list
  338. }
  339. }
  340. }
  341. </script>
  342. <style lang="scss" scoped>
  343. .content {
  344. height: auto;
  345. }
  346. </style>