1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<BasicModal width="40%" v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<Tabs default-active-key="1" @change="changeTabs">
<Tabs.TabPane key="1" tab="用户">
<BasicTree
:treeData="treeData"
:checkable="true"
:defaultExpandAll="true"
@check="handleCheck"
/>
</Tabs.TabPane>
<Tabs.TabPane key="2" tab="角色">
<a-input placeholder="请输入" v-model:value="valueRef" />
<div>
<Checkbox
v-model:checked="state.checkAll"
:indeterminate="state.indeterminate"
@change="onCheckAllChange"
>
全部角色
</Checkbox>
</div>
<a-divider />
<CheckboxGroup v-model:value="state.checkedList" :options="plainOptions" />
</Tabs.TabPane>
<Tabs.TabPane key="3" tab="机构">
<BasicTree
:treeData="treeDataTwo"
:checkable="true"
:defaultExpandAll="true"
@check="handleCheck"
/>
</Tabs.TabPane>
</Tabs>
</BasicModal>
</template>
<script lang="ts" setup>
import { Card, Col, Row, Space, message,Tabs,Badge,Checkbox,CheckboxGroup } from 'ant-design-vue';
import {ref, computed, unref, reactive,watch} from 'vue';
import {BasicModal, useModal, useModalInner} from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { formSchema } from './protectionRules.data';
import { BasicTree, TreeActionType, TreeItem } from '@/components/Tree';
import {treeData,treeDataTwo} from './mock'
import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const valueRef = ref('');
const plainOptions = ['系统管理员', '工作组管理员', '工作组开发者', '工作组访客'];
const state = reactive({
indeterminate: true,
checkAll: false,
checkedList: ['工作组管理员'],
});
const onCheckAllChange = (e: any) => {
Object.assign(state, {
checkedList: e.target.checked ? plainOptions : [],
indeterminate: false,
});
};
watch(
() => state.checkedList,
val => {
state.indeterminate = !!val.length && val.length < plainOptions.length;
state.checkAll = val.length === plainOptions.length;
},
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { lg: 24, md: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
// 通过id获取行详情信息
// 塞值
setFieldsValue({
...data.record,
});
}
});
const getTitle = computed(() => ('添加对象'));
function changeTabs(activeKey: any) {
console.log('activeKey',activeKey)
}
async function handleSubmit() {
closeModal();
}
</script>
<style lang="scss" scoped>
.choseOB_title{
font-weight: 600;
}
::v-deep.ant-checkbox-group{
display: grid;
}
</style>