| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 |
- <?php
- use common\helpers\ComponentHelper;
- $diyPath = dirname(__DIR__) . '/components';
- ComponentHelper::loadComponentView('com-dialog-select');
- ComponentHelper::loadComponentView('com-select-cat');
- ComponentHelper::loadComponentView('agent-setting-add', $diyPath);
- ?>
- <div id="app" v-cloak>
- <el-card class="box-card" v-loading="cardLoading" shadow="never" style="border:0;min-width: 1500px;"
- body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item>
- <span style="color: #409EFF;cursor: pointer"
- @click="$navigate({r:'cloud-stock-two/level/index'})">
- 代理商等级
- </span>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{titleName}}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="form-body">
- <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="180px" v-loading="btnLoading">
- <el-row>
- <el-col :span="40">
- <el-form-item label="代理商等级权重" prop="level">
- <el-select style="width: 100%" v-model="ruleForm.level" @change="levelChangeFun" placeholder="请选择">
- <el-option
- v-for="item in weights"
- :key="item.level"
- :label="item.name"
- :value="item.level"
- :disabled="item.is_can_choose == 0?true:false">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="代理商等级名称" prop="name">
- <el-input v-model="ruleForm.name" placeholder="请输入代理商等级名称" maxlength="10"></el-input>
- </el-form-item>
- <el-form-item label="代理进货数量限制" prop="name">
- <el-switch
- v-model="ruleForm.is_open_fill_min"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- <el-input v-model="ruleForm.fill_min" placeholder="请输入限制数量" maxlength="10"></el-input>
- </el-form-item>
- <!-- <el-form-item label="是否开启越级奖" prop="is_over" required>
- <el-switch
- v-model="ruleForm.is_over"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item label="是否开启平级奖" prop="is_equal" required>
- <el-switch
- v-model="ruleForm.is_equal"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item label="补货奖" prop="is_fill" required>
- <el-switch
- v-model="ruleForm.is_fill"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- </el-form-item> -->
- <!-- <el-form-item label="团队奖佣金类型" prop="is_percent_team">
- <el-radio-group v-model="ruleForm.commission.is_percent_team">
- <el-radio :label="0">百分比</el-radio>
- <el-radio :label="1">固定金额</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="团队奖励">
- <el-input v-model.number="ruleForm.commission.agent_team_prize" type="number" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="ruleForm.commission.is_percent_team == 0">%</template>
- <template slot="append" v-if="ruleForm.commission.is_percent_team == 1">元</template>
- </el-input>
- </el-form-item> -->
- <el-form-item label="被越级的奖励">
- <el-input v-model.number="ruleForm.commission.agent_over_prize" type="number">
- <template slot="append">%</template>
- </el-input>
- </el-form-item>
- <!-- <el-form-item label="团队奖积分类型" prop="is_percent_team" >
- <el-radio-group v-model="ruleForm.score.is_percent_team">
- <el-radio :label="0">百分比</el-radio>
- <el-radio :label="1">固定积分</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="团队积分奖励">
- <el-input v-model.number="ruleForm.score.agent_team_prize" type="number" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="ruleForm.score.is_percent_team == 0">%</template>
- <template slot="append" v-if="ruleForm.score.is_percent_team == 1">积分</template>
- </el-input>
- </el-form-item>
- <el-form-item label="被越级的积分奖励">
- <el-input v-model.number="ruleForm.score.agent_over_prize" type="number" onInput="value=toNumber(value,2)">
- <template slot="append">%</template>
- </el-input>
- </el-form-item> -->
- <el-form-item label="平级奖佣金类型" prop="is_percent_equal">
- <el-radio-group v-model="ruleForm.commission.is_percent_equal">
- <el-radio :label="0">百分比</el-radio>
- <el-radio :label="1">固定金额</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="平级奖励">
- <el-input v-model.number="ruleForm.commission.agent_equal_prize" type="number" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="ruleForm.commission.is_percent_equal == 0">%</template>
- <template slot="append" v-if="ruleForm.commission.is_percent_equal == 1">元</template>
- </el-input>
- </el-form-item>
- <!-- <el-form-item label="平级奖积分类型" prop="is_percent_equal">
- <el-radio-group v-model="ruleForm.score.is_percent_equal">
- <el-radio :label="0">百分比</el-radio>
- <el-radio :label="1">固定积分</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="平级积分奖励">
- <el-input v-model.number="ruleForm.score.agent_equal_prize" type="number" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="ruleForm.score.is_percent_equal == 0">%</template>
- <template slot="append" v-if="ruleForm.score.is_percent_equal == 1">积分</template>
- </el-input>
- </el-form-item> -->
- <!-- <el-form-item label="开启独立平级奖结算" prop="is_open_equal_settle_type">
- <el-switch v-model="ruleForm.is_open_equal_settle_type" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item v-if="ruleForm.is_open_equal_settle_type==1" prop="equal_settle_type" label="平级奖结算方式">
- <label slot="label">平级奖结算方式
- <el-tooltip class="item" effect="dark" content="奖励是由谁来结算平级奖" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
- <el-col :span="30">
- <el-radio-group v-model="ruleForm.equal_settle_type" size="small">
- <el-radio :label="0" border>平台结算</el-radio>
- <el-radio :label="1" border>上级拿级差或团队奖者支付</el-radio>
- <el-radio :label="2" border>下级拿级差或团队奖者支付</el-radio>
- </el-radio-group>
- </el-col>
- </el-form-item> -->
- <el-form-item label="直推下级代理奖励设置" prop="is_recommender_reward">
- <el-switch v-model="ruleForm.is_recommender_reward" :active-value="1" :inactive-value="0">
- </el-switch>
- <div style="width:800px;" v-if="ruleForm.is_recommender_reward">
- <agent-setting-add v-model="ruleForm.agent_setting_info"
- text1="直推下级成为" text2=",奖励" append2="元" :type="2" :level_list="edit.list"></agent-setting-add>
- </div>
- </el-form-item>
- <el-form-item label="直推下级代理奖条件" prop="is_recommender_condition">
- <el-switch v-model="ruleForm.is_recommender_condition" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item label="直推下级代理奖条件前需自身进货价的" v-if="ruleForm.is_recommender_condition">
- <el-input v-model.number="ruleForm.recommender_condition_prize" type="number">
- <template slot="append">%</template>
- </el-input>
- </el-form-item>
- <el-form-item label="结算比例" prop="recommender_settle_prize">
- <el-radio-group v-model="ruleForm.recommender_settle_prize">
- <el-radio :label="0">百分比</el-radio>
- <el-radio :label="1">固定金额</el-radio>
- </el-radio-group>
- <el-input v-model.number="ruleForm.recommender_settle_rate" type="number" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="ruleForm.recommender_settle_prize == 0">%</template>
- <template slot="append" v-if="ruleForm.recommender_settle_prize== 1">元</template>
- </el-input>
- </el-form-item>
- <!-- <el-form-item label="直推下级代理奖条件" prop="is_recommender_diff">
- <el-switch v-model="ruleForm.is_recommender_diff" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item> -->
- <el-form-item label="条件升级">
- <el-form-item>
- <el-switch
- v-model="ruleForm.upgrade_type_condition"
- @change="upgradeTypeSwitch"
- :active-value="1"
- :inactive-value="0"
- active-text="开启"
- inactive-text="关闭"
- >
- </el-switch>
- </el-form-item>
- <el-form-item v-if="ruleForm.upgrade_type_condition==1">
- <el-radio-group v-model="ruleForm.condition_type">
- <el-radio :label="1">满足其一条件可升级</el-radio>
- <el-radio :label="2">满足所有条件可升级</el-radio>
- </el-radio-group>
- </el-form-item>
- <div v-if="ruleForm.upgrade_type_condition==1">
- <div style="margin-bottom: 20px;display: flex;">
- <el-checkbox v-model="checkbox1isCheck" label="条件1:购买指定商品"></el-checkbox>
- <com-dialog-select :multiple="true" @selected="goodsSelect"
- title="商品选择">
- <el-button v-if="checkbox1isCheck" type="primary" style="margin-left: 20px;">选择商品</el-button>
- </com-dialog-select>
- </div>
- <el-form-item v-if="checkbox1isCheck">
- <template>
- <div style="color: #ff4544;">最多可添加10个商品 当前已经选择 <span style="font-size: 18px;">{{ruleForm.goods_list.length}}</span> 个商品</div>
- <div style="max-height: 300px;overflow-y: auto" >
- <el-table :data="ruleForm.goods_list" :show-header="false" border>
- <el-table-column label="">
- <template slot-scope="scope">
- <div flex>
- <div style="padding-right: 10px;flex-grow: 0">
- <com-image mode="aspectFill"
- :src="scope.row.cover_pic"></com-image>
- </div>
- <div style="display:flex;flex-direction:column;align-items:flex-start;">
- <div>{{scope.row.goods_name}}</div>
- <div>
- <span style="color: #ff4544;" v-if="scope.row.price">¥{{ scope.row.price }}</span>
- <span style="margin-left: 20px;" v-if="scope.row.stock">库存:{{ scope.row.stock }}</span>
- </div>
- </div>
- <div style="flex-grow: 0;">
- <el-button @click="deleteGoods(scope.$index)"
- type="text" circle size="mini">
- <el-tooltip class="item" effect="dark"
- content="删除" placement="top">
- <img src="resources/img/mall/del.png" alt="">
- </el-tooltip>
- </el-button>
- </div>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </el-form-item>
- <el-col>
- <el-checkbox v-model="checkbox4isCheck" label="条件2:一次性补货商品金额达到N元">
- </el-checkbox>
- <div v-if="checkbox4isCheck" style="margin-left: 23px;" style="background-color: red;">
- <el-input v-model="ruleForm.checked_condition_values[3].nums" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入金额"><!-- conditionNum -->
- <template slot="append">元</template>
- </el-input>
- </div>
- </el-col>
- <el-col>
- <el-checkbox v-model="checkbox2isCheck" label="条件3:直推代理商满足指定人数"></el-checkbox>
- <div v-if="checkbox2isCheck" style="margin-left: 23px;" style="background-color: red;">
- <div v-for="(item,index) in ruleForm.checked_condition_values[1].value" :key="index" style="margin-bottom: 10px;width: 400px" v-if="item.is_use == 1">
- <el-input v-model="item.num" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量"><!-- conditionNum -->
- <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 的人数满</div>
- <template slot="append">个</template>
- </el-input>
- </div>
- </div>
- </el-col>
- <el-col>
- <el-checkbox v-model="checkbox3isCheck" label="条件4:直推代理商累计业绩达"></el-checkbox>
- <div v-if="checkbox3isCheck" style="margin-left: 23px;" style="background-color: red;">
- <div v-for="(item,index) in ruleForm.checked_condition_values[2].value" :key="index" style="margin-bottom: 10px;width: 400px" v-if="item.is_use == 1">
- <el-input v-model="item.num" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入金额"><!-- conditionNum -->
- <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 的累计业绩达</div>
- <template slot="append">元</template>
- </el-input>
- </div>
- </div>
- </el-col>
- <el-col>
- <el-checkbox v-model="checkbox5isCheck" label="条件5:下级代理商满足指定人数"></el-checkbox>
- <div v-if="checkbox5isCheck" style="margin-left: 23px;" style="background-color: red;">
- <div v-for="(item,index) in ruleForm.checked_condition_values[4].value" :key="index" style="margin-bottom: 10px;width: 800px" v-if="item.is_use == 1">
- <div style="display:flex;">
- <el-input v-model="item.num" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量" style="margin-right: 10px;"><!-- conditionNum -->
- <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 的人数满</div>
- <template slot="append">个</template>
- </el-input>
- <el-input v-model="item.direct_num" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量"><!-- conditionNum -->
- <div slot="prepend">其中直推<span style="color:#03C5FF">{{item.name}}</span> 的人数满</div>
- <template slot="append">个</template>
- </el-input>
- </div>
- </div>
- </div>
- </el-col>
- <!-- <div style="display: inline-block;">
- <div style="display: flex;">
- <el-checkbox v-model="checkbox3isCheck" label="条件3:商品补货升级" @change="editCheckbox3isCheck"></el-checkbox>
- <com-dialog-select :multiple="true" @selected="addGoodsTree"
- title="商品选择">
- <el-button v-if="checkbox3isCheck" style="background: none;border: 0;color: #0373ff;" type="primary" style="margin-left: 20px;">选择商品</el-button>
- </com-dialog-select>
- </div>
- <div style="margin-left: 10px;font-size: 12px;color: #666;margin-left: 20px;">商品补货升级包含云库存代理商在商城购买的商品和云库存补货的商品</div>
- </div> -->
- <!-- <div v-if="checkbox3isCheck">
- <el-radio-group v-if="ruleForm.checked_condition_values[2]" v-model="ruleForm.checked_condition_values[2].radio_type">
- <el-radio :label="1">或</el-radio>
- <el-radio :label="2">与</el-radio>
- </el-radio-group>
- <template>
- <div style="max-height: 300px;overflow-y: auto;max-width: 514px;" v-if="ruleForm.checked_condition_values[2]">
- <el-table ref="goodsInfos" :data="ruleForm.checked_condition_values[2].value" style="width: 100%" @selection-change="selectionGoods">
- <el-table-column
- type="selection"
- width="55"
- >
- </el-table-column>
- <el-table-column
- label="商品"
- width="200">
- <template slot-scope="scope">
- <div style="display: flex;align-items: center;">
- <el-image style="height:40px;width:40px;min-height:40px;min-width:40px;margin-right:10px;" :src="scope.row.cover_pic"></el-image>
- <div>
- <div style="color: #000;">{{scope.row.name}}</div>
- <div style="font-size: 12px;">
- <label>{{scope.row.cost_price}}</label>
- -
- <label>{{scope.row.original_price}}</label>
- </div>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="数量"
- width="120">
- <template slot-scope="scope">
- <el-input v-model.number="scope.row.num" onkeyup="value=value.replace(/[^\d]/g,'')" style="width: 110px;">
- <template slot="append">件</template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column
- fixed="right"
- label="操作"
- width="120">
- <template slot-scope="scope">
- <el-button
- @click.native.prevent="deleteGoodsThree(scope.$index)"
- type="text"
- size="small">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </div> -->
- </div>
- </el-form-item>
- <el-form-item label="赠送等级" v-if="ruleForm.give_quota.length && is_show_give">
- <div style="display: flex;flex-wrap: wrap;width: 400px;justify-content: space-between;">
- <el-input v-for="(item,index) in ruleForm.give_quota" v-if="item.is_use == 1" :key="index" v-model="item.num" style="margin-top: 10px;" placeholder="请填入数量" onkeyup="value=value.replace(/[^\d]/g,'')">
- <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 赠送</div><!-- 因为这里的等级名称长度不确定 不能固定input的长度 prepend文字不会换行 所以input竖着排列 -->
- <template slot="append">个</template>
- </el-input>
- </div>
- </el-form-item>
- <el-form-item label="是否启用" prop="status">
- <el-switch
- v-model="ruleForm.status"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item label="等级说明" >
- <el-input
- type="textarea"
- :autosize="{ minRows: 4, maxRows: 4}"
- placeholder="请输入等级说明"
- v-model="ruleForm.detail">
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <el-button class="button-item" :loading="btnLoading" type="primary" @click="saveFun"
- size="small">保存
- </el-button>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- titleName:'添加代理商等级',
- msg: 1,
- options: [],//会员等级列表
- enable_level_list:[], //可用等级列表
- level: 0,
- form: {
- type: [],
- },
- checked_condition_keys: [],
- showConditionMsg: false,
- conditionMsg: '',
- weights: [],//等级权重列表
- ruleForm: {
- id:'',
- level: '',//权重 1 2 3等
- name: '',
- is_open_fill_min: 0,
- fill_min: 0,
- status: 1,
- is_equal: 1,
- is_over: 1,
- is_fill: 1,
- condition_type: 1,//1=满足其一可升级 2=满足所有条件可升级
- service_price: 0,
- is_auto_upgrade: 1,
- service_price_type: 0,
- upgrade_type_condition: 0,//条件升级
- sub_stock_rate: 100,
- rule: '',
- checked_condition_keys: [],//升级条件选中的key集合 ["0","1"]
- goodsNum:1,//指定购买商品的数量
- detail:'',//等级说明
- checked_condition_values:[//条件升级的数据upgradeData
- {"key":"0","value":[]},//{"goods_id":1},{"goods_id":2}条件1的数据 商品的数据id列表
- {"key":"1","value":[]},//{"level":1,"num":2},{"level":2,"num":3}条件2的数据 等级id和人数
- {"key":"2","value":[]},
- {"key":"3","value":[]},
- {"key":"4","value":[]},
- ],
- goods_list:[],
- give_quota:[],
- commission:{
- is_percent_team:0,
- is_percent_equal:0,
- is_percent_over:0,
- agent_team_prize:0,
- agent_equal_prize:0,
- agent_over_prize:0,
- },
- score:{
- is_percent_team:0,
- is_percent_equal:0,
- is_percent_over:0,
- agent_team_prize:0,
- agent_equal_prize:0,
- agent_over_prize:0,
- },
- is_open_equal_settle_type:0,
- equal_settle_type:0,
- is_recommender_reward:0,
- agent_setting_info:[],
- is_recommender_condition:0,
- recommender_condition_prize:0,
- is_recommender_diff:0,
- recommender_settle_prize:0,
- recommender_settle_rate:0,
- },
- rules: {
- level: [
- {required: true, message: '请选择代理商等级', trigger: 'change'},
- ],
- name: [
- {required: true, message: '请输入代理商等级名称', trigger: 'change'},
- ],
- is_use: [
- {required: true, message: '请选择代理商等级状态', trigger: 'change'},
- ],
- detail: [
- {required: true, message: '等级说明不能为空', trigger: 'change'},
- ],
- },
- btnLoading: false,
- cardLoading: false,
- checkList:[],
- checkbox1isCheck:false,//条件1 购买指定商品 是否勾选
- checkbox2isCheck:false,//条件2 代理商团队满足指定的人数 是否勾选
- checkbox3isCheck: false, //条件3 商品补货升级
- checkbox4isCheck: false, //条件3 商品补货升级
- checkbox5isCheck: false,
- goods:null,
- conditionNum:'',//条件2 代理商权重指定满足的人数
- //lowerLevel:[],//比当前选中的等级低的等级列表
- is_show_give:true,
- getWeightsLevel:'', //编辑的时候传进来的level
- radio_type: 1,
- goodsInfos: [],//商品假数据
- edit:{
- list:null,
- },
- };
- },
- mounted() {
- this.getLevel();
- if (getQuery('id')) {
- this.titleName="编辑代理商等级";
- this.getWeightsLevel = getQuery('level');
- this.loadData();//请求详情的数据
- }
- this.getWeights();//获取权重列表
- },
- methods: {
- getWeights(){
- let that = this;
- request({
- params: {
- r: 'cloud-stock-two/level/get-can-choose-level-list',
- level:this.getWeightsLevel
- },
- method: 'get',
- }).then(e => {
- if(e.data.code == 0){
- that.weights = e.data.data;
- }else{
- that.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- close(e) {
- this.visible = false;
- },
- levelChangeFun(e){
- this.getLowerLevel();//获取代理商等级下级等级列表
- },
- getLowerLevel(){//获取代理商等级下级等级列表
- request({
- params: {
- r: 'cloud-stock-two/level/get-less-level-list',
- level:this.ruleForm.level
- },
- method: 'get',
- }).then(e => {
- if(e.data.code == 0){
- let arr = e.data.data;
- arr.forEach((item,index)=>{
- item.num = '';
- })
- this.ruleForm.give_quota = arr;
- /* 判断是否显示 等级赠送 start */
- let arr2 = [];
- arr2 = this.ruleForm.give_quota.filter((item)=>{
- return item.is_use == 1;
- })
- if(arr2.length){
- this.is_show_give=true;
- }else{
- this.is_show_give=false;
- }
- console.log(arr2.length)
- console.log(this.is_show_give)
- /* 判断是否显示 等级赠送 end */
- this.ruleForm.checked_condition_values[1].value = JSON.parse(JSON.stringify(arr))
- this.ruleForm.checked_condition_values[2].value = JSON.parse(JSON.stringify(arr))
- arr.forEach((item,index)=>{
- item.direct_num = '';
- })
- this.ruleForm.checked_condition_values[4].value = JSON.parse(JSON.stringify(arr))
- }else{
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- saveFun(){
- //console.log('请求了保存的函数')
- this.ruleForm.checked_condition_keys = [];
- if(this.checkbox1isCheck){//条件1 购买指定商品 是否勾选
- this.ruleForm.checked_condition_keys.push("0");
- }
- if(this.checkbox2isCheck){//条件2 代理商团队满足指定的人数 是否勾选
- this.ruleForm.checked_condition_keys.push("1");
- }
- if(this.checkbox3isCheck){
- this.ruleForm.checked_condition_keys.push("2");
- }
- if(this.checkbox4isCheck){
- this.ruleForm.checked_condition_keys.push("3");
- }
- if(this.checkbox5isCheck){
- this.ruleForm.checked_condition_keys.push("4");
- }
- if(this.ruleForm.level == ''){
- return this.$message.error('请选择代理商等级权重');
- }
- if(this.ruleForm.name == ''){
- return this.$message.error('请输入代理商等级名称');
- }
- if(this.ruleForm.upgrade_type_condition == 1){//勾选了条件升级
- if(!this.ruleForm.checked_condition_keys.length){//为空数组 没有勾选任何一个条件
- return this.$message.error('请勾选升级条件');
- }
- if(this.ruleForm.condition_type == 1 && this.ruleForm.checked_condition_keys.length == 0){//选择了满足其一条件
- return this.$message.error('请填写其中一个升级条件');
- }
- /* if(this.ruleForm.condition_type == 2 && this.ruleForm.checked_condition_keys.length == 1){//选择了满足所有条件
- return this.$message.error('请勾选升级条件1和条件2');
- } */
- if(this.checkbox1isCheck && !this.ruleForm.goods_list.length){//勾选条件1 没有选择商品
- return this.$message.error('请选择商品');
- }
- /* if(this.checkbox1isCheck && this.ruleForm.upgradeData[0].value.val1 <= 0){//勾选条件1 商品数量不对
- return this.$message.error('请填写正确的商品数量');
- } */
- if(this.checkbox2isCheck){//勾选条件2 但是没有可用下级代理商列表
- let is_use_arr = [];
- let judge_arr = [];
- is_use_arr = this.ruleForm.checked_condition_values[1].value.filter((item)=>{
- return item.is_use == 1
- })
- judge_arr = this.ruleForm.checked_condition_values[1].value.filter((item)=>{
- return item.num == '' || item.num == 0
- })
- //console.log('judge_arr='+JSON.stringify(judge_arr))
- if(is_use_arr.length == 0){
- return this.$message.error('升级条件3暂不可选');
- }
- if(judge_arr.length == this.ruleForm.checked_condition_values[1].value.length){
- return this.$message.error('升级条件3:代理商团队指定满足的人数,至少填一个大于0的数字');
- }
- }
- if(this.checkbox3isCheck){//勾选条件3 但是没有可用下级代理商列表
- let is_use_arr_checkbox3isCheck = [];
- let judge_arr_checkbox3isCheck = [];
- is_use_arr_checkbox3isCheck = this.ruleForm.checked_condition_values[2].value.filter((item)=>{
- return item.is_use == 1
- })
- judge_arr_checkbox3isCheck = this.ruleForm.checked_condition_values[2].value.filter((item)=>{
- return item.num == '' || item.num == 0
- })
- //console.log('judge_arr='+JSON.stringify(judge_arr))
- if(is_use_arr_checkbox3isCheck.length == 0){
- return this.$message.error('升级条件4暂不可选');
- }
- if(judge_arr_checkbox3isCheck.length == this.ruleForm.checked_condition_values[2].value.length){
- return this.$message.error('升级条件4:代理商团队指定满足的人数,至少填一个大于0的数字');
- }
- }
- if(this.checkbox5isCheck){//勾选条件5 但是没有可用下级代理商列表
- let is_use_arr_checkbox5isCheck = [];
- let judge_arr_checkbox5isCheck = [];
- is_use_arr_checkbox5isCheck = this.ruleForm.checked_condition_values[4].value.filter((item)=>{
- return item.is_use == 1
- })
- judge_arr_checkbox5isCheck = this.ruleForm.checked_condition_values[4].value.filter((item)=>{
- return item.num == '' || item.num == 0
- })
- //console.log('judge_arr='+JSON.stringify(judge_arr))
- if(is_use_arr_checkbox5isCheck.length == 0){
- return this.$message.error('升级条件5暂不可选');
- }
- if(judge_arr_checkbox5isCheck.length == this.ruleForm.checked_condition_values[4].value.length){
- return this.$message.error('升级条件5:代理商团队指定满足的人数,至少填一个大于0的数字');
- }
- }
- }
- for(var i=0;i<this.ruleForm.checked_condition_values[1].value.length;i++){
- if(this.ruleForm.checked_condition_values[1].value[i].num < 0){
- return this.$message.error('请正确填写升级条件3的数据');
- break;
- }
- }
- for(var i=0;i<this.ruleForm.checked_condition_values[2].value.length;i++){
- if(this.ruleForm.checked_condition_values[2].value[i].num < 0){
- return this.$message.error('请正确填写升级条件4的数据');
- break;
- }
- }
- for(var i=0;i<this.ruleForm.checked_condition_values[4].value.length;i++){
- if(this.ruleForm.checked_condition_values[4].value[i].num < 0){
- return this.$message.error('请正确填写升级条件5的数据');
- break;
- }
- }
- for(var i=0;i<this.ruleForm.give_quota.length;i++){
- if(this.ruleForm.give_quota[i].num < 0){
- return this.$message.error('赠送等级:请填写正确的赠送数量');
- break;
- }
- }
- //let give_quota_arr=[];
- this.ruleForm.give_quota.forEach((item,index)=>{
- if(item.num == ''){
- item.num = 0
- }
- /* let obj ={
- level:item.level,
- num:item.num
- }
- give_quota_arr.push(obj) */
- })
- //console.log('赠送名额='+JSON.stringify(give_quota_arr))
- this.ruleForm.checked_condition_values[1].value.forEach((item,index)=>{
- if(item.num == ''){
- item.num = 0
- }
- })
- this.ruleForm.checked_condition_values[2].value.forEach((item,index)=>{
- if(item.num == ''){
- item.num = 0
- }
- })
- let submitObj={};//提交给后台的对象
- submitObj.level = this.ruleForm.level;
- submitObj.name = this.ruleForm.name;
- submitObj.fill_min = this.ruleForm.fill_min;
- submitObj.is_open_fill_min = this.ruleForm.is_open_fill_min;
- submitObj.is_use = this.ruleForm.is_use;
- submitObj.checked_condition_keys = JSON.stringify(this.ruleForm.checked_condition_keys);
- submitObj.condition_type = this.ruleForm.condition_type;
- submitObj.checked_condition_values =JSON.stringify(this.ruleForm.checked_condition_values);
- submitObj.give_quota =JSON.stringify(this.ruleForm.give_quota);
- submitObj.is_over = this.ruleForm.is_over;
- submitObj.is_equal = this.ruleForm.is_equal;
- submitObj.is_fill = this.ruleForm.is_fill;
- submitObj.upgrade_type_condition = this.ruleForm.upgrade_type_condition;
- submitObj.detail = this.ruleForm.detail;
- submitObj.status = this.ruleForm.status;
- submitObj.commission = JSON.stringify(this.ruleForm.commission);
- submitObj.agent_setting_info = JSON.stringify(this.ruleForm.agent_setting_info);
- submitObj.score = JSON.stringify(this.ruleForm.score);
- submitObj.is_open_equal_settle_type = this.ruleForm.is_open_equal_settle_type;
- submitObj.equal_settle_type = this.ruleForm.equal_settle_type;
- submitObj.is_recommender_reward = this.ruleForm.is_recommender_reward;
- submitObj.is_recommender_condition = this.ruleForm.is_recommender_condition;
- submitObj.recommender_condition_prize = this.ruleForm.recommender_condition_prize;
- submitObj.recommender_settle_prize = this.ruleForm.recommender_settle_prize;
- submitObj.recommender_settle_rate = this.ruleForm.recommender_settle_rate;
- if(getQuery('id')){
- submitObj.id = this.ruleForm.id
- }
- this.btnLoading = true;
- request({
- params: {
- r: 'cloud-stock-two/level/edit'
- },
- method: 'post',
- data:submitObj
- }).then(e => {
- this.btnLoading = false;
- if (e.data.code == 0) {
- this.$message.success('保存成功');
- navigateTo({
- r: 'cloud-stock-two/level/index'
- })
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.$message.error(e.data.msg);
- this.btnLoading = false;
- });
- },
- submitForm(formName) {
- let self = this;
- self.showConditionMsg = false;
- if (this.ruleForm.upgrade_type_condition == 1) {
- if (this.ruleForm.checked_condition_keys.length == 0) {
- this.$message.error('请完善升级条件');
- return;
- }
- let checked_condition_values = this.ruleForm.checked_condition_values;
- this.ruleForm.checked_condition_keys.forEach(v => {
- self.conditionMsg = '请完善条件:' + (parseInt(v) + 1);
- if (v == 0) {
- if (!checked_condition_values[v].value.val || !checked_condition_values[v].value.val1) {
- self.showConditionMsg = true;
- return;
- }
- }
- if (v > 0) {
- if (!checked_condition_values[v].value.val) {
- self.showConditionMsg = true;
- return;
- }
- }
- })
- if (self.showConditionMsg) {
- return
- }
- if (this.ruleForm.checked_condition_keys.length > 0) {
- if (this.ruleForm.condition_type == 0) {
- this.$message.error('请选择条件升级的方式升级类型');
- return;
- }
- }
- }
- this.$refs[formName].validate((valid) => {
- if (valid) {
- self.btnLoading = true;
- request({
- params: {
- r: 'plugin/stock/mall/level/edit'
- },
- method: 'post',
- data: {
- form: self.ruleForm,
- }
- }).then(e => {
- self.btnLoading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- navigateTo({
- r: 'plugin/stock/mall/level/index'
- })
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.btnLoading = false;
- });
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- loadData() {//请求详情的数据
- this.cardLoading = true;
- //console.log('请求详情前的参数=='+getQuery('id'))
- request({
- params: {
- r: 'cloud-stock-two/level/edit',//'plugin/stock/mall/level/edit',
- id: getQuery('id'),
- },
- method: 'get'
- }).then(e => {
- this.cardLoading = false;
- //console.log('请求详情的结果='+JSON.stringify(e))
- if (e.data.code == 0) {
- let data = e.data.data;
- this.ruleForm.id = data.id;
- this.ruleForm.level = data.level;
- this.ruleForm.name = data.name;
- this.ruleForm.is_open_fill_min = data.is_open_fill_min;
- this.ruleForm.fill_min = data.fill_min;
- this.ruleForm.status = data.status;
- this.ruleForm.checked_condition_keys = data.checked_condition_keys;
- this.ruleForm.checked_condition_keys.forEach((item)=>{
- if(item == 0){
- this.checkbox1isCheck = true;
- }
- if(item == 1){
- this.checkbox2isCheck = true;
- }
- if(item == 2){
- this.checkbox3isCheck = true;
- // localStorage.setItem("booType",1);
- // this.editCheckbox3isCheck(true);
- }
- if(item == 3){
- this.checkbox4isCheck = true;
- }
- if(item == 4){
- this.checkbox5isCheck = true;
- }
- })
- this.ruleForm.condition_type = data.condition_type;
- this.ruleForm.goods_list = data.checked_condition_values[0].value;//给商品进行赋值
- // if(!data.checked_condition_values[2]){
- // data.checked_condition_values.push({
- // key: 2,
- // radio_type: 1,
- // value: []
- // })
- // }
- // if(data.checked_condition_values[2] && data.checked_condition_values[2].value){
- // data.checked_condition_values[2].value.forEach(v => {
- // if(typeof(v.num) == "undefined"){
- // this.$set(v,'num',1);
- // }
- // })
- // }
- this.ruleForm.checked_condition_values = data.checked_condition_values;
- let arr = [];
- this.ruleForm.checked_condition_values[0].value.forEach((item)=>{
- let obj={
- goods_id:item.goods_id,
- cover_pic:item.cover_pic,
- goods_name:item.goods_name
- }
- arr.push(obj)
- })
- this.ruleForm.checked_condition_values[0].value = arr;
- /* end */
- this.ruleForm.give_quota = data.give_quota;
- /* 判断是否显示 等级赠送 start */
- let arr2 = [];
- arr2 = this.ruleForm.give_quota.filter((item)=>{
- return item.is_use == 1;
- })
- if(arr2.length){
- this.is_show_give=true;
- }else{
- this.is_show_give=false;
- }
- this.ruleForm.is_over = data.is_over;
- this.ruleForm.is_equal = data.is_equal;
- this.ruleForm.is_fill = data.is_fill;
- this.ruleForm.upgrade_type_condition = data.upgrade_type_condition;
- this.ruleForm.detail = data.detail;
- this.ruleForm.commission = data.commission;
- this.ruleForm.score = data.score;
- this.ruleForm.is_open_equal_settle_type = data.is_open_equal_settle_type;
- this.ruleForm.equal_settle_type = data.equal_settle_type;
- this.ruleForm.is_recommender_reward = data.is_recommender_reward;
- this.ruleForm.agent_setting_info = data.agent_setting_info;
- this.ruleForm.is_recommender_condition = data.is_recommender_condition;
- this.ruleForm.recommender_condition_prize = data.recommender_condition_prize;
- this.ruleForm.recommender_settle_prize = data.recommender_settle_prize;
- this.ruleForm.recommender_settle_rate = data.recommender_settle_rate;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- goodsSelect(param){
- for (let j in param) {
- let item = param[j];
- if (this.ruleForm.goods_list.length >= 10) {
- this.$message.error('指定商品不能大于10个');
- return;
- }
- let flag = true;
- for (let i in this.ruleForm.checked_condition_values[0].value) {
- if (this.ruleForm.checked_condition_values[0].value[i].goods_id == item.id) {
- flag = false;
- break;
- }
- }
- if (flag) {
- let obj={};
- obj.goods_id = item.id;
- obj.goods_name = item.goods_name;
- obj.cover_pic = item.cover_pic;
- obj.price = item.price;
- obj.stock = item.stock;
- this.ruleForm.checked_condition_values[0].value.push(obj);
- this.ruleForm.goods_list.push({
- id: item.id,
- goods_name: item.goods_name,
- cover_pic: item.cover_pic,
- price: item.price,
- stock: item.stock,
- });
- }
- }
- },
- deleteGoods(index) {
- //this.goods = null;
- this.ruleForm.checked_condition_values[0].value.splice(index, 1);
- this.ruleForm.goods_list.splice(index, 1);
- },
- deleteGoodsThree(index) {
- this.ruleForm.checked_condition_values[2].value.splice(index, 1);
- },
- addGoodsTree(param){
- for (let j in param) {
- let item = param[j];
- let obj = {
- id: item.id,
- name: item.goods_name,
- cover_pic: item.cover_pic,
- cost_price: item.cost_price,
- original_price: item.original_price,
- }
- this.$set(obj,'num',1);
- this.ruleForm.checked_condition_values[2].value.push(obj);
- console.info(this.ruleForm.checked_condition_values[2]);
- }
- console.log(obj);
- },
- selectionGoods(val){
- let boo = localStorage.getItem("booType");
- if(boo) return;
- let that = this;
- this.ruleForm.checked_condition_values[2].value.forEach((v,i) => {
- let index = val.findIndex(vv => vv.id == v.id);
- if(index != -1){
- v.isSelected = true;
- }else{
- v.isSelected = false;
- }
- })
- },
- editCheckbox3isCheck(v){
- if(v){
- // 等模板渲染完毕再加载
- this.$nextTick( () => {
- console.info(this.$refs,this.ruleForm.checked_condition_values[2].value);
- if(!this.ruleForm.checked_condition_values[2]) return
- this.ruleForm.checked_condition_values[2].value.forEach((v,i) => {
- if (v.isSelected) {
- this.$refs.goodsInfos.toggleRowSelection(v);
- }else {
- this.$refs.goodsInfos.clearSelection();
- }
- })
- localStorage.removeItem("booType");
- })
- }
- },
- upgradeTypeSwitch(boo){
- // if(boo == 1 && this.checkbox3isCheck){
- // this.editCheckbox3isCheck(true)
- // }
- },
- getLevel() {
- request({
- params: {
- r: 'cloud-stock-two/default/get-level-list',//代理商等级列表
- page: 1
- }
- }).then(res => {
- this.edit.loading = false;
- if (res.data.code == 0) {
- this.edit.list =res.data.data;
- } else {
- this.$message.error(res.data.msg);
- }
- }).catch(res => {
- });
- },
- }
- });
- </script>
- <style>
- .form-body {
- padding: 20px;
- background-color: #fff;
- margin-bottom: 20px;
- padding-right: 20%;
- min-width: 900px;
- }
- .form-body .el-form-item {
- padding-right: 25%;
- min-width: 850px;
- }
- .form-button {
- margin: 0;
- }
- .form-button .el-form-item__content {
- margin-left: 0 !important;
- }
- .button-item {
- padding: 9px 25px;
- }
- .check-group {
- font-size: 14px !important;
- }
- .check-group .el-col {
- display: flex;
- }
- .check-group .el-input {
- margin: 0 5px;
- }
- .check-group .el-col .el-checkbox {
- display: flex;
- align-items: center;
- }
- .check-group .el-col .el-input {
- width: 100px;
- }
- .check-group .el-col .el-input .el-input__inner {
- height: 30px;
- width: 100px;
- }
- .el-checkbox-group .el-col {
- margin-bottom: 10px;
- }
- </style>
|