<template>
  <ele-modal
    :width="400"
    :visible="visible"
    :title="`邀请新成员`"
    :body-style="{ paddingBottom: '28px' }"
    @update:visible="updateVisible"
    :footer="null"
    @ok="save"
  >
    <div
      class="qrcode-list"
      style="display: flex; justify-content: space-around"
    >
      <div>
        <img :src="qrcode" width="240" height="240" />
        <div
          style="
            display: flex;
            justify-content: center;
            font-size: 26px;
            padding-top: 20px;
          "
          >使用微信扫一扫</div
        >
      </div>
    </div>
  </ele-modal>
</template>
<script lang="ts" setup>
  import { User } from '@/api/system/user/model';
  import { reactive, ref } from 'vue';
  import { taskJoinQRCode } from '@/api/oa/task';

  defineProps<{
    // 弹窗是否打开
    visible: boolean;
  }>();

  const emit = defineEmits<{
    (e: 'done', user: User): void;
    (e: 'update:visible', visible: boolean): void;
  }>();

  /* 更新visible */
  const updateVisible = (value: boolean) => {
    emit('update:visible', value);
  };

  const qrcode = ref('');

  // 用户信息
  const form = reactive<User>({
    userId: undefined,
    nickname: undefined
  });

  const save = () => {
    emit('done', form);
  };

  taskJoinQRCode({}).then((text) => {
    qrcode.value = String(text);
  });
</script>
<style scoped lang="less"></style>
