feat: 开始节点获取

This commit is contained in:
tony
2022-12-15 18:24:12 +08:00
parent dd11a1ac66
commit 295a46662e
16 changed files with 311 additions and 227 deletions

View File

@@ -57,9 +57,10 @@ export default {
dicts: ['sys_common_status'],
// 接受父组件的值
props: {
// 回显数据传值
selectValues: {
type: Number,
default: 0,
type: Number | String,
default: null,
required: false
}
},
@@ -91,16 +92,15 @@ export default {
expression: null,
status: null,
},
radioSelected: this.selectValues
radioSelected: null // 单选框传值
};
},
watch: {
selectValues: {
immediate: true,
handler(newVal) {
console.log(newVal,"selectValues")
this.radioSelected = newVal
}
},
immediate: true,
}
},
created() {

View File

@@ -16,7 +16,7 @@
</el-form-item>
</el-form>
<el-table v-if="selectType === 'multiple'" v-loading="loading" :data="roleList" @selection-change="handleMultipleRoleSelect">
<el-table v-if="selectType === 'multiple'" ref="dataTable" v-loading="loading" :data="roleList" @selection-change="handleMultipleRoleSelect">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="角色编号" prop="roleId" width="120" />
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" />
@@ -66,9 +66,17 @@ export default {
dicts: ['sys_normal_disable'],
// 接受父组件的值
props: {
checkType: String,
default: 'multiple',
required: false
// 回显数据传值
selectValues: {
type: Number | String | Array,
default: null,
required: false
},
checkType: {
type: String,
default: 'multiple',
required: true
},
},
data() {
return {
@@ -91,41 +99,6 @@ export default {
title: "",
// 是否显示弹出层
open: false,
// 是否显示弹出层(数据权限)
openDataScope: false,
menuExpand: false,
menuNodeAll: false,
deptExpand: true,
deptNodeAll: false,
// 日期范围
dateRange: [],
// 数据范围选项
dataScopeOptions: [
{
value: "1",
label: "全部数据权限"
},
{
value: "2",
label: "自定数据权限"
},
{
value: "3",
label: "本部门数据权限"
},
{
value: "4",
label: "本部门及以下数据权限"
},
{
value: "5",
label: "仅本人数据权限"
}
],
// 菜单列表
menuOptions: [],
// 部门列表
deptOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
@@ -136,13 +109,38 @@ export default {
},
// 表单参数
form: {},
defaultProps: {
children: "children",
label: "label"
},
radioSelected:''
radioSelected: null, // 单选框传值
selectRoleList: null // 回显数据传值
};
},
watch: {
selectValues: {
handler(newVal) {
if (newVal instanceof Number) {
this.radioSelected = newVal
} else {
this.selectRoleList = newVal;
}
},
immediate: true
},
roleList: {
handler(newVal) {
if (newVal) {
this.$nextTick(() => {
this.$refs.dataTable.clearSelection();
this.selectRoleList?.split(',').forEach(key => {
this.$refs.dataTable.toggleRowSelection(newVal.find(
item => key == item.roleId
), true)
});
});
}
},
immediate: true, // 立即生效
deep: true //监听对象或数组的时候,要用到深度监听
}
},
created() {
this.getList();
},
@@ -150,7 +148,7 @@ export default {
/** 查询角色列表 */
getList() {
this.loading = true;
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
listRole(this.queryParams).then(response => {
this.roleList = response.rows;
this.total = response.total;
this.loading = false;
@@ -158,26 +156,16 @@ export default {
);
},
// 多选框选中数据
handleRoleSelect(selection) {
// this.ids = selection.map(item => item.userId);
this.radioSelected = selection.roleId;//点击当前行时,radio同样有选中效果
console.log(selection,"handleRoleSelect");
this.$emit('handleRoleSelect', selection);
},
// 多选框选中数据
handleMultipleRoleSelect(selection) {
this.ids = selection.map(item => item.roleId);
const idList = selection.map(item => item.roleId);
const nameList = selection.map(item => item.roleName);
console.log( this.ids,"handleRoleSelect");
this.$emit('handleRoleSelect',this.ids.join(','),nameList.join(','));
this.$emit('handleRoleSelect', idList.join(','), nameList.join(','));
},
// 单选框选中数据
handleSingleRoleSelect(selection) {
this.radioSelected = selection.roleId;//点击当前行时,radio同样有选中效果
const name = selection.roleName;//点击当前行时,radio同样有选中效果
console.log(this.radioSelected.toString() ,"handleRoleSelect");
this.$emit('handleRoleSelect',this.radioSelected.toString(),name);
this.radioSelected = selection.roleId;
const roleName = selection.roleName;
this.$emit('handleRoleSelect', this.radioSelected.toString(), roleName);
},
/** 搜索按钮操作 */
handleQuery() {
@@ -186,7 +174,6 @@ export default {
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.handleQuery();
},
}

View File

@@ -53,7 +53,7 @@
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-if="selectType === 'multiple'" v-loading="loading" :data="userList" @selection-change="handleMultipleUserSelect">
<el-table v-if="selectType === 'multiple'" ref="dataTable" v-loading="loading" :data="userList" @selection-change="handleMultipleUserSelect">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
<el-table-column label="登录账号" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
@@ -97,11 +97,13 @@ export default {
components: { Treeselect },
// 接受父组件的值
props: {
// 回显数据传值
selectValues: {
type: Number | String,
default: 0,
type: Number | String | Array,
default: null,
required: false
},
// 表格类型
checkType: {
type: String,
default: 'multiple',
@@ -133,14 +135,6 @@ export default {
open: false,
// 部门名称
deptName: undefined,
// 默认密码
initPassword: undefined,
// 日期范围
dateRange: [],
// 岗位选项
postOptions: [],
// 角色选项
roleOptions: [],
// 表单参数
form: {},
defaultProps: {
@@ -166,7 +160,8 @@ export default {
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
],
radioSelected:null
radioSelected: null, // 单选框传值
selectUserList: null // 回显数据传值
};
},
watch: {
@@ -175,25 +170,41 @@ export default {
this.$refs.tree.filter(val);
},
selectValues: {
immediate: true,
handler(newVal) {
console.log(newVal,"user-selectValues")
this.radioSelected = newVal
}
if (newVal instanceof Number) {
this.radioSelected = newVal
} else {
this.selectUserList = newVal;
}
},
immediate: true
},
userList: {
handler(newVal) {
if (newVal) {
this.$nextTick(() => {
this.$refs.dataTable.clearSelection();
this.selectUserList?.split(',').forEach(key => {
this.$refs.dataTable.toggleRowSelection(newVal.find(
item => key == item.userId
), true)
});
});
}
},
immediate: true, // 立即生效
deep: true //监听对象或数组的时候,要用到深度监听
}
},
created() {
this.getList();
this.getDeptTree();
this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg;
});
},
methods: {
/** 查询用户列表 */
getList() {
this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
listUser(this.queryParams).then(response => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;