<template>
    <div class="app-container">
        <div class="searchPanel">
            <div class="more-search-pane">
                <div class="search-where-container">
                    <el-form :model="queryParams" ref="queryRef" :inline="true" class="searchPanelForm">
                        <el-form-item label="发票类型:">
                            <el-select v-model="queryParams.invoice_type" placeholder="请选择" style="min-width: 30px;"
                                clearable> 
                                <el-option v-for="dict in invoice_type" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="媒体归属:">
                            <el-select v-model="queryParams.media_ownership" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in media_ownership" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="人员规模:">
                            <el-select v-model="queryParams.personnel_size" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in personnel_size" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="主营媒体类型:">
                            <el-select v-model="queryParams.main_media_types" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in main_media_types" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="媒体质量:">
                            <el-select v-model="queryParams.media_quality" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in media_quality" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="有无合作历史:">
                            <el-select v-model="queryParams.history_cooperation" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in history_cooperation" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="供应商级别:">
                            <el-select v-model="queryParams.supplier_level" placeholder="请选择" style="min-width: 30px;" clearable>
                                <el-option v-for="dict in supplier_level" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="search-more-button">
                    <el-button v-if="!unfoldFlag" text class="foladText" @click="handleFlod">展开
                        <svg-icon icon-class="unfold" class="ml10" />
                    </el-button>
                    <el-button v-else text class="foladText" @click="handleFlod">收起
                        <svg-icon icon-class="packUp" class="ml10" />
                    </el-button>
                </div>
            </div>
        </div>
        <div class="searchSmallPanel" v-show="unfoldFlag">
            <el-form :model="queryParams" ref="queryRef" :inline="true" class="searchSmallPanelForm">
                <el-form-item label="供应商配合度:">
                    <el-select v-model="queryParams.supplier_cooperation_degree" placeholder="请选择" style="min-width: 30px;" clearable >
                        <el-option v-for="dict in supplier_cooperation_degree" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="主营业务:">
                    <el-select v-model="queryParams.main_business" placeholder="请选择" clearable style="min-width: 30px;">
                        <el-option v-for="dict in main_business" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="业务部门:">

                </el-form-item>
                <el-form-item label="城市:">

                </el-form-item>
                <el-form-item label="">

                </el-form-item>
                <el-form-item label="">

                </el-form-item>
            </el-form>
        </div>

        <el-card class="mt20">
            <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="">
                            <el-input v-model="form.postCode" placeholder="请输入供应商名称/集团公司名称/联系人/联系人电话"
                                :prefix-icon="Search" style="width: 500px;" />
                        </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-col>
            </el-row>

             <el-table v-loading="loading" :data="supplierList" :height="unfoldFlag ? 'calc(100vh - 342px)' : 'calc(100vh - 308px)'"> 
                 <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="postId" width="230" />
                <el-table-column label="城市" align="center" prop="postCode" width="150"/> 
                <el-table-column label="主营业务" align="center" prop="postCode" width="150"/> 
                <el-table-column label="主营媒体类型" align="center" prop="postCode" width="150"/> 
                <el-table-column label="媒体质量" align="center" prop="postCode" width="150"/> 
                <el-table-column label="供应商配合度" align="center" prop="postCode" width="150"/> 
                <el-table-column label="人员规模" align="center" prop="postCode" width="150"/> 
                <el-table-column label="公司类型" align="center" prop="postCode" width="150"/> 
                <el-table-column label="年营收金额" align="center" prop="postCode" width="150"/> 
                <el-table-column label="媒体归属" align="center" prop="postCode" width="150"/> 
                <el-table-column label="媒体年限" align="center" prop="postCode" width="150"/> 
                <el-table-column label="有无合作历史" align="center" prop="postCode" width="150"/> 
                <el-table-column label="合作折扣力度" align="center" prop="postCode" width="150"/> 
                <el-table-column label="供应商联系人" align="center" prop="postCode" width="150"/> 
                <el-table-column label="供应商联系电话" align="center" prop="postCode" width="150"/> 
                <!-- <el-table-column label="反馈时间" align="center" prop="createTime" width="210">
                    <template #default="scope">
                        <span>{{ parseTime(scope.row.createTime) }}</span>
                    </template>
                </el-table-column> -->
                <el-table-column label="操作" width="160" align="center" fixed="right" >
                    <template #default="scope">
                        <el-button link type="primary" @click="handleUpdate(scope.row)"
                            v-hasPermi="['problemFeedback:edit']">修改</el-button>
                        <el-button link type="primary" @click="handleDelete(scope.row)"
                            v-hasPermi="['problemFeedback:remove']">删除</el-button>
                        <el-button link type="primary" @click="handleDelete(scope.row)"
                            v-hasPermi="['problemFeedback:remove']">日志</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
                @pagination="getList" />
        </el-card>
    </div>
</template>
<script setup name="Post">

import { onMounted, ref } from 'vue';
import { Search } from '@element-plus/icons-vue'
import { useBackgroundStore } from '@/store/modules/background'
import otherbg from '@/assets/images/otherbg.png'
const bgStore = useBackgroundStore()

const { proxy } = getCurrentInstance()
const { invoice_type, media_ownership, personnel_size, main_media_types, media_quality, history_cooperation, supplier_level, supplier_cooperation_degree, main_business } = proxy.useDict("invoice_type", "media_ownership", "personnel_size", "main_media_types", "media_quality", "history_cooperation", "supplier_level", "supplier_cooperation_degree", "main_business")



const supplierList = ref([])
const loading = ref(true)
const total = ref(0)
const data = reactive({
    form: {},
    queryParams: {
        pageNum: 1,
        pageSize: 10,
    },
    rules: {
        postName: [{ required: true, message: "岗位名称不能为空", trigger: "blur" }],
        postCode: [{ required: true, message: "岗位编码不能为空", trigger: "blur" }],
        postSort: [{ required: true, message: "岗位顺序不能为空", trigger: "blur" }],
    }
})

const { queryParams, form, rules } = toRefs(data)

// 折叠展开
const unfoldFlag = ref(false)
const handleFlod = () => {
    unfoldFlag.value = !unfoldFlag.value
}

/** 查询岗位列表 */
const getList = () => {
    loading.value = false
    // listPost(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => {
    //     postList.value = response.rows
    //     total.value = response.total
    //     loading.value = false
    // })
}
/** 搜索按钮操作 */
const handleQuery = () => {
    queryParams.value.pageNum = 1
    getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
    proxy.resetForm("queryRef")
    handleQuery()
}
/** 删除按钮操作 */
const handleDelete = (row) => {
    const postIds = row.postId || ids.value
    proxy.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项？').then(function () {
        return delPost(postIds)
    }).then(() => {
        getList()
        proxy.$modal.msgSuccess("删除成功")
    }).catch(() => { })
}

// 初始化
onMounted(() => {
    bgStore.setBgImage(otherbg)
    getList()
}); 
</script>