【更新】重写用户、机构、角色、职位设计器,加入v-model引用形式,业务内完成替换

pull/227/head
俞宝山 2024-07-19 01:38:00 +08:00
parent a6424ca5ba
commit deb617da7e
14 changed files with 1914 additions and 79 deletions

View File

@ -0,0 +1,36 @@
## 小诺机构选择器
### 说明
改组件为小诺机构选择器可返回id用逗号隔离的字符串或id数组类型的数据格式
@author yubaoshan
@data 2024年7月5日23:59:23
### props定义
| 序号 | 编码 | 类型 | 说明 | 默认 |
|-----|-------------------------|---------------|------------------------------|--------|
| 1 | radioModel | Boolean | 是否单选与addShow隐藏同时可用 | false |
| 2 | dataIsConverterFlw | Boolean | 是否为工作流格式 | false |
| 3 | orgTreeApi | function | 机构树接口 | - |
| 4 | orgPageApi | function | 机构分页接口 | - |
| 5 | orgListByIdListApi | function | 通过id数组查询list数据接口 | 已配置 |
| 6 | value | object或string | 通过v-model:value绑定数据 | - |
| 7 | dataType | string | 数据类型object或string | string |
| 8 | show | Boolean | 是否显示已选择机构(非表单内、单纯的选择机构需要隐藏) | true |
| 9 | addShow | Boolean | 是否默认的增加人员按钮与radioModel为或的关系 | true |
### emits定义
| 序号 | 方法名 | 参数类型 | 说明 |
|----|--------|----------------|---------------------------------|
| 1 | value | 根据 dataType 而定 | 当选择机构后通过v-model:value绑定到组件上 |
| 2 | onBack | 根据 dataType 而定 | 通过@onBack 方法返回选中的数据,触发点为选中或删除机构 |
### slot定义
| 序号 | 插槽名 | 用途 | 用途 |
|----|--------|-------------------|-------------------|
| 1 | button | 在机构新增按钮后可以插入自定义按钮 | 不满足新增机构按钮样式,可以自定义 |

View File

@ -0,0 +1,579 @@
<template>
<!-- 这是引入后展示的样式 -->
<div v-if="props.show">
<a-tag v-for="data in dataArray" closable @close="deleteObj(data)" :key="data.id" class="mb-1">{{
data.name
}}</a-tag>
<a-button
type="primary"
size="small"
@click="openModal"
v-if="(props.radioModel ? dataArray.length !== 1 : true) && addShow"
>
<slot name="button"></slot>
<span v-if="!hasContent('button')">
<plus-outlined />
选择
</span>
</a-button>
</div>
<!-- 以下是弹窗内容 -->
<a-modal
v-model:open="visible"
title="机构选择"
:width="1000"
:mask-closable="false"
:destroy-on-close="true"
@ok="handleOk"
@cancel="handleClose"
>
<a-row :gutter="10">
<a-col :span="7">
<a-card size="small" :loading="cardLoading" class="selectorTreeDiv">
<a-tree
v-if="treeData"
v-model:expandedKeys="defaultExpandedKeys"
:tree-data="treeData"
:field-names="treeFieldNames"
@select="treeSelect"
>
</a-tree>
</a-card>
</a-col>
<a-col :span="11">
<div class="table-operator xn-mb10">
<a-form ref="searchFormRef" name="advanced_search" class="ant-advanced-search-form" :model="searchFormState">
<a-row :gutter="24">
<a-col :span="12">
<a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入机构名" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-button type="primary" class="xn-mr-10" @click="loadData()"> </a-button>
<a-button @click="reset()"> </a-button>
</a-col>
</a-row>
</a-form>
</div>
<div class="selector-table">
<a-table
ref="tableRef"
size="small"
:columns="commons"
:data-source="tableData"
:expand-row-by-click="true"
:loading="pageLoading"
bordered
:pagination="false"
>
<template #title>
<span>待选择列表 {{ tableRecordNum }} </span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" size="small" @click="addAllPageRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" size="small" @click="addRecord(record)"><PlusOutlined /></a-button>
</template>
<template v-if="column.dataIndex === 'category'">
{{ $TOOL.dictTypeData('ORG_CATEGORY', record.category) }}
</template>
</template>
</a-table>
<div class="mt-2">
<a-pagination
v-if="!isEmpty(tableData)"
v-model:current="current"
v-model:page-size="pageSize"
:total="total"
size="small"
showSizeChanger
@change="paginationChange"
/>
</div>
</div>
</a-col>
<a-col :span="6">
<div class="selector-table">
<a-table
ref="selectedTable"
size="small"
:columns="selectedCommons"
:data-source="selectedData"
:expand-row-by-click="true"
:loading="selectedTableListLoading"
bordered
>
<template #title>
<span>已选择: {{ selectedData.length }}</span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" danger size="small" @click="delAllRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" danger size="small" @click="delRecord(record)"><MinusOutlined /></a-button>
</template>
</template>
</a-table>
</div>
</a-col>
</a-row>
</a-modal>
</template>
<script setup name="orgSelector">
import { message } from 'ant-design-vue'
import { remove, isEmpty, cloneDeep } from 'lodash-es'
import userCenterApi from '@/api/sys/userCenterApi'
import { useSlots } from 'vue'
//
const visible = ref(false)
// common
const commons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
},
{
title: '分类',
dataIndex: 'category'
}
]
// common
const selectedCommons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
}
]
const props = defineProps({
radioModel: {
type: Boolean,
default: () => false
},
dataIsConverterFlw: {
type: Boolean,
default: () => false
},
orgTreeApi: {
type: Function
},
orgPageApi: {
type: Function
},
orgListByIdListApi: {
type: Function
},
value: {
default: () => ''
},
dataType: {
type: String,
default: () => 'array'
},
show: {
type: Boolean,
default: () => true
},
addShow: {
type: Boolean,
default: () => true
}
})
// ref
const tableRef = ref()
// ref
const selectedTable = ref()
const tableRecordNum = ref()
const searchFormState = ref({})
const searchFormRef = ref()
const cardLoading = ref(true)
const pageLoading = ref(false)
const selectedTableListLoading = ref(false)
const slots = useSlots()
// treeNode title,key,children
const treeFieldNames = { children: 'children', title: 'name', key: 'id' }
//
const treeData = ref()
// id
const defaultExpandedKeys = ref([])
const emit = defineEmits(['update:value', 'onBack'])
const tableData = ref([])
const selectedData = ref([])
const recordIds = ref([])
//
const current = ref(0) //
const pageSize = ref(10) //
const total = ref(0) //
const hasContent = (slotName) => {
return !!(slots[slotName] && slots[slotName]().length > 0)
}
//
const showModel = (ids = []) => {
const data = goDataConverter(ids)
recordIds.value = data
getDataNameById(data)
openModal()
}
// api
const orgTree = (param) => {
if (typeof props.orgTreeApi === 'function') {
return props.orgTreeApi(param)
} else {
message.warning('未配置机构树API')
return Promise.resolve([])
}
}
// api
const orgPage = (param) => {
if (typeof props.orgPageApi === 'function') {
return props.orgPageApi(param)
} else {
message.warning('未配置机构选择器API')
return Promise.resolve([])
}
}
// api
const orgListByIdList = (param) => {
if (typeof props.orgListByIdListApi === 'function') {
return props.orgListByIdListApi(param)
} else {
return userCenterApi.userCenterGetOrgListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
const openModal = () => {
if (typeof props.orgTreeApi !== 'function' || typeof props.orgPageApi !== 'function') {
message.warning('未配置机构选择器API')
return
}
visible.value = true
//
orgTree()
.then((data) => {
if (!isEmpty(data)) {
treeData.value = data
// 2
treeData.value.forEach((item) => {
// 0
if (item.parentId === '0') {
defaultExpandedKeys.value.push(item.id)
// ID
if (item.children) {
item.children.forEach((items) => {
defaultExpandedKeys.value.push(items.id)
})
}
}
})
}
})
.finally(() => {
cardLoading.value = false
})
searchFormState.value.size = pageSize.value
loadData()
if (isEmpty(recordIds.value)) {
return
}
const param = {
idList: recordIds.value
}
selectedTableListLoading.value = true
orgListByIdList(param)
.then((data) => {
selectedData.value = data
})
.finally(() => {
selectedTableListLoading.value = false
})
}
//
const deleteObj = (obj) => {
//
remove(dataArray.value, (item) => item.id === obj.id)
//
remove(recordIds.value, (item) => item === obj.id)
const value = []
const showData = []
dataArray.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
}
//
const loadData = () => {
pageLoading.value = true
orgPage(searchFormState.value)
.then((data) => {
current.value = data.current
total.value = data.total
//
tableData.value = []
tableRecordNum.value = 0
tableData.value = data.records
if (data.records) {
tableRecordNum.value = data.records.length
} else {
tableRecordNum.value = 0
}
})
.finally(() => {
pageLoading.value = false
})
}
// pageSize
const paginationChange = (page, pageSize) => {
searchFormState.value.current = page
searchFormState.value.size = pageSize
loadData()
}
const judge = () => {
return !(props.radioModel && selectedData.value.length > 0)
}
//
const addRecord = (record) => {
if (!judge()) {
message.warning('只可选择一条')
return
}
const selectedRecord = selectedData.value.filter((item) => item.id === record.id)
if (selectedRecord.length === 0) {
selectedData.value.push(record)
} else {
message.warning('该记录已存在')
}
}
//
const addAllPageRecord = () => {
let newArray = selectedData.value.concat(tableData.value)
let list = []
for (let item1 of newArray) {
let flag = true
for (let item2 of list) {
if (item1.id === item2.id) {
flag = false
}
}
if (flag) {
list.push(item1)
}
}
selectedData.value = list
}
//
const delRecord = (record) => {
remove(selectedData.value, (item) => item.id === record.id)
}
//
const delAllRecord = () => {
selectedData.value = []
}
//
const treeSelect = (selectedKeys) => {
searchFormState.value.current = 0
if (selectedKeys.length > 0) {
searchFormState.value.parentId = selectedKeys.toString()
} else {
delete searchFormState.value.parentId
}
loadData()
}
const dataArray = ref([])
//
const handleOk = () => {
dataArray.value = []
const value = []
const showData = []
selectedData.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
handleClose()
}
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => {
searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
current.value = 0
pageSize.value = 20
total.value = 0
selectedData.value = []
// dataArray.value = []
visible.value = false
}
//
const goDataConverter = (data) => {
if (props.dataIsConverterFlw) {
const resultData = []
//
if (!isEmpty(data.value)) {
const values = data.value.split(',')
if (values.length > 0) {
values.forEach((id) => {
resultData.push(id)
})
} else {
resultData.push(data.value)
}
} else {
//
if (!isEmpty(data) && !isEmpty(data[0]) && !isEmpty(data[0].value)) {
const values = data[0].value.split(',')
for (let i = 0; i < values.length; i++) {
resultData.push(values[i])
}
}
}
return resultData
} else {
if (getValueType() !== 'string') {
return data
}
if (data.length > 1) {
const resultData = []
data.split(',').forEach((id) => {
resultData.push(id)
})
return resultData
} else {
return data
}
}
}
//
const outDataConverter = (data) => {
if (props.dataIsConverterFlw) {
data = dataArray.value
const obj = {}
let label = ''
let value = ''
for (let i = 0; i < data.length; i++) {
if (data.length === i + 1) {
label = label + data[i].name
value = value + data[i].id
} else {
label = label + data[i].name + ','
value = value + data[i].id + ','
}
}
obj.key = 'ORG'
obj.label = label
obj.value = value
obj.extJson = ''
return obj
} else {
if (getValueType() !== 'string') {
return data
}
let resultData = ''
data.forEach((id) => {
resultData = resultData + ',' + id
})
resultData = resultData.substring(1, resultData.length)
return resultData
}
}
//
const getValueType = () => {
if (props.dataType) {
return props.dataType
} else {
if (props.radioModel) {
return 'string'
}
return typeof typeof props.value
}
}
const getDataNameById = (ids) => {
if (isEmpty(dataArray.value) && !isEmpty(ids)) {
const param = {
idList: recordIds.value
}
//
orgListByIdList(param).then((data) => {
dataArray.value = data
})
}
}
watch(
() => props.value,
(newValue) => {
if (!isEmpty(props.value)) {
const ids = goDataConverter(newValue)
recordIds.value = ids
getDataNameById(ids)
}
},
{
immediate: true //
}
)
defineExpose({
showModel
})
</script>
<style lang="less" scoped>
.xn-mr-5 {
margin-right: 5px;
}
.xn-mr-10 {
margin-right: 10px;
}
.selectorTreeDiv {
max-height: 500px;
overflow: auto;
}
.ant-form-item {
margin-bottom: 0 !important;
}
.selector-table {
overflow: auto;
max-height: 450px;
}
</style>

View File

@ -0,0 +1,36 @@
## 小诺职位选择器
### 说明
改组件为小诺职位选择器可返回id用逗号隔离的字符串或id数组类型的数据格式
@author yubaoshan
@data 2024年7月5日23:59:23
### props定义
| 序号 | 编码 | 类型 | 说明 | 默认 |
|-----|---------------------|---------------|------------------------------|--------|
| 1 | radioModel | Boolean | 是否单选与addShow隐藏同时可用 | false |
| 2 | dataIsConverterFlw | Boolean | 是否为工作流格式 | false |
| 3 | orgTreeApi | function | 机构树接口 | - |
| 4 | positionPageApi | function | 职位分页接口 | - |
| 5 | positionListByIdListApi | function | 通过id数组查询list数据接口 | 已配置 |
| 6 | value | object或string | 通过v-model:value绑定数据 | - |
| 7 | dataType | string | 数据类型object或string | string |
| 8 | show | Boolean | 是否显示已选择职位(非表单内、单纯的选择职位需要隐藏) | true |
| 9 | addShow | Boolean | 是否默认的增加人员按钮与radioModel为或的关系 | true |
### emits定义
| 序号 | 方法名 | 参数类型 | 说明 |
|----|--------|----------------|---------------------------------|
| 1 | value | 根据 dataType 而定 | 当选择职位后通过v-model:value绑定到组件上 |
| 2 | onBack | 根据 dataType 而定 | 通过@onBack 方法返回选中的数据,触发点为选中或删除职位 |
### slot定义
| 序号 | 插槽名 | 用途 | 用途 |
|----|--------|-------------------|-------------------|
| 1 | button | 在职位新增按钮后可以插入自定义按钮 | 不满足新增职位按钮样式,可以自定义 |

View File

@ -0,0 +1,579 @@
<template>
<!-- 这是引入后展示的样式 -->
<div v-if="props.show">
<a-tag v-for="data in dataArray" closable @close="deleteObj(data)" :key="data.id" class="mb-1">{{
data.name
}}</a-tag>
<a-button
type="primary"
size="small"
@click="openModal"
v-if="(props.radioModel ? dataArray.length !== 1 : true) && addShow"
>
<slot name="button"></slot>
<span v-if="!hasContent('button')">
<plus-outlined />
选择
</span>
</a-button>
</div>
<!-- 以下是弹窗内容 -->
<a-modal
v-model:open="visible"
title="职位选择"
:width="1000"
:mask-closable="false"
:destroy-on-close="true"
@ok="handleOk"
@cancel="handleClose"
>
<a-row :gutter="10">
<a-col :span="7">
<a-card size="small" :loading="cardLoading" class="selectorTreeDiv">
<a-tree
v-if="treeData"
v-model:expandedKeys="defaultExpandedKeys"
:tree-data="treeData"
:field-names="treeFieldNames"
@select="treeSelect"
>
</a-tree>
</a-card>
</a-col>
<a-col :span="11">
<div class="table-operator xn-mb10">
<a-form ref="searchFormRef" name="advanced_search" class="ant-advanced-search-form" :model="searchFormState">
<a-row :gutter="24">
<a-col :span="12">
<a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入职位名" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-button type="primary" class="xn-mr-10" @click="loadData()"> </a-button>
<a-button @click="reset()"> </a-button>
</a-col>
</a-row>
</a-form>
</div>
<div class="selector-table">
<a-table
ref="tableRef"
size="small"
:columns="commons"
:data-source="tableData"
:expand-row-by-click="true"
:loading="pageLoading"
bordered
:pagination="false"
>
<template #title>
<span>待选择列表 {{ tableRecordNum }} </span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" size="small" @click="addAllPageRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" size="small" @click="addRecord(record)"><PlusOutlined /></a-button>
</template>
<template v-if="column.dataIndex === 'category'">
{{ $TOOL.dictTypeData('POSITION_CATEGORY', record.category) }}
</template>
</template>
</a-table>
<div class="mt-2">
<a-pagination
v-if="!isEmpty(tableData)"
v-model:current="current"
v-model:page-size="pageSize"
:total="total"
size="small"
showSizeChanger
@change="paginationChange"
/>
</div>
</div>
</a-col>
<a-col :span="6">
<div class="selector-table">
<a-table
ref="selectedTable"
size="small"
:columns="selectedCommons"
:data-source="selectedData"
:expand-row-by-click="true"
:loading="selectedTableListLoading"
bordered
>
<template #title>
<span>已选择: {{ selectedData.length }}</span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" danger size="small" @click="delAllRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" danger size="small" @click="delRecord(record)"><MinusOutlined /></a-button>
</template>
</template>
</a-table>
</div>
</a-col>
</a-row>
</a-modal>
</template>
<script setup name="positionSelector">
import { message } from 'ant-design-vue'
import { remove, isEmpty, cloneDeep } from 'lodash-es'
import userCenterApi from '@/api/sys/userCenterApi'
import { useSlots } from 'vue'
//
const visible = ref(false)
// common
const commons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
},
{
title: '分类',
dataIndex: 'category'
}
]
// common
const selectedCommons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
}
]
const props = defineProps({
radioModel: {
type: Boolean,
default: () => false
},
dataIsConverterFlw: {
type: Boolean,
default: () => false
},
orgTreeApi: {
type: Function
},
positionPageApi: {
type: Function
},
positionListByIdListApi: {
type: Function
},
value: {
default: () => ''
},
dataType: {
type: String,
default: () => 'array'
},
show: {
type: Boolean,
default: () => true
},
addShow: {
type: Boolean,
default: () => true
}
})
// ref
const tableRef = ref()
// ref
const selectedTable = ref()
const tableRecordNum = ref()
const searchFormState = ref({})
const searchFormRef = ref()
const cardLoading = ref(true)
const pageLoading = ref(false)
const selectedTableListLoading = ref(false)
const slots = useSlots()
// treeNode title,key,children
const treeFieldNames = { children: 'children', title: 'name', key: 'id' }
//
const treeData = ref()
// id
const defaultExpandedKeys = ref([])
const emit = defineEmits(['update:value', 'onBack'])
const tableData = ref([])
const selectedData = ref([])
const recordIds = ref([])
//
const current = ref(0) //
const pageSize = ref(10) //
const total = ref(0) //
const hasContent = (slotName) => {
return !!(slots[slotName] && slots[slotName]().length > 0)
}
//
const showModel = (ids = []) => {
const data = goDataConverter(ids)
recordIds.value = data
getDataNameById(data)
openModal()
}
// api
const orgTree = (param) => {
if (typeof props.orgTreeApi === 'function') {
return props.orgTreeApi(param)
} else {
message.warning('未配置机构树API')
return Promise.resolve([])
}
}
// api
const positionPage = (param) => {
if (typeof props.positionPageApi === 'function') {
return props.positionPageApi(param)
} else {
message.warning('未配置职位选择器API')
return Promise.resolve([])
}
}
// api
const positionListByIdList = (param) => {
if (typeof props.positionListByIdListApi === 'function') {
return props.positionListByIdListApi(param)
} else {
return userCenterApi.userCenterGetPositionListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
const openModal = () => {
if (typeof props.orgTreeApi !== 'function' || typeof props.positionPageApi !== 'function') {
message.warning('未配置职位选择器API')
return
}
visible.value = true
//
orgTree()
.then((data) => {
if (!isEmpty(data)) {
treeData.value = data
// 2
treeData.value.forEach((item) => {
// 0
if (item.parentId === '0') {
defaultExpandedKeys.value.push(item.id)
// ID
if (item.children) {
item.children.forEach((items) => {
defaultExpandedKeys.value.push(items.id)
})
}
}
})
}
})
.finally(() => {
cardLoading.value = false
})
searchFormState.value.size = pageSize.value
loadData()
if (isEmpty(recordIds.value)) {
return
}
const param = {
idList: recordIds.value
}
selectedTableListLoading.value = true
positionListByIdList(param)
.then((data) => {
selectedData.value = data
})
.finally(() => {
selectedTableListLoading.value = false
})
}
//
const deleteObj = (obj) => {
//
remove(dataArray.value, (item) => item.id === obj.id)
//
remove(recordIds.value, (item) => item === obj.id)
const value = []
const showData = []
dataArray.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
}
//
const loadData = () => {
pageLoading.value = true
positionPage(searchFormState.value)
.then((data) => {
current.value = data.current
total.value = data.total
//
tableData.value = []
tableRecordNum.value = 0
tableData.value = data.records
if (data.records) {
tableRecordNum.value = data.records.length
} else {
tableRecordNum.value = 0
}
})
.finally(() => {
pageLoading.value = false
})
}
// pageSize
const paginationChange = (page, pageSize) => {
searchFormState.value.current = page
searchFormState.value.size = pageSize
loadData()
}
const judge = () => {
return !(props.radioModel && selectedData.value.length > 0)
}
//
const addRecord = (record) => {
if (!judge()) {
message.warning('只可选择一条')
return
}
const selectedRecord = selectedData.value.filter((item) => item.id === record.id)
if (selectedRecord.length === 0) {
selectedData.value.push(record)
} else {
message.warning('该记录已存在')
}
}
//
const addAllPageRecord = () => {
let newArray = selectedData.value.concat(tableData.value)
let list = []
for (let item1 of newArray) {
let flag = true
for (let item2 of list) {
if (item1.id === item2.id) {
flag = false
}
}
if (flag) {
list.push(item1)
}
}
selectedData.value = list
}
//
const delRecord = (record) => {
remove(selectedData.value, (item) => item.id === record.id)
}
//
const delAllRecord = () => {
selectedData.value = []
}
//
const treeSelect = (selectedKeys) => {
searchFormState.value.current = 0
if (selectedKeys.length > 0) {
searchFormState.value.orgId = selectedKeys.toString()
} else {
delete searchFormState.value.orgId
}
loadData()
}
const dataArray = ref([])
//
const handleOk = () => {
dataArray.value = []
const value = []
const showData = []
selectedData.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
handleClose()
}
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => {
searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
current.value = 0
pageSize.value = 20
total.value = 0
selectedData.value = []
// dataArray.value = []
visible.value = false
}
//
const goDataConverter = (data) => {
if (props.dataIsConverterFlw) {
const resultData = []
//
if (!isEmpty(data.value)) {
const values = data.value.split(',')
if (values.length > 0) {
values.forEach((id) => {
resultData.push(id)
})
} else {
resultData.push(data.value)
}
} else {
//
if (!isEmpty(data) && !isEmpty(data[0]) && !isEmpty(data[0].value)) {
const values = data[0].value.split(',')
for (let i = 0; i < values.length; i++) {
resultData.push(values[i])
}
}
}
return resultData
} else {
if (getValueType() !== 'string') {
return data
}
if (data.length > 1) {
const resultData = []
data.split(',').forEach((id) => {
resultData.push(id)
})
return resultData
} else {
return data
}
}
}
//
const outDataConverter = (data) => {
if (props.dataIsConverterFlw) {
data = dataArray.value
const obj = {}
let label = ''
let value = ''
for (let i = 0; i < data.length; i++) {
if (data.length === i + 1) {
label = label + data[i].name
value = value + data[i].id
} else {
label = label + data[i].name + ','
value = value + data[i].id + ','
}
}
obj.key = 'POSITION'
obj.label = label
obj.value = value
obj.extJson = ''
return obj
} else {
if (getValueType() !== 'string') {
return data
}
let resultData = ''
data.forEach((id) => {
resultData = resultData + ',' + id
})
resultData = resultData.substring(1, resultData.length)
return resultData
}
}
//
const getValueType = () => {
if (props.dataType) {
return props.dataType
} else {
if (props.radioModel) {
return 'string'
}
return typeof typeof props.value
}
}
const getDataNameById = (ids) => {
if (isEmpty(dataArray.value) && !isEmpty(ids)) {
const param = {
idList: recordIds.value
}
//
positionListByIdList(param).then((data) => {
dataArray.value = data
})
}
}
watch(
() => props.value,
(newValue) => {
if (!isEmpty(props.value)) {
const ids = goDataConverter(newValue)
recordIds.value = ids
getDataNameById(ids)
}
},
{
immediate: true //
}
)
defineExpose({
showModel
})
</script>
<style lang="less" scoped>
.xn-mr-5 {
margin-right: 5px;
}
.xn-mr-10 {
margin-right: 10px;
}
.selectorTreeDiv {
max-height: 500px;
overflow: auto;
}
.ant-form-item {
margin-bottom: 0 !important;
}
.selector-table {
overflow: auto;
max-height: 450px;
}
</style>

View File

@ -0,0 +1,36 @@
## 小诺角色选择器
### 说明
改组件为小诺角色选择器可返回id用逗号隔离的字符串或id数组类型的数据格式
@author yubaoshan
@data 2024年7月5日23:59:23
### props定义
| 序号 | 编码 | 类型 | 说明 | 默认 |
|-----|---------------------|---------------|------------------------------|--------|
| 1 | radioModel | Boolean | 是否单选与addShow隐藏同时可用 | false |
| 2 | dataIsConverterFlw | Boolean | 是否为工作流格式 | false |
| 3 | orgTreeApi | function | 机构树接口 | - |
| 4 | rolePageApi | function | 角色分页接口 | - |
| 5 | roleListByIdListApi | function | 通过id数组查询list数据接口 | 已配置 |
| 6 | value | object或string | 通过v-model:value绑定数据 | - |
| 7 | dataType | string | 数据类型object或string | string |
| 8 | show | Boolean | 是否显示已选择角色(非表单内、单纯的选择角色需要隐藏) | true |
| 9 | addShow | Boolean | 是否默认的增加人员按钮与radioModel为或的关系 | true |
### emits定义
| 序号 | 方法名 | 参数类型 | 说明 |
|----|--------|----------------|---------------------------------|
| 1 | value | 根据 dataType 而定 | 当选择角色后通过v-model:value绑定到组件上 |
| 2 | onBack | 根据 dataType 而定 | 通过@onBack 方法返回选中的数据,触发点为选中或删除角色 |
### slot定义
| 序号 | 插槽名 | 用途 | 用途 |
|----|--------|-------------------|-------------------|
| 1 | button | 在角色新增按钮后可以插入自定义按钮 | 不满足新增角色按钮样式,可以自定义 |

View File

@ -0,0 +1,607 @@
<template>
<!-- 这是引入后展示的样式 -->
<div v-if="props.show">
<a-tag v-for="data in dataArray" closable @close="deleteObj(data)" :key="data.id" class="mb-1">{{
data.name
}}</a-tag>
<a-button
type="primary"
size="small"
@click="openModal"
v-if="(props.radioModel ? dataArray.length !== 1 : true) && addShow"
>
<slot name="button"></slot>
<span v-if="!hasContent('button')">
<plus-outlined />
选择
</span>
</a-button>
</div>
<!-- 以下是弹窗内容 -->
<a-modal
v-model:open="visible"
title="角色选择"
:width="1000"
:mask-closable="false"
:destroy-on-close="true"
@ok="handleOk"
@cancel="handleClose"
>
<a-row :gutter="10">
<a-col :span="7">
<a-card size="small" :loading="cardLoading" class="selectorTreeDiv">
<a-tree
v-if="treeData"
v-model:expandedKeys="defaultExpandedKeys"
:tree-data="treeData"
:field-names="treeFieldNames"
@select="treeSelect"
>
</a-tree>
</a-card>
</a-col>
<a-col :span="11">
<div class="table-operator xn-mb10">
<a-form ref="searchFormRef" name="advanced_search" class="ant-advanced-search-form" :model="searchFormState">
<a-row :gutter="24">
<a-col :span="12">
<a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入职位名" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-button type="primary" class="xn-mr-10" @click="loadData()"> </a-button>
<a-button @click="reset()"> </a-button>
</a-col>
</a-row>
</a-form>
</div>
<div class="selector-table">
<a-table
ref="tableRef"
size="small"
:columns="commons"
:data-source="tableData"
:expand-row-by-click="true"
:loading="pageLoading"
bordered
:pagination="false"
>
<template #title>
<span>待选择列表 {{ tableRecordNum }} </span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" size="small" @click="addAllPageRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" size="small" @click="addRecord(record)"><PlusOutlined /></a-button>
</template>
<template v-if="column.dataIndex === 'category'">
{{ $TOOL.dictTypeData('ROLE_CATEGORY', record.category) }}
</template>
</template>
</a-table>
<div class="mt-2">
<a-pagination
v-if="!isEmpty(tableData)"
v-model:current="current"
v-model:page-size="pageSize"
:total="total"
size="small"
showSizeChanger
@change="paginationChange"
/>
</div>
</div>
</a-col>
<a-col :span="6">
<div class="selector-table">
<a-table
ref="selectedTable"
size="small"
:columns="selectedCommons"
:data-source="selectedData"
:expand-row-by-click="true"
:loading="selectedTableListLoading"
bordered
>
<template #title>
<span>已选择: {{ selectedData.length }}</span>
<div v-if="!radioModel" class="xn-fdr">
<a-button type="dashed" danger size="small" @click="delAllRecord"></a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<a-button type="dashed" danger size="small" @click="delRecord(record)"><MinusOutlined /></a-button>
</template>
</template>
</a-table>
</div>
</a-col>
</a-row>
</a-modal>
</template>
<script setup name="roleSelector">
import { message } from 'ant-design-vue'
import { remove, isEmpty, cloneDeep } from 'lodash-es'
import userCenterApi from '@/api/sys/userCenterApi'
import { useSlots } from 'vue'
//
const visible = ref(false)
// common
const commons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
},
{
title: '分类',
dataIndex: 'category'
}
]
// common
const selectedCommons = [
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: 50
},
{
title: '名称',
dataIndex: 'name',
ellipsis: true
}
]
const props = defineProps({
radioModel: {
type: Boolean,
default: () => false
},
dataIsConverterFlw: {
type: Boolean,
default: () => false
},
orgTreeApi: {
type: Function
},
rolePageApi: {
type: Function
},
roleListByIdListApi: {
type: Function
},
value: {
default: () => ''
},
dataType: {
type: String,
default: () => 'array'
},
show: {
type: Boolean,
default: () => true
},
addShow: {
type: Boolean,
default: () => true
},
//
roleGlobal: {
type: Boolean,
default: true,
required: false
}
})
// ref
const tableRef = ref()
// ref
const selectedTable = ref()
const tableRecordNum = ref()
const searchFormState = ref({})
const searchFormRef = ref()
const cardLoading = ref(true)
const pageLoading = ref(false)
const selectedTableListLoading = ref(false)
const slots = useSlots()
// treeNode title,key,children
const treeFieldNames = { children: 'children', title: 'name', key: 'id' }
//
const treeData = ref()
// id
const defaultExpandedKeys = ref([])
const emit = defineEmits(['update:value', 'onBack'])
const tableData = ref([])
const selectedData = ref([])
const recordIds = ref([])
//
const current = ref(0) //
const pageSize = ref(10) //
const total = ref(0) //
const hasContent = (slotName) => {
return !!(slots[slotName] && slots[slotName]().length > 0)
}
//
const showModel = (ids = []) => {
const data = goDataConverter(ids)
recordIds.value = data
getDataNameById(data)
openModal()
}
// api
const orgTree = (param) => {
if (typeof props.orgTreeApi === 'function') {
return props.orgTreeApi(param)
} else {
message.warning('未配置机构树API')
return Promise.resolve([])
}
}
// api
const rolePage = (param) => {
if (typeof props.rolePageApi === 'function') {
return props.rolePageApi(param)
} else {
message.warning('未配置角色选择器API')
return Promise.resolve([])
}
}
// api
const roleListByIdList = (param) => {
if (typeof props.roleListByIdListApi === 'function') {
return props.roleListByIdListApi(param)
} else {
return userCenterApi.userCenterGetRoleListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
const openModal = () => {
if (typeof props.orgTreeApi !== 'function' || typeof props.rolePageApi !== 'function') {
message.warning('未配置角色选择器API')
return
}
visible.value = true
//
orgTree()
.then((data) => {
if (!isEmpty(data)) {
treeData.value = data
//
if (props.roleGlobal) {
const globalRoleType = [
{
id: 'GLOBAL',
parentId: '-1',
name: '全局'
}
]
treeData.value = globalRoleType.concat(data)
}
// 2
treeData.value.forEach((item) => {
// 0
if (item.parentId === '0') {
defaultExpandedKeys.value.push(item.id)
// ID
if (item.children) {
item.children.forEach((items) => {
defaultExpandedKeys.value.push(items.id)
})
}
}
})
}
})
.finally(() => {
cardLoading.value = false
})
searchFormState.value.size = pageSize.value
loadData()
if (isEmpty(recordIds.value)) {
return
}
const param = {
idList: recordIds.value
}
selectedTableListLoading.value = true
roleListByIdList(param)
.then((data) => {
selectedData.value = data
})
.finally(() => {
selectedTableListLoading.value = false
})
}
//
const deleteObj = (obj) => {
//
remove(dataArray.value, (item) => item.id === obj.id)
//
remove(recordIds.value, (item) => item === obj.id)
const value = []
const showData = []
dataArray.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
}
//
const loadData = () => {
//
if (!props.roleGlobal) {
searchFormState.value.category = 'ORG'
}
pageLoading.value = true
rolePage(searchFormState.value)
.then((data) => {
current.value = data.current
total.value = data.total
//
tableData.value = []
tableRecordNum.value = 0
tableData.value = data.records
if (data.records) {
tableRecordNum.value = data.records.length
} else {
tableRecordNum.value = 0
}
})
.finally(() => {
pageLoading.value = false
})
}
// pageSize
const paginationChange = (page, pageSize) => {
searchFormState.value.current = page
searchFormState.value.size = pageSize
loadData()
}
const judge = () => {
return !(props.radioModel && selectedData.value.length > 0)
}
//
const addRecord = (record) => {
if (!judge()) {
message.warning('只可选择一条')
return
}
const selectedRecord = selectedData.value.filter((item) => item.id === record.id)
if (selectedRecord.length === 0) {
selectedData.value.push(record)
} else {
message.warning('该记录已存在')
}
}
//
const addAllPageRecord = () => {
let newArray = selectedData.value.concat(tableData.value)
let list = []
for (let item1 of newArray) {
let flag = true
for (let item2 of list) {
if (item1.id === item2.id) {
flag = false
}
}
if (flag) {
list.push(item1)
}
}
selectedData.value = list
}
//
const delRecord = (record) => {
remove(selectedData.value, (item) => item.id === record.id)
}
//
const delAllRecord = () => {
selectedData.value = []
}
//
const treeSelect = (selectedKeys) => {
searchFormState.value.current = 0
if (selectedKeys.length > 0) {
if (selectedKeys[0] === 'GLOBAL') {
searchFormState.value.category = selectedKeys[0]
delete searchFormState.value.orgId
} else {
searchFormState.value.orgId = selectedKeys.toString()
delete searchFormState.value.category
}
} else {
delete searchFormState.value.category
delete searchFormState.value.orgId
}
loadData()
}
const dataArray = ref([])
//
const handleOk = () => {
dataArray.value = []
const value = []
const showData = []
selectedData.value.forEach((item) => {
const obj = {
id: item.id,
name: item.name
}
value.push(item.id)
// obj
const objClone = cloneDeep(obj)
showData.push(objClone)
})
dataArray.value = showData
//
const resultData = outDataConverter(value)
emit('update:value', resultData)
emit('onBack', resultData)
handleClose()
}
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => {
searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
current.value = 0
pageSize.value = 20
total.value = 0
selectedData.value = []
// dataArray.value = []
visible.value = false
}
//
const goDataConverter = (data) => {
if (props.dataIsConverterFlw) {
const resultData = []
//
if (!isEmpty(data.value)) {
const values = data.value.split(',')
if (values.length > 0) {
values.forEach((id) => {
resultData.push(id)
})
} else {
resultData.push(data.value)
}
} else {
//
if (!isEmpty(data) && !isEmpty(data[0]) && !isEmpty(data[0].value)) {
const values = data[0].value.split(',')
for (let i = 0; i < values.length; i++) {
resultData.push(values[i])
}
}
}
return resultData
} else {
if (getValueType() !== 'string') {
return data
}
if (data.length > 1) {
const resultData = []
data.split(',').forEach((id) => {
resultData.push(id)
})
return resultData
} else {
return data
}
}
}
//
const outDataConverter = (data) => {
if (props.dataIsConverterFlw) {
data = dataArray.value
const obj = {}
let label = ''
let value = ''
for (let i = 0; i < data.length; i++) {
if (data.length === i + 1) {
label = label + data[i].name
value = value + data[i].id
} else {
label = label + data[i].name + ','
value = value + data[i].id + ','
}
}
obj.key = 'ROLE'
obj.label = label
obj.value = value
obj.extJson = ''
return obj
} else {
if (getValueType() !== 'string') {
return data
}
let resultData = ''
data.forEach((id) => {
resultData = resultData + ',' + id
})
resultData = resultData.substring(1, resultData.length)
return resultData
}
}
//
const getValueType = () => {
if (props.dataType) {
return props.dataType
} else {
if (props.radioModel) {
return 'string'
}
return typeof typeof props.value
}
}
const getDataNameById = (ids) => {
if (isEmpty(dataArray.value) && !isEmpty(ids)) {
const param = {
idList: recordIds.value
}
//
roleListByIdList(param).then((data) => {
dataArray.value = data
})
}
}
watch(
() => props.value,
(newValue) => {
if (!isEmpty(props.value)) {
const ids = goDataConverter(newValue)
recordIds.value = ids
getDataNameById(ids)
}
},
{
immediate: true //
}
)
defineExpose({
showModel
})
</script>
<style lang="less" scoped>
.xn-mr-5 {
margin-right: 5px;
}
.xn-mr-10 {
margin-right: 10px;
}
.selectorTreeDiv {
max-height: 500px;
overflow: auto;
}
.ant-form-item {
margin-bottom: 0 !important;
}
.selector-table {
overflow: auto;
max-height: 450px;
}
</style>

View File

@ -1,6 +1,6 @@
<template>
<!-- 这是引入后展示的样式 -->
<div style="display: flex" v-if="props.userShow">
<a-flex wrap="wrap" gap="small" v-if="props.userShow">
<div
class="user-container"
v-for="(user, index) in userObj"
@ -22,7 +22,7 @@
<PlusOutlined />
</a-button>
<slot name="button"></slot>
</div>
</a-flex>
<!-- 以下是弹窗内容 -->
<a-modal
@ -137,6 +137,7 @@
<script setup name="userSelector">
import { message } from 'ant-design-vue'
import { remove, isEmpty, cloneDeep } from 'lodash-es'
import userCenterApi from '@/api/sys/userCenterApi'
//
const visible = ref(false)
const deleteShow = ref('')
@ -187,16 +188,13 @@
default: () => false
},
orgTreeApi: {
type: Function,
default: () => undefined
type: Function
},
userPageApi: {
type: Function,
default: () => undefined
type: Function
},
userListByIdListApi: {
type: Function,
default: () => undefined
type: Function
},
value: {
default: () => ''
@ -238,6 +236,16 @@
const current = ref(0) //
const pageSize = ref(20) //
const total = ref(0) //
// api
const userListByIdList = (param) => {
if (typeof props.userListByIdListApi === 'function') {
return props.userListByIdListApi(param)
} else {
return userCenterApi.userCenterGetUserListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
//
const showUserPlusModal = (ids = []) => {
const data = goDataConverter(ids)
@ -260,10 +268,6 @@
message.warning('未配置选择器需要的userPageApi接口')
return
}
if (typeof props.userListByIdListApi !== 'function') {
message.warning('未配置选择器需要的userListByIdListApi接口')
return
}
visible.value = true
//
props
@ -291,23 +295,20 @@
})
searchFormState.value.size = pageSize.value
loadData()
if (props.userListByIdListApi) {
if (isEmpty(recordIds.value)) {
return
}
const param = {
idList: recordIds.value
}
selectedTableListLoading.value = true
props
.userListByIdListApi(param)
.then((data) => {
selectedData.value = data
})
.finally(() => {
selectedTableListLoading.value = false
})
if (isEmpty(recordIds.value)) {
return
}
const param = {
idList: recordIds.value
}
selectedTableListLoading.value = true
userListByIdList(param)
.then((data) => {
selectedData.value = data
})
.finally(() => {
selectedTableListLoading.value = false
})
}
//
const deleteUser = (user) => {
@ -543,7 +544,7 @@
idList: recordIds.value
}
//
props.userListByIdListApi(param).then((data) => {
userListByIdList(param).then((data) => {
userObj.value = data
})
}

View File

@ -363,6 +363,8 @@ body,
.gen-preview-content,
.ant-menu,
.ant-tabs-dropdown-menu,
.xn-table,
.selector-table,
.admin-ui-main{
&::-webkit-scrollbar {

View File

@ -43,7 +43,6 @@
<xn-user-selector
:org-tree-api="selectorApiFunction.orgTreeApi"
:user-page-api="selectorApiFunction.userPageApi"
:user-list-by-id-list-api="selectorApiFunction.checkedUserListApi"
:radio-model="true"
v-model:value="formData.directorId"
/>
@ -59,7 +58,6 @@
<script setup name="bizOrgForm">
import { required } from '@/utils/formRules'
import bizOrgApi from '@/api/biz/bizOrgApi'
import userCenterApi from '@/api/sys/userCenterApi'
import tool from '@/utils/tool'
// emit
@ -144,11 +142,6 @@
return bizOrgApi.orgUserSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedUserListApi: (param) => {
return userCenterApi.userCenterGetUserListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
//

View File

@ -145,11 +145,11 @@
</a-col>
</a-row>
<Form ref="formRef" @successful="tableRef.refresh()" />
<role-selector-plus
<xn-role-selector
ref="RoleSelectorPlusRef"
:org-tree-api="selectorApiFunction.orgTreeApi"
:role-page-api="selectorApiFunction.rolePageApi"
:checked-role-list-api="selectorApiFunction.checkedRoleListApi"
:add-show="false"
:role-global="true"
@onBack="roleBack"
/>
@ -161,8 +161,6 @@
import downloadUtil from '@/utils/downloadUtil'
import bizUserApi from '@/api/biz/bizUserApi'
import bizOrgApi from '@/api/biz/bizOrgApi'
import userCenterApi from '@/api/sys/userCenterApi'
import RoleSelectorPlus from '@/components/Selector/roleSelectorPlus.vue'
import Form from './form.vue'
const columns = [
@ -369,7 +367,7 @@
id: record.id
}
bizUserApi.userOwnRole(param).then((data) => {
RoleSelectorPlusRef.value.showRolePlusModal(data)
RoleSelectorPlusRef.value.showModel(data)
})
}
//
@ -380,7 +378,7 @@
}
if (value.length > 0) {
value.forEach((item) => {
params.roleIdList.push(item.id)
params.roleIdList.push(item)
})
}
bizUserApi.grantRole(params).then(() => {})
@ -409,11 +407,6 @@
return bizUserApi.userRoleSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedRoleListApi: (param) => {
return userCenterApi.userCenterGetRoleListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
</script>

View File

@ -19,7 +19,6 @@
<xn-user-selector
:org-tree-api="selectorApiFunction.orgTreeApi"
:user-page-api="selectorApiFunction.userPageApi"
:user-list-by-id-list-api="selectorApiFunction.checkedUserListApi"
data-type="object"
v-model:value="formData.receiverIdList"
/>
@ -37,7 +36,6 @@
import { message } from 'ant-design-vue'
import messageApi from '@/api/dev/messageApi'
import userApi from '@/api/sys/userApi'
import userCenterApi from '@/api/sys/userCenterApi'
import tool from '@/utils/tool'
const sendLoading = ref(false)
@ -94,11 +92,6 @@
return userApi.userSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedUserListApi: (param) => {
return userCenterApi.userCenterGetUserListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
//

View File

@ -43,7 +43,6 @@
<xn-user-selector
:org-tree-api="selectorApiFunction.orgTreeApi"
:user-page-api="selectorApiFunction.userPageApi"
:user-list-by-id-list-api="selectorApiFunction.checkedUserListApi"
:radio-model="true"
v-model:value="formData.directorId"
/>
@ -59,7 +58,6 @@
<script setup name="orgForm">
import { required } from '@/utils/formRules'
import orgApi from '@/api/sys/orgApi'
import userCenterApi from '@/api/sys/userCenterApi'
import tool from '@/utils/tool'
// emit
@ -144,11 +142,6 @@
return orgApi.orgUserSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedUserListApi: (param) => {
return userCenterApi.userCenterGetUserListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
//

View File

@ -106,7 +106,6 @@
ref="userSelectorPlusRef"
:org-tree-api="selectorApiFunction.orgTreeApi"
:user-page-api="selectorApiFunction.userPageApi"
:user-list-by-id-list-api="selectorApiFunction.checkedUserListApi"
data-type="object"
:user-show="false"
@onBack="userCallBack"
@ -118,7 +117,6 @@
import { isEmpty } from 'lodash-es'
import roleApi from '@/api/sys/roleApi'
import orgApi from '@/api/sys/orgApi'
import userCenterApi from '@/api/sys/userCenterApi'
import GrantResourceForm from './grantResourceForm.vue'
import GrantMobileResourceForm from './grantMobileResourceForm.vue'
import GrantPermissionForm from './grantPermissionForm.vue'
@ -290,11 +288,6 @@
return roleApi.roleUserSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedUserListApi: (param) => {
return userCenterApi.userCenterGetUserListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
</script>

View File

@ -140,11 +140,12 @@
</a-col>
</a-row>
<Form ref="formRef" @successful="tableRef.refresh()" />
<role-selector-plus
<xn-role-selector
ref="RoleSelectorPlusRef"
:org-tree-api="selectorApiFunction.orgTreeApi"
:role-page-api="selectorApiFunction.rolePageApi"
:checked-role-list-api="selectorApiFunction.checkedRoleListApi"
:add-show="false"
:role-global="true"
@onBack="roleBack"
/>
<ImpExp ref="ImpExpRef" />
@ -159,8 +160,6 @@
import downloadUtil from '@/utils/downloadUtil'
import userApi from '@/api/sys/userApi'
import orgApi from '@/api/sys/orgApi'
import userCenterApi from '@/api/sys/userCenterApi'
import RoleSelectorPlus from '@/components/Selector/roleSelectorPlus.vue'
import Form from './form.vue'
import ImpExp from './impExp.vue'
import GrantResourceForm from './grantResourceForm.vue'
@ -365,7 +364,7 @@
id: record.id
}
userApi.userOwnRole(param).then((data) => {
RoleSelectorPlusRef.value.showRolePlusModal(data)
RoleSelectorPlusRef.value.showModel(data)
})
}
//
@ -376,7 +375,7 @@
}
if (value.length > 0) {
value.forEach((item) => {
params.roleIdList.push(item.id)
params.roleIdList.push(item)
})
}
userApi.grantRole(params).then(() => {})
@ -405,11 +404,6 @@
return userApi.userRoleSelector(param).then((data) => {
return Promise.resolve(data)
})
},
checkedRoleListApi: (param) => {
return userCenterApi.userCenterGetRoleListByIdList(param).then((data) => {
return Promise.resolve(data)
})
}
}
</script>