From 5f84efe26a889f11e1c7241a869e176389b1e69b Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期六, 14 九月 2024 15:43:56 +0800
Subject: [PATCH] 1.优惠券添加图片

---
 pages/marketing/coupon/activity/index.vue |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/pages/marketing/coupon/activity/index.vue b/pages/marketing/coupon/activity/index.vue
index 631647f..e9564a1 100644
--- a/pages/marketing/coupon/activity/index.vue
+++ b/pages/marketing/coupon/activity/index.vue
@@ -44,6 +44,16 @@
         columns: [
           ...couponColumn(),
           {
+            label: '优惠券图片',
+            formatter: (row) => (
+              <el-bus-image
+                style="width:50px;height:50px"
+                lazy={true}
+                src={row.imageUrl}
+              />
+            ),
+          },
+          {
             label: '领取时间',
             formatter: getActivityReceiveTime,
             minWidth: 320,
@@ -105,6 +115,36 @@
             str: true,
             strKey: 'getTypeName',
             rules: { required: true, message: '请选择领取渠道' },
+            on: {
+              change: (e, updateForm,obj) => {
+    
+                if(e[0]==='home'){
+                  // 如果是首页领取的话,则图片为必传递
+                  this.updateImageUrlRules(this.tableConfig.form,"imageUrl",true,"图片为必填项目")
+                }else{
+                  this.updateImageUrlRules(this.tableConfig.form,"imageUrl",false,"请输入图片")
+                }
+              },
+            },
+
+          },
+          {
+            label: '优惠券图片:',
+            id: 'imageUrl',
+            type: 'bus-upload',
+            el: {
+              listType: 'picture-card',
+              limit: 1,
+              limitSize: 2,
+              tipText: '大小不超过2M',
+              valueType: 'string',
+            },
+            forceDisabled: true,
+            rules: {
+              required: true,
+              message: '请上传商品图片',
+              trigger: 'blur',
+            },
           },
           {
             label: '领取时间:',
@@ -259,5 +299,19 @@
       title: '活动优惠券',
     }
   },
+  methods: {
+    updateImageUrlRules(form,id,required,message) {
+      const curField =form.find(
+        (field) => field.id === id
+      );
+      if (curField && curField.rules && required) {
+        curField.rules.required = true;
+        curField.rules.message = message;
+      }else if(curField && curField.rules){
+        curField.rules.required = false;
+        curField.rules.message = message;
+      }
+    },
+  },
 }
 </script>

--
Gitblit v1.9.3