<template>
    <div class="main_box">
        <!-- <navbar title="走访记录"></navbar> -->
        <div class="mian_box">
            <div class="main_top">总共走访{{historyList.length}}次</div>
            <div class="content" v-for="(item, index) in historyList">
                <div class="content_item">
                    <span class="content_item_left">任务名称：</span>
                    <span>{{ item.campaignName }}</span>
                </div>
                <div class="content_item">
                    <span class="content_item_left">任务时间：</span>
                    <span>{{ item.visTime }}</span>
                </div>
                <div class="content_item">
                    <span class="content_item_left">任务机构：</span>
                    <span>{{ item.deptName }}</span>
                </div>
                <div class="content_item">
                    <span class="content_item_left">任务人：</span>
                    <span>{{ item.visName }}</span>
                </div>
                <div class="content_item">
                    <span class="content_item_left">走访备注：</span>
                    <span>{{ item.remark }}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import navbar from '../../components/navbar/navbar.vue';
import { socVisitInfoList, cusVisitInfoList } from "@/service/api/custome";
export default {
    props:{
        socialCreditCode: {
            type: String,
            default: "",   
        },
        historyType: {
            type: String,
            default: "",   
        },
        custIdc: {
            type: String,
            default: "",   
        },
    },
    data() {
        return {
            historyList: [

            ],
        }
    },
    components: {
        navbar: navbar,
    },
    created() {
        let historyType = this.historyType
        if (historyType == '1') {
            this.initFirAndCom()
        } else if (historyType == '2') {
            this.initPerson()
        }
    },
    methods: {
        initFirAndCom() {
            let socialCreditCode = this.socialCreditCode
            socVisitInfoList(socialCreditCode).then(res => {
                if (res.code == 200) {
                    let arr = res.rows.map(item => {
                        return item.infoList
                    })
                    let list = arr.flat()
                    list.forEach(item => {
                        item.isRemarkEdit = true
                        item.isZfEdit = (item.visId == this.userName)
                    })

                    this.historyList = JSON.parse(JSON.stringify(list))

                }
            })
        },
        initPerson() {

            let custIdc = this.custIdc
            cusVisitInfoList(custIdc).then(res => {
                if (res.code == 200) {
                    let arr = res.rows.map(item => {
                        return item.infoList
                    })
                    let list = arr.flat()
                    list.forEach(item => {
                        item.isRemarkEdit = true
                        item.isZfEdit = (item.visId == this.userName)
                    })

                    this.historyList = JSON.parse(JSON.stringify(list))

                }
            })
        }
    }
}

</script>

<style lang="less" scoped>
.mian_box {
    // padding-top: 46px;
    // min-height: 100vh;
    font-size: 14px;
    // padding-bottom: 60px;
}

.main_top {
    padding: 10px 10px;
    background-color: #fff;
    // margin-top: 10px;
    font-size: 16px;
    font-weight: 600;
    color: rgb(22, 13, 13);
}

.content {
    padding: 15px;
    background-color: #fff;
    // margin-top: 10px;
}

.content_item {
    line-height: 30px;
    font-size: 14px;
    color: rgb(22, 13, 13);
}

.content_item_left {
    color: rgb(89, 89, 89);
}
</style>