<template>
  <el-dialog title="成交登记" v-model="show" width="800px" style="height: 90vh">
    <Descriptions :data="info" :schema="schema" :columns="2" />
    <el-form :model="form" ref="formRef" :rules="rules" label-width="80px" class="mt-20px">
      <el-row :gutter="20">
        <el-col :span="12" :offset="0">
          <el-form-item label="成交日期">
            <el-date-picker
              v-model="form.date"
              type="date"
              placeholder="选择日期时间"
              style="width: 100%"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12" :offset="0">
          <el-form-item label="是否全款">
            <el-radio-group v-model="form.isFull">
              <el-radio :label="1"> 全款 </el-radio>
              <el-radio :label="2"> 非全款 </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="12" :offset="0">
          <el-form-item label="支付金额">
            <el-input-number v-model="form.pay" :min="1" :step="1" style="width: 100%" />
          </el-form-item>
        </el-col>
        <el-col :span="24" :offset="0">
          <el-form-item label="备注">
            <Editor v-model:modelValue="form.remark" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <span>
        <el-button @click="show = false">取 消</el-button>
        <el-button type="primary" @click="handleSave">保 存</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
const show = ref(false)
const form = ref({})
const rules = ref({})
const info = ref({})

const schema = ref([
  {
    field: 'name',
    label: '线索名称'
  },
  {
    field: 'specsName',
    label: '联系方式'
  },
  {
    field: 'supplier',
    label: '意向状态'
  },
  {
    field: 'supplier',
    label: '创建时间'
  },
  {
    field: 'purchaseCount',
    label: '诉求',
    span: 2
  },
  {
    field: 'remark',
    label: '备注',
    isEditor: true,
    span: 2
  }
])

function open(val) {
  show.value = true
  info.value = { ...val }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

function handleSave() {
  console.log('保存成功')
}
</script>

<style lang="scss" scoped></style>
