groupSpace.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['doc:dir:add']"
  6. v-hasRole="['group.manager']">新增</el-button>
  7. </el-col>
  8. <el-col :span="1.5">
  9. <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
  10. </el-col>
  11. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  12. </el-row>
  13. <el-table v-if="refreshTable" v-loading="loading" :data="dirList" row-key="dirId" :default-expand-all="isExpandAll"
  14. :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  15. <el-table-column label="目录名称" align="left" prop="dirName" />
  16. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  17. <template slot-scope="scope">
  18. <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
  19. v-hasPermi="['doc:dir:add']" v-hasRole="['group.manager']">新增</el-button>
  20. <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-edit"
  21. @click="handleUpdate(scope.row)" v-hasPermi="['doc:dir:edit']" v-hasRole="['group.manager']">修改</el-button>
  22. <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete"
  23. @click="handleDelete(scope.row)" v-hasPermi="['doc:dir:remove']"
  24. v-hasRole="['group.manager']">删除</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. <!-- 个人空间相关信息 -->
  29. <el-row :gutter="10" class="mb8">
  30. <el-col :span="1.5">
  31. 总容量:{{spaceData.spaceCap}} GB 已使用容量:{{spaceData.usedCap}} GB 可用容量:{{spaceData.avlCap}} GB
  32. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleExpand">扩容申请</el-button>
  33. </el-col>
  34. </el-row>
  35. <!-- 添加或修改目录信息对话框 -->
  36. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  37. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  38. <el-form-item label="上级目录" prop="parentId">
  39. <treeselect v-model="form.parentId" :options="dirOptions" :normalizer="normalizer" placeholder="请选择上级目录" />
  40. </el-form-item>
  41. <el-form-item label="目录名称" prop="dirName">
  42. <el-input v-model="form.dirName" placeholder="请输入目录名称" />
  43. </el-form-item>
  44. <el-form-item label="备注" prop="remark">
  45. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  46. </el-form-item>
  47. </el-form>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="submitForm">确 定</el-button>
  50. <el-button @click="cancel">取 消</el-button>
  51. </div>
  52. </el-dialog>
  53. <!-- 扩容申请对话框 -->
  54. <el-dialog :title="title" :visible.sync="openSpace" width="500px" append-to-body>
  55. <el-form ref="formSpace" :model="formSpace" :rules="rulesSpace" label-width="80px">
  56. <el-form-item label="扩充容量" prop="expandCap">
  57. <el-input-number v-model="formSpace.expandCap" placeholder="扩充容量"></el-input-number><label>GB</label>
  58. </el-form-item>
  59. <el-form-item label="申请理由" prop="remark">
  60. <el-input v-model="formSpace.remark" type="textarea" rows="5" placeholder="请输入申请理由" />
  61. </el-form-item>
  62. </el-form>
  63. <div slot="footer" class="dialog-footer">
  64. <el-button type="primary" @click="submitFormSpace">确 定</el-button>
  65. <el-button @click="cancelSpace">取 消</el-button>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import {
  72. listDir,
  73. getDir,
  74. delDir,
  75. addDir,
  76. updateDir,
  77. groupList
  78. } from "@/api/doc/dir";
  79. import {
  80. getGroupSpace
  81. } from "@/api/doc/space";
  82. import {
  83. listExpand,
  84. getExpand,
  85. delExpand,
  86. addExpand,
  87. updateExpand
  88. } from "@/api/doc/expand";
  89. import Treeselect from "@riophae/vue-treeselect";
  90. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  91. export default {
  92. name: "GroupSpace",
  93. components: {
  94. Treeselect
  95. },
  96. data() {
  97. return {
  98. // 遮罩层
  99. loading: true,
  100. // 显示搜索条件
  101. showSearch: true,
  102. // 目录信息表格数据
  103. dirList: [],
  104. // 目录信息树选项
  105. dirOptions: [],
  106. // 弹出层标题
  107. title: "",
  108. // 是否显示弹出层
  109. open: false,
  110. openSpace: false,
  111. // 是否展开,默认全部展开
  112. isExpandAll: true,
  113. // 重新渲染表格状态
  114. refreshTable: true,
  115. // 查询参数
  116. queryParams: {
  117. parentId: null,
  118. dirName: null,
  119. },
  120. //个人空间数据
  121. spaceData: {},
  122. // 表单参数
  123. form: {},
  124. formSpace: {},
  125. // 表单校验
  126. rules: {
  127. dirName: [{
  128. required: true,
  129. message: "目录名称不能为空",
  130. trigger: "blur"
  131. }],
  132. parentId: [{
  133. required: true,
  134. message: "上级目录不能为空",
  135. trigger: "blur"
  136. }],
  137. },
  138. // 表单校验
  139. rulesSpace: {
  140. expandCap: [{
  141. required: true,
  142. message: "扩容容量不能为空",
  143. trigger: "blur"
  144. }],
  145. remark: [{
  146. required: true,
  147. message: "申请理由不能为空",
  148. trigger: "blur"
  149. }],
  150. }
  151. };
  152. },
  153. created() {
  154. console.log(this.$cache.local.get('USERNAME')) // 输出'local value'
  155. const groupId = this.$route.params && this.$route.params.groupId;
  156. if (groupId) {
  157. this.queryParams.groupId = groupId;
  158. this.getList();
  159. }
  160. this.spaceInfo();
  161. },
  162. methods: {
  163. /** 查询个人空间相关信息 */
  164. spaceInfo() {
  165. this.loading = true;
  166. getGroupSpace(this.queryParams.groupId).then(response => {
  167. this.spaceData = response.data;
  168. this.loading = false;
  169. });
  170. },
  171. /** 查询目录信息列表 */
  172. getList() {
  173. this.loading = true;
  174. groupList(this.queryParams.groupId).then(response => {
  175. this.dirList = this.handleTree(response.data, "dirId");
  176. this.loading = false;
  177. });
  178. },
  179. /** 转换目录信息数据结构 */
  180. normalizer(node) {
  181. if (node.children && !node.children.length) {
  182. delete node.children;
  183. }
  184. return {
  185. id: node.dirId,
  186. label: node.dirName,
  187. children: node.children
  188. };
  189. },
  190. // 取消按钮
  191. cancel() {
  192. this.open = false;
  193. this.reset();
  194. },
  195. // 取消按钮
  196. cancelSpace() {
  197. this.openSpace = false;
  198. this.reset();
  199. },
  200. // 表单重置
  201. reset() {
  202. this.form = {
  203. dirId: null,
  204. spaceId: null,
  205. parentId: null,
  206. dirName: null,
  207. dirPath: null,
  208. createBy: null,
  209. createTime: null,
  210. updateBy: null,
  211. updateTime: null,
  212. remark: null,
  213. isDel: null
  214. };
  215. this.resetForm("form");
  216. },
  217. /** 搜索按钮操作 */
  218. handleQuery() {
  219. this.getList();
  220. },
  221. /** 重置按钮操作 */
  222. resetQuery() {
  223. this.resetForm("queryForm");
  224. this.handleQuery();
  225. },
  226. /** 新增按钮操作 */
  227. handleAdd(row) {
  228. this.reset();
  229. // this.getTreeselect();
  230. if (row != null && row.dirId) {
  231. this.form.parentId = row.dirId;
  232. // } else {
  233. // this.form.parentId = 0;
  234. }
  235. this.open = true;
  236. this.title = "添加目录信息";
  237. groupList(this.queryParams.groupId).then(response => {
  238. this.form.spaceId = response.data[0].spaceId;
  239. this.dirOptions = this.handleTree(response.data, "dirId");
  240. });
  241. },
  242. /** 扩容申请 */
  243. handleExpand(row) {
  244. this.formSpace.currentCap = this.spaceData.spaceCap;
  245. this.formSpace.spaceId = this.spaceData.spaceId;
  246. this.formSpace.spaceName = this.spaceData.spaceName;
  247. this.reset();
  248. // this.getTreeselect();
  249. if (row != null && row.dirId) {
  250. this.form.parentId = row.dirId;
  251. // } else {
  252. // this.form.parentId = 0;
  253. }
  254. this.openSpace = true;
  255. this.title = "扩容申请";
  256. groupList(this.queryParams.groupId).then(response => {
  257. this.form.spaceId = response.data[0].spaceId;
  258. this.dirOptions = this.handleTree(response.data, "dirId");
  259. });
  260. },
  261. /** 展开/折叠操作 */
  262. toggleExpandAll() {
  263. this.refreshTable = false;
  264. this.isExpandAll = !this.isExpandAll;
  265. this.$nextTick(() => {
  266. this.refreshTable = true;
  267. });
  268. },
  269. /** 修改按钮操作 */
  270. handleUpdate(row) {
  271. this.reset();
  272. if (row != null) {
  273. this.form.parentId = row.dirId;
  274. }
  275. getDir(row.dirId).then(response => {
  276. this.form = response.data;
  277. this.open = true;
  278. this.title = "修改目录信息";
  279. });
  280. personalList().then(response => {
  281. this.dirOptions = this.handleTree(response.data, "dirId");
  282. });
  283. },
  284. /** 提交按钮 */
  285. submitForm() {
  286. this.$refs["form"].validate(valid => {
  287. if (valid) {
  288. if (this.form.dirId != null) {
  289. updateDir(this.form).then(response => {
  290. this.$modal.msgSuccess("修改成功");
  291. this.open = false;
  292. this.getList();
  293. });
  294. } else {
  295. addDir(this.form).then(response => {
  296. this.$modal.msgSuccess("新增成功");
  297. this.open = false;
  298. this.getList();
  299. });
  300. }
  301. }
  302. });
  303. },
  304. /** 提交按钮 */
  305. submitFormSpace() {
  306. console.log(this.formSpace);
  307. this.$refs["formSpace"].validate(valid => {
  308. if (valid) {
  309. addExpand(this.formSpace).then(response => {
  310. this.$modal.msgSuccess("扩容申请提交成功");
  311. this.openSpace = false;
  312. });
  313. }
  314. });
  315. },
  316. /** 删除按钮操作 */
  317. handleDelete(row) {
  318. this.$modal.confirm('是否确认删除目录信息编号为"' + row.dirId + '"的数据项?').then(function() {
  319. return delDir(row.dirId);
  320. }).then(() => {
  321. this.getList();
  322. this.$modal.msgSuccess("删除成功");
  323. }).catch(() => {});
  324. }
  325. }
  326. };
  327. </script>