| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- use common\helpers\ComponentHelper;
- //自定义公共方法
- ComponentHelper::loadComponentView('common-js', dirname(__DIR__) . '/components');
- ?>
- <template id="com-boss-bonus">
- <div class="com-boss-bonus">
- <el-card class="edit-card" shadow="never">
- <div slot="header" class="clearfix">
- <div class="card-title">刮刮卡2+1<span class="card-sub-title"></span></div>
- </div>
- <el-form :model="form" size="small">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane v-for="(config,key) in form" :label="commission_type_map2[key]" :name="key" :key="key">
- <el-form-item label="是否参与刮刮卡2+1" prop="is_partake">
- <el-switch :active-value="1" :inactive-value="0" v-model="config.is_partake"></el-switch>
- </el-form-item>
- <el-form-item label="独立设置分红" prop="is_enable" v-if="config.is_partake == 1">
- <el-switch :active-value="1" :inactive-value="0" v-model="config.is_enable"></el-switch>
- </el-form-item>
- <el-row :gutter="24" v-if="config.is_enable == 1 && config.is_partake == 1">
- <el-col :span="24">
- <el-card shadow="always">
- <el-form-item label="奖励类型" prop="is_percent">
- <el-radio-group v-model="config.is_percent">
- <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
- <el-radio :label="1" class="grid-content bg-purple">固定{{commission_type_map2[config.commission_type]}}</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item>
- <template v-if="config.settings == 0 || is_attr == 0">
- <el-table ref="normal" :data="level_arr.Scratch" border stripe style="width: 100%;" @selection-change="handleSelectionChange">
- <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
- <el-table-column label="直推奖" width="300" v-if="levels>=1">
- <template slot-scope="scope">
- <el-input type="text"
- v-model="config.detail[scope.row.level].first_prize"
- @input="firstPrizeViolationNumInput($event, key, scope.row.level)"
- >
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="团队奖" width="300" v-if="levels>=2">
- <template slot-scope="scope">
- <el-input type="text"
- v-model="config.detail[scope.row.level].second_prize"
- @input="secondPrizeViolationNumInput($event, key, scope.row.level)"
- >
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="三级奖励" width="300" v-if="levels>=3">
- <template slot-scope="scope">
- <el-input type="text"
- v-model="config.detail[scope.row.level].third_prize"
- @input="thirdPrizeViolationNumInput($event, key, scope.row.level)"
- >
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <!-- <el-table-column label="团队奖" width="300" >-->
- <!-- <template slot-scope="scope">-->
- <!-- <el-input type="number" v-model="config.detail[scope.row.level].team_prize" onkeyup="value=toNumber(value,2)">-->
- <!-- <template slot="append" v-if="config.is_percent == 0">%</template>-->
- <!-- <template slot="append" v-if="config.is_percent == 1">-->
- <!-- <template v-if="config.commission_type == 'commission'">元</template>-->
- <!-- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>-->
- <!-- </template>-->
- <!-- </el-input>-->
- <!-- </template>-->
- <!-- </el-table-column>-->
- <el-table-column label="平级奖" width="300" >
- <template slot-scope="scope">
- <el-input type="text"
- v-model="config.detail[scope.row.level].peer_award_prize"
- @input="peerAwardPrizeViolationNumInput($event, key, scope.row.level)"
- >
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </el-form-item>
- </el-card>
- </el-col>
- </el-row>
- </el-tab-pane>
- </el-tabs>
- </el-form>
- </el-card>
- </div>
- </template>
- <script>
- Vue.component('com-boss-bonus', {
- template: "#com-boss-bonus",
- props: {
- level_arr: {
- type: Object,
- default: () => {
- return {};
- }
- },
- setting: {
- type: Object,
- default: () => {
- return {};
- }
- },
- commission_type_map:{
- type: Object,
- default: () => {
- return {};
- }
- },
- commission_type_map2:{
- type: Object,
- default: () => {
- return {commission: "佣金"};
- }
- }
- },
- data() {
- return {
- levels:2,
- activeName: 'commission',
- form: {
- },
- is_attr:0,
- install: {// 初始化数据
- is_enable: 0,
- is_partake: 0,
- is_percent:0,
- item_type: 'goods',
- commission_type: '',
- settings: 0,
- detail: {}
- }
- }
- },
- mounted() {
- this.loadData();
- console.info(this.form,111);
- },
- watch: {
- setting: {
- deep:true,
- immediate: true,
- handler(value){
- if (!isEmpty(value)) {
- this.form = value;
- }
- }
- },
- level_arr: {
- deep:true,
- immediate: true,
- handler(value){
- if (!isEmpty(value)) {
- let self = this;
- var data = value.Scratch;
- // 初始化赋值
- for (let name in self.commission_type_map2) {
- let detail = {};
- var prize = isEmpty(self.form[name]) ? {} : self.form[name].detail;
- Object.keys(data).forEach(function (key) {
- var formKey = data[key].level;
- Object.assign(detail, {
- [formKey]: {
- level: data[key].level,
- first_prize:!isEmpty(prize[formKey]) ? prize[formKey].first_prize : 0,
- second_prize:!isEmpty(prize[formKey]) ? prize[formKey].second_prize : 0,
- third_prize:!isEmpty(prize[formKey]) ? prize[formKey].third_prize : 0,
- team_prize:!isEmpty(prize[formKey]) ? prize[formKey].team_prize : 0,
- peer_award_prize:!isEmpty(prize[formKey]) ? prize[formKey].peer_award_prize : 0,
- }
- });
- });
- self.install = {
- is_partake: isEmpty(self.form[name]) ? 0 : self.form[name].is_partake,
- is_enable: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable,
- is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
- item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
- commission_type: name,
- detail: detail
- };
- this.$set(self.form,name,JSON.parse(JSON.stringify(self.install)));
- }
- }
- }
- },
- form:{
- deep:true,
- immediate: true,
- handler(value){
- this.$emit("change",JSON.stringify(value), "Scratch");
- }
- },
- },
- methods:{
- loadData() {
- this.cardLoading = true;
- request({
- params: {
- r: 'boss-bonus/setting/config-setting',
- id: getQuery('id'),
- },
- method: 'get'
- }).then(e => {
- this.cardLoading = false;
- if (e.data.code == 0) {
- this.levels = e.data.data.levels;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- handleSelectionChange(){},
- handleClick(tab, event) {
- console.log(tab, event);
- },
- //检测当前输入的违规次数--输入的时候
- firstPrizeViolationNumInput(value, v_key, level) {
- this.form[v_key].detail[level].first_prize = numberHandle(value, 2, 2);
- },
- //检测当前输入的违规次数--输入的时候
- secondPrizeViolationNumInput(value, v_key, level) {
- this.form[v_key].detail[level].second_prize = numberHandle(value, 2, 2);
- },
- //检测当前输入的违规次数--输入的时候
- thirdPrizeViolationNumInput(value, v_key, level) {
- this.form[v_key].detail[level].third_prize = numberHandle(value, 2, 2);
- },
- //检测当前输入的违规次数--输入的时候
- peerAwardPrizeViolationNumInput(value, v_key, level) {
- this.form[v_key].detail[level].peer_award_prize = numberHandle(value, 2, 2);
- },
- }
- });
- </script>
|