<template>
    <div class=''>
        <div class="card" :style="{ height: tableHeight }" v-show="!showView">
            <div class="flex title">
                <h3>任务信息</h3>
                <el-button type="text" round @click="handelClickBack" icon="el-icon-back">返回</el-button>
            </div>
            <el-form ref="form" label-position="left" :model="formData" label-width="120px"
                style="margin-left: 3%; margin-top: 30px;">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="任务主题">
                            <div style="display: flex; align-items: center;">
                                <div>{{ formData.taskTitle}}</div>
                            </div>

                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="任务发布时间">
                            <div>{{formData.createdTime}}</div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="任务发布部门">
                            <div>{{formData.agencyName}}</div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="任务发布人">
                            <div>{{formData.createByName}}</div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="任务类型">
                            <div>{{formData.type}}</div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="任务周期">
                            <div>{{formData.taskPeriod === 'once' ? '一次性' : '每周'}}</div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="任务接收人">
                            <div style="display: flex;flex-direction: row; align-items: center;">
                                <div>{{formData.userName}}</div>
                                <el-button @click="oncClickInfo('adjust')" style="margin-left: 10px;"
                                    type="primary">转派其他接受人</el-button>
                            </div>

                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="任务说明">
                            <div style="display: flex;flex-direction: row; align-items: center;">
                                <div>{{formData.taskIntroduction}}</div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div class="flex title flex-center-deputy">
                <h3>任务提醒</h3>
                <span>（点击以下表格开始提报任务）</span>
            </div>
            <div class="flex-wrap flex">
                <div class="item flex flex-y flex-center-deputy" @click="handleClickShowView('1877549575149813762')"
                    :key="index">
                    <img :src="require(`@/assets/images/index/Excel.png`)" alt="">
                    <div class="agencyName">周期更新表</div>
                    <div>（）</div>
                </div>
            </div>
            <div class="flex title flex-center-deputy">
                <h3>相关任务</h3>
            </div>
            <div class="m-table">
                <el-table :data="tableData" border class="m-table-item"
                    style="width: 70%;margin-left: 3%; margin-top: 30px;" :height="maxTableHeight">
                    <el-table-column label="序号" fixed="left" type="index" align="center" width="80" />
                    <el-table-column prop="renwu" align="center" :show-overflow-tooltip="true" label="任务周期">
                    </el-table-column>
                    <el-table-column prop="status" fixed="right" label="状态" align="center">
                        <template slot-scope="scope">
                            <div  :style="{ color: scope.row.status ? '#08af58' : '' }">{{ scope.row.status?"已存档":"未完成" }}</div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <div v-if="showView">
            <excel-view @close="close" :workbookId="workbookId" :pageType="'filling'" :sheetTotal="true"></excel-view>
        </div>
        <el-dialog title="转派其他接收人" :visible.sync="showPersonel" width="50%" :close-on-click-modal="false">
                <acceptingPersonel :showType="showType" :acceptingId="formData.acceptingId"
                    @handelPersonel="handelPersonel"></acceptingPersonel>
            </el-dialog>
    </div>
</template>

<script>
import { requestPost, requestGet } from "@/js/dai/request";
import { mapGetters } from 'vuex'
import excelView from "./excel-view.vue";
import acceptingPersonel from "./acceptingPersonel.vue";
export default {
    data() {
        return {
            workbookId:"",
            showView:false,
            showType:"",
            showPersonel:false,
            tableData:[
                {
                    renwu:"2024年11月 第三周",
                    data:"12/16",
                    status:1
                    
                }
            ],
            formData:{
                acceptingId:"12313",
                title:"请各社区提报党员信息进行中",
                date:"2024-11-18 11:20:32",
                person:"张三",
                bumen:"xx区xx街道",
                status:1,
                type:"数据采集",
                cycle:"每周",
                fenfa:"16",
                shuoming:"请各社区技照模板表格提报各自的党员信息，并于每周五前完成提报。请各社区按照模板表格提报各自的党员信息，并于每周五完成提报。请各社区按照模板表格提报各自的党员信息，并于每周五前完成提报"
            },
        };
    },
    created() { },
    async mounted() {
        this.getDetail()
    },
    methods: {
        getDetail() {
            let parms = {
                id: this.taskId,
            };
            requestGet('/actual/base/communityOneTablePeriodPublish/getDetail', parms).then(res => {
                this.formData=res.data
            });
        },
        close() {
            this.showView = false
        },
        handleClickBack() {
            this.$emit('close')
        },
        handelPersonel() {
            this.showPersonel = false;
        },
        oncClickInfo(value){
            this.showType=value
            this.showPersonel=true
        },
        handelClickBack() {
            this.$emit('handleShowPage')
        },
        handleClickShowView(val){
            this.$store.state.sidebarFold = true;
            this.showView = true;
            this.workbookId = val
        },
    },
    components: {acceptingPersonel,excelView},
    computed: {
        tableHeight() {
            return (this.clientHeight - 140) + 'px'
        },
        ...mapGetters(['clientHeight', 'resolution']),
    },
    watch: {},
    props: {
        taskId: {
            type: String,
            default: ""
        },
    },
}
</script>

<style lang='scss' scoped>
.card {
    background-color: #ffffff;
    border-radius: 5px;
    margin: 10px 16px;
}

.basic {
    padding: 0 30px;
    box-sizing: border-box;
    .el-row{
        margin-bottom: 16px;
        .label{
            min-width: 80px;
        }
    }
}

.title {
    position: relative;
    margin: 0 16px;

    &::after {
        content: '';
        width: 4px;
        height: 16px;
        background: #5493ff;
        display: block;
        position: absolute;
        top: 16px;
        left: -16px;
    }
}
.item {
    margin-right: 16px;
    width: 16%;
    margin-bottom: 16px;

    img {
        width: 80px;
        height: 80px;
    }
}
</style>
