<template>
    <div class="main_box">
        <navbar title="走访反馈" special @handleClickLeft="handleGoBefore"></navbar>
        <div class="wrapper">
            <div class="top">
                <div class="userMan_box">
                    <img src="../../images/part_one/icon_company.png" alt="">
                </div>
                <div class="top_name">{{ baseInfo.custName }}</div>
            </div>
            <div class="main">
                <div class="main_title">信息反馈</div>
                <van-form ref="form">
                    <van-field v-model="baseForm.clientSuggestion" label="客户处理方案反馈" name="clientSuggestion" placeholder="请输入"
                        type="textarea" rows="3" required label-width="200px"
                        :rules="[{ required: true, message: '不能为空' }]"></van-field>
                </van-form>
            </div>
            <div class="footer_view">
                <van-button type="primary" @click="handleCommit">提交</van-button>
            </div>
        </div>
    </div>
</template>
<script>
import navbar from '../../components/navbar/navbar.vue';
import { feedbackPrivate ,getFeedbackDetail} from "@/service/api/visiting";
import {
    Tab,
    Icon,
    Button,
    Field,
    Form,
    Toast
} from 'vant';
export default {
    data() {
        return {
            baseForm: {
                clientSuggestion: ''
            },

            baseInfo: {}
        }
    },
    components: {
        navbar: navbar,
        VanTab: Tab,
        VanIcon: Icon,
        VanButton: Button,
        VanField: Field,
        VanForm: Form,
        VanToast: Toast,
    },
    mounted() {
        this.baseInfo = JSON.parse(sessionStorage.getItem('baseInfo'))
        if(this.baseInfo.feedbackId){
            this.initGetFeedbackDetail()
        }
    },
    methods: {
        initGetFeedbackDetail(){
            const params = {
                feedbackType:this.baseInfo.feedbackType,
                feedbackId:this.baseInfo.feedbackId,
            }
            getFeedbackDetail(params).then(res=>{
                if(res.code == 200){
                    this.baseForm = res.data
                }
            })
        },
        handleCommit() {
            this.$refs.form.validate().then(() => {
                const params = {
                    clientSuggestion: this.baseForm.clientSuggestion,
                    recordId:this.baseInfo.recordId
                }
                feedbackPrivate(params).then(res => {
                    if (res.code == 200) {
                        Toast.success(res.msg);
                        this.$router.push("/visitingTaskDetails");
                    }
                })
            }).catch(() => {
                this.$toast('请输入必填项')
            })
        },
        handleGoBefore() {
            this.$router.push("/visitingTaskHome");
          }
    }
}

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

}

.userMan_box {
    background-color: rgb(35, 114, 235);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 5px;
    color: #fff;
}

.top {
    display: flex;
    background-color: #fff;
    align-items: center;
    padding: 15px;
}

.top_name {
    font-size: 16px;
    font-weight: 600;
    margin-left: 10px;
}

.main {
    margin-top: 5px;
    background-color: #fff;
    padding: 15px;

    /deep/ .van-cell {
        display: flex;
        flex-direction: column;
    }

    /deep/ .van-field__value {
        margin-top: 13px;
        background-color: rgba(140, 140, 140, 0.1);
    }
}

.main_title {
    font-size: 14px;
    font-weight: 600;
}

.footer_view {
    text-align: center;

    /deep/ .van-button {
        width: 90%;
    }
}</style>