<template>
  <div>
    <el-drawer
      size="800px"
      :append-to-body="true"
      :destroy-on-close="true"
      :visible="true"
      :modal="false"
      title="扩展配置"
      :modal-append-to-body="true"
      :before-close="handleClose"
      :wrapperClosable="false"
      ref="drawer_close">
      <el-form  style="padding-top: 20px;padding-right: 20px;" label-width="100px" v-loading="loading" class="qs-form-add">
        <el-form-item label="轻识主页">
          <el-input v-model="ruleForm.qs_user_link" placeholder="请输入轻识的主页"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="save()">保存</el-button>
        </el-form-item>
      </el-form>
    </el-drawer>
    <div class="ccf_modal"></div>
  </div>
</template>
<script>
  export default {
    components: {},
    props: {
      value: {
        type: Number,
        default: 0
      },
      back:{
        type:Object
      }
    },
    async mounted() {
      await this.get_config();
    },
    data() {
      return {
        loading:false,
        ruleForm:{
          qs_g_user:[],
          is_lanchbox:0
        },
      };
    },
    methods: {
      async get_config(){
        this.loading=true;
        let res = await this.$post("/uapi/admin/user/user_config/get_config",{uid:this.value});
        if (res.status == 1) {
          this.ruleForm={
            "qs_user_link":res.data.qs_user_link
          }
        }
        this.loading=false;
      },
      handleClose()
      {
        this.back.child_page.type="";
      },
      async del_user(index)
      {
        this.ruleForm.qs_g_user.splice(index, 1);
      },
      async add_user()
      {
        let user=this.ruleForm.qs_g_user;
        user.push({});
      },
      async save(){
        let data=this.ruleForm;
        let res = await this.$post("/uapi/admin/user/user_config/save",{uid:this.value,data:JSON.stringify(data)});
        if (res.status == 1) {
          this.$message.success("设置成功");
          await this.get_config();
        }
      }
    }
  }
</script>
<style scoped>
  .action{
    margin-bottom: 20px;
    display: flex;
    margin-left: 100px;
  }
  .action span{
    margin-right: 20px;
  }
  .box{
    max-width: 800px;
    margin: 0px auto;
  }
</style>
