浏览代码

Merge branch 'dev' of http://159.75.201.17:3000/zwq/tuanfeng-pc-admin into dev

GuYun-D 5 月之前
父节点
当前提交
fbf78e4d6c

+ 225 - 135
src/views/active/combinationActivities/components/EditModal.vue

@@ -1,51 +1,85 @@
 <template>
   <el-dialog :visible.sync="visible" v-bind="modalOptions">
-    <el-form ref="formData" :model="formData" :rules="formRules" size="mini" label-suffix=":" label-width="150px">
+    <el-form
+      ref="formData"
+      :model="formData"
+      :rules="formRules"
+      size="mini"
+      label-suffix=":"
+      label-width="150px"
+    >
       <h2>基础信息</h2>
       <el-form-item label="活动名称" prop="composeName">
         <el-input
-          v-model="formData.composeName" maxlength="20" placeholder="请输入活动名称"
+          v-model="formData.composeName"
+          maxlength="20"
+          placeholder="请输入活动名称"
           :disabled="formData.state === 0"
         />
       </el-form-item>
       <el-form-item label="请选择区域" prop="regionId">
         <el-cascader
-          v-model="regionArrDialog" :props="regionProps" size="large" placeholder="请选择区域"
-          @change="formData.regionId = [ ...new Set(regionArrDialog.map(i => i[i.length - 1])) ].join(',')"
+          v-model="regionArrDialog"
+          :props="regionProps"
+          size="large"
+          placeholder="请选择区域"
+          @change="
+            formData.regionId = [
+              ...new Set(regionArrDialog.map((i) => i[i.length - 1])),
+            ].join(',')
+          "
         ></el-cascader>
-        <div v-if="String(formData.regionId)">已选ID:{{ formData.regionId }}</div>
+        <div v-if="String(formData.regionId)">
+          已选ID:{{ formData.regionId }}
+        </div>
       </el-form-item>
       <el-form-item label="备注" prop="remark">
         <el-input
-          v-model="formData.remark" maxlength="255" type="textarea" placeholder="请输入活动介绍"
-          :disabled="formData.state === 0" style="width: 400px;"
+          v-model="formData.remark"
+          maxlength="255"
+          type="textarea"
+          placeholder="请输入活动介绍"
+          :disabled="formData.state === 0"
+          style="width: 400px"
         />
       </el-form-item>
       <el-form-item label="报名时间" prop="dateTime1">
         <el-date-picker
-          v-model="formData.dateTime1" type="datetimerange" range-separator="至" start-placeholder="开始时间"
-          end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss"
-          :disabled="(formData.state === 3) || (formData.state === 4)"
+          v-model="formData.dateTime1"
+          type="datetimerange"
+          range-separator="至"
+          start-placeholder="开始时间"
+          end-placeholder="结束时间"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          :disabled="formData.state === 3 || formData.state === 4"
         />
         <p class="timeInfo">报名时间不能交叉且报名时间不能大于活动时间</p>
       </el-form-item>
       <el-form-item label="活动时间" prop="dateTime2">
         <el-date-picker
-          v-model="formData.dateTime2" type="datetimerange" range-separator="至" start-placeholder="开始时间"
-          end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss"
-          :disabled="(formData.state === 3) || (formData.state === 4)"
+          v-model="formData.dateTime2"
+          type="datetimerange"
+          range-separator="至"
+          start-placeholder="开始时间"
+          end-placeholder="结束时间"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          :disabled="formData.state === 3 || formData.state === 4"
         />
         <p class="timeInfo">平台活动时间不能交叉并且活动时间不能小于报名时间</p>
       </el-form-item>
       <el-form-item label="活动保证金">
         <el-radio-group v-model="formData.ifBond">
           <el-radio :label="1" :disabled="formData.state === 0">需要</el-radio>
-          <el-radio :label="0" :disabled="formData.state === 0">不需要</el-radio>
+          <el-radio :label="0" :disabled="formData.state === 0"
+            >不需要</el-radio
+          >
         </el-radio-group>
       </el-form-item>
       <el-form-item v-if="formData.ifBond === 1" label="保证金金额">
         <el-input
-          v-model="formData.bondMoney" maxlength="9" placeholder="请输入活动保证金金额"
+          v-model="formData.bondMoney"
+          maxlength="9"
+          placeholder="请输入活动保证金金额"
           :disabled="formData.state === 0"
         />
       </el-form-item>
@@ -53,218 +87,274 @@
       <el-form-item label="是否限购">
         <el-radio-group v-model="formData.ifLimit">
           <el-radio :label="2" :disabled="formData.state === 0">限购</el-radio>
-          <el-radio :label="1" :disabled="formData.state === 0">不限购</el-radio>
+          <el-radio :label="1" :disabled="formData.state === 0"
+            >不限购</el-radio
+          >
         </el-radio-group>
       </el-form-item>
       <el-form-item v-if="formData.ifLimit === 2" label="限购(件/人)">
-        <el-input v-model="formData.limitNumber" maxlength="9" placeholder="请输入限购数量" :disabled="formData.state === 0" />
+        <el-input
+          v-model="formData.limitNumber"
+          maxlength="9"
+          placeholder="请输入限购数量"
+          :disabled="formData.state === 0"
+        />
       </el-form-item>
       <el-form-item label="优惠券叠加">
         <el-radio-group v-model="formData.ifAdd">
           <el-radio :label="1" :disabled="formData.state === 0">叠加</el-radio>
-          <el-radio :label="0" :disabled="formData.state === 0">不叠加</el-radio>
+          <el-radio :label="0" :disabled="formData.state === 0"
+            >不叠加</el-radio
+          >
         </el-radio-group>
       </el-form-item>
     </el-form>
     <template #footer>
       <span class="dialog-footer">
         <el-button size="mini" @click="handleClose">取 消</el-button>
-        <el-button type="primary" size="mini" @click="handleSubmit">确 定</el-button>
+        <el-button type="primary" size="mini" @click="handleSubmit"
+          >确 定</el-button
+        >
       </span>
     </template>
   </el-dialog>
 </template>
 
 <script>
-import { getPlatformComposeById, savePlatformComposeActivity, updatePlatformComposeActivity } from '@/api/active/combinationActivities'
-import { getProvinceList, getChildAreaList } from '@/api/address'
+import {
+  getPlatformComposeById,
+  savePlatformComposeActivity,
+  updatePlatformComposeActivity,
+} from "@/api/active/combinationActivities";
+import { getProvinceList, getChildAreaList } from "@/api/address";
 
 export default {
-  name: 'EditModal',
-  components: {
-  },
+  name: "EditModal",
+  components: {},
   data() {
     return {
       modalOptions: {
         closeOnClickModal: false,
-        width: '820px',
-        title: ''
+        width: "820px",
+        title: "",
       },
       visible: false,
       formData: {
         dateTime1: [], // 后端不接收
         dateTime2: [], // 后端不接收
-        composeId: '',
-        regionId: '',
-        composeName: '',
-        remark: '',
-        signStartTime: '',
-        signEndTime: '',
-        startTime: '',
-        endTime: '',
-        ifLimit: '',
-        limitNumber: '',
-        ifAdd: '',
-        state: '',
-        ifBond: '', // 活动保证金
-        bondMoney: '', // 保证金金额
+        composeId: "",
+        regionId: "",
+        composeName: "",
+        remark: "",
+        signStartTime: "",
+        signEndTime: "",
+        startTime: "",
+        endTime: "",
+        ifLimit: "",
+        limitNumber: "",
+        ifAdd: "",
+        state: "",
+        ifBond: "", // 活动保证金
+        bondMoney: "", // 保证金金额
         shops: null,
-        products: null
+        products: null,
       },
       formRules: {
-        remark: [
-          { max: 255, message: '长度在 255 个字符内', trigger: 'blur' }
-        ],
+        remark: [{ max: 255, message: "长度在 255 个字符内", trigger: "blur" }],
         composeName: [
-          { required: true, message: '请输入活动名称', trigger: 'blur' }
+          { required: true, message: "请输入活动名称", trigger: "blur" },
         ],
-        regionId: [ { required: true, message: '请选择地址', trigger: 'blur' } ],
+        regionId: [{ required: true, message: "请选择地址", trigger: "blur" }],
         dateTime1: [
-          { type: 'array', required: true, message: '请选择报名时间' }
+          { type: "array", required: true, message: "请选择报名时间" },
         ],
         dateTime2: [
-          { type: 'array', required: true, message: '请选择活动时间' }
+          { type: "array", required: true, message: "请选择活动时间" },
         ],
-        bondMoney: []
+        bondMoney: [],
       },
       regionArrDialog: [],
       regionProps: {
         checkStrictly: true,
         multiple: true,
         lazy: true,
-        label: 'name',
-        value: 'id',
+        label: "name",
+        value: "id",
         lazyLoad(node, resolve) {
-          const { level, value } = node
+          const { level, value } = node;
           if (level === 0) {
-            resolve([ { id: 0, parentId: 0, name: '全中国', shortName: '全国', longitude: '108.55', latitude: '34.32', level: 1, sort: 1, status: true } ])
+            resolve([
+              {
+                id: 0,
+                parentId: 0,
+                name: "全中国",
+                shortName: "全国",
+                longitude: "108.55",
+                latitude: "34.32",
+                level: 1,
+                sort: 1,
+                status: true,
+              },
+            ]);
           } else if (level === 1) {
             getProvinceList().then((res) => {
-              resolve(res.data)
-            })
-          } else if ((level != 0) && (level != 1)) {
+              resolve(res.data);
+            });
+          } else if (level != 0 && level != 1) {
             getChildAreaList(value).then((res) => {
-              resolve(res.data.map((item) => {
-                item.leaf = level === 4
-                return item
-              }))
-            })
+              resolve(
+                res.data.map((item) => {
+                  item.leaf = level === 4;
+                  return item;
+                })
+              );
+            });
           }
-        }
-      }
-    }
+        },
+      },
+    };
   },
   watch: {
-    'formData.ifBond': {
+    "formData.ifBond": {
       deep: true,
       handler(val) {
         if (val) {
           this.formRules.bondMoney = [
-            { required: true, message: '请输入金额', trigger: 'blur' },
-            { pattern: /^0\.\d{0,2}$|^[1-9]\d*\.\d{0,2}$|^[1-9]\d*$/, message: '数值有误' }
-          ]
+            { required: true, message: "请输入金额", trigger: "blur" },
+            {
+              pattern: /^0\.\d{0,2}$|^[1-9]\d*\.\d{0,2}$|^[1-9]\d*$/,
+              message: "数值有误",
+            },
+          ];
         } else {
-          this.formRules.bondMoney = []
+          this.formRules.bondMoney = [];
         }
-      }
-    }
+      },
+    },
   },
   methods: {
-    handleClose() {
-      this.visible = false
+    //  分享规则切换
+    shareRuleChange(){
+      this.formData.shareMoney = 0
     },
-    async initList() {
+    handleClose() {
+      this.visible = false;
     },
+    async initList() {},
     handleOpen(params = {}) {
-      this.modalOptions.title = params.composeId ? '编辑组合活动' : '添加组合活动'
+      this.modalOptions.title = params.composeId
+        ? "编辑组合活动"
+        : "添加组合活动";
       this.formData = Object.assign(this.$options.data().formData, params, {
-        dateTime1: params.signTime ? params.signTime.split('~') : '',
-        dateTime2: params.time ? params.time.split('~') : ''
-      })
-      if (this.formData.regionId) this.regionArrDialog = this.formData.regionId.split(',').map((i) => [ i ])
-      this.visible = true
-      this.initList()
+        dateTime1: params.signTime ? params.signTime.split("~") : "",
+        dateTime2: params.time ? params.time.split("~") : "",
+      });
+      if (this.formData.regionId)
+        this.regionArrDialog = this.formData.regionId
+          .split(",")
+          .map((i) => [i]);
+      this.visible = true;
+      this.initList();
       if (params.composeId) {
-        this.getInfo(params.composeId)
+        this.getInfo(params.composeId);
       } else {
-        this.$refs.formData && this.$refs.formData.resetFields()
+        this.$refs.formData && this.$refs.formData.resetFields();
       }
     },
     async getInfo(id) {
-      const loading = this.$loading({ text: '加载中' })
+      const loading = this.$loading({ text: "加载中" });
       try {
-        const res = await getPlatformComposeById({ id })
-        this.formData = Object.assign(this.$options.data().formData, res.data, {
-          composeId: res.data.composeId || '',
-          composeName: res.data.composeName || '',
-          remark: res.data.remark || '',
-          signStartTime: res.data.signStartTime || '',
-          signEndTime: res.data.signEndTime || '',
-          startTime: res.data.startTime || '',
-          endTime: res.data.endTime || '',
-          ifLimit: res.data.ifLimit || '',
-          limitNumber: res.data.limitNumber || '',
-          ifAdd: res.data.ifAdd,
-          state: res.data.state,
-          ifBond: res.data.ifBond,
-          bondMoney: res.data.bondMoney || '',
-          shops: res.data.shops || null,
-          products: res.data.products || null
-        }, {
-          dateTime1: res.data.signStartTime || res.data.signEndTime ? [res.data.signStartTime, res.data.signEndTime] : '',
-          dateTime2: res.data.startTime || res.data.endTime ? [res.data.startTime, res.data.endTime] : ''
-        })
-        if (this.formData.regionId) this.regionArrDialog = this.formData.regionId.split(',').map((i) => [ i ])
+        const res = await getPlatformComposeById({ id });
+        this.formData = Object.assign(
+          this.$options.data().formData,
+          res.data,
+          {
+            composeId: res.data.composeId || "",
+            composeName: res.data.composeName || "",
+            remark: res.data.remark || "",
+            signStartTime: res.data.signStartTime || "",
+            signEndTime: res.data.signEndTime || "",
+            startTime: res.data.startTime || "",
+            endTime: res.data.endTime || "",
+            ifLimit: res.data.ifLimit || "",
+            limitNumber: res.data.limitNumber || "",
+            ifAdd: res.data.ifAdd,
+            state: res.data.state,
+            ifBond: res.data.ifBond,
+            bondMoney: res.data.bondMoney || "",
+            shops: res.data.shops || null,
+            products: res.data.products || null,
+          },
+          {
+            dateTime1:
+              res.data.signStartTime || res.data.signEndTime
+                ? [res.data.signStartTime, res.data.signEndTime]
+                : "",
+            dateTime2:
+              res.data.startTime || res.data.endTime
+                ? [res.data.startTime, res.data.endTime]
+                : "",
+          }
+        );
+        if (this.formData.regionId)
+          this.regionArrDialog = this.formData.regionId
+            .split(",")
+            .map((i) => [i]);
         this.$nextTick(() => {
-          this.$refs.formData && this.$refs.formData.validate()
-        })
+          this.$refs.formData && this.$refs.formData.validate();
+        });
       } finally {
-        loading.close()
+        loading.close();
       }
     },
     handleSubmit() {
       this.$refs.formData.validate(async (valid) => {
         if (valid) {
-          const loading = this.$loading({ text: '加载中' })
+          const loading = this.$loading({ text: "加载中" });
           try {
-            const { dateTime1, dateTime2, ...otps } = this.formData
+            const { dateTime1, dateTime2, ...otps } = this.formData;
             const params = {
               ...otps,
               signStartTime: dateTime1 && dateTime1[0],
               signEndTime: dateTime1 && dateTime1[1],
               startTime: dateTime2 && dateTime2[0],
-              endTime: dateTime2 && dateTime2[1]
-            }
-            let errMsg = ''
-            if (params.composeName === '') {
-              errMsg += ' 活动名称 '
+              endTime: dateTime2 && dateTime2[1],
+            };
+            let errMsg = "";
+            if (params.composeName === "") {
+              errMsg += " 活动名称 ";
             }
-            if (params.signStartTime === '' || params.signEndTime === '') {
-              errMsg += ' 报名时间 '
+            if (params.signStartTime === "" || params.signEndTime === "") {
+              errMsg += " 报名时间 ";
             }
-            if (params.startTime === '' || params.endTime === '') {
-              errMsg += ' 活动时间 '
+            if (params.startTime === "" || params.endTime === "") {
+              errMsg += " 活动时间 ";
             }
             if (errMsg.length !== 0) {
-              this.$message.error(`请输入${errMsg}`)
-              return
+              this.$message.error(`请输入${errMsg}`);
+              return;
             }
-            this.formData.composeId ? await updatePlatformComposeActivity(params) : await savePlatformComposeActivity(params)
-            loading.close()
-            this.$message({ message: `${this.formData.composeId ? '编辑' : '添加'}成功!`, type: 'success' })
-            this.$emit('success')
-            this.visible = false
+            this.formData.composeId
+              ? await updatePlatformComposeActivity(params)
+              : await savePlatformComposeActivity(params);
+            loading.close();
+            this.$message({
+              message: `${this.formData.composeId ? "编辑" : "添加"}成功!`,
+              type: "success",
+            });
+            this.$emit("success");
+            this.visible = false;
           } catch (e) {
-            loading.close()
+            loading.close();
           } finally {
-            loading.close()
+            loading.close();
           }
         } else {
-          this.$message({ message: '请输入相关信息', type: 'warning' })
-          return false
+          this.$message({ message: "请输入相关信息", type: "warning" });
+          return false;
         }
-      })
-    }
-  }
-}
+      });
+    },
+  },
+};
 </script>

+ 29 - 6
src/views/active/combinationActivityConfiguration/components/EditModal.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog :visible.sync="visible" v-bind="modalOptions">
-    <el-form ref="formData" :model="formData" :rules="formRules" size="mini" label-suffix=":" label-width="150px">
+    <el-form ref="formData" :model="formData" :rules="formRules" size="mini" label-suffix=":" label-width="180px">
       <el-form-item label="关联平台组合活动" prop="composeId">
         <el-select v-model="formData.composeId" size="mini" placeholder="请选择关联平台组合活动" filterable>
           <el-option
@@ -27,6 +27,20 @@
           <el-option label="同城联盟卡" :value="11" />
         </el-select>
       </el-form-item>
+      <el-form-item label="分享爆品活动佣金" prop="shareRule">
+        <el-select v-model="formData.shareRule" clearable size="mini" placeholder="请选择规则">
+          <el-option label="赠送固定金额" :value="1" />
+          <el-option label="商品价格比例" :value="2" />
+        </el-select>
+      </el-form-item>
+        <el-form-item label="爆品分配佣金" prop="shareMoney" v-if="formData.shareRule">
+        <el-input v-model="formData.shareMoney" placeholder="请输入分享爆品获得固定金额或价格比例" style="width: 250px;">
+          <template #append>
+            <div v-if="formData.shareRule === 1">元</div>
+            <div v-else-if="formData.shareRule === 2">%</div>
+          </template>
+        </el-input>
+      </el-form-item>
       <el-form-item label="是否参与" prop="joinRole">
         <el-select
           v-model="formData.joinRole" clearable size="mini" placeholder="请选择是否参与"
@@ -239,7 +253,9 @@ export default {
         cardRange: '',
         cardJson: '',
         cardBusinessFields: '',
-        serverId: [] // 非后端参数
+        serverId: [], // 非后端参数
+        shareRule: null, // 分享活动规则
+        shareMoney: 0, // 分享的佣金/比例
       },
       formRules: {
         composeId: [
@@ -250,7 +266,7 @@ export default {
         ],
         joinMoney: [
           { required: false, message: '请输入参与值' },
-          { pattern: /^0\.\d{0,2}$|^[1-9]\d*\.\d{0,2}$|^[1-9]\d*$/, message: '数值有误' }
+          { pattern: /^0(\.\d{0,2})?$|^[1-9]\d*(\.\d{0,2})?$|^0$/, message: '数值有误' }
         ],
         commissionPrice: [
           { required: false, message: '请输入固定分配佣金总额' },
@@ -268,7 +284,10 @@ export default {
           { required: false, message: '请输入卡券有效期' },
           { pattern: /^(0|[1-9][0-9]*)$/, message: '请输入正整数' }
         ],
-        isCardHolder: [ { required: true, message: '请选择是否发送卡包' } ]
+        isCardHolder: [ { required: true, message: '请选择是否发送卡包' } ],
+        shareRule: [
+          { required: true, message: "请配置分享规则", trigger: "blur" },
+        ],
       },
       activityList: [],
       ruleList: [],
@@ -346,7 +365,8 @@ export default {
           cardEffectiveTime: res.data.cardEffectiveTime || '',
           cardRange: res.data.cardRange || '',
           cardJson: res.data.cardJson || '',
-          cardBusinessFields: res.data.cardBusinessFields || ''
+          cardBusinessFields: res.data.cardBusinessFields || '',
+          shareRule:res.data.shareRule || ''
         })
         if (this.formData.cardJson) this.regionArrDialog = this.formData.cardJson.split(',').map((i) => [ i ])
         this.$nextTick(() => {
@@ -361,18 +381,21 @@ export default {
         if (valid) {
           const loading = this.$loading({ text: '加载中' })
           try {
-            const { joinRule, joinMoney, ...otps } = this.formData
+            const { joinRule, joinMoney,shareMoney,shareRule, ...otps } = this.formData
             const params = {
               joinMoney: joinRule === 2 ? joinMoney / 100 : joinMoney,
+              shareMoney: shareRule === 2 ? shareMoney / 100 : shareMoney,
               joinRule,
               ...otps
             }
+            console.log(params);
             this.formData.configId ? await updatePlatformComposeConfig(params) : await savePlatformComposeConfig(params)
             loading.close()
             this.$message({ message: `${this.formData.configId ? '编辑' : '添加'}成功!`, type: 'success' })
             this.$emit('success')
             this.visible = false
           } catch (e) {
+            console.log(e);
             loading.close()
           } finally {
             loading.close()

+ 3 - 2
vue.config.js

@@ -42,9 +42,10 @@ module.exports = {
     // before: require('./mock/mock-server.js'),
     proxy: {
       '/api': {
-        target: 'https://nsadminapi.tuanfengkeji.cn', // 正式
-        // target: 'https://nsadminapitest.tuanfengkeji.cn', // 测试
+        // target: 'https://nsadminapi.tuanfengkeji.cn', // 正式
+        target: 'https://nsadminapitest.tuanfengkeji.cn', // 测试
         // target: 'http://192.168.0.91:9103', // 平台端
+        // target: 'http://192.168.0.110:9103', // 平台端(勇哥)
         changeOrigin: true,
         pathRewrite: {
           '^/api': ''