<template>
    <div class="default-main">
        <TableHeader datePicker>
            <template v-slot:select>
                <el-form-item label="关键字筛选">
                    <el-input maxlength="32" show-word-limit    v-model.trim="tableStore.table.params.searchValue"
                        clearable placeholder="请输入关键字筛选" />
                </el-form-item>
            </template>
        </TableHeader>
        <Table ref="tableRef"></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' , sortable: true},
        {
            title: '状态',
            field: 'status',
            width: '100',
            render: 'tag',
            custom: {
                0: 'success',
                1: 'warning',
                2: 'primary'
            },
            replaceValue: {
                0: '已解决',
                1: '待处理',
                2: '处理中'
            }
        },
        {
            title: '操作', fixed: 'right',
            align: 'center',
            width: '180',
            render: 'buttons',
            buttons: [
                {
                    name: 'Finished',
                    title: '解决',
                    type: 'primary',
                    icon: 'el-icon-Finished',
                    render: 'confirmButton',
                    disabled: row => {
                        return row.status == 0
                    },
                    popconfirm: {
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        confirmButtonType: 'danger',
                        title: '该问题是否已解决？'
                    },
                    click: row => {
                        auditFeedBack({
                            id: row.id,
                            status: 0
                        }).then(res => {
                            tableStore.onTableAction('search', {})
                            ElMessage.success('操作成功!')
                        })
                    }
                }
            ]
        }
    ],

    loadCallback: () => { }
})

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

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

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