<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="main">
      <div class="main_title">
        <div class="bluekuai"></div>
        <div class="title_word">{{ '显示配置' }}</div>
      </div>
      <div class="main_content">
        <el-form ref="form" :model="form">
          <el-form-item
            v-for="(item, index) in form.registerPageList"
            :label="item.name"
            :key="index"
          >
            <el-radio-group v-model="item.display">
              <el-radio
                :label="item.value"
                v-for="(item, index) in yesnoList"
                :key="index"
                >{{ item.label }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="footer">
      <div style="margin: 0 auto">
        <el-button class="thebtn"> {{ '取消' }}</el-button>
        <el-button type="primary" class="thebtn" @click="saveDate"
          > {{ '确认' }}</el-button
        >
      </div>
    </div>
  </div>
</template>

  <script>
import topBar from "@/components/topBar";
import {
  getYseNoList,
  getRegisterPageList,
  saveRegisterPage,
} from "@/api/systemconfiguration";
export default {
  name: "Zcympz",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "zcympz",
      topList: [
        {
          name: '注册页面配置',
          path: "zcympz",
        },
      ],
      form: {
        registerPageList: [],
      },
      yesnoList: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      getYseNoList().then((res) => {
        this.yesnoList = res.data;
      });
      getRegisterPageList().then((res) => {
        this.form.registerPageList = res.data;
      });
    },
    // changeBox(row) {
    //   this.ysfsList.forEach((aitem) => {
    //     aitem.value = 1;
    //     row.forEach((item) => {
    //       if (item == aitem.label) {
    //         aitem.value = 0;
    //       }
    //     });
    //   });
    // },
    saveDate() {
      const pushList = [];
      this.form.registerPageList.forEach((element) => {
        if (element.display == 0) {
          pushList.push(element.field);
        }
      });

      saveRegisterPage(pushList).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.msg,
            type: "success",
          });
          this.getData();
        } else {
          this.$message({
            message: res.msg,
            type: "warning",
          });
        }
      });
    },
  },
};
</script>

  <style lang="scss" scoped>
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .main_title {
      display: flex;
      align-items: center;
      padding: 10px 0;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      .bluekuai {
        width: 5px;
        height: 19px;
        background: #c8161d;
        margin-right: 20px;
      }
      .title_word {
        font-size: 14px;
        font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
        font-weight: bold;
        color: #333333;
      }
    }
    .main_content {
      padding: 20px 25px;
    }
  }
  .footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    .thebtn {
      width: 120px;
      height: 38px;
    }
  }
}
</style>
