From fde624998f89ee20394bb5a310eaf53c744286f5 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 13 十月 2022 15:59:43 +0800
Subject: [PATCH] Merge remote-tracking branch 'ruoyi-vue/master' into dev
---
ruoyi-ui/src/views/demo/tree/index.vue | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/ruoyi-ui/src/views/demo/tree/index.vue b/ruoyi-ui/src/views/demo/tree/index.vue
index ddf7677..6cfa7f2 100644
--- a/ruoyi-ui/src/views/demo/tree/index.vue
+++ b/ruoyi-ui/src/views/demo/tree/index.vue
@@ -39,14 +39,24 @@
v-hasPermi="['demo:tree:add']"
>鏂板</el-button>
</el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="info"
+ plain
+ icon="el-icon-sort"
+ size="mini"
+ @click="toggleExpandAll"
+ >灞曞紑/鎶樺彔</el-button>
+ </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
+ v-if="refreshTable"
v-loading="loading"
:data="treeList"
row-key="id"
- default-expand-all
+ :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="鐖秈d" prop="parentId" />
@@ -54,12 +64,12 @@
<el-table-column label="鐢ㄦ埛id" align="center" prop="userId" />
<el-table-column label="鏍戣妭鐐瑰悕" align="center" prop="treeName" />
<el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
- <template slot-scope="scope">
+ <template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
+ <template #default="scope">
<el-button
size="mini"
type="text"
@@ -102,7 +112,7 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
+ <el-button :loading="buttonLoading" type="primary" @click="submitForm">纭� 瀹�</el-button>
<el-button @click="cancel">鍙� 娑�</el-button>
</div>
</el-dialog>
@@ -110,7 +120,7 @@
</template>
<script>
-import { listTree, getTree, delTree, addTree, updateTree, exportTree } from "@/api/demo/tree";
+import { listTree, getTree, delTree, addTree, updateTree } from "@/api/demo/tree";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -121,6 +131,8 @@
},
data() {
return {
+ //鎸夐挳loading
+ buttonLoading: false,
// 閬僵灞�
loading: true,
// 鏄剧ず鎼滅储鏉′欢
@@ -133,6 +145,10 @@
title: "",
// 鏄惁鏄剧ず寮瑰嚭灞�
open: false,
+ // 鏄惁灞曞紑锛岄粯璁ゅ叏閮ㄥ睍寮�
+ isExpandAll: true,
+ // 閲嶆柊娓叉煋琛ㄦ牸鐘舵��
+ refreshTable: true,
// 鍒涘缓鏃堕棿鏃堕棿鑼冨洿
daterangeCreateTime: [],
// 鏌ヨ鍙傛暟
@@ -231,14 +247,24 @@
this.open = true;
this.title = "娣诲姞娴嬭瘯鏍戣〃";
},
+ /** 灞曞紑/鎶樺彔鎿嶄綔 */
+ toggleExpandAll() {
+ this.refreshTable = false;
+ this.isExpandAll = !this.isExpandAll;
+ this.$nextTick(() => {
+ this.refreshTable = true;
+ });
+ },
/** 淇敼鎸夐挳鎿嶄綔 */
handleUpdate(row) {
+ this.loading = true;
this.reset();
this.getTreeselect();
if (row != null) {
this.form.parentId = row.id;
}
getTree(row.id).then(response => {
+ this.loading = false;
this.form = response.data;
this.open = true;
this.title = "淇敼娴嬭瘯鏍戣〃";
@@ -248,17 +274,22 @@
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
+ this.buttonLoading = true;
if (this.form.id != null) {
updateTree(this.form).then(response => {
- this.msgSuccess("淇敼鎴愬姛");
+ this.$modal.msgSuccess("淇敼鎴愬姛");
this.open = false;
this.getList();
+ }).finally(() => {
+ this.buttonLoading = false;
});
} else {
addTree(this.form).then(response => {
- this.msgSuccess("鏂板鎴愬姛");
+ this.$modal.msgSuccess("鏂板鎴愬姛");
this.open = false;
this.getList();
+ }).finally(() => {
+ this.buttonLoading = false;
});
}
}
@@ -266,16 +297,16 @@
},
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
handleDelete(row) {
- this.$confirm('鏄惁纭鍒犻櫎娴嬭瘯鏍戣〃缂栧彿涓�"' + row.id + '"鐨勬暟鎹」?', "璀﹀憡", {
- confirmButtonText: "纭畾",
- cancelButtonText: "鍙栨秷",
- type: "warning"
- }).then(function() {
+ this.$modal.confirm('鏄惁纭鍒犻櫎娴嬭瘯鏍戣〃缂栧彿涓�"' + row.id + '"鐨勬暟鎹」锛�').then(() => {
+ this.loading = true;
return delTree(row.id);
}).then(() => {
+ this.loading = false;
this.getList();
- this.msgSuccess("鍒犻櫎鎴愬姛");
- })
+ this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ }).finally(() => {
+ this.loading = false;
+ });
}
}
};
--
Gitblit v1.9.3