snow 2 лет назад
Родитель
Сommit
1f782d2ba0

+ 14 - 2
src/components/BasicForm/src/_createDafaultData.ts

@@ -1,10 +1,22 @@
 import { FormItem } from "./types";
 
 export function createDefaultData(formItems: FormItem[]) {
+  console.log(formItems);
   const data: Record<string, any> = {};
-
+  //创建默认值策略
   for (const item of formItems) {
-    data[item.field] = "";
+    switch (item.type) {
+      case "checkbox":
+      case "img_upload_list":
+        data[item.field] = [];
+        break;
+      case "number":
+        data[item.field] = 0;
+        break;
+      default:
+        data[item.field] = "";
+        break;
+    }
   }
 
   return data;

+ 2 - 2
src/views/parameter/good/config/_details.ts

@@ -63,15 +63,15 @@ export const projectFormConfig: FormConfig = {
     },
     {
       label: "轮播图",
+      type: 'img_upload_list',
       field: "good_banner_img",
-      slot: "good_banner_img",
       placeholder: "轮播图",
       span: 24
     },
     {
       label: "详情图",
       field: "good_img",
-      slot: "good_img",
+      type: 'img_upload_list',
       placeholder: "详情图",
       span: 24
     },

+ 2 - 26
src/views/parameter/good/cpns/project-form.vue

@@ -16,11 +16,6 @@ import { Customer } from "/@/components/RemoteSelect";
 // import { AmountInput } from "/@/components/Input";
 import { useResponseHandle } from "/@/hooks/useAsync";
 
-const config = {
-  name: "project_name",
-  platform: "platform_name"
-};
-
 const emit = defineEmits(["create"]);
 
 const props = defineProps<{
@@ -35,6 +30,7 @@ const { formItems } = projectFormConfig;
 const responseHandle = useResponseHandle();
 const basicFormRef = ref<InstanceType<typeof ElForm>>(null);
 const formData = ref<Record<string, any>>(createDefaultData(formItems));
+
 const ladderModalRef = ref<InstanceType<typeof LadderModal>>(null);
 
 function requesetCategoryById(id: string) {
@@ -90,9 +86,9 @@ function handleDateChange(prop: string) {
 }
 
 function handleCreate() {
+  console.log(formData.value);
   basicFormRef.value.validate(isValid => {
     if (!isValid) return;
-    console.log("9897979");
     // const { ladder, ...rest } = unref(formData);
     // const transform = ladder => {
     //   return {
@@ -120,8 +116,6 @@ watchEffect(() => {
   if (readonly && !data) {
     return;
   }
-
-  formData.value = transform(formItems, data, config);
 });
 </script>
 
@@ -139,24 +133,6 @@ watchEffect(() => {
         <Unit v-model="formData.unit_id" placeholder="单位" />
       </template>
 
-      <template #good_cover_img>
-        <ImageUpload v-model:url="formData.good_cover_img" />
-      </template>
-      <template #good_banner_img>
-        <ImageUploadList
-          v-model:urls="formData.good_banner_img"
-          :descs="['小于1Mb']"
-          :types="['png', 'jpg', 'jpeg']"
-        />
-      </template>
-      <template #good_img>
-        <ImageUploadList
-          v-model:urls="formData.good_img"
-          :descs="['小于1Mb']"
-          :types="['png', 'jpg', 'jpeg']"
-        />
-      </template>
-
       <template #good_param>
         111 先展示
         <!-- <LadderTable