<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-button type="primary" @click="handleAdd('入库')" v-auth="'assetlog.create'">资产入库</el-button>
            </div>
            <div class="right-panel">
                <el-input
                    v-model="query.search"
                    placeholder="关键词"
                    clearable
                    @keyup.enter="$refs.table.refresh()"
                ></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.asm.assetlog.list"
            row-key="id"
            stripe
            :query="query"
            @row-click="(row)=>{t_id=row.id;mode='show';drawerVisible=true;drawerTitle=row.type}"
            >
            <el-table-column label="操作类型" prop="type" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column label="流程状态" width="300" show-overflow-tooltip>
                <template #default="scope">
                                <el-tag :type="actStateEnum[scope.row.ticket_?.act_state]?.type">
                        {{ actStateEnum[scope.row.ticket_?.act_state]?.text }}
                    </el-tag>
            <el-tag type="info" effect="plain">{{ scope.row.ticket_?.state_.name }}</el-tag>
          </template>
            </el-table-column>
            <el-table-column label="启用日期" prop="start_date"  width="160" show-overflow-tooltip></el-table-column>
            <el-table-column label="保管部门" prop="keep_dept_name" width="160" show-overflow-tooltip></el-table-column>`
            <el-table-column label="保管人" prop="keeper_name"  width="80" show-overflow-tooltip></el-table-column>
            <el-table-column label="资产条数" width="80" show-overflow-tooltip>
                <template #default="scope">
                    {{ scope.row.items?.length }}
                </template>
            </el-table-column>
            <el-table-column label="创建时间" prop="create_time" show-overflow-tooltip></el-table-column>
            </scTable>
        </el-main>
    </el-container>
    <el-drawer :title="drawerTitle" v-model="drawerVisible" :size="'80%'" destroy-on-close>
        <assetlogin_form :mode="mode" :t_id="t_id"></assetlogin_form>
    </el-drawer>
</template>
<script setup>
import { ref } from 'vue'
import API from '@/api'
import { actStateEnum, interveneTypeEnum } from "@/utils/enum.js";
import assetlogin_form from './assetlogin_form.vue'
const query = ref({});
const drawerVisible = ref(false);
const drawerTitle = ref('资产入库');
const mode = ref('add');
const t_id = ref(null);
const handleAdd = () => {
    mode.value = 'add';
    drawerVisible.value = true;
}
</script>