<template>
  <div>
    <el-form label-width="180px">
      <el-form-item label="是否享受会员功能" size="small">
        <el-switch :active-value="1" :inactive-value="0" v-model="msg.EnjoyMember">
        </el-switch>
      </el-form-item>
      <el-form-item label="是否单独设置会员价" size="small">
        <el-switch :active-value="1" :inactive-value="0" v-model="msg.SeparateSetMember">
        </el-switch>
      </el-form-item>
      <el-form-item v-if="msg.SeparateSetMember == 1 && huiyList.length == 0" label="会员价设置">
        <el-button @click="CommonJump('setMember')" size="small" type="danger">如需设置请先添加会员</el-button>
      </el-form-item>

      <el-form-item v-if="
                msg.SeparateSetMember == 1 &&
                  SpecificationPriceList.length > 0
              " label="会员价设置">
        <div class="app-attr">
          <div class="box">
            <el-form-item style="display:inline-block">
              <el-input style="width:500px;position:relative;top:5px" size="small" v-model="memberinput"
                placeholder="请输入内容">
                <el-select slot="prepend" style="width:130px" v-model="memberVal" size="small">
                  <el-option v-for="(item, index) in huiyList" :label="item.Name" :value="item.Grade" :key="index">
                  </el-option>
                </el-select>
                <el-button @click="HySet" slot="append">确定</el-button>
              </el-input>
            </el-form-item>
          </div>
          <el-table ref="table" border style="width: 100%"
            @selection-change="TbaleSelectionChange">
            <el-table-column type="selection" width="55">
            </el-table-column>
            <template v-for="(item, index) in SpecificationList">
              <el-table-column :key="index+'16'" :label="item.Name" width="100">
                <template slot-scope="scope">
                  <span v-if="index == index2" v-for="(item2, index2) in scope.row.AttrList" :key="index2+'17'">
                    {{ scope.row.AttrList[index2].SVName }}
                  </span>
                </template>
              </el-table-column>
            </template>
            <template v-for="(item, index) in huiyList">
              <el-table-column :key="index+'18'" :label="item.Name">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.GradePriceList[index].MemberPrice" size="small"></el-input>
                </template>
              </el-table-column>
            </template>
          </el-table>
        </div>
      </el-form-item>

    </el-form>
  </div>
</template>
<script>
  export default {
    props: ['SpecificationPriceList', 'SpecificationList'],
    data() {
      return {
        huiyList: [], //会员数组
        memberinput: "", //会员价设置输入
        memberVal: '', //会员类型下拉

        memberList2: [],  //列表数据

        msg: {
          EnjoyMember: 1, //是否享受会员功能
          SeparateSetMember: 0, //是否开启会员价
        }
      };
    },
    created() {

    },
    methods: {
      gethuiyList() {
        let msg = {
          Grade: 0,
          Name: "",
          Enabled: 1
        };
        this.apipost("/api/user/GetMemberGradeList", msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            let pageData = res.data.data;
            this.huiyList = pageData;
            // this.huiyList.forEach(item => {
            //   let obj = {
            //     Name: item.Name,
            //     MemberGrade: item.Grade,
            //     MemberPrice: 0
            //   };
            //   this.memberList1[0].GradePriceList.push(obj);
            // });
          }
        });
      },
      HySet() {
        // this.memberList2.forEach(item => {
        //   this.memberCheck.forEach(check => {
        //     if (item.Id == check.Id) {
        //       item.GradePriceList.forEach(list1 => {
        //         if (list1.MemberGrade == this.memberVal) {
        //           list1.MemberPrice = this.memberinput;
        //         }
        //       });
        //     }
        //   });
        // });
      },
      TbaleSelectionChange(){

      }

    },
    mounted() {
      this.gethuiyList();
    },
    computed: {

    },
  };

</script>
