<template>
  <div>
    <el-button size="small" style="width:120px" type="primary" @click="updateSite_Parameter">设 置</el-button>
    <el-dialog title="设置" :visible.sync="dialogEditVisible" width="600px">
      <el-row :gutter="16">
        <el-col>
          <p style="margin-bottom:20px">登录方式</p>
          <el-checkbox-group v-model="checkList" @change="checkboxChange">
            <el-checkbox label="loginmode_account">账号登录</el-checkbox>
            <el-checkbox label="loginmode_phonenumber">手机动态短信登录</el-checkbox>
            <el-checkbox label="loginmode_wechat">微信登录</el-checkbox>
          </el-checkbox-group>
        </el-col>
      </el-row>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogEditVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="updateSite_Parameter" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import uploadFile from '../../../../components/upload/hw_obs_upload.vue'
export default {
  props:['basicInfo'],
  components:{
    uploadFile
  },
  data () {
    return {
      dialogEditVisible:false,
      form:{},
      checkList:[]
    }
  },
  methods:{
    async querySite_Parameter () {
      this.dialogEditVisible = true
      this.disabled = true
      
      const res = await this.$api.requested({
        "classname": "webmanage.site.site",
        "method": "querySite_Parameter",
        "content": {
        }
      })
      let obj = {
        password_needcapital:res.data.password_needcapital,
        password_needlowercase:res.data.password_needlowercase,
        password_neednum:res.data.password_neednum,
        password_needspecialchar:res.data.password_needspecialchar,
        password_length:res.data.password_length,
        loginmode_account:res.data.loginmode_account,
        loginmode_phonenumber:res.data.loginmode_phonenumber,
        loginmode_wechat:res.data.loginmode_wechat
      }
      this.form = Object.assign({},this.form,obj)

      Object.keys(res.data).map((key,item)=>{
        res.data[key] === 1?this.checkList.push(key):''
      })
    },
    checkboxChange () {
      Object.keys(this.form).map((key,item)=>{
         if (key !== 'password_length')
         return this.form[key] = this.checkList.some(item=>item === key)?1:0
      })
    },
    async updateSite_Parameter () {
      const res = await this.$api.requested({
        "classname": "webmanage.site.site",
        "method": "updateSite_Parameter",
        "content": this.form
      })
      this.tool.showMessage(res,()=>{
        this.dialogEditVisible = false
      })
    },
  }
}

</script>
<style scoped>
.dialog-footer{
  margin-top: 50px;
  text-align: center;
}
</style>