Kaynağa Gözat

⚙️ 修改细节问题

快乐的梦鱼 4 gün önce
ebeveyn
işleme
c1a8dd8597

+ 2 - 0
src/api/CommonContent.ts

@@ -575,6 +575,8 @@ export class CommonContentApi extends AppServerRequestModule<DataModel> {
           let data = JSON.parse(result.data);
           if (data.code !== 1)
             throw new Error(data.msg ?? 'code: ' + data.code);
+          if (data.data.fullurl.startsWith('http:'))
+            data.data.fullurl = data.data.fullurl.replace('http:', 'https:');
           resolve(data.data);
         },
         fail(result) {

+ 3 - 1
src/common/components/form/RichTextEditor.vue

@@ -62,7 +62,9 @@ onPageShow(() => {
     editorOpened = false;
     uni.getStorage({
       key: 'editorContent',
-      success: (success) => emit('update:modelValue', success.data),
+      success: (success) => {
+        emit('update:modelValue', success.data)
+      },
     })
   }
 })

+ 1 - 1
src/components/dialog/Popup.vue

@@ -107,7 +107,7 @@
           :top="true"
           @close="doClose"
         />
-        <slot />
+        <slot :show="show" />
         <PopupTitle
           v-if="position === 'top'"
           :closeable="closeable"

+ 27 - 19
src/components/form/SignatureField.vue

@@ -6,24 +6,27 @@
     size="auto"
     closeable
   >
-    <FlexCol :padding="16">
-      <ActionSheetTitle 
-        cancelText="取消"
-        confirmText="确定"
-        v-bind="titleProps"
-        :title="title"
-        @cancel="popupShow = false"
-        @confirm="onConfirm"
-      />
-      <Signature 
-        ref="signatureRef" 
-        v-bind="props" 
-      />
-    </FlexCol>
+    <template #default="{ show }">
+      <FlexCol v-if="show" :padding="16">
+        <ActionSheetTitle 
+          cancelText="取消"
+          confirmText="确定"
+          v-bind="titleProps"
+          :title="title"
+          @cancel="popupShow = false"
+          @confirm="onConfirm"
+        />
+        <Signature 
+          ref="signatureRef" 
+          v-bind="props"
+        />
+      </FlexCol>
+    </template>
   </Popup> 
   <FlexCol width="100%" :gap="10">
-    <Text v-if="!value && placeholder" :text="placeholder" />
-    <Image v-else-if="value" :src="value" width="100%" mode="widthFix" />
+    <Text v-if="!value && outerPlaceholder" :text="outerPlaceholder" />
+    <Image v-else-if="value" :src="value" width="600rpx" mode="widthFix" v-bind="previewImageProps" />
+    <Text v-else text="暂无签名" />
   </FlexCol>
 </template>
 
@@ -33,7 +36,7 @@ import type { SignatureInstance, SignatureProps } from '@/components/form/Signat
 import { useFieldChildValueInjector } from './FormContext';
 import Signature from '@/components/form/Signature.vue';
 import FlexCol from '../layout/FlexCol.vue';
-import Image from '../basic/Image.vue';
+import Image, { type ImageProps } from '../basic/Image.vue';
 import Popup from '../dialog/Popup.vue';
 import ActionSheetTitle, { type ActionSheetTitleProps } from '../dialog/ActionSheetTitle.vue';
 import Text from '../basic/Text.vue';
@@ -42,6 +45,10 @@ import type { UploaderAction } from './Uploader';
 export interface SignatureFieldProps extends Omit<SignatureProps, 'value'> {
   modelValue?: string | null;
   /**
+   * 预览图片属性
+   */
+  previewImageProps?: ImageProps;
+  /**
    * 初始值
    */
   initalValue?: string | null;
@@ -53,7 +60,7 @@ export interface SignatureFieldProps extends Omit<SignatureProps, 'value'> {
   /**
    * 占位符
    */
-  placeholder?: string;
+  outerPlaceholder?: string;
   /**
    * 上传处理。允许用户在签名后自动上传图片。不提供则返回临时图片路径。
    */
@@ -61,8 +68,9 @@ export interface SignatureFieldProps extends Omit<SignatureProps, 'value'> {
 }
 
 const props = withDefaults(defineProps<SignatureFieldProps>(), {
-  placeholder: '请签名',
+  outerPlaceholder: '请签名',
   title: '签名',
+  border: true,
   innerStyle: () => ({
     width: '100%',
     height: '400rpx',

+ 6 - 0
src/pages.json

@@ -8,6 +8,12 @@
       }
     },
     {
+      "path": "pages/test/test",
+      "style": {
+        "navigationBarTitleText": "test"
+      }
+    },
+    {
       "path": "pages/home/introduction",
       "style": {
         "navigationBarTitleText": "闽南文化生态保护-介绍",

+ 48 - 36
src/pages/collect/assessment/evaluation-form.vue

@@ -17,40 +17,37 @@
               :model="currentForm"
               :options="formOptions"
             />
+            <Button @click="navTo('/pages/test/test')">test</Button>
             <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">
                 <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}分)`"
                       :modelValue="hasCheckedItem(child.id)" 
                       @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>
             <DynamicForm
@@ -102,14 +99,21 @@ import type { RadioValueProps } from '@/components/dynamic/wrappers/RadioValue';
 import type { FieldProps } from '@/components/form/Field.vue';
 import type { SignatureFieldProps } from '@/components/form/SignatureField.vue';
 import { useImageSimpleUploadCo } from '@/common/components/upload/ImageUploadCo';
+import { navTo } from '@/components/utils/PageAction';
+
+let loaded = false;
 
 const { querys } = useLoadQuerys({
   id: 0,
 }, () => {
+  if (loaded)
+    return;
+  loaded = true;
   loader.load();
 });
 
 const currentForm = ref<SelfAssessmentDetail | null>(null);
+const currentFormCheckItems = ref<SelfAssessmentCheckItemAnswer[]>([]);
 const authStore = useAuthStore();
 
 const form1Ref = ref<IDynamicFormRef | null>(null);
@@ -247,8 +251,10 @@ const formOptionsEnd = ref<IDynamicFormOptions>({
           label: '传承人签名',
           name: 'sign',
           type: 'sign',
+          formProps: {
+            showRightArrow: true,
+          },
           additionalProps: {
-            placeholder: '请签名',
             upload: useImageSimpleUploadCo(),
           } as SignatureFieldProps,
         }
@@ -265,8 +271,7 @@ const checkItemList = ref<CheckItemInfo[]>([]);
 const totalPoints = computed(() => {
   if (!currentForm.value) 
     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() {
@@ -284,12 +289,14 @@ async function loadBasicInfo() {
 async function loadCheckItems() {
   assertNotNull(currentForm.value, 'currentForm is null');
   checkItemList.value = await AssessmentContentApi.getCheckItems(Number(currentForm.value.level));
+  currentFormCheckItems.value = currentForm.value.checkItems.concat();
 }
 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) {
-  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) {
   if (!currentForm.value)
@@ -297,11 +304,14 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
   if (typeof count === 'boolean') {
     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) {
     item = new SelfAssessmentCheckItemAnswer();
-    currentForm.value.checkItems.push(item);
+    currentFormCheckItems.value.push(item);
   }
+  if (item.count === count)
+    return;
   item.id = childItem.id;
   item.points = childItem.points;
   item.count = count;
@@ -309,7 +319,7 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
     case 1: {
       /** 单选,清除其他选项 */
       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)
           item.count = 0;
       });
@@ -317,7 +327,7 @@ function setCheckedItem(checkItem: CheckItemInfo, childItem: CheckItemInfo, coun
     }
   }
   if (item.count === 0)
-    ArrayUtils.remove(currentForm.value.checkItems, item);
+    ArrayUtils.remove(currentFormCheckItems.value, item);
 }
 
 const submitLoading = ref(false);
@@ -343,6 +353,7 @@ async function saveForm() {
   }
 
   submitLoading.value = true;
+  currentForm.value!.checkItems = currentFormCheckItems.value;
 
   try {
     assertNotNull(detail, 'currentForm is null');
@@ -370,6 +381,7 @@ async function downloadForm() {
 
 const loader = useSimpleDataLoader(async () => {
   await waitTimeOut(1000);
+  console.log('load');
   
   if (querys.value.id > 0) {
     const detail = await AssessmentContentApi.getSelfAssessmentDetail(querys.value.id);

+ 7 - 0
src/pages/test/test.vue

@@ -0,0 +1,7 @@
+<template>
+  <div>test</div>
+</template>
+
+<script setup lang="ts">
+
+</script>