<template>
  <div class="Global">
    <div class="GlobalMain">
      <div class="CRTop">
        <div>
          <span>企业设置 / 全局设置</span>
        </div>
      </div>
    <!-- <div class="projectSettings"> -->
      
      <!-- <el-form :model="projectSetting" :inline="true" label-position="left"> -->
        
        <!-- <p class="mb10">项目组维保工是否能查看到项目的所有电梯，并接收该项目内所有维保任务</p>
        <el-radio-group v-model="projectSetting.radio2">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group> -->
        <!-- <el-row>
          <el-button type="primary" plain>保存</el-button>
        </el-row> -->
      <!-- </el-form> -->
    <!-- </div> -->
    <div class="LiftSettings">
      <el-form :model="LiftSetting" :inline="true" label-position="left">
        <p class="title">项目设置</p>
        <p class="mb10">项目组维保工是否能查看到项目的所有电梯，并接收该项目内所有维保任务</p>
        <el-radio-group v-model="LiftSetting.workLift">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
         <p class="title">电梯维保设置</p>
         <p class="mb10">维保类型选项</p>
        <el-radio-group v-model="LiftSetting.typeOption">
          <el-radio :label="1">维保工按默认规则在APP选择保养类型</el-radio>
          <el-radio :label="2">维保文员制定维保计划和维保类型，维保工无需选择</el-radio>
        </el-radio-group>
            <el-row>
              <el-form-item label="可同时签到保养的台量" :xs="24" :sm="24" :md="24" :lg="24">
                <el-input type="number" placeholder="选择台量（1-5台）" min="1" max="5" v-model="LiftSetting.sameUnits"></el-input>
              </el-form-item>
            </el-row>
            <el-row>
              <el-col :xs="6" :sm="6" :md="6" :lg="6">
                <p  class="mb10">签退时是否需要定位</p> 
                <el-radio-group v-model="LiftSetting.signLocate">
           <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
              </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="8">
                <p  class="mb10">保养单是否显示停梯时间与恢复时间</p>
                <el-radio-group v-model="LiftSetting.showTime">
           <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
              </el-col>
            </el-row>
             <el-row>
              <el-form-item label="填写维保间隔">
                <el-input placeholder="填写维保间隔" v-model="LiftSetting.mtInterval"></el-input>
              </el-form-item>
            </el-row>
        <p class="mb10">补录权限</p>
        <el-radio-group v-model="LiftSetting.addAuthority">
          <el-radio :label="1">文员补录</el-radio>
          <el-radio :label="2">文员与维保工均可补录</el-radio>
        </el-radio-group>
        <el-row>
          <el-button v-if="GlobalBtn.GlobalBtn29" type="primary" plain @click="submitSet">保存</el-button>
        </el-row>
      </el-form>
    </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  name: "Global",
  data() {
    return {
      LiftSetting: {
        workLift: 1,
        typeOption: 2,
        sameUnits: 1,
        signLocate: 0,
        showTime: 1,
        mtInterval: 15,
        addAuthority:1,
        
      },
      GlobalBtn:{
        GlobalBtn29:0
      }
    };
  },
  created() {
    this.getSetList()

    var GlobalBtn = {}
    this.getButton(28).then(result => {
      if (result.data.statusCode==="1") {
        GlobalBtn = result.data.data
        console.log(GlobalBtn)
        GlobalBtn.map((item)=>{
          if(item.id==29){
            this.GlobalBtn.GlobalBtn29 = item.checked?1:0 
          }
        })
      }
    });
  },
  methods: {
    getSetList(){
      var url = "system/set/list";
      var param = {
        companyId:JSON.parse(sessionStorage.getItem('mtCompanyId'))
      };
      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.LiftSetting = data.data.sets;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    submitSet(){
      var url = "system/set/modify";
      var param = {
        companyId:JSON.parse(sessionStorage.getItem('mtCompanyId')),
        sets:this.LiftSetting
      };
      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.$message.success(data.message);
        } else {
          this.$message.error(data.message);
        }
      });
    }
  }
};
</script>
<style lang="stylus">
.Global {
  height: 100%;
  .GlobalMain {
    height: 100%;
    background: #fff;
  }

  .projectSettings {
    margin-bottom: 20px;
  }

  .LiftSettings, .projectSettings {
    background: #fff;

    p.title {
      width: 100%;
      padding: 15px 0;
      font-size: 16px;
      margin-bottom: 10px;
      /* border-bottom: 3px solid rgba(187, 187, 187, 1);*/
    }

    .el-form {
      padding: 20px;
      font-size: 14px;

      .el-radio-group {
        margin-bottom: 20px;
      }

      .el-button {
        padding: 8px 20px;
      }
    }
  }
}
</style>

