Procházet zdrojové kódy

!360 Review代码修改
Merge pull request !360 from 疯狂的世界/dev

芋道源码 před 1 rokem
rodič
revize
fdfb028dd9

+ 1 - 1
src/api/mall/promotion/diy/page.ts

@@ -5,7 +5,7 @@ export interface DiyPageVO {
   templateId?: number
   name: string
   remark: string
-  previewImageUrls: string[]
+  previewPicUrls: string[]
   property: string
 }
 

+ 1 - 1
src/api/mall/promotion/diy/template.ts

@@ -7,7 +7,7 @@ export interface DiyTemplateVO {
   used: boolean
   usedTime?: Date
   remark: string
-  previewImageUrls: string[]
+  previewPicUrls: string[]
   property: string
 }
 

+ 2 - 2
src/components/DiyEditor/components/ComponentContainerProperty.vue

@@ -23,7 +23,7 @@
               <template #tip>建议宽度 750px</template>
             </UploadImg>
           </el-form-item>
-          <el-tree :data="treeData" :expand-on-click-node="false">
+          <el-tree :data="treeData" :expand-on-click-node="false" default-expand-all>
             <template #default="{ node, data }">
               <el-form-item
                 :label="data.label"
@@ -43,7 +43,7 @@
               </el-form-item>
             </template>
           </el-tree>
-          <slot name="style" :formData="formData"></slot>
+          <slot name="style" :style="formData"></slot>
         </el-form>
       </el-card>
     </el-tab-pane>

+ 4 - 10
src/components/DiyEditor/components/mobile/CouponCard/component.tsx

@@ -2,15 +2,13 @@ import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
 import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants'
 import { floatToFixed2 } from '@/utils'
 import { formatDate } from '@/utils/formatTime'
+import { object } from 'vue-types'
 
 // 优惠值
-// TODO @疯狂:idea 有告警
 export const CouponDiscount = defineComponent({
   name: 'CouponDiscount',
   props: {
-    coupon: {
-      type: CouponTemplateApi.CouponTemplateVO
-    }
+    coupon: object<CouponTemplateApi.CouponTemplateVO>()
   },
   setup(props) {
     const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO
@@ -35,9 +33,7 @@ export const CouponDiscount = defineComponent({
 export const CouponDiscountDesc = defineComponent({
   name: 'CouponDiscountDesc',
   props: {
-    coupon: {
-      type: CouponTemplateApi.CouponTemplateVO
-    }
+    coupon: object<CouponTemplateApi.CouponTemplateVO>()
   },
   setup(props) {
     const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO
@@ -61,9 +57,7 @@ export const CouponDiscountDesc = defineComponent({
 export const CouponValidTerm = defineComponent({
   name: 'CouponValidTerm',
   props: {
-    coupon: {
-      type: CouponTemplateApi.CouponTemplateVO
-    }
+    coupon: object<CouponTemplateApi.CouponTemplateVO>()
   },
   setup(props) {
     const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO

+ 0 - 1
src/components/DiyEditor/components/mobile/CouponCard/config.ts

@@ -24,7 +24,6 @@ export interface CouponCardProperty {
 }
 
 // 定义组件
-// TODO @疯狂:idea 有告警
 export const component = {
   id: 'CouponCard',
   name: '优惠券',

+ 0 - 1
src/components/DiyEditor/components/mobile/MagicCube/config.ts

@@ -31,7 +31,6 @@ export interface MagicCubeItemProperty {
 }
 
 // 定义组件
-// TODO @疯狂:有 idea 爆红告警
 export const component = {
   id: 'MagicCube',
   name: '广告魔方',

+ 0 - 1
src/components/DiyEditor/components/mobile/ProductCard/config.ts

@@ -59,7 +59,6 @@ export interface ProductCardFieldProperty {
 }
 
 // 定义组件
-// TODO @疯狂:idea 有告警
 export const component = {
   id: 'ProductCard',
   name: '商品卡片',

+ 0 - 1
src/components/DiyEditor/components/mobile/ProductList/config.ts

@@ -38,7 +38,6 @@ export interface ProductListFieldProperty {
 }
 
 // 定义组件
-// TODO @疯狂:idea 有告警
 export const component = {
   id: 'ProductList',
   name: '商品栏',

+ 2 - 3
src/components/DiyEditor/components/mobile/PromotionArticle/index.vue

@@ -1,17 +1,16 @@
 <template>
-  <div class="min-h-30px" v-html="article.content"></div>
+  <div class="min-h-30px" v-html="article?.content"></div>
 </template>
 <script setup lang="ts">
 import { PromotionArticleProperty } from './config'
 import * as ArticleApi from '@/api/mall/promotion/article/index'
 
 /** 营销文章 */
-// TODO @疯狂:idea 有告警
 defineOptions({ name: 'PromotionArticle' })
 // 定义属性
 const props = defineProps<{ property: PromotionArticleProperty }>()
 // 商品列表
-const article = ref<ArticleApi.ArticleVO[]>({})
+const article = ref<ArticleApi.ArticleVO>()
 watch(
   () => props.property.id,
   async () => {

+ 0 - 2
src/components/DiyEditor/components/mobile/PromotionCombination/config.ts

@@ -39,13 +39,11 @@ export interface PromotionCombinationFieldProperty {
 }
 
 // 定义组件
-// TODO @疯狂:idea 有告警
 export const component = {
   id: 'PromotionCombination',
   name: '拼团',
   icon: 'mdi:account-group',
   property: {
-    activityId: undefined,
     layoutType: 'oneCol',
     fields: {
       name: { show: true, color: '#000' },

+ 0 - 1
src/components/DiyEditor/components/mobile/SearchBar/config.ts

@@ -17,7 +17,6 @@ export interface SearchProperty {
 export type PlaceholderPosition = 'left' | 'center'
 
 // 定义组件
-// TODO @疯狂:idea 这里爆红,可以卡看咋优化下哇:is missing the following properties from type DiyComponent<SearchProperty>: uid, position
 export const component = {
   id: 'SearchBar',
   name: '搜索框',

+ 1 - 2
src/components/DiyEditor/components/mobile/VideoPlayer/config.ts

@@ -19,7 +19,6 @@ export interface VideoPlayerStyle extends ComponentStyle {
 }
 
 // 定义组件
-// TODO @疯狂:idea 有告警
 export const component = {
   id: 'VideoPlayer',
   name: '视频播放',
@@ -33,6 +32,6 @@ export const component = {
       bgColor: '#fff',
       marginBottom: 8,
       height: 300
-    } as ComponentStyle
+    } as VideoPlayerStyle
   }
 } as DiyComponent<VideoPlayerProperty>

+ 2 - 2
src/components/DiyEditor/components/mobile/VideoPlayer/property.vue

@@ -1,9 +1,9 @@
 <template>
   <ComponentContainerProperty v-model="formData.style">
-    <template #style="{ formData }">
+    <template #style>
       <el-form-item label="高度" prop="height">
         <el-slider
-          v-model="formData.height"
+          v-model="formData.style.height"
           :max="500"
           :min="100"
           show-input

+ 3 - 4
src/components/DiyEditor/util.ts

@@ -6,7 +6,7 @@ import { TabBarProperty } from '@/components/DiyEditor/components/mobile/TabBar/
 // 页面装修组件
 export interface DiyComponent<T> {
   // 用于区分同一种组件的不同实例
-  uid: number
+  uid?: number
   // 组件唯一标识
   id: string
   // 组件名称
@@ -21,7 +21,7 @@ export interface DiyComponent<T> {
    空:同center
    fixed: 由组件自己决定位置,如弹窗位于手机中心、浮动按钮一般位于手机右下角
   */
-  position: 'top' | 'bottom' | 'center' | '' | 'fixed'
+  position?: 'top' | 'bottom' | 'center' | '' | 'fixed'
   // 组件属性
   property: T
 }
@@ -103,8 +103,7 @@ export function usePropertyForm<T>(modelValue: T, emit: Function): { formData: R
     }
   )
 
-  // TODO @疯狂:这个 idea 爆红,看看怎么可以解决哈
-  return { formData }
+  return { formData } as { formData: Ref<T> }
 }
 
 // 页面组件库

+ 2 - 4
src/router/modules/remaining.ts

@@ -473,8 +473,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
           title: '模板装修',
           noCache: true,
           hidden: true,
-          // TODO @疯狂:建议 menu 那的 /mall/promotion/diy-template/diy-template 改成 /mall/promotion/diy/template
-          activeMenu: '/mall/promotion/diy-template/diy-template'
+          activeMenu: '/mall/promotion/diy/template'
         },
         component: () => import('@/views/mall/promotion/diy/template/decorate.vue')
       },
@@ -485,8 +484,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
           title: '页面装修',
           noCache: true,
           hidden: true,
-          // TODO @疯狂:建议 menu 那的 /mall/promotion/diy-template/diy-page 改成 /mall/promotion/diy/page
-          activeMenu: '/mall/promotion/diy-template/diy-page'
+          activeMenu: '/mall/promotion/diy/page'
         },
         component: () => import('@/views/mall/promotion/diy/page/decorate.vue')
       }

+ 8 - 8
src/views/mall/promotion/diy/page/DiyPageForm.vue

@@ -13,8 +13,8 @@
       <el-form-item label="备注" prop="remark">
         <el-input v-model="formData.remark" placeholder="请输入备注" />
       </el-form-item>
-      <el-form-item label="预览图" prop="previewImageUrls">
-        <UploadImgs v-model="formData.previewImageUrls" />
+      <el-form-item label="预览图" prop="previewPicUrls">
+        <UploadImgs v-model="formData.previewPicUrls" />
       </el-form-item>
     </el-form>
     <template #footer>
@@ -40,7 +40,7 @@ const formData = ref({
   id: undefined,
   name: undefined,
   remark: undefined,
-  previewImageUrls: []
+  previewPicUrls: []
 })
 const formRules = reactive({
   name: [{ required: true, message: '页面名称不能为空', trigger: 'blur' }]
@@ -58,8 +58,8 @@ const open = async (type: string, id?: number) => {
     formLoading.value = true
     try {
       const diyPage = await DiyPageApi.getDiyPage(id) // 处理预览图
-      if (diyPage?.previewImageUrls?.length > 0) {
-        diyPage.previewImageUrls = diyPage.previewImageUrls.map((url: string) => {
+      if (diyPage?.previewPicUrls?.length > 0) {
+        diyPage.previewPicUrls = diyPage.previewPicUrls.map((url: string) => {
           return { url }
         })
       }
@@ -82,10 +82,10 @@ const submitForm = async () => {
   formLoading.value = true
   try {
     // 处理预览图
-    const previewImageUrls = formData.value.previewImageUrls.map((item) => {
+    const previewPicUrls = formData.value.previewPicUrls.map((item) => {
       return item['url'] ? item['url'] : item
     })
-    const data = { ...formData.value, previewImageUrls } as unknown as DiyPageApi.DiyPageVO
+    const data = { ...formData.value, previewPicUrls } as unknown as DiyPageApi.DiyPageVO
     if (formType.value === 'create') {
       await DiyPageApi.createDiyPage(data)
       message.success(t('common.createSuccess'))
@@ -107,7 +107,7 @@ const resetForm = () => {
     id: undefined,
     name: undefined,
     remark: undefined,
-    previewImageUrls: []
+    previewPicUrls: []
   }
   formRef.value?.resetFields()
 }

+ 1 - 1
src/views/mall/promotion/diy/page/decorate.vue

@@ -52,7 +52,7 @@ const resetForm = () => {
     templateId: undefined,
     name: '',
     remark: '',
-    previewImageUrls: [],
+    previewPicUrls: [],
     property: ''
   } as DiyPageApi.DiyPageVO
   formRef.value?.resetFields()

+ 3 - 3
src/views/mall/promotion/diy/page/index.vue

@@ -47,14 +47,14 @@
   <ContentWrap>
     <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
       <el-table-column label="编号" align="center" prop="id" />
-      <el-table-column label="预览图" align="center" prop="previewImageUrls">
+      <el-table-column label="预览图" align="center" prop="previewPicUrls">
         <template #default="scope">
           <el-image
             class="h-40px max-w-40px"
-            v-for="(url, index) in scope.row.previewImageUrls"
+            v-for="(url, index) in scope.row.previewPicUrls"
             :key="index"
             :src="url"
-            :preview-src-list="scope.row.previewImageUrls"
+            :preview-src-list="scope.row.previewPicUrls"
             :initial-index="index"
             preview-teleported
           />

+ 8 - 8
src/views/mall/promotion/diy/template/DiyTemplateForm.vue

@@ -13,8 +13,8 @@
       <el-form-item label="备注" prop="remark">
         <el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
       </el-form-item>
-      <el-form-item label="预览图" prop="previewImageUrls">
-        <UploadImgs v-model="formData.previewImageUrls" />
+      <el-form-item label="预览图" prop="previewPicUrls">
+        <UploadImgs v-model="formData.previewPicUrls" />
       </el-form-item>
     </el-form>
     <template #footer>
@@ -40,7 +40,7 @@ const formData = ref({
   id: undefined,
   name: undefined,
   remark: undefined,
-  previewImageUrls: []
+  previewPicUrls: []
 })
 const formRules = reactive({
   name: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }]
@@ -59,8 +59,8 @@ const open = async (type: string, id?: number) => {
     try {
       const diyTemplate = await DiyTemplateApi.getDiyTemplate(id)
       // 处理预览图
-      if (diyTemplate?.previewImageUrls?.length > 0) {
-        diyTemplate.previewImageUrls = diyTemplate.previewImageUrls.map((url: string) => {
+      if (diyTemplate?.previewPicUrls?.length > 0) {
+        diyTemplate.previewPicUrls = diyTemplate.previewPicUrls.map((url: string) => {
           return { url }
         })
       }
@@ -83,10 +83,10 @@ const submitForm = async () => {
   formLoading.value = true
   try {
     // 处理预览图
-    const previewImageUrls = formData.value.previewImageUrls.map((item) => {
+    const previewPicUrls = formData.value.previewPicUrls.map((item) => {
       return item['url'] ? item['url'] : item
     })
-    const data = { ...formData.value, previewImageUrls } as unknown as DiyTemplateApi.DiyTemplateVO
+    const data = { ...formData.value, previewPicUrls } as unknown as DiyTemplateApi.DiyTemplateVO
     if (formType.value === 'create') {
       await DiyTemplateApi.createDiyTemplate(data)
       message.success(t('common.createSuccess'))
@@ -108,7 +108,7 @@ const resetForm = () => {
     id: undefined,
     name: undefined,
     remark: undefined,
-    previewImageUrls: []
+    previewPicUrls: []
   }
   formRef.value?.resetFields()
 }

+ 1 - 1
src/views/mall/promotion/diy/template/decorate.vue

@@ -118,7 +118,7 @@ const resetForm = () => {
     used: false,
     usedTime: undefined,
     remark: '',
-    previewImageUrls: [],
+    previewPicUrls: [],
     property: '',
     pages: []
   } as DiyTemplateApi.DiyTemplatePropertyVO

+ 3 - 3
src/views/mall/promotion/diy/template/index.vue

@@ -47,14 +47,14 @@
   <ContentWrap>
     <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
       <el-table-column label="编号" align="center" prop="id" />
-      <el-table-column label="预览图" align="center" prop="previewImageUrls">
+      <el-table-column label="预览图" align="center" prop="previewPicUrls">
         <template #default="scope">
           <el-image
             class="h-40px max-w-40px"
-            v-for="(url, index) in scope.row.previewImageUrls"
+            v-for="(url, index) in scope.row.previewPicUrls"
             :key="index"
             :src="url"
-            :preview-src-list="scope.row.previewImageUrls"
+            :preview-src-list="scope.row.previewPicUrls"
             :initial-index="index"
             preview-teleported
           />