<template>

<PermissionContainer 
    :jiBieArr=[1] 
    :tipArr="[,'集团的配置信息只对集团级别开放','',,'',]"  
  > 
    <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="160px">
      <el-form-item label="集团内共享积分" prop="integralRuleFlag">
        <el-radio-group v-model="form.integralRuleFlag" :disabled="disabled">
          <el-radio label="0">不共享</el-radio>
          <el-radio label="1">共享</el-radio>
        </el-radio-group>
        <div style="color: red; font-size: 12px">
          不共享：每个站点单独设置积分规则，集团下每个站点的积分不通用
        </div>
        <div style="color: red; font-size: 12px">
          共享：集团站点统一设置积分规则，集团下的每个站点积分通用，每个站点下的商品需要站点单独配置
        </div>
      </el-form-item>
      <el-form-item label="集团内共享电子卡" prop="cardRuleFlag">
        <el-radio-group v-model="form.cardRuleFlag" :disabled="disabled">
          <el-radio label="0">不共享</el-radio>
          <el-radio label="1">共享</el-radio>
        </el-radio-group>
        <div style="color: red; font-size: 12px">
          不共享：每个站点单独设置电子卡规则，每个集团下电子卡不通用
        </div>
        <div style="color: red; font-size: 12px">
          共享：集团站点统一设置电子卡规则，每个集团下的站点电子卡通用
        </div>
      </el-form-item>
      <el-form-item label="集团内共享优惠劵" prop="couponFlag">
        <el-radio-group v-model="form.couponFlag" :disabled="disabled">
          <el-radio label="0">不共享</el-radio>
          <el-radio label="1">共享</el-radio>
        </el-radio-group>
        <div style="color: red; font-size: 12px">
          不共享：每个站点单独设置优惠卷规则，每个集团下优惠卷不通用
        </div>
        <div style="color: red; font-size: 12px">
          共享：集团站点统一设置优惠卷规则，每个集团下的站点优惠卷通用
        </div>
      </el-form-item>
      <el-form-item label="退款审核权限归属" prop="refundExaminStatus">
        <el-radio-group v-model="form.refundExaminStatus" :disabled="disabled">
          <el-radio label="0">站点</el-radio>
          <el-radio label="1">集团</el-radio>
        </el-radio-group>
        <div style="color: red; font-size: 12px">
          站点：站点发起退款后，审核的权限放在站点
        </div>
        <div style="color: red; font-size: 12px">
          集团：站点发起退款后，审核的权限放在集团
        </div>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-row>
        <el-col :span="4" :offset="1">
          <el-button
            type="warning"
            icon="el-icon-edit"
            size="mini"
            @click="edit"
            >{{ this.disabled ? "修改配置" : "取消修改" }}</el-button
          >
        </el-col>
        <el-col :span="4" :offset="4">
          <el-button
            type="cyan"
            icon="el-icon-success"
            size="mini"
            @click="submitForm"
            :disabled="disabled"
            >确认设置</el-button
          >
        </el-col>
      </el-row>
    </div>
  </div>
</PermissionContainer>

</template>

<script>
import { getGroupInfo, updateDept } from "@/api/system/dept";
export default {
  name: "Station_Group",
  data() {
    return {
      // 表单参数
      form: {},
      disabled: true,
      rules: {
        integralRuleFlag: [
          { required: true, message: "请选择是否", trigger: "change" },
        ],
        cardRuleFlag: [
          { required: true, message: "请选择是否开启积分", trigger: "change" },
        ],
        couponFlag: [
          { required: true, message: "请选择是否开启优惠券", trigger: "change" },
        ],
        refundExaminStatus: [
          { required: true, message: "请选择是否退款的权限", trigger: "change" },
        ]
      },
      pageStatus: 0
    };
  },
  created() {
    this.init();
    this.setPageStatus();
  },
  methods: {
    init() {
      this.getGroupInfo();
    },
    setPageStatus() {
      this.queryPageStatus([1]).then((res) => {
        this.pageStatus = res;
      });
    },
    edit() {
      this.disabled = !this.disabled;
    },
    /** 修改按钮操作 */
    getGroupInfo() {
      getGroupInfo().then((response) => {
        this.form = response.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.deptId != null) {
            updateDept(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.disabled = true;
            });
          }
        }
      });
    },
  },
};
</script>
