Browse Source

chore: UserPicker make done

master
wangxiang 2 years ago
parent
commit
73831d1840
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 77
      src/views/workflow/task/popups/UserPicker/index.vue

77
src/views/workflow/task/popups/UserPicker/index.vue

@ -14,6 +14,15 @@
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { ScrollContainer } from '/@/components/Container'; import { ScrollContainer } from '/@/components/Container';
import { useAppStore } from '/@/store/modules/app'; import { useAppStore } from '/@/store/modules/app';
import { isArray } from '/@/utils/is';
import { useMessage } from '/@/hooks/web/useMessage';
import { propTypes } from '/@/utils/propTypes';
const props = defineProps({
limit: propTypes.number.def(0),
title: propTypes.string.def('用户选择'),
emitEventNameClosable: propTypes.bool.def(false)
});
/** 类型规范统一声明定义区域 */ /** 类型规范统一声明定义区域 */
interface TableState { interface TableState {
@ -21,13 +30,15 @@
single: boolean; single: boolean;
multiple: boolean; multiple: boolean;
searchInfo: Recordable; searchInfo: Recordable;
tag: string, tag: string;
emitEventName: string;
} }
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const appStore = useAppStore(); const appStore = useAppStore();
const darkMode = appStore.getDarkMode; const darkMode = appStore.getDarkMode;
const { prefixCls } = useDesign('user-picker'); const { prefixCls } = useDesign('user-picker');
const { createMessage } = useMessage();
const state = reactive<TableState>({ const state = reactive<TableState>({
// //
ids: [], ids: [],
@ -39,8 +50,10 @@
searchInfo: {}, searchInfo: {},
// //
tag: '', tag: '',
//
emitEventName: ''
}); });
const [registerTable, { reload, clearSelectedRowKeys, redoHeight }] = useTable({ const [registerTable, { reload, clearSelectedRowKeys, getSelectRows, setSelectedRowKeys }] = useTable({
title: '用户列表', title: '用户列表',
api: listUser, api: listUser,
rowKey: 'id', rowKey: 'id',
@ -66,29 +79,26 @@
}); });
const modal = ref(); const modal = ref();
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register'] as Recordable);
const [registerModal, { setModalProps, closeModal, changeLoading }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { const [registerModal, { setModalProps, closeModal, changeLoading }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
changeLoading(true); changeLoading(true);
// //
await handleRefreshTable();
// //
state.tag = data._tag; state.tag = data._tag;
const { ids, emitEventName } = data.record as Recordable;
const regionId = data.record?.id; isArray(ids) && setSelectedRowKeys(ids);
const props: Partial<ModalProps> = { confirmLoading: false }; const modalProps: Partial<ModalProps> = { title: props.title };
props.title = '用户选择'; state.emitEventName = emitEventName || 'success';
// tag // ,tag()
switch (state.tag) { switch (state.tag) {
case 'add': case 'single':
break; break;
case 'edit': case 'multiple':
break; break;
} }
// : // :
setModalProps(props); setModalProps(modalProps);
changeLoading(false); changeLoading(false);
}); });
@ -115,18 +125,15 @@
/** 处理弹出框提交 */ /** 处理弹出框提交 */
async function handleSubmit() { async function handleSubmit() {
try { try {
// tag if (props.limit !== 0 && props.limit < getSelectRows().length) {
switch (state.tag) { return createMessage.error(`你最多只能选择${props.limit}个用户`);
case 'add':
break;
case 'edit':
break;
} }
//
closeModal(); closeModal();
emit('success'); if (props.emitEventNameClosable) {
emit('success', state.emitEventName ,(getSelectRows()));
} else {
emit(state.emitEventName, toRaw(getSelectRows()));
}
} finally { } finally {
setModalProps({ confirmLoading: false }); setModalProps({ confirmLoading: false });
} }
@ -152,16 +159,12 @@
</a-layout-content> </a-layout-content>
<a-layout-sider :theme="darkMode"> <a-layout-sider :theme="darkMode">
<ScrollContainer class="pl-2"> <ScrollContainer class="pl-2">
<div v-loading="true"> <a-tag v-for="row in getSelectRows()"
<a-tag color="pink">pink</a-tag> :key="row.id"
<a-tag color="pink">pink</a-tag> color="processing"
<a-tag color="pink">pink</a-tag> >
<a-tag color="pink">pink</a-tag> {{ row.username }}
<a-tag color="pink">pink</a-tag> </a-tag>
<a-tag color="pink">pink</a-tag>
<a-tag color="pink">pink</a-tag>
<a-tag color="pink">pink</a-tag>
</div>
</ScrollContainer> </ScrollContainer>
</a-layout-sider> </a-layout-sider>
</a-layout> </a-layout>
@ -183,6 +186,10 @@
.scroll-container { .scroll-container {
max-height: 720px; max-height: 720px;
.ant-tag {
margin: 0 0 5px 8px;
}
} }
} }

Loading…
Cancel
Save