feat: 将草稿箱分拆为单独页面
This commit is contained in:
@ -285,7 +285,6 @@
|
||||
<style lang="less" scoped>
|
||||
.form-container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
</slot>
|
||||
提交
|
||||
</a-button>
|
||||
<a-button>
|
||||
<a-button @click="saveDraft" :disabled="disableSubmit">
|
||||
<slot name="icon">
|
||||
<clock-circle-outlined />
|
||||
</slot>
|
||||
@ -61,13 +61,19 @@
|
||||
const tabStore = useMultipleTabStore();
|
||||
|
||||
import { nextTick, onMounted, ref, toRaw } from 'vue';
|
||||
import { postDraft, putDraft } from '/@/api/workflow/process';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
|
||||
const { data, initProcessData } = userTaskItem();
|
||||
const { t } = useI18n();
|
||||
const { data, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
||||
const currentRoute = router.currentRoute;
|
||||
const rParams = currentRoute.value.query;
|
||||
const rSchemaId = rParams.schemaId;
|
||||
const rDraftsId = rParams.draftsId;
|
||||
const draftsJsonStr = localStorage.getItem('draftsJsonStr');
|
||||
let formInformation = ref();
|
||||
const showFlowChart = ref(false);
|
||||
const disableSubmit = ref(false);
|
||||
let randKey = ref('randkey'); // 强制表单重新渲染
|
||||
|
||||
function closeFlowChart() {
|
||||
@ -83,9 +89,6 @@
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
draftsJsonStr: {
|
||||
type: String
|
||||
},
|
||||
draftsId: {
|
||||
type: String
|
||||
},
|
||||
@ -138,17 +141,16 @@
|
||||
initProcessData(res);
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
await nextTick();
|
||||
initDraftsFormData();
|
||||
|
||||
randKey.value = Math.random() + '';
|
||||
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
|
||||
await nextTick();
|
||||
await initDraftsFormData();
|
||||
});
|
||||
|
||||
async function initDraftsFormData() {
|
||||
//isPublish.value = Object.keys(data.formInfos).length > 0 ? false : true;
|
||||
if (props.draftsJsonStr) {
|
||||
let formDataJson = JSON.parse(props.draftsJsonStr);
|
||||
if (draftsJsonStr) {
|
||||
let formDataJson = JSON.parse(draftsJsonStr);
|
||||
let formData = [];
|
||||
|
||||
data.formInfos.forEach((item) => {
|
||||
@ -159,6 +161,30 @@
|
||||
await formInformation.value.setFormData(formData);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
try {
|
||||
disableSubmit.value = true;
|
||||
let formModels = await formInformation.value.saveDraftData();
|
||||
if (rDraftsId) {
|
||||
let res = await putDraft(rSchemaId, formModels, rDraftsId, props.rowKeyData);
|
||||
showResult(res, t('保存草稿'));
|
||||
} else {
|
||||
let res = await postDraft(rSchemaId, formModels, props.rowKeyData);
|
||||
showResult(res, t('保存草稿'));
|
||||
}
|
||||
} catch (error) {
|
||||
notificationError(t('保存草稿'));
|
||||
}
|
||||
}
|
||||
|
||||
function showResult(res, title) {
|
||||
if (res) {
|
||||
notificationSuccess(title);
|
||||
} else {
|
||||
notificationError(title);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
});
|
||||
|
||||
const Drafts = defineAsyncComponent({
|
||||
loader: () => import('../workflow/task/components/processTasks/Drafts.vue')
|
||||
loader: () => import('../workflow/task/components/processTasks/DraftsV2.vue')
|
||||
});
|
||||
const componentByType: Map<string, any> = new Map([
|
||||
['ToDoTasks', ToDoTasks],
|
||||
|
||||
Reference in New Issue
Block a user