| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('com-dialog-select');
- ?>
- <style>
- .el-form-item {
- margin-bottom: 15px;
- }
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- display: inline-block;
- width: 250px;
- margin: 0 0 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- /* .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- } */
- .form-body {
- background-color: #fff;
- /* margin-bottom: 20px; */
- }
- .el-tabs__header {
- background-color: #fff;
- }
- .el-tabs__item {
- width: 100px;
- text-align: center;
- }
- .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>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;" style="min-width: 1000px;">
- <div slot="header">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item>
- <span style="color: #409EFF;cursor: pointer" @click="$navigate({r:'lucky-group/level/list'})">
- <!--mall/stock/level -->
- 拼团等级
- </span>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{titleName}}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="table-body">
- <el-form label-width="110px" ref="ruleForm" :model="ruleForm" :rules="rules" v-loading="loading">
- <el-form-item label="等级权重" prop="level">
- <el-select size="small" class="select" v-model="ruleForm.level" placeholder="请选择等级">
- <!-- v-model="search.status" @change='toSearch' -->
- <el-option :key="index" :label="item.name" :value="item.level" v-for="(item, index) in weights" :disabled="item.disabled"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="等级名称" prop="name">
- <el-input size="small" style="width: 300px;" v-model="ruleForm.name" placeholder='请输入等级名称'></el-input>
- </el-form-item>
- <br />
- <br />
- <el-form-item label="渠道奖励1" prop="team_commission">
- <!-- <div v-show="false">
- <el-radio v-model="ruleForm.is_percent_team" :label="1" size="small">百分比</el-radio>
- <el-radio v-model="ruleForm.is_percent_team" :label="0" size="small">固定金额</el-radio>
- </div> -->
- <el-input size="small" v-model="ruleForm.team_commission" onInput="value=toNumber(value,2)" placeholder="请输入渠道奖励" size="small" style="width: 300px;">
- <template slot="append">{{ruleForm.is_percent_team == 1?'%':'元'}}</template>
- </el-input>
- </el-form-item>
- <el-form-item label="平级奖励" prop="equal_commission">
- <!-- <div v-show="false">
- <el-radio v-model="ruleForm.is_percent_equal" :label="1" size="small">百分比</el-radio>
- <el-radio v-model="ruleForm.is_percent_equal" :label="0" size="small">固定金额</el-radio>
- </div> -->
- <el-input size="small" v-model="ruleForm.equal_commission" onInput="value=toNumber(value,2)" placeholder="请输入渠道奖佣金" size="small" style="width: 300px;">
- <template slot="append">{{ruleForm.is_percent_equal == 1?'%':'元'}}</template>
- </el-input>
- </el-form-item>
- <el-form-item label="越级奖" prop="over_commission">
- <el-input size="small" v-model="ruleForm.over_commission" onInput="value=toNumber(value,2)" placeholder="请输入渠道奖佣金" size="small" style="width: 300px;">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="每日参团次数" prop="init_attend_times">
- <el-input size="small" type="number" v-model="ruleForm.init_attend_times" onchange="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" placeholder="请输入每日参团次数" size="small" style="width: 300px;">
- </el-input>
- </el-form-item>
- <br />
- <br />
- <el-form-item label="是否启用升级" prop="is_auto_upgrade">
- <el-switch v-model="ruleForm.is_auto_upgrade" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <template v-if="ruleForm.is_auto_upgrade == 1">
- <?php echo $tpl ?>
- </template>
- <br />
- <br />
- <el-form-item label="等级说明" prop="desc">
- <el-input type="textarea" v-model="ruleForm.desc" size="small" style="width: 300px;" placeholder='请输入权益说明'></el-input type="textarea">
- </el-form-item>
- </el-form>
- <el-button type="primary" size="small" style="margin-left: 20px;margin-top: 10px;" :loading="btnLoading" @click="saveFun">保存</el-button>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- titleName: "添加拼团等级",
- loading: false,
- btnLoading: false,
- // goods_list: [],
- weights: [],
- options_list: <?= $source_list ?>,
- checkbox_list: <?= $checkbox_list ?>,
- ruleForm: {
- level: '',
- name: '',
- is_auto_upgrade: 0, //是否开启升级
- team_commission: 0, //渠道奖
- equal_commission: 0, //平级奖
- over_commission: 0, //越级奖
- desc: '', // 等级说明
- upgrade_type_goods: 0, //购买商品升级 0关,1开
- upgrade_type_condition: 0, //条件升级开关,0关,1开
- condition_type: 1, // 条件升级方式,1:满足其一可升级;2:满足所有才可升级
- goods_type: 1, // 购买商品升级类型,1:任意商品;2:指定商品
- buy_goods_type: 1, //购买商品升级时间场景【1订单完成 2支付】
- goods_ids: [], //指定商品集合
- init_attend_times: 3, // 每日参团次数
- checked_condition_values: <?= $key_arr ?>,
- checked_condition_keys: [], //对应条件的key
- goods_list: [],
- },
- rules: {
- level: {
- required: true,
- message: '请选择等级',
- trigger: 'blur'
- },
- name: {
- required: true,
- message: '请输入等级名称',
- trigger: 'blur'
- },
- // team_commission:{pattern:/^\d+(\.\d{0,2})?$/, message: '渠道奖佣金格式为数字,最多保留两位小数', trigger: 'blur'}
- },
- formLabelWidth: '110px',
- }
- },
- mounted: function() {
- if (getQuery('id')) {
- this.titleName = "编辑拼团等级";
- this.ruleForm.id = getQuery('id');
- this.loadData(getQuery('id')); //请求详情的数据
- } else {
- this.loadData();
- }
- },
- methods: {
- loadData(id) {
- // console.log('请求前的参数id='+id)
- this.loading = true;
- let params = {
- r: '/lucky-group/group-level/storage',
- id: id
- };
- request({
- params: params,
- method: 'get',
- }).then(e => {
- this.loading = false;
- // console.log('等级详情==', e)
- if (e.data.code == 0) {
- e.data.data.weights && (this.weights = e.data.data.weights);
- if (e.data.data.level_info.goods_ids.length > 0) {
- // this.goods_list = e.data.data.level_info.goods_list
- this.ruleForm.goods_type = 2
- }
- if (e.data.data.level_info.checked_condition_values.length) {
- this.ruleForm = e.data.data.level_info;
- } else {
- let checked_condition_values = this.ruleForm.checked_condition_values;
- this.ruleForm = e.data.data.level_info;
- this.ruleForm.checked_condition_values = checked_condition_values;
- }
- } else {
- this.$message.error(e.data.msg)
- }
- }).catch(e => {
- this.loading = false;
- });
- },
- goodsSelect(param) {
- console.log('kkkkk: ', this.ruleForm);
- for (let j in param) {
- let item = param[j];
- if (this.ruleForm.goods_ids.length >= 99) {
- this.$message.error('指定商品不能大于99个');
- return;
- }
- let flag = true;
- for (let i in this.ruleForm.goods_ids) {
- if (this.ruleForm.goods_ids[i] == param[j].id) {
- flag = false;
- break;
- }
- }
- if (flag) {
- this.ruleForm.goods_ids.push(param[j].id);
- this.ruleForm.goods_list.push({
- id: param[j].id,
- name: param[j].goods_name,
- cover_pic: param[j].cover_pic,
- });
- }
- }
- },
- deleteGoods(index) {
- this.ruleForm.goods_list.splice(index, 1);
- this.ruleForm.goods_ids.splice(index, 1);
- },
- saveFun() {
- if (this.ruleForm.is_auto_upgrade == 1 && this.ruleForm.upgrade_type_goods == 1 && this.ruleForm.goods_type == 2 && !this.ruleForm.goods_ids.length) {
- return this.$message.error("请选择商品");
- }
- // 升级条件验证
- // console.log(this.ruleForm);
- try {
- if (this.ruleForm.is_auto_upgrade == 1 && this.ruleForm.upgrade_type_condition == 1) {
- // console.log(this.ruleForm.checked_condition_keys, this.ruleForm.checked_condition_values);return null;
- if (this.ruleForm.checked_condition_keys.length) {
- var checked_condition_values = [];
- for (key in this.ruleForm.checked_condition_values) {
- checked_condition_values[this.ruleForm.checked_condition_values[key].key] = this.ruleForm.checked_condition_values[key].value
- }
- for (index in this.ruleForm.checked_condition_keys) {
- let i = this.ruleForm.checked_condition_keys[index];
- if (checked_condition_values[i]) {
- for (j in checked_condition_values[i]) {
- if (!checked_condition_values[i][j]) {
- throw '请完善所选择的第 ' + (parseInt(index) + 1) + ' 个条件';
- }
- }
- }
- }
- } else {
- throw '请完善升级条件';
- }
- }
- } catch (error) {
- this.$message.error(error);
- return false;
- }
- /* let checked_condition_keys = this.ruleForm.checked_condition_keys;
- console.log(checked_condition_keys);return null;
- let forNum = checked_condition_keys.length;
- if (forNum) {
- for (let i = 0; i < checked_condition_keys.length; i++) {
- let key = checked_condition_keys[i];
- this.ruleForm.checked_condition_keys[i] = this.ruleForm.checked_condition_values[i].key
- }
- } */
- // console.log(this.ruleForm);return null;
- this.$refs['ruleForm'].validate((valid) => {
- if (valid) {
- // console.log(this.goods_type)
- if (this.ruleForm.goods_type == 1) {
- this.ruleForm.goods_ids = [];
- }
- // console.log('ruleForm=', this.ruleForm)
- this.btnLoading = true;
- request({
- params: {
- r: 'lucky-group/group-level/storage',
- },
- method: 'post',
- data: this.ruleForm
- }).then(e => {
- this.btnLoading = false;
- //console.log('提交的结果='+JSON.stringify(e))
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- navigateTo({
- r: 'lucky-group/group-level/index'
- });
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.$message.error(e);
- this.btnLoading = false;
- })
- } else {
- this.$message.error('请填写必要的参数!');
- return false;
- }
- });
- },
- setCondition() {
- navigateTo({
- r: 'lucky-group/group-level/condition'
- });
- },
- },
- });
- </script>
|