修正ts类型
This commit is contained in:
@@ -31,10 +31,10 @@
|
||||
|
||||
<!-- 填空题/多行文本展示 -->
|
||||
<div v-else-if="q.type === 'input'" class="input-placeholder">
|
||||
<el-input v-model="q.placeholder" placeholder="用户输入区域" />
|
||||
<el-input disabled placeholder="用户输入区域" />
|
||||
</div>
|
||||
<div v-else-if="q.type === 'textarea'" class="input-placeholder">
|
||||
<el-input type="textarea" v-model="q.placeholder" placeholder="用户输入区域" />
|
||||
<el-input disabled type="textarea" placeholder="用户输入区域" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,7 +90,8 @@ function init() {
|
||||
getQuestionnaire(viewid.value).then((res) => {
|
||||
viewData.value = {
|
||||
...viewData.value,
|
||||
...res.data
|
||||
...res.data,
|
||||
content: [] as QuestionComponentItem[]
|
||||
};
|
||||
if (typeof res.data.content === 'string') {
|
||||
viewData.value.content = JSON.parse(res.data.content) as QuestionComponentItem[];
|
||||
|
||||
@@ -82,9 +82,8 @@ import QuestionnaireEdit from './components/QuestionnaireEdit.vue';
|
||||
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { Delete, DocumentAdd } from '@element-plus/icons-vue';
|
||||
import { getQuestionnaire } from '../test/api';
|
||||
import { QuestionnaireForm, QuestionnaireVO } from '@/api/system/Questionnaire/type';
|
||||
import { addQuestionnaire, updateQuestionnaire } from '@/api/system/Questionnaire';
|
||||
import { QuestionComponentnaireForm, QuestionnaireForm, QuestionnaireVO } from '@/api/system/Questionnaire/type';
|
||||
import { addQuestionnaire, getQuestionnaire, updateQuestionnaire } from '@/api/system/Questionnaire';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_questionnaire_scope } = toRefs<any>(proxy?.useDict('com_questionnaire_scope'));
|
||||
@@ -119,14 +118,13 @@ function delteUse(id: string | number) {
|
||||
}
|
||||
// ! 编辑问卷 ------------------------------------------------------------------------
|
||||
const questionnaireEditRef = ref<InstanceType<typeof QuestionnaireEdit>>();
|
||||
const editData = ref<QuestionnaireVO | null>(null);
|
||||
const editData = ref<QuestionComponentnaireForm>(null);
|
||||
|
||||
// ! 路由参数 --------------------------------------------------------------------------------
|
||||
const userid = ref(null);
|
||||
|
||||
if (route.query.id) {
|
||||
userid.value = route.query.id;
|
||||
|
||||
handleEdit(userid.value);
|
||||
} else {
|
||||
handleAdd();
|
||||
@@ -146,9 +144,9 @@ async function handleEdit(id: string | number) {
|
||||
tableData.value = res.rows;
|
||||
// 父组件自己调用接口获取数据
|
||||
getQuestionnaire(id).then((res) => {
|
||||
editData.value = res.data;
|
||||
editData.value.content = JSON.parse(res.data.content);
|
||||
questionnaireEditRef.value?.init(res.data);
|
||||
editData.value = res.data as QuestionComponentnaireForm;
|
||||
editData.value.content = JSON.parse(res.data.content as string);
|
||||
questionnaireEditRef.value?.init(res.data as QuestionComponentnaireForm);
|
||||
form.value = {
|
||||
scope: res.data.scope,
|
||||
residents: res.data.residents,
|
||||
@@ -171,7 +169,7 @@ async function handleEdit(id: string | number) {
|
||||
}
|
||||
|
||||
// 保存草稿
|
||||
async function handleSave(data: QuestionnaireForm) {
|
||||
async function handleSave(data: QuestionComponentnaireForm) {
|
||||
try {
|
||||
// 父组件自己调用接口提交
|
||||
if (userid.value) {
|
||||
@@ -202,7 +200,7 @@ async function handleSave(data: QuestionnaireForm) {
|
||||
}
|
||||
|
||||
// 发布问卷
|
||||
async function handlePublish(data: QuestionnaireForm) {
|
||||
async function handlePublish(data: QuestionComponentnaireForm) {
|
||||
try {
|
||||
if (userid.value) {
|
||||
await updateQuestionnaire({
|
||||
|
||||
@@ -120,6 +120,8 @@ const initFormData: QuestionnaireForm = {
|
||||
status: undefined,
|
||||
scope: undefined,
|
||||
residents: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<QuestionnaireForm, QuestionnaireQuery>>({
|
||||
@@ -127,19 +129,10 @@ const data = reactive<PageData<QuestionnaireForm, QuestionnaireQuery>>({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
villageId: undefined,
|
||||
title: undefined,
|
||||
description: undefined,
|
||||
content: undefined,
|
||||
status: undefined,
|
||||
scope: undefined,
|
||||
residents: undefined,
|
||||
params: {}
|
||||
title: undefined
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '问卷ID不能为空', trigger: 'blur' }],
|
||||
title: [{ required: true, message: '问卷标题不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '问卷题目结构不能为空', trigger: 'blur' }]
|
||||
title: [{ required: true, message: '问卷标题不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user