- 将所有表格的单元格合并方法从数组格式 [rowspan, colspan] 改为对象格式 { rowspan, colspan }
- 为 vxe-table 组件添加 checkbox-config 配置以支持复选框保留选择功能
- 移除复选框的 :reserve-selection 属性并改用 checkbox-config 配置
- 全局注册 VxeTableCompat 组件来归一化 cell-click 和 current-change 事件参数
- 更新技术执行和技术审批页面的表格组件配置和操作逻辑
- 优化
183 lines
4.1 KiB
Vue
Executable File
183 lines
4.1 KiB
Vue
Executable File
<template>
|
|
<div class="app-container">
|
|
<h4 class="form-header h4">
|
|
基本信息
|
|
</h4>
|
|
<el-form
|
|
:model="form"
|
|
label-width="80px"
|
|
>
|
|
<el-row>
|
|
<el-col
|
|
:span="8"
|
|
:offset="2"
|
|
>
|
|
<el-form-item
|
|
label="用户昵称"
|
|
prop="nickName"
|
|
>
|
|
<el-input
|
|
v-model="form.nickName"
|
|
disabled
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col
|
|
:span="8"
|
|
:offset="2"
|
|
>
|
|
<el-form-item
|
|
label="登录账号"
|
|
prop="userName"
|
|
>
|
|
<el-input
|
|
v-model="form.userName"
|
|
disabled
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
|
|
<h4 class="form-header h4">
|
|
角色信息
|
|
</h4>
|
|
<vxe-table :checkbox-config="{ reserve: true }"
|
|
ref="roleRef"
|
|
v-loading="loading"
|
|
:row-key="getRowKey"
|
|
:data="roles.slice((pageNum - 1) * pageSize, pageNum * pageSize)"
|
|
@cell-click="clickRow"
|
|
@checkbox-change="handleSelectionChange"
|
|
>
|
|
<vxe-column
|
|
title="序号"
|
|
width="55"
|
|
type="seq"
|
|
align="center"
|
|
>
|
|
<template #default="scope">
|
|
<span>{{ (pageNum - 1) * pageSize + scope.rowIndex + 1 }}</span>
|
|
</template>
|
|
</vxe-column>
|
|
<vxe-column
|
|
type="checkbox"
|
|
|
|
width="55"
|
|
/>
|
|
<vxe-column
|
|
title="角色编号"
|
|
align="center"
|
|
field="roleId"
|
|
/>
|
|
<vxe-column
|
|
title="角色名称"
|
|
align="center"
|
|
field="roleName"
|
|
/>
|
|
<vxe-column
|
|
title="权限字符"
|
|
align="center"
|
|
field="roleKey"
|
|
/>
|
|
<vxe-column
|
|
title="创建时间"
|
|
align="center"
|
|
field="createTime"
|
|
width="180"
|
|
>
|
|
<template #default="scope">
|
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
|
</template>
|
|
</vxe-column>
|
|
</vxe-table>
|
|
|
|
<pagination
|
|
v-show="total > 0"
|
|
v-model:page="pageNum"
|
|
v-model:limit="pageSize"
|
|
:total="total"
|
|
/>
|
|
|
|
<el-form label-width="100px">
|
|
<div style="text-align: center;margin-left:-120px;margin-top:30px;">
|
|
<el-button
|
|
type="primary"
|
|
@click="submitForm()"
|
|
>
|
|
提交
|
|
</el-button>
|
|
<el-button @click="close()">
|
|
返回
|
|
</el-button>
|
|
</div>
|
|
</el-form>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="AuthRole">
|
|
import {getAuthRole, updateAuthRole} from "@/api/system/user";
|
|
|
|
const route = useRoute();
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
const loading = ref(true);
|
|
const total = ref(0);
|
|
const pageNum = ref(1);
|
|
const pageSize = ref(10);
|
|
const roleIds = ref([]);
|
|
const roles = ref([]);
|
|
const form = ref({
|
|
nickName: undefined,
|
|
userName: undefined,
|
|
userId: undefined
|
|
});
|
|
|
|
/** 单击选中行数据 */
|
|
function clickRow(row) {
|
|
proxy.$refs["roleRef"].toggleCheckboxRow(row);
|
|
};
|
|
/** 多选框选中数据 */
|
|
function handleSelectionChange(selection) {
|
|
roleIds.value = selection.map(item => item.roleId);
|
|
};
|
|
/** 保存选中的数据编号 */
|
|
function getRowKey(row) {
|
|
return row.roleId;
|
|
};
|
|
/** 关闭按钮 */
|
|
function close() {
|
|
const obj = { path: "/system/basicmanage/user" };
|
|
proxy.$tab.closeOpenPage(obj);
|
|
};
|
|
/** 提交按钮 */
|
|
function submitForm() {
|
|
const userId = form.value.userId;
|
|
const rIds = roleIds.value.join(",");
|
|
updateAuthRole({ userId: userId, roleIds: rIds }).then(response => {
|
|
proxy.$modal.msgSuccess("授权成功");
|
|
close();
|
|
});
|
|
};
|
|
|
|
(() => {
|
|
const userId = route.params && route.params.userId;
|
|
if (userId) {
|
|
loading.value = true;
|
|
getAuthRole(userId).then(response => {
|
|
form.value = response.user;
|
|
roles.value = response.roles;
|
|
total.value = roles.value.length;
|
|
nextTick(() => {
|
|
roles.value.forEach(row => {
|
|
if (row.flag) {
|
|
proxy.$refs["roleRef"].toggleCheckboxRow(row);
|
|
}
|
|
});
|
|
});
|
|
loading.value = false;
|
|
});
|
|
}
|
|
})();
|
|
</script>
|