| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template id="com-operation-center">
- <div class="com-operation-center">
- <el-card class="edit-card" shadow="never">
- <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="是否参与运营中心" 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">固定金额</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.OperationCenter" 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">
- <template slot-scope="scope">
- <el-input type="text" v-model="config.detail[scope.row.level].commission1_value" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">元</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].commission2_value" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">元</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-operation-center', {
- template: "#com-operation-center",
- props: {
- level_arr: {
- type: Object,
- default: () => {
- return {};
- }
- },
- setting: {
- type: Object,
- default: () => {
- return {};
- }
- },
- commission_type_map2: {
- type: Object,
- default: () => {
- return { commission: "佣金" };
- }
- },
- },
- data() {
- return {
- activeName: 'commission',
- form: {
- },
- is_attr: 0,
- install: {// 初始化数据
- is_enable: 0,
- is_partake: 1,
- is_percent: 0,
- item_type: 'goods',
- commission_type: 'commission',
- settings: 0,
- detail: {}
- },
- }
- },
- mounted() {
- },
- 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.OperationCenter;
- // 初始化赋值
- 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,
- commission1_value: !isEmpty(prize[formKey]) ? prize[formKey].commission1_value : 0,
- commission2_value: !isEmpty(prize[formKey]) ? prize[formKey].commission2_value : 0,
- }
- });
- });
- self.install = {
- is_partake: isEmpty(self.form[name]) ? 1 : 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), "OperationCenter");
- }
- },
- },
- methods: {
- handleSelectionChange() { },
- handleClick(tab, event) {
- console.log(tab, event);
- },
- }
- });
- </script>
|