Browse Source

chore: handle user picker

master
wangxiang 2 years ago
parent
commit
96c8cd1625
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 1
      .eslintrc.js
  2. 94
      src/views/workflow/task/TaskForm.vue
  3. 18
      src/views/workflow/task/popups/UserPicker/index.vue

1
.eslintrc.js

@ -116,5 +116,6 @@ module.exports = defineConfig({ @@ -116,5 +116,6 @@ module.exports = defineConfig({
'vue/no-v-html': 'off',
'vue/multi-word-component-names': 'off',
'vue/first-attribute-linebreak': 'off',
'vue/v-on-event-hyphenation': 'off',
}
});

94
src/views/workflow/task/TaskForm.vue

@ -128,7 +128,7 @@ @@ -128,7 +128,7 @@
/>
<a-button type="primary"
style="width: 48px"
@click="handleCCUserPicker"
@click="handleAssignUserPicker"
>
<Icon icon="fa6-solid:clipboard-user"/>
</a-button>
@ -142,7 +142,12 @@ @@ -142,7 +142,12 @@
<a-button size="large" type="primary" @click="test">审批</a-button>
<a-button size="large" type="primary" danger>驳回</a-button>
</footer>
<UserPicker @register="registerModal" @success="handleTransferTask"/>
<UserPicker :title="state.userPickerProps.title"
:limit="state.userPickerProps.limit"
@register="registerModal"
@ccEmit="handleCCEmit"
@assignEmit="handleAssignEmit"
/>
</div>
</template>
<script lang="ts" setup>
@ -189,47 +194,51 @@ @@ -189,47 +194,51 @@
//
formPath: string;
//
formReadOnly: boolean,
formReadOnly: boolean;
// ID
businessId: string,
businessId: string;
//
taskFormData: FormProperty[],
taskFormData: FormProperty[];
//
taskSelectedTab: string,
taskSelectedTab: string;
// ID
taskId: string,
taskId: string;
// key
taskDefKey: string,
taskDefKey: string;
// ID
processDefId: string,
processDefId: string;
// ID
processInsId: string,
processInsId: string;
// Key
processDefKey: string,
processDefKey: string;
//
status: string,
status: string;
//
historyFlowChangeList: Workflow[],
historyFlowChangeList: Workflow[];
//
buttons: Partial<WorkflowButton>[],
buttons: Partial<WorkflowButton>[];
//
isCC: boolean,
isCC: boolean;
//
isAssign: boolean,
isAssign: boolean;
//
auditForm: {
message: string,
mesCode: string,
mesName: string,
message: string;
mesCode: string;
mesName: string;
// ID
userIds: string[],
userIds: string[];
// ID
assignee: string,
assignee: string;
},
rulesRef: Recordable;
userPickerProps: {
title: string;
limit: number;
};
}
/** 通用变量统一声明区域 */
@ -276,8 +285,12 @@ @@ -276,8 +285,12 @@
assignee: ''
},
rulesRef: {
assignee: [{ required: true, whitespace: true, message: '用户不能为空', validateTrigger: 'blur' }],
userIds: [{ required: true, type: 'array', message: '用户不能为空', validateTrigger: 'blur' }]
userIds: [{ required: true, type: 'array', message: '抄送用户不能为空', validateTrigger: 'blur' }],
assignee: [{ required: true, whitespace: true, message: '处理用户不能为空', validateTrigger: 'blur' }]
},
userPickerProps: {
title: '任务表单用户选择器',
limit: 0,
}
});
const { currentRoute, push } = useRouter();
@ -345,9 +358,11 @@ @@ -345,9 +358,11 @@
state.formReadOnly = query.formReadOnly === 'true';
state.isCC = false;
state.isAssign = false;
state.auditForm.assignee = '1510539584287346688';
state.auditForm.userIds = ['1510539584287346688'];
state.auditForm.assignee = '';
state.auditForm.userIds = [];
state.auditForm.message = '';
state.userPickerProps.title = '任务表单用户选择器';
state.userPickerProps.limit = 0;
}
/** 流程抄送 */
@ -421,9 +436,34 @@ @@ -421,9 +436,34 @@
});
}
/** 抄送 */
function handleCCUserPicker() {
openModal(true,{ record: { ids: [], emitEventName: 'test' } });
state.userPickerProps.title = '抄送用户选择';
state.userPickerProps.limit = 0;
openModal(true,{
record: {
ids: state.auditForm.userIds,
emitEventName: 'ccEmit'
}
});
}
function handleCCEmit(rows: KiccUser[]) {
state.auditForm.userIds = rows.map(item => item.id);
}
function handleAssignUserPicker() {
state.userPickerProps.title = '代理用户选择';
state.userPickerProps.limit = 1;
openModal(true,{
record: {
ids: [ state.auditForm.assignee ],
emitEventName: 'assignEmit'
}
});
}
function handleAssignEmit(rows: KiccUser[]) {
state.auditForm.assignee = rows[0].id;
}
/** 转办 */

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

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved.
* author wangxiang4
*/
import { reactive, ref, toRaw } from 'vue';
import { reactive, ref, toRaw, watch } from 'vue';
import { BasicTable, useTable } from '/@/components/Table';
import DeptTree from '/@/views/system/user/DeptTree.vue';
import { listUser } from '/@/api/platform/system/controller/user';
@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
//
emitEventName: ''
});
const [registerTable, { reload, clearSelectedRowKeys, getSelectRows, setSelectedRowKeys }] = useTable({
const [registerTable, { reload, clearSelectedRowKeys, getSelectRows, setSelectedRowKeys, setProps }] = useTable({
title: '用户列表',
api: listUser,
rowKey: 'id',
@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
},
maxHeight: 450,
rowSelection: { type: props.limit == 1 ? 'radio' : 'checkbox' },
rowSelection: { type: 'checkbox' },
useSearchForm: true,
showTableSetting: true,
bordered: true,
@ -77,6 +77,12 @@ @@ -77,6 +77,12 @@
searchInfo: state.searchInfo,
handleSearchInfoFn: () => clearSelectedRowKeys()
});
watch(() => props.limit, limit => {
const rowSelectType = limit === 1 ? 'radio' : 'checkbox';
setProps({
rowSelection: { type: rowSelectType },
});
});
const modal = ref();
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register'] as Recordable);
@ -125,8 +131,10 @@ @@ -125,8 +131,10 @@
/** 处理弹出框提交 */
async function handleSubmit() {
try {
if (props.limit !== 0 && props.limit < getSelectRows().length) {
return createMessage.error(`你最多只能选择${props.limit}个用户`);
if (getSelectRows().length === 0) {
return createMessage.error('请选择一个用户!');
} else if (props.limit !== 0 && props.limit < getSelectRows().length) {
return createMessage.error(`最多只能选择${props.limit}个用户!`);
}
closeModal();
if (props.emitEventNameClosable) {

Loading…
Cancel
Save