表单创建页面及只读页面修改,formlist列表跳转修改
This commit is contained in:
@ -173,32 +173,29 @@ function getTaskRecords() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (unref(taskId)) {
|
||||
try {
|
||||
let res = await getApprovalProcess(unref(taskId), unref(processId));
|
||||
initProcessData(res);
|
||||
if (!readonly.value) {
|
||||
if (res.buttonConfigs) {
|
||||
approvalData.buttonConfigs = res.buttonConfigs;
|
||||
}
|
||||
if (res.relationTasks) {
|
||||
data.predecessorTasks = res.relationTasks;
|
||||
}
|
||||
if (res.isAddOrSubSign) {
|
||||
approvalData.isAddOrSubSign = res.isAddOrSubSign;
|
||||
}
|
||||
|
||||
approvalData.approvedType = ApproveType.AGREE;
|
||||
approvedType.value = ApproveType.AGREE;
|
||||
approvalData.approvedContent = '';
|
||||
approvalData.rejectNodeActivityId = '';
|
||||
approvalData.rejectNodeActivityIds = [];
|
||||
approvalData.circulateConfigs = [];
|
||||
try {
|
||||
let res = await getApprovalProcess(unref(taskId), unref(processId));
|
||||
initProcessData(res);
|
||||
if (!readonly.value) {
|
||||
if (res.buttonConfigs) {
|
||||
approvalData.buttonConfigs = res.buttonConfigs;
|
||||
}
|
||||
renderKey.value = Math.random() + '';
|
||||
} catch (error) { }
|
||||
} else {
|
||||
}
|
||||
if (res.relationTasks) {
|
||||
data.predecessorTasks = res.relationTasks;
|
||||
}
|
||||
if (res.isAddOrSubSign) {
|
||||
approvalData.isAddOrSubSign = res.isAddOrSubSign;
|
||||
}
|
||||
|
||||
approvalData.approvedType = ApproveType.AGREE;
|
||||
approvedType.value = ApproveType.AGREE;
|
||||
approvalData.approvedContent = '';
|
||||
approvalData.rejectNodeActivityId = '';
|
||||
approvalData.rejectNodeActivityIds = [];
|
||||
approvalData.circulateConfigs = [];
|
||||
}
|
||||
renderKey.value = Math.random() + '';
|
||||
} catch (error) { }
|
||||
});
|
||||
|
||||
async function submit() {
|
||||
|
||||
@ -21,121 +21,123 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useRouter } from 'vue-router';
|
||||
import { FromPageType } from '/@/enums/workflowEnum';
|
||||
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
import useEventBus from '/@/hooks/event/useEventBus';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { FromPageType } from '/@/enums/workflowEnum';
|
||||
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
import useEventBus from '/@/hooks/event/useEventBus';
|
||||
|
||||
const dynamicComponent = ref(null);
|
||||
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||
const formRef = ref();
|
||||
const props = defineProps({});
|
||||
const { bus, FORM_LIST_MODIFIED } = useEventBus();
|
||||
const dynamicComponent = ref(null);
|
||||
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||
const formRef = ref();
|
||||
const props = defineProps({});
|
||||
const { bus, FORM_LIST_MODIFIED } = useEventBus();
|
||||
|
||||
const router = useRouter();
|
||||
const { currentRoute } = router;
|
||||
const router = useRouter();
|
||||
const { currentRoute } = router;
|
||||
|
||||
const { formPath } = currentRoute.value.query;
|
||||
const pathArr = formPath.split('/');
|
||||
const { formPath } = currentRoute.value.query;
|
||||
const pathArr = formPath.split('/');
|
||||
|
||||
const tabStore = useMultipleTabStore();
|
||||
const formProps = ref(null);
|
||||
const formId = ref(currentRoute.value?.params?.id);
|
||||
const tabStore = useMultipleTabStore();
|
||||
const formProps = ref(null);
|
||||
console.error(currentRoute.value)
|
||||
const formId = ref(currentRoute.value?.params?.id);
|
||||
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const hash = location.hash;
|
||||
const mode = ref('read');
|
||||
if (hash.indexOf('createForm') > 0) {
|
||||
mode.value = 'create';
|
||||
} else if (hash.indexOf('updateForm') > 0) {
|
||||
mode.value = 'update';
|
||||
} else if (hash.indexOf('viewForm') > 0) {
|
||||
mode.value = 'view';
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const hash = location.hash;
|
||||
const mode = ref('read');
|
||||
if (hash.indexOf('createForm') > 0) {
|
||||
mode.value = 'create';
|
||||
} else if (hash.indexOf('updateForm') > 0) {
|
||||
mode.value = 'update';
|
||||
} else if (hash.indexOf('viewForm') > 0) {
|
||||
mode.value = 'view';
|
||||
}
|
||||
|
||||
dynamicComponent.value = defineAsyncComponent({
|
||||
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
||||
});
|
||||
|
||||
function onFormMounted(_formProps) {
|
||||
formProps.value = _formProps;
|
||||
setFormType();
|
||||
}
|
||||
|
||||
async function setFormType() {
|
||||
const _mode = mode.value;
|
||||
if (_mode === 'create') {
|
||||
return;
|
||||
}
|
||||
|
||||
dynamicComponent.value = defineAsyncComponent({
|
||||
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
||||
});
|
||||
|
||||
function onFormMounted(_formProps) {
|
||||
formProps.value = _formProps;
|
||||
setFormType();
|
||||
await nextTick();
|
||||
if (_mode === 'view') {
|
||||
await formRef.value.setDisabledForm();
|
||||
}
|
||||
// console.error(55555, _formProps)
|
||||
await formRef.value.setFormDataFromId(formId.value);
|
||||
}
|
||||
|
||||
async function setFormType() {
|
||||
const _mode = mode.value;
|
||||
if (_mode === 'create') {
|
||||
return;
|
||||
function close() {
|
||||
tabStore.closeTab(currentRoute.value, router);
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const saveSuccess = await saveModal();
|
||||
if (saveSuccess) {
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: formType.value === '0' ? t('新增成功!') : t('修改成功!')
|
||||
}); //提示消息
|
||||
formRef.value.resetFields();
|
||||
setTimeout(() => {
|
||||
bus.emit(FORM_LIST_MODIFIED, { path: formPath, mode });
|
||||
close();
|
||||
}, 1000);
|
||||
}
|
||||
await nextTick();
|
||||
if (_mode === 'view') {
|
||||
await formRef.value.setDisabledForm();
|
||||
}
|
||||
await formRef.value.setFormDataFromId(formId.value);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
tabStore.closeTab(currentRoute.value, router);
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const saveSuccess = await saveModal();
|
||||
if (saveSuccess) {
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: formType.value === '0' ? t('新增成功!') : t('修改成功!')
|
||||
}); //提示消息
|
||||
formRef.value.resetFields();
|
||||
setTimeout(() => {
|
||||
bus.emit(FORM_LIST_MODIFIED, { path: formPath, mode });
|
||||
close();
|
||||
}, 1000);
|
||||
}
|
||||
} finally {
|
||||
async function saveModal() {
|
||||
let saveSuccess = false;
|
||||
const _mode = mode.value;
|
||||
try {
|
||||
const values = await formRef.value?.validate();
|
||||
//添加隐藏组件
|
||||
if (formProps.hiddenComponent?.length) {
|
||||
formProps.hiddenComponent.forEach((component) => {
|
||||
values[component.bindField] = component.value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function saveModal() {
|
||||
let saveSuccess = false;
|
||||
const _mode = mode.value;
|
||||
try {
|
||||
const values = await formRef.value?.validate();
|
||||
//添加隐藏组件
|
||||
if (formProps.hiddenComponent?.length) {
|
||||
formProps.hiddenComponent.forEach((component) => {
|
||||
values[component.bindField] = component.value;
|
||||
});
|
||||
}
|
||||
if (values !== false) {
|
||||
try {
|
||||
if (_mode === 'create') {
|
||||
saveSuccess = await formRef.value.add(values);
|
||||
} else {
|
||||
saveSuccess = await formRef.value.update({ values, rowId: formId.value });
|
||||
}
|
||||
return saveSuccess;
|
||||
} catch (error) {}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('saveModal Error: ', error);
|
||||
if (values !== false) {
|
||||
try {
|
||||
if (_mode === 'create') {
|
||||
saveSuccess = await formRef.value.add(values);
|
||||
} else {
|
||||
saveSuccess = await formRef.value.update({ values, rowId: formId.value });
|
||||
}
|
||||
return saveSuccess;
|
||||
} catch (error) { }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('saveModal Error: ', error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.page-bg-wrap {
|
||||
background-color: #fff;
|
||||
}
|
||||
.page-bg-wrap {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.top-toolbar {
|
||||
min-height: 40px;
|
||||
margin-bottom: 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.top-toolbar {
|
||||
min-height: 40px;
|
||||
margin-bottom: 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user