<template>
  <my-dialog
    :visible="visible"
    @close="emit('update:visible', false)"
    :header="`${isEdit ? '修改' : '新增'}服务单元`"
    :width="600"
    :closeOnOverlayClick="false"
  >
    <t-form ref="formRef" :model="formData" labelWidth="120px">
      <t-form-item label="服务单元名称：">
        <t-input v-model="formData.a"></t-input>
      </t-form-item>
      <t-form-item label="业务类型：">
        <t-select v-model="formData.b"></t-select>
      </t-form-item>
      <t-form-item label="服务开始时间：">
        <t-date-picker v-model="formData.c" />
      </t-form-item>
      <t-form-item label="服务截止时间：">
        <t-date-picker v-model="formData.d" />
      </t-form-item>
      <t-form-item label="区域配比：">
        <t-input-number
          v-model="formData.e"
          theme="column"
          :decimalPlaces="0"
          align="center"
          :max="1000"
          :min="0"
          style="width: 80px"
        ></t-input-number>
        <span style="padding: 0 10px">:</span>
        <t-input-number
          v-model="formData.f"
          theme="column"
          :decimalPlaces="0"
          align="center"
          :max="1000"
          :min="0"
          style="width: 80px"
        ></t-input-number>
      </t-form-item>
      <t-form-item label="负责人：">
        <t-select v-model="formData.g"></t-select>
      </t-form-item>
    </t-form>
    <template #foot>
      <t-button theme="default" @click="emit('update:visible', false)"
        >取消</t-button
      >
      <t-button theme="primary" @click="save">保存</t-button>
    </template>
  </my-dialog>
</template>
<script setup name="AddUnitDialog">
import useClearDialog from '@/hooks/useClearDialog';
import { ref } from 'vue';
const emit = defineEmits(['update:visible']);
const formRef = ref(null);

const props = defineProps({
  visible: Boolean,
  curRow: Object,
});
const getDetail = async () => {
  //编辑状态下获取回显数据的接口请求业务,如果curRow里的字段够用，就直接把curRow里的字段赋值给formData
  alert('获取详情中...');
};
const { formData, isEdit } = useClearDialog(
  {
    a: '',
    b: '',
    c: '',
    d: '',
    e: '',
    f: '',
    g: '',
  },
  props,
  getDetail
);
const save = () => {};
</script>
