<template>
    <lay-container fluid="true" style="padding: 20px">
        <lay-row :space="10">
            <lay-col :md="24">
                <lay-card>
                    <lay-form style="margin-top: 20px">
                        <lay-row>
                            <lay-col :md="5">
                                <lay-form-item label="年度：" label-width="50">
                                    <lay-date-picker type="year" v-model="searchAccount" placeholder="请选择"
                                        allow-clear></lay-date-picker>
                                </lay-form-item>
                            </lay-col>
                            <lay-col :md="4">
                                <lay-form-item label-width="0">
                                    <lay-button type="primary" @click="toSearch">查询</lay-button>
                                    <lay-button @click="toReset">重置</lay-button>
                                </lay-form-item>
                            </lay-col>
                        </lay-row>
                    </lay-form>
                </lay-card>
            </lay-col>
            <lay-col :md="24">
                <lay-card>
                    <div style="padding: 10px">
                        <span style="font-size: 18px;vertical-align: center;margin-right: 20px">季度评价填报</span>
                        <lay-button type="primary" @click="addShow = true" size="sm">新增自我评价</lay-button>
                    </div>
                    <lay-table :columns="columns" :dataSource="dataSource" :even="true" height="500px"
                        size="lg"></lay-table>
                </lay-card>
            </lay-col>
        </lay-row>
        <lay-layer v-model="addShow" title="季度自评详情" :shade="true" :area="['500px', '500px']"
            :btn="addIsInfo == 1 ? addButton : ''">
            <lay-container fluid="true" style="padding: 20px">
                <div style="margin-bottom: 20px">填报季度：第 {{ quarter }} 季度</div>
                <lay-form :pane="true">
                    <lay-form-item label="自评内容" prop="desc">
                        <lay-textarea :rows="10" placeholder="请输入评价内容" v-model="addModel.desc"></lay-textarea>
                    </lay-form-item>
                </lay-form>
            </lay-container>
        </lay-layer>
    </lay-container>
</template>

<script setup lang="ts">
import { ref, onMounted, reactive } from 'vue'
import { layer } from '@layui/layer-vue'
import {
    MonthlyList,
    MonthlyContent
} from '../../api/module/home'
import { useUserStore } from "@/store/user";
import dayjs from "dayjs";
const addIsInfo = ref(1);
const dataSource = ref([]);
const addShow = ref(false);
//

const addModel = reactive({
    desc: ''
})
const getQuarter = () => {
    //帮我改造一下
    return dayjs().month() < 3 ? 1 : dayjs().month() < 6 ? 2 : dayjs().month() < 9 ? 3 : 4;
}
const quarter = ref(getQuarter());
onMounted(() => {
    //getMonthlyList();
    //getMonthlyContent();
})

const searchAccount = ref(dayjs().year())

function toReset() {
    searchAccount.value = dayjs().year()
}
const columns = [
    {
        title: '季度',
        width: '120px',
        align: 'center',
        key: 'quarter'
    },
    {
        title: '考评对象',
        width: '150px',
        align: 'center',
        key: 'user'
    },
    {
        title: '评价时间',
        width: '250px',
        align: 'center',
        key: 'createtime'
    },
    {
        title: '我的评价',
        key: 'self_score',
        align: 'center',
    }, {
        title: '科室评价',
        key: 'department_score',
        customSlot: 'department_score',
        align: 'center',
    },
    {
        title: '操作',
        width: '180px',
        customSlot: 'operator',
        key: 'operator',
        align: 'center',
        fixed: 'right'
    }
]
const addButton = ref([
    {
        text: "确认",
        callback: async () => {
            //   var json = JSON.stringify(dataSource6.value);
            //   var res = await MonthlyCreate({ 'json': json, 'user_id': userStore.userInfo.id, evaluation_schedule_id: current1.value });
            //   console.log(res)
            //   if (res.code == 1) {
            //     layer.msg('提交成功！', { icon: 1 })
            //     visible11.value = false;
            //     getMonthlyList();
            //     //getMonthlyContent();
            //   } else {
            //     layer.msg(res.msg, { icon: 2 })
            //   }
        }
    },
    {
        text: "取消",
        callback: () => {
            addShow.value = false;
        }
    }
])
</script>
<style>
.layui-table-header .layui-table-cell {
    background-color: #ECF8FA !important;
}
</style>