<script setup lang="ts">
import type { BasicForm, ICRUD } from '@/types/form'

const CRUD: ICRUD = {
  create(data: any) {
    return Promise.resolve(data)
  },
  update(data: any) {
    return Promise.resolve(data)
  },
  getList() {
    return Promise.resolve()
  },
  delete(data: any) {
    return Promise.resolve(data)
  }
}

const formConfig = reactive<BasicForm>({
  span: 24,
  formItems: []
})

const dialogVisible = ref(false)
const replyConfig = reactive<BasicForm>({
  span: 24,
  formItems: [
    {
      label: '回复内容',
      value: '',
      name: 'reply',
      type: 'input',
      rules: [{ required: true, message: '请输入回复内容', trigger: 'blur' }],
      props: {
        type: 'textarea'
      }
    }
  ]
})
const curQuestion = ref<any>(null)
const formData = ref<any>({})

const openDiolog = (row: any) => {
  dialogVisible.value = true
  curQuestion.value = row
}
const handleReply = () => {
  // 回复接口
}
</script>

<template>
  <pro-table
    :formConfig="formConfig"
    :crud="CRUD"
    :selection="false"
    :showToolbar="false"
    :tableConfig="{ showOperate: false }"
  >
    <el-table-column prop="content" label="反馈内容"></el-table-column>
    <el-table-column prop="publishDate" label="反馈时间"></el-table-column>
    <el-table-column fixed="right" label="操作" width="100">
      <template #default="{ row }">
        <el-button link type="primary" size="small" @click="openDiolog(row)">回复</el-button>
      </template>
    </el-table-column>
  </pro-table>

  <dialog-form
    v-model="dialogVisible"
    :formConfig="replyConfig"
    :create="handleReply"
    :update="handleReply"
    :formData="formData"
    v-if="dialogVisible"
  />
</template>

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