|
@@ -17,40 +17,37 @@
|
|
|
:model="currentForm"
|
|
:model="currentForm"
|
|
|
:options="formOptions"
|
|
:options="formOptions"
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <Button @click="navTo('/pages/test/test')">test</Button>
|
|
|
<H3>自查项目选择</H3>
|
|
<H3>自查项目选择</H3>
|
|
|
- <FlexCol gap="gap.md">
|
|
|
|
|
|
|
+ <FlexCol v-if="checkItemList && checkItemList.length > 0" gap="gap.md">
|
|
|
<FlexCol v-for="(item, index) in checkItemList" :key="item.id" gap="gap.md">
|
|
<FlexCol v-for="(item, index) in checkItemList" :key="item.id" gap="gap.md">
|
|
|
<Text fontConfig="subTitleText" :text="`${index + 1}. ${item.name}`" />
|
|
<Text fontConfig="subTitleText" :text="`${index + 1}. ${item.name}`" />
|
|
|
- <template v-if="item.checkType == 2">
|
|
|
|
|
- <FlexCol gap="gap.sm">
|
|
|
|
|
- <FlexRow v-for="child in item.children" :key="child.id" justify="space-between">
|
|
|
|
|
- <CheckBox
|
|
|
|
|
- :text="`${child.name} (${child.points}分)`"
|
|
|
|
|
- :modelValue="hasCheckedItem(child.id)"
|
|
|
|
|
- @update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
|
|
|
- />
|
|
|
|
|
- <Stepper
|
|
|
|
|
- v-if="hasCheckedItem(child.id)"
|
|
|
|
|
- :min="0"
|
|
|
|
|
- :max="20"
|
|
|
|
|
- :step="1"
|
|
|
|
|
- :modelValue="getCheckedItemCount(child.id) ?? 0"
|
|
|
|
|
- @update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
|
|
|
- />
|
|
|
|
|
- <view v-else></view>
|
|
|
|
|
- </FlexRow>
|
|
|
|
|
- </FlexCol>
|
|
|
|
|
- </template>
|
|
|
|
|
- <template v-else>
|
|
|
|
|
- <FlexCol gap="gap.sm">
|
|
|
|
|
- <CheckBox
|
|
|
|
|
- v-for="child in item.children" :key="child.id"
|
|
|
|
|
|
|
+ <FlexCol v-if="item.checkType == 2" gap="gap.sm">
|
|
|
|
|
+ <FlexRow v-for="child in item.children" :key="child.id" justify="space-between">
|
|
|
|
|
+ <CheckBox
|
|
|
:text="`${child.name} (${child.points}分)`"
|
|
:text="`${child.name} (${child.points}分)`"
|
|
|
:modelValue="hasCheckedItem(child.id)"
|
|
:modelValue="hasCheckedItem(child.id)"
|
|
|
@update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
@update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
|
/>
|
|
/>
|
|
|
- </FlexCol>
|
|
|
|
|
- </template>
|
|
|
|
|
|
|
+ <Stepper
|
|
|
|
|
+ v-if="hasCheckedItem(child.id)"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="20"
|
|
|
|
|
+ :step="1"
|
|
|
|
|
+ :modelValue="getCheckedItemCount(child.id) ?? 0"
|
|
|
|
|
+ @update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view v-else></view>
|
|
|
|
|
+ </FlexRow>
|
|
|
|
|
+ </FlexCol>
|
|
|
|
|
+ <FlexCol v-else gap="gap.sm">
|
|
|
|
|
+ <CheckBox
|
|
|
|
|
+ v-for="child in item.children" :key="child.id"
|
|
|
|
|
+ :text="`${child.name} (${child.points}分)`"
|
|
|
|
|
+ :modelValue="hasCheckedItem(child.id)"
|
|
|
|
|
+ @update:modelValue="setCheckedItem(item as CheckItemInfo, child as CheckItemInfo, $event)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </FlexCol>
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
<DynamicForm
|
|
<DynamicForm
|
|
@@ -102,14 +99,21 @@ import type { RadioValueProps } from '@/components/dynamic/wrappers/RadioValue';
|
|
|
import type { FieldProps } from '@/components/form/Field.vue';
|
|
import type { FieldProps } from '@/components/form/Field.vue';
|
|
|
import type { SignatureFieldProps } from '@/components/form/SignatureField.vue';
|
|
import type { SignatureFieldProps } from '@/components/form/SignatureField.vue';
|
|
|
import { useImageSimpleUploadCo } from '@/common/components/upload/ImageUploadCo';
|
|
import { useImageSimpleUploadCo } from '@/common/components/upload/ImageUploadCo';
|
|
|
|
|
+import { navTo } from '@/components/utils/PageAction';
|
|
|
|
|
+
|
|
|
|
|
+let loaded = false;
|
|
|
|
|
|
|
|
const { querys } = useLoadQuerys({
|
|
const { querys } = useLoadQuerys({
|
|
|
id: 0,
|
|
id: 0,
|
|
|
}, () => {
|
|
}, () => {
|
|
|
|
|
+ if (loaded)
|
|
|
|
|
+ return;
|
|
|
|
|
+ loaded = true;
|
|
|
loader.load();
|
|
loader.load();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const currentForm = ref<SelfAssessmentDetail | null>(null);
|
|
const currentForm = ref<SelfAssessmentDetail | null>(null);
|
|
|
|
|
+const currentFormCheckItems = ref<SelfAssessmentCheckItemAnswer[]>([]);
|
|
|
const authStore = useAuthStore();
|
|
const authStore = useAuthStore();
|
|
|
|
|
|
|
|
const form1Ref = ref<IDynamicFormRef | null>(null);
|
|
const form1Ref = ref<IDynamicFormRef | null>(null);
|
|
@@ -247,8 +251,10 @@ const formOptionsEnd = ref<IDynamicFormOptions>({
|
|
|
label: '传承人签名',
|
|
label: '传承人签名',
|
|
|
name: 'sign',
|
|
name: 'sign',
|
|
|
type: 'sign',
|
|
type: 'sign',
|
|
|
|
|
+ formProps: {
|
|
|
|
|
+ showRightArrow: true,
|
|
|
|
|
+ },
|
|
|
additionalProps: {
|
|
additionalProps: {
|
|
|
- placeholder: '请签名',
|
|
|
|
|
upload: useImageSimpleUploadCo(),
|
|
upload: useImageSimpleUploadCo(),
|
|
|
} as SignatureFieldProps,
|
|
} as SignatureFieldProps,
|
|
|
}
|
|
}
|
|
@@ -265,8 +271,7 @@ const checkItemList = ref<CheckItemInfo[]>([]);
|
|
|
const totalPoints = computed(() => {
|
|
const totalPoints = computed(() => {
|
|
|
if (!currentForm.value)
|
|
if (!currentForm.value)
|
|
|
return 0;
|
|
return 0;
|
|
|
- console.log(currentForm.value?.checkItems);
|
|
|
|
|
- return Object.values(currentForm.value.checkItems).reduce((acc, item) => acc + (item.count * item.points), 0);
|
|
|
|
|
|
|
+ return currentFormCheckItems.value.reduce((acc, item) => acc + (item.count * item.points), 0);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
async function loadBasicInfo() {
|
|
async function loadBasicInfo() {
|
|
@@ -284,12 +289,14 @@ async function loadBasicInfo() {
|
|
|
async function loadCheckItems() {
|
|
async function loadCheckItems() {
|
|
|
assertNotNull(currentForm.value, 'currentForm is null');
|
|
assertNotNull(currentForm.value, 'currentForm is null');
|
|
|
checkItemList.value = await AssessmentContentApi.getCheckItems(Number(currentForm.value.level));
|
|
checkItemList.value = await AssessmentContentApi.getCheckItems(Number(currentForm.value.level));
|
|
|
|
|
+ currentFormCheckItems.value = currentForm.value.checkItems.concat();
|
|
|
}
|
|
}
|
|
|
function hasCheckedItem(id: number) {
|
|
function hasCheckedItem(id: number) {
|
|
|
- return currentForm.value?.checkItems.some(item => item.id === id);
|
|
|
|
|
|
|
+ return currentFormCheckItems.value.some(item => item.id === id);
|
|
|
}
|
|
}
|
|
|
function getCheckedItemCount(id: number) {
|
|
function getCheckedItemCount(id: number) {
|
|
|
- return currentForm.value?.checkItems.find(item => item.id === id)?.count;
|
|
|
|
|
|
|
+ console.log('getCheckedItemCount', id);
|
|
|
|
|
+ return currentFormCheckItems.value.find(item => item.id === id)?.count;
|
|
|
}
|
|
}
|
|
|
function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, count: number|boolean) {
|
|
function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, count: number|boolean) {
|
|
|
if (!currentForm.value)
|
|
if (!currentForm.value)
|
|
@@ -297,11 +304,14 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
|
|
|
if (typeof count === 'boolean') {
|
|
if (typeof count === 'boolean') {
|
|
|
count = count ? 1 : 0;
|
|
count = count ? 1 : 0;
|
|
|
}
|
|
}
|
|
|
- let item = currentForm.value.checkItems.find(item => item.id === childItem.id);
|
|
|
|
|
|
|
+ console.log('setCheckedItem', childItem.id, count);
|
|
|
|
|
+ let item = currentFormCheckItems.value.find(item => item.id === childItem.id);
|
|
|
if (!item) {
|
|
if (!item) {
|
|
|
item = new SelfAssessmentCheckItemAnswer();
|
|
item = new SelfAssessmentCheckItemAnswer();
|
|
|
- currentForm.value.checkItems.push(item);
|
|
|
|
|
|
|
+ currentFormCheckItems.value.push(item);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (item.count === count)
|
|
|
|
|
+ return;
|
|
|
item.id = childItem.id;
|
|
item.id = childItem.id;
|
|
|
item.points = childItem.points;
|
|
item.points = childItem.points;
|
|
|
item.count = count;
|
|
item.count = count;
|
|
@@ -309,7 +319,7 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
|
|
|
case 1: {
|
|
case 1: {
|
|
|
/** 单选,清除其他选项 */
|
|
/** 单选,清除其他选项 */
|
|
|
const allChildren = checkItem.children.map(child => child.id);
|
|
const allChildren = checkItem.children.map(child => child.id);
|
|
|
- currentForm.value?.checkItems.forEach(item => {
|
|
|
|
|
|
|
+ currentFormCheckItems.value.forEach(item => {
|
|
|
if (allChildren.includes(item.id) && item.id !== childItem.id)
|
|
if (allChildren.includes(item.id) && item.id !== childItem.id)
|
|
|
item.count = 0;
|
|
item.count = 0;
|
|
|
});
|
|
});
|
|
@@ -317,7 +327,7 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (item.count === 0)
|
|
if (item.count === 0)
|
|
|
- ArrayUtils.remove(currentForm.value.checkItems, item);
|
|
|
|
|
|
|
+ ArrayUtils.remove(currentFormCheckItems.value, item);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const submitLoading = ref(false);
|
|
const submitLoading = ref(false);
|
|
@@ -343,6 +353,7 @@ async function saveForm() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
submitLoading.value = true;
|
|
submitLoading.value = true;
|
|
|
|
|
+ currentForm.value!.checkItems = currentFormCheckItems.value;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
assertNotNull(detail, 'currentForm is null');
|
|
assertNotNull(detail, 'currentForm is null');
|
|
@@ -370,6 +381,7 @@ async function downloadForm() {
|
|
|
|
|
|
|
|
const loader = useSimpleDataLoader(async () => {
|
|
const loader = useSimpleDataLoader(async () => {
|
|
|
await waitTimeOut(1000);
|
|
await waitTimeOut(1000);
|
|
|
|
|
+ console.log('load');
|
|
|
|
|
|
|
|
if (querys.value.id > 0) {
|
|
if (querys.value.id > 0) {
|
|
|
const detail = await AssessmentContentApi.getSelfAssessmentDetail(querys.value.id);
|
|
const detail = await AssessmentContentApi.getSelfAssessmentDetail(querys.value.id);
|