import Api from "~/service/Api"
import event from "../../tcp/event";

export default {
    mixins: [event],
    methods: {
        commitEdit() {
            this.$refs['modelForm'].validate(async (validStatic) => {
                if (validStatic) {
                    // const loading = this.loading('正在校验数据');
                    // const rtnmsg = await Api.post("/report/rmbsel/validate2135", this.model.tdo2122.tdoVo);
                    // if (rtnmsg.respCode == SUCCESS) {
                    // 	const fieldErrors = rtnmsg.data;
                    // 	if (fieldErrors && Object.keys(fieldErrors).length == 0) {
                    // 		// 清除之前的校验状态
                    // 		this.$refs.modelForm.clearValidate();
                    // 		loading.close();
                    // 		this.add()
                    // 		return
                    // 	}
                    // 	const tab = this.showBackendErrors(fieldErrors);
                    // 	if (tab) {
                    // 		// 判断校验失败的表单不属于当前的tab,则切换tab到对应报错的tab页面
                    // 		if (tab.name !== this.tabVal) {
                    // 			this.tabClick(tab, '1');
                    // 		}
                    // 	}
                    // 	loading.close();
                    // }
                    let data = {
                        inr: this.model.pblmod.pbl.inr,
                        tcpVo: this.model.recgrp.ads
                    };
                    Api.post('/report/rmbsel/edit2135', data).then(res => {
                        if (res.respCode == SUCCESS) {
                            this.$notify({
                                title: "成功",
                                message: "修改成功",
                                type: "success",
                            });
                            this.$store.commit('delTagsArry', this.$route.path);
                            this.$router.back()
                        } else {
                            this.$notify({
                                title: "失败",
                                message: "修改失败",
                                type: "error",
                            });
                        }
                    })
                } else {
                    // 前端校验失败
                    this.$notify({
                        title: '失败',
                        message: '校验失败',
                        type: 'error',
                    });
                }
            })
        },
        validate() {
            this.$refs['modelForm'].validate(async (validStatic) => {
                if (validStatic) {
                    this.$notify({
                        title: '成功',
                        message: '校验成功',
                        type: 'success',
                    });
                } else {
                    // 前端校验失败
                    this.$notify({
                        title: '失败',
                        message: '校验失败',
                        type: 'error',
                    });
                }
            })
        },
    },
}