index.vue 11 KB

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