<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" label-width="0px">
          <el-row>
            <el-col :span="8">
              <el-form-item label="" prop="type">
                <el-checkbox-group v-model="form.type" @change="changeBox">
                  <el-checkbox
                    v-for="(item, index) in ysfsList"
                    :key="index"
                    :label="item.label"
                    name="type"
                  ></el-checkbox>
                </el-checkbox-group>
              </el-form-item> </el-col
          ></el-row>
        </el-form>
      </div>
    </div>
    <div class="my_footer">
      <div style="margin: 0 auto">
        <el-button class="myBtn"> {{ '取消' }}</el-button>
        <el-button type="primary" class="myBtn1" style="margin-left: 40px" @click="saveDate"
                   v-has-buttons="['ysfsConfirm']"
          > {{ '确认' }}</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import topBar from "@/components/topBarRole";
import { getzccsList, saveYfpz } from "@/api/system";
import {getRouters} from "@/api/settle";
export default {
  name: "Ysfs",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "ysfs",
      topList: [
        {
          name: '注册次数',
          path: "xtcs",
          url: "xtcs",
          changed: false,
        },
        {
          name: '运输方式',
          path: "ysfs",
          url: "ysfs",
          changed: false,
        },
        {
          name: '支付配置',
          path: "zfpz",
          url: "zfpz",
          changed: false,
        },
        {
          name: '邮费配置',
          path: "yfpz",
          url: "yfpz",
          changed: false,
        },
        {
          name: '安置校验',
          path: "azjy",
          url: "azjy",
          changed: false,
        },
        {
          name: '撤单日期',
          path: "cdsj",
          url: "cdsj",
          changed: false,
        },
        {
          name: '升级方式',
          path: "sjfs",
          url: "cdsj",
          changed: false,
        },
        {
          name:'直推方式',
          path:'ztfs',
          url: "ztfs",
          changed: false,
        }
      ],
      form: {
        type: [],
      },
      ysfsList: [],
    };
  },
  created() {
    this.getzccsList();
    this.getUserRoute();
  },
  methods: {
    getUserRoute() {
      getRouters().then((res)=>{
        res.data.forEach((item)=>{
          this.topList.forEach((items)=>{
            if (item.routeName == items.url){
              items.changed = true
            }
          })
        })
      })
    },
    getzccsList() {
      getzccsList({ key: "TRANSPORT_TYPE" }).then((res) => {
        this.ysfsList = res.data;
        // var selectit = [];
        this.ysfsList.forEach((item) => {
          if (item.value == 0) {
            this.form.type.push(item.label);
          }
        });
      });
    },
    changeBox(row) {
      this.ysfsList.forEach((aitem) => {
        aitem.value = 1;
        row.forEach((item) => {
          if (item == aitem.label) {
            aitem.value = 0;
          }
        });
      });
    },
    saveDate() {
      saveYfpz(this.ysfsList).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.msg,
            type: "success",
          });
          this.getzccsList();
        } else {
          this.$message({
            message: res.msg,
            type: "warning",
          });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.myBtn{
  width: 120px;
  height: 38px;
  border-radius: 5px;
  color: #fff;
  background-color: #CCCCCC;
  border-color: #ccc;
}
.myBtn1{
  width: 120px;
  height: 38px;
  border-radius: 5px;
  color: #fff;
  background-color: #C8161D;
  border-color: #C8161D;
}
::v-deep .el-checkbox{
  margin-right: 60px;
}
.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 {

    .thebtn {
      width: 120px;
      height: 38px;
    }
  }
}
</style>
