<template>
  <el-dialog title="修改用户" :close-on-click-modal="false" :visible.sync="open" width="800px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row>
        <el-form-item label="标签" prop="tag">
          <el-select v-model="form.tag" size="small" style="width: 95%">
            <el-option
                v-for="dict in userTagList"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            />
          </el-select>
        </el-form-item>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="open = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { userTagList } from '@/constant/statusMap'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { updateUserTag } from '@/api/xq/user'

export default {
  name: "UserInfo",
  components: { },
  data() {
    return {
      userTagList,
      open:false,
      buttonLoading: false,
      userIds: [],
      form:{
        tag: undefined,
      },
      rules:{
      },
    };
  },
  created() {
  },
  methods: {
    init(userIds,tag){
      this.open = true;
      this.$nextTick(() => {
        this.form.tag = tag
        this.userIds = userIds
      })
    },
    submitForm(){
      updateUserTag({
        'tag': this.form.tag,
        'userIds': this.userIds,
      }).then(data => {
        this.$modal.msgSuccess("修改用户成功");
        this.buttonLoading = false;
        this.open = false
        this.$emit('refreshDataList')
      }).finally(() => {
        this.buttonLoading = false;
      });
    },
  }
};
</script>
