Zory 5 часов назад
Родитель
Сommit
245fbae075

+ 79 - 23
src/views/merchant/cps/index/components/form.vue

@@ -21,18 +21,12 @@
                         <el-input v-model="formData.merchant_phone" clearable placeholder="请输入"></el-input>
                         <div class="el-form-item-msg">必须是真实可用的手机号码,否则计划可能会不通过审核</div>
                     </el-form-item>
-                    <fieldset>
-                        <legend><el-tag>推广团购商品</el-tag></legend>
-                        <el-button type="primary" @click="addGoods" v-if="goodsData.length<50">添加团购商品({{ goodsData.length }}/50</el-button>
+                    <el-form-item label="推广团购商品">
+                        <el-button type="default" @click="addGoods" v-if="goodsData.length<50">添加团购商品({{ goodsData.length }}/50</el-button>
+                        <el-button type="default" @click="quickGoods" v-if="goodsData.length > 0">一键设置佣金</el-button>
                         <div class="goods-live" v-if="goodsData.length>0">
-                            <scTable ref="starTable" :data="goodsData" row-key="id" height="300" hidePagination style="width: 750px;">
-                                <el-table-column label="商品ID" width="180" fixed="left" prop="goods_id">
-                                    <template #default="scope">
-                                        {{ scope.row.goods_id?scope.row.goods_id:'审核中' }}
-                                    </template>
-                                </el-table-column>
-                                <el-table-column label="商品类型" prop="types" width="100"></el-table-column>
-                                <el-table-column label="商品信息" width="340" prop="name">
+                            <scTable ref="starTable" :data="goodsData" row-key="id" height="300" hidePagination hideDo style="width: 750px;">
+                                <el-table-column label="商品信息" width="340" prop="name" fixed="left">
                                     <template #default="scope">
                                         <div class="goods-img">
                                             <div class="img">
@@ -54,6 +48,15 @@
                                         </div>
                                     </template>
                                 </el-table-column>
+                                <el-table-column label="佣金比例" prop="types" width="150">
+                                    <template #default="scope">
+                                        <el-input v-model="scope.row.rate" @input="setRate(scope.$index)" @focus="setRate(scope.$index)" placeholder="0%-29%">
+                                            <template #suffix>%</template>
+                                        </el-input>
+                                        <div class="el-form-item-msg">预估每单佣金 {{ scope.row.rate_money }}</div>
+                                    </template>
+                                </el-table-column>
+                                <el-table-column label="商品类型" prop="types" width="100"></el-table-column>
                                 <el-table-column label="价格" width="200" prop="id">
                                     <template #default="scope">
                                         <div class="price">{{ $TOOL.moneyFormat(scope.row.price) }}</div>
@@ -84,12 +87,11 @@
                                 </el-table-column>
                             </scTable>
                         </div>
-                    </fieldset>
-                    <fieldset>
-                        <legend><el-tag>指定带货达人</el-tag></legend>
-                        <el-button type="primary" @click="addStar" v-if="starData.length<200">添加达人({{ starData.length }}/200)</el-button>
+                    </el-form-item>
+                    <el-form-item label="指定带货达人">
+                        <el-button type="default" @click="addStar" v-if="starData.length<200">添加达人({{ starData.length }}/200)</el-button>
                         <div class="goods-live" v-if="starData.length>0">
-                            <scTable ref="starTable" :data="starData" row-key="id" height="300" hidePagination style="width: 750px;">
+                            <scTable ref="starTable" :data="starData" row-key="id" height="300" hidePagination hideDo style="width: 750px;">
                                 <el-table-column label="达人" width="340" prop="name" fixed="left">
                                     <template #default="scope">
                                         <div class="goods-img">
@@ -170,7 +172,7 @@
                                 </el-table-column>
                             </scTable>
                         </div>
-                    </fieldset>
+                    </el-form-item>
                     <el-form-item label="状态" prop="status">
                         <el-radio-group v-model="formData.status">
                             <el-radio-button :label="1">正常</el-radio-button>
@@ -188,6 +190,20 @@
     </el-drawer>
     <starMain ref="starMain" :multiple="true" @success="handleStar"></starMain>
     <goodsMain ref="goodsMain" :multiple="true" @success="handleGoods"></goodsMain>
+    <el-dialog title="一键设置佣金" v-model="quickData.visible" :width="460" append-to-body destroy-on-close :close-on-click-modal="false">
+        <el-form ref="quickForm" :model="quickData.formData" :rules="quickData.rules" label-width="100px" label-position="top">
+            <el-form-item label="输入后商品将设置相同佣金" prop="rate">
+                <el-input v-model="quickData.formData.rate" clearable placeholder="0%-29%">
+                    <template #suffix>%</template>
+                </el-input>
+                <div class="el-form-item-msg">佣金比例请设置在0%-29%之间</div>
+            </el-form-item>
+        </el-form>
+		<template #footer>
+            <el-button @click="quickData.visible=false" size="large">取 消</el-button>
+            <el-button size="large" type="primary" :loading="quickData.isSaveing" @click="submitRate()">保 存</el-button>
+		</template>
+    </el-dialog>
 </template>
 
 <script>
@@ -199,6 +215,19 @@ export default {
     },
     data(){
         return {
+            quickData:{
+                visible:false,
+                rate:null,
+                isSaveing:false,
+                formData:{
+                    rate:null
+                },
+                rules:{
+                    rate: [
+                        {required: true, message: '请输入'}
+                    ],
+                }
+            },
             goodsData:[],
             starData:[],
             loading: false,
@@ -235,6 +264,19 @@ export default {
         setData(data){
             this.formData = JSON.parse(JSON.stringify(data));
         },
+        setRate(index){
+            const goods = this.goodsData[index];
+            if (parseFloat(goods.rate) > 29) {
+                this.goodsData[index].rate = 0;
+                this.goodsData[index].rate_money = 0;
+                return ;
+            }
+            const rateMoney = this.$TOOL.moneyFormat(parseFloat(goods.rate) * goods.price / 100);
+            this.goodsData[index].rate_money = rateMoney;
+        },
+        quickGoods(){
+            this.quickData.visible = true;
+        },
         addGoods(){
             this.$nextTick(() => {
                 this.$refs.goodsMain.open("add")
@@ -242,9 +284,6 @@ export default {
         },
         removeGoods(index){
             this.goodsData.splice(index,1);
-            this.$nextTick(() => {
-                this.$refs.starTable.refresh()
-            })
         },
         addStar(){
             this.$nextTick(() => {
@@ -253,9 +292,6 @@ export default {
         },
         removeStar(index){
             this.starData.splice(index,1);
-            this.$nextTick(() => {
-                this.$refs.starTable.refresh()
-            })
         },
         handleStar(data){
             var newData = [];
@@ -270,6 +306,8 @@ export default {
         handleGoods(data){
             var newData = [];
             data.forEach((value)=>{
+                value.rate = 0;
+                value.rate_money = 0;
                 const has = this.goodsData.some(item => item['id'] === value['id'])
                 if (!has) newData.push(value)
             })
@@ -277,6 +315,24 @@ export default {
                 this.goodsData = this.goodsData.concat(newData);
             }
         },
+        async submitRate(){
+            var validate = await this.$refs.quickForm.validate().catch(()=>{});
+            if(!validate){ return false }
+            if (parseFloat(this.quickData.formData.rate) > 29) {
+                this.quickData.formData.rate = 0;
+                return ;
+            }
+            this.quickData.isSaveing = true;
+            var goodsData = this.goodsData;
+            goodsData.forEach((item) =>{
+                const rateMoney = this.$TOOL.moneyFormat(parseFloat(this.quickData.formData.rate) * item.price / 100);
+                item.rate_money = rateMoney;
+                item.rate = this.quickData.formData.rate;
+            })
+            this.goodsData = goodsData;
+            this.quickData.isSaveing = false;
+            this.quickData.visible = false;
+        },
         async submit(){
             var validate = await this.$refs.dialogForm.validate().catch(()=>{});
             if(!validate){ return false }

+ 3 - 3
src/views/merchant/cps/index/components/table.vue

@@ -14,7 +14,7 @@
                 </el-tooltip>
             </template>
             <template #default="scope">
-                <span v-if="scope.row.talent_item_level_display">{{ scope.row.done_money }}</span>
+                <span v-if="scope.row.done_money">{{ scope.row.done_money }}</span>
                 <span v-else>-</span>
             </template>
         </el-table-column>
@@ -52,8 +52,8 @@
         <el-table-column label="操作" width="180" align="left" fixed="right">
             <template #default="scope">
                 <el-button-group>
-                    <el-button size="small" text @click="table_update(scope.row)" v-if="scope.row.status == 1">更新</el-button>
-                    <el-button type="danger" text size="small" @click="table_del(scope.row)">删除</el-button>
+                    <el-button size="small" text @click="table_update(scope.row)" v-if="scope.row.status == 1">修改佣金</el-button>
+                    <el-button type="danger" text size="small" @click="table_del(scope.row)">关闭</el-button>
                 </el-button-group>
             </template>
         </el-table-column>

+ 1 - 2
src/views/merchant/cps/star/components/table.vue

@@ -61,8 +61,7 @@
         </el-table-column>
         <el-table-column label="视频榜" prop="category_id" width="120">
             <template #default="scope">
-                <span v-if="scope.row.rank_display">{{ scope.row.city_name }} 第{{ scope.row.rank_display }}名</span>
-                <span v-else>-</span>
+                <span>{{ scope.row.city_name }} {{ scope.row.rank_display?'第'+scope.row.rank_display+'名':'无名次' }}</span>
             </template>
         </el-table-column>
         <el-table-column label="状态" prop="enable" width="120" align="center">