<!-- 用户编辑弹窗 -->
<template>
  <ele-modal
    :width="360"
    :visible="visible"
    :confirm-loading="loading"
    :maskClosable="false"
    :maxable="maxable"
    :title="`批量转移`"
    :body-style="{ paddingBottom: '8px' }"
    @update:visible="updateVisible"
    @ok="save"
  >
    <a-space>
      <a-form
        :label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
        :wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
      >
        <a-form-item label="转移到">
          <UserSelect
            v-model:value="userId"
            :placeholder="`请选择用户`"
            @select="onSelect"
          />
        </a-form-item>
      </a-form>
    </a-space>
  </ele-modal>
</template>

<script lang="ts" setup>
  import { ref, reactive, watch, computed } from 'vue';
  import { Form, message } from 'ant-design-vue';
  import UserSelect from '@/components/UserSelect/index.vue';
  import { updateBatchCustomer } from '@/api/oa/customer';
  import type { Customer } from '@/api/oa/customer/model';
  import { useUserStore } from '@/store/modules/user';
  import {Organization} from "@/api/system/organization/model";

  const userStore = useUserStore();
  // 当前用户信息
  const loginUser = computed(() => userStore.info ?? {});
  // 是否是修改
  const isUpdate = ref(false);
  const useForm = Form.useForm;
  const props = defineProps<{
    // 弹窗是否打开
    visible: boolean;
    // 修改回显的数据
    data?: Customer[] | [];
  }>();

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

  // 提交状态
  const loading = ref(false);
  // 是否显示最大化切换按钮
  const maxable = ref(false);
  const userId = ref(0);

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

  // 选择用户
  const onSelect = (item) => {
    userId.value = item.userId;
  };

  /* 保存编辑 */
  const save = () => {
    const saveData = props.data;
    saveData?.map((d) => {
      d.userId = userId.value;
    });
    // updateBatchCustomer(saveData);
  };

  watch(
    () => props.visible,
    () => {}
  );
</script>
<style lang="less"></style>
