<template>
    <div class="default-main">
        <TableHeader datePicker>
            <template v-slot:select>
                <el-form-item label="关键词">
                    <el-input v-model="tableStore.table.params.searchValue" clearable placeholder="请输入关键词" />
                </el-form-item>
            </template>
        </TableHeader>
        <Table ref="tableRef" :isGroup="true">
            <template v-slot:columns>
                <vxe-column title="问题状态">
                    <template v-slot:default="scoped">
                        <el-tag v-if="scoped.row.status == 2">处理中</el-tag>
                        <el-tag v-if="scoped.row.status == 0" type="success">已解决</el-tag>
                        <el-tag v-if="scoped.row.status == 1" type="warning">待处理</el-tag>
                    </template>
                </vxe-column>
                <vxe-column title="操作" width="180">
                    <template v-slot:default="scoped">
                        <el-button
                            size="small"
                            type="primary"
                            icon="el-icon-Finished"
                            @click="solve(scoped.row)"
                            v-if="scoped.row.status != 0"
                        >
                            解决
                        </el-button>
                    </template>
                </vxe-column>
            </template>
            >
        </Table>
    </div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { auditFeedBack } from '@/api/cs-system-boot/manage'
import { ElMessageBox, ElMessage } from 'element-plus'

defineOptions({
    name: 'govern/manage/feedback'
})
const tableStore = new TableStore({
    url: '/cs-system-boot/feedback/queryFeedBackPage',
    method: 'POST',
    column: [
        { title: '问题标题', field: 'title', align: 'center' },
        { title: '问题描述', field: 'description', align: 'center' },
        { title: '发布时间', field: 'createTime', align: 'center' }
    ],

    loadCallback: () => {}
})

provide('tableStore', tableStore)
tableStore.table.params.searchState = 0
tableStore.table.params.sortBy = ''
tableStore.table.params.orderBy = ''
tableStore.table.params.searchValue = ''

const solve = (row: any) => {
    ElMessageBox.confirm('该问题是否已解决？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(() => {
        auditFeedBack({
            id: row.id,
            status: 0
        }).then(res => {
            tableStore.onTableAction('search', {})
            ElMessage.success('操作成功!')
        })
    })
}

onMounted(() => {
    tableStore.index()
})

const addMenu = () => {}
</script>
