<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader
            :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
            :quick-search-placeholder="t('quick Search Placeholder', { fields: t('xuqiuOrder.quick Search Fields') })"
        />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table ref="tableRef" />

        <!-- 表单 -->
        <PopupForm />
    </div>
</template>

<script setup lang="ts">
import { ref, provide, onMounted } from 'vue'
import baTableClass from '/@/utils/baTable'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'

const { t } = useI18n()
const tableRef = ref()
const optButtons = defaultOptButtons(['edit', 'delete'])
const baTable = new baTableClass(
    new baTableApi('/admin/XuqiuOrder/'),
    {
        pk: 'id',
        column: [
            { type: 'selection', align: 'center', operator: false },
            { label: t('xuqiuOrder.id'), prop: 'id', align: 'center', width: 70, operator: 'RANGE', sortable: 'custom' },
            { label: t('xuqiuOrder.需求订单编号'), prop: '需求订单编号', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.活动城市'), prop: '活动城市', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.需求项目'), prop: '需求项目', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.活动人数'), prop: '活动人数', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.活动需求'), prop: '活动需求', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.活动时间'), prop: '活动时间', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.活动总天数'), prop: '活动总天数', align: 'center', operator: 'RANGE', sortable: false },
            { label: t('xuqiuOrder.咨询截止时间'), prop: '咨询截止时间', align: 'center', operator: '=', sortable: 'custom', width: 160 },
            { label: t('xuqiuOrder.状态'), prop: '状态', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.需求公司'), prop: '需求公司', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.联系电话'), prop: '联系电话', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.创建人'), prop: '创建人', align: 'center', operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', sortable: false },
            { label: t('xuqiuOrder.创建时间'), prop: '创建时间', align: 'center', operator: '=', sortable: 'custom', width: 160 },
            { label: t('xuqiuOrder.更新时间'), prop: '更新时间', align: 'center', operator: '=', sortable: 'custom', width: 160 },
            { label: t('operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
        ],
        dblClickNotEditColumn: [undefined],
    },
    {
        defaultItems: { '需求订单编号': null, '活动城市': null, '需求项目': null, '活动人数': null, '活动需求': null, '活动时间': null, '活动总天数': 0, '咨询截止时间': null, '状态': null, '需求公司': null, '联系电话': null, '创建人': null },
    }
)

provide('baTable', baTable)

onMounted(() => {
    baTable.table.ref = tableRef.value
    baTable.mount()
    baTable.getIndex()?.then(() => {
        baTable.initSort()
        baTable.dragSort()
    })
})
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'xuqiuOrder',
})
</script>

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