| | |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-table ref="dataTable" v-loading="loading" :data="roleList" @selection-change="handleMultipleRoleSelect"> |
| | | <el-table 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" /> |
| | | <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="显示顺序" prop="roleSort" width="100" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | <el-table-column label="角色编号" prop="roleId"/> |
| | | <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true"/> |
| | | <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true"/> |
| | | <el-table-column label="显示顺序" prop="roleSort"/> |
| | | <el-table-column label="创建时间" align="center" prop="createTime"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | |
| | | }; |
| | | }, |
| | | watch: { |
| | | selectValues: { |
| | | deep: true, |
| | | handler(newVal) { |
| | | if (newVal && newVal.length > 0) { |
| | | this.$nextTick(() => { |
| | | this.$refs.dataTable.clearSelection(); |
| | | this.selectRoleList = [] |
| | | newVal.forEach(item => { |
| | | this.roleList.forEach(role => { |
| | | if (item.roleId === role.roleId) { |
| | | this.selectRoleList.push(role) |
| | | this.$refs.dataTable.toggleRowSelection(role) |
| | | } |
| | | }) |
| | | }); |
| | | }) |
| | | } else { |
| | | this.selectRoleList = [] |
| | | } |
| | | } |
| | | }, |
| | | roleList: { |
| | | deep: true, |
| | | handler(newVal) { |
| | | if (newVal && newVal.length > 0) { |
| | | this.$nextTick(() => { |
| | | this.$refs.dataTable.clearSelection(); |
| | | this.selectValues.forEach(item => { |
| | | newVal.forEach(role => { |
| | | if (item.roleId === role.roleId) { |
| | | this.$refs.dataTable.toggleRowSelection(role) |
| | | } |
| | | }) |
| | | }); |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | console.log("我家在了") |
| | | this.getList(); |
| | | }, |
| | | methods: { |
| | | // 保存选中的数据id,row-key就是要指定一个key标识这一行的数据 |
| | | getRowKey (row) { |
| | | return row.roleId |
| | | }, |
| | | setChecked(val) { |
| | | if (val && val.length > 0) { |
| | | this.$nextTick(() => { |
| | | this.$refs.dataTable.clearSelection(); |
| | | this.selectRoleList = val |
| | | val.forEach(check => { |
| | | this.roleList.forEach(item => { |
| | | if (check.roleId === item.roleId) { |
| | | this.$refs.dataTable.toggleRowSelection(item) |
| | | } |
| | | }) |
| | | }) |
| | | }); |
| | | } else { |
| | | this.selectRoleList = [] |
| | | } |
| | | console.log("接收到的数据", val) |
| | | this.selectRoleList = val |
| | | this.$nextTick(() => { |
| | | val.forEach(check => { |
| | | this.$refs.dataTable.toggleRowSelection(check, true) |
| | | }) |
| | | }); |
| | | }, |
| | | close() { |
| | | this.$emit("close") |
| | |
| | | ); |
| | | }, |
| | | // 多选框选中数据 |
| | | handleMultipleRoleSelect(selection) { |
| | | this.selectRoleList = selection |
| | | handleMultipleRoleSelect(rows) { |
| | | this.selectRoleList = rows |
| | | }, |
| | | /** 搜索按钮操作 */ |
| | | handleQuery() { |