<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-button
                type="primary"
                icon="el-icon-plus"
                @click="addWork"
                v-auth="'carbon_work.create'"
                >新建核算工作</el-button>
            </div>
            <div class="right-panel">
                <el-input v-model="query.search" placeholder="名称" @keyup.enter="handleQuery"></el-input>
                <el-button
                    type="primary"
                    icon="el-icon-search"
                    @click="handleQuery"
                ></el-button>
            </div>
        </el-header>
        <el-main class="nopadding">
            <scTable
            ref="table"
            :apiObj="API.carbon.work.my"
            row-key="id"
            stripe
            :query="query"
            @row-click="(row)=>{t_id=row.id;mode='show';drawerVisible=true;}"
            >
            <el-table-column  label="ID" prop="id" width="160"></el-table-column>
            <el-table-column  label="核算名称" prop="name" width="200"></el-table-column>
            <el-table-column  label="核算类型" prop="type" width="100"></el-table-column>
            <el-table-column  label="贷前得分" prop="score_dq" width="100"></el-table-column>
            <el-table-column  label="贷后得分" prop="score_dh" width="100"></el-table-column>
            <el-table-column  label="创建人" prop="create_by_name" width="100"></el-table-column>
            <el-table-column  label="所属单位" prop="belong_dept_name" width="200" show-overflow-tooltip></el-table-column>
            <el-table-column  label="工作描述" prop="description" show-overflow-tooltip></el-table-column>
            <el-table-column  label="创建时间" prop="create_time" width="160"></el-table-column>
            </scTable>
        </el-main>
    </el-container>
    <el-drawer title="核算工作" v-model="drawerVisible" :size="'90%'" destroy-on-close @close="table.refresh()">
        <work_form :mode="mode" :t_id="t_id"></work_form>
    </el-drawer>
</template>
<script setup>
import { ref } from 'vue';
import API from '@/api'
import work_form from './work_form.vue';
const drawerVisible = ref(false);
const mode = ref('show');
const table = ref();
const query = ref({
    search: ''
});
const t_id = ref(null);
function addWork(){
    mode.value = 'add';
    t_id.value = null;
    drawerVisible.value = true;
}
function handleQuery(){
    table.value.refresh();
}
</script>