<template>
    <div>
        <!-- <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="查询" prop="name">
                    <el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入内容" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card> -->

        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <div class="mt-4">
                <el-table :data="pager.lists" @cell-click="handleCurrentChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="序号" type="index" width="55" />
                    <el-table-column label="流程编号" prop="approve_id" show-overflow-tooltip />
                    <el-table-column label="客户名称" prop="custom_name" show-overflow-tooltip />
                    <el-table-column label="项目名称" prop="project_name" show-overflow-tooltip />
                    <el-table-column label="项目编码" prop="project_code" show-overflow-tooltip />
                    <el-table-column label="合同名称" prop="contract_name" show-overflow-tooltip />
                    <el-table-column label="合同编号" prop="contract_code" show-overflow-tooltip />
                    <el-table-column label="合同类型" prop="contract_type">
                        <template #default="{ row }">
                            <dict-value :options="dictData.contract_type" :value="row.contract_type" />
                        </template>
                    </el-table-column>
                    <el-table-column label="甲方" prop="party_a" show-overflow-tooltip />
                    <el-table-column label="甲方通讯地址" prop="party_a_contact_address" show-overflow-tooltip />
                    <el-table-column label="甲方主要负责人" prop="party_a_diretor" show-overflow-tooltip />
                    <el-table-column label="甲方电话" prop="party_a_phone" show-overflow-tooltip />
                    <el-table-column label="甲方手机" prop="party_a_mobile" show-overflow-tooltip />
                    <el-table-column label="甲方邮箱" prop="party_a_email" show-overflow-tooltip />
                    <el-table-column label="乙方" prop="party_b" show-overflow-tooltip />
                    <el-table-column label="乙方通讯地址" prop="party_b_contact_address" show-overflow-tooltip />
                    <el-table-column label="乙方主要负责人" prop="party_b_diretor" show-overflow-tooltip />
                    <el-table-column label="乙方电话	" prop="party_b_phone" show-overflow-tooltip />
                    <el-table-column label="乙方手机	" prop="party_b_mobile" show-overflow-tooltip />
                    <el-table-column label="乙方邮箱	" prop="party_b_email" show-overflow-tooltip />
                    <el-table-column label="合同金额" prop="amount" show-overflow-tooltip />
                    <el-table-column label="金额大写	" prop="amount_daxie" show-overflow-tooltip />
                    <el-table-column label="合同有效期" prop="expire" show-overflow-tooltip />
                    <el-table-column label="状态" prop="contract_status" show-overflow-tooltip>
                        <template #default="{ row }">
                            <dict-value :options="dictData.contract_status" :value="row.contract_status" />
                        </template>
                    </el-table-column>
                    <el-table-column label="主要条款" prop="" show-overflow-tooltip />
                    <el-table-column label="备注" prop="" show-overflow-tooltip />
                    <el-table-column label="已回款" prop="" show-overflow-tooltip />
                    <el-table-column label="未回款" prop="" show-overflow-tooltip />
                    <el-table-column label="已开票" prop="" show-overflow-tooltip />
                    <el-table-column label="未开票" prop="" show-overflow-tooltip />
                    <el-table-column label="实际合同金额" prop="business_director" show-overflow-tooltip />
                    <el-table-column label="已退款金额" prop="contract_status" show-overflow-tooltip />
                    <el-table-column label="合同附件" prop="expire" show-overflow-tooltip>
                        <template #default="{ row }">
                            <div v-if="row.annex && row.annex.length > 0">
                                <div v-for="(item, index) in row.annex" :key="index" style="margin-left: 5px;display: block;">
                                    <a style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item" target="_blank">文件{{ index + 1 }}查看</a>
                                </div>
                            </div>
                            <div v-else>暂无文件</div>
                        </template>
                    </el-table-column>

                    <el-table-column label="投标编号" prop="contract_date" show-overflow-tooltip />
                    <el-table-column label="签约日期" prop="contract_date" show-overflow-tooltip />
                    <el-table-column label="业务负责人" prop="contract_date" show-overflow-tooltip />
                </el-table>

            </div>
            <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
  
<script lang="ts" setup>
import { usePaging } from "@/hooks/usePaging"
import { useDictData } from "@/hooks/useDictOptions"
import { projectcontracts } from '@/api/common'
import { defineEmits } from "vue"
import { timeFormat } from '@/utils/util'
const props = defineProps({

    project_id: {
        type: String
    },
})
// console.log(props.productid)
// 查询条件
const queryParams = reactive({
    project_id: props.project_id || '',

});
const { dictData } = useDictData('contract_type,contract_pricing_method,contract_status')
// 选中数据
const emits = defineEmits(["customEvent"]);

// 选中数据子父传递
const handleCurrentChange = (value: any) => {
    emits("customEvent", value);
};

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: projectcontracts,
    params: queryParams,

});

getLists();
</script>