<template>
    <div class="app-container">
        <el-card>
            <template #header>
                <div class="card-header">
                    <span>工作台</span> <span class="subHeaderTitle">- 系统通知</span>
                </div>
            </template>
            <el-row :gutter="10" class="my_row">
                <el-col :span="12">
                    <el-form :model="queryParams" ref="queryRef" :inline="true" class="searchInputForm">
                        <el-form-item label="" prop="templateName">
                            <el-input v-model="queryParams.templateName" placeholder="请输入供应商/媒体名称/业务部门名称"
                                :prefix-icon="Search" style="width: 400px;" />
                        </el-form-item>
                    </el-form>
                </el-col>
                <el-col :span="12" style="text-align: right;">
                    <el-button type="primary" class="primaryBtn" @click="handleQuery">查询</el-button>
                    <el-button type="primary" class="primaryBtn" @click="resetQuery">重置</el-button>
                    <el-button type="primary" class="primaryBtn" @click="handleExport">导出</el-button>
                </el-col>
            </el-row>

            <el-table v-loading="loading" :data="noticeList" height="calc(100vh - 306px)">
                <el-table-column label="序号" align="center" width="80">
                    <template #default="scope">
                        {{ scope.$index + 1 }}
                    </template>
                </el-table-column>
                <el-table-column label="供应商/媒体名称" align="center" prop="templateName" />
                <el-table-column label="业务部门" align="center" prop="type" />
                <el-table-column label="通知内容" align="center" prop="originalFileName" />
                <el-table-column label="通知时间" align="center" prop="createTime">
                    <template #default="scope">
                        <span>{{ parseTime(scope.row.createTime) }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="130" align="center" class-name="small-padding fixed-width">
                    <template #default="scope">
                        <el-button link type="primary" @click="handleUpdate(scope.row)"
                            v-hasPermi="['system:pptTemplate:edit']">去处理</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <pagination :total="total" v-model:page="queryParams.pageIndex" v-model:limit="queryParams.pageSize"
                @pagination="getpptTemplatePageList" />

        </el-card>

    </div>
</template>

<script setup name="Post">
import { onMounted, ref } from 'vue';
import { Search } from '@element-plus/icons-vue'
// import { pptTemplatePage, addPptTemplate, updatePptTemplate, getPptTemplate, deletePptTemplate } from "@/api/system/pptTemplate"
import { uploadFile } from "@/api/common"
import { useBackgroundStore } from '@/store/modules/background'
import otherbg from '@/assets/images/otherbg.png'
const bgStore = useBackgroundStore()

const { proxy } = getCurrentInstance()

// 列表数据
const noticeList = ref([])
const loading = ref(true)
const total = ref(0)

const data = reactive({
    queryParams: {
        pageIndex: 1,
        pageSize: 10,
        templateName: undefined,
    }
})

const { queryParams } = toRefs(data)

/** 查询通知列表 */
const getNoticePageList = () => {
    loading.value = false
    // pptTemplatePage(queryParams.value).then(res => {
    //     templateList.value = res.data.list
    //     total.value = res.data.total
    //     loading.value = false
    // })
}

/** 搜索按钮操作 */
const handleQuery = () => {
    queryParams.value.pageIndex = 1
    getNoticePageList()
}

/** 重置按钮操作 */
function resetQuery() {
    proxy.resetForm("queryRef")
    handleQuery()
}

/** 去处理 */
const handleUpdate = (row) => {

}
/** 导出按钮操作 */
const handleExport = () => {
    // exportSupplier(queryParams.value).then(res => {
    //     // 通过a标签打开新页面下载文件
    //     const a = document.createElement('a')
    //     a.href = URL.createObjectURL(res)
    //     // a标签里有download属性可以自定义文件名
    //     const downLoadName = '供应商_' + Date.now() + '.xlsx'
    //     a.setAttribute('download', downLoadName)
    //     document.body.appendChild(a)
    //     a.click()
    //     document.body.removeChild(a)
    // })
}

// 初始化
onMounted(() => {
    bgStore.setBgImage(otherbg)
    getNoticePageList()
}); 
</script>
<style lang='scss'>
.el-form-item__content {
    display: block;
}
</style>