evaluate.vue 6.75 KB
<template>
    <div v-loading="loading" class="evaluate-wrapper">
        <template v-if="detailInfo">
            <div class="layout">
                <!-- 车辆信息 -->
                <vehicle-info :detail-info="detailInfo"></vehicle-info>
                <!-- 总部定价师估价与意见 -->
                <assess v-if="scene === 'assess'"
                        ref="assessRef"
                        :detail-info="detailInfo">
                </assess>
                <!-- 总部定价师估价与意见 -->
                <assess-info v-if="scene === 'checkPrice'" :detail-info="detailInfo"></assess-info>
                <!-- 核价与意见 -->
                <check v-if="scene === 'checkPrice'"
                       ref="checkPriceRef"
                       :detail-info="detailInfo">
                </check>
                <!-- 评估动态 -->
                <dynamics :dynamics-data="dynamicsData"></dynamics>
            </div>
            <div class="footer">
                <el-button class="save-btn"
                           data-event-code="evaluate_management_assess_save"
                           :data-track="
                               JSON.stringify({
                                   evalOrderNo,
                               })
                           "
                           :loading="btnLoding"
                           size="small"
                           @click="handleSave">
                    保存
                </el-button>
                <el-button class="reject-btn"
                           data-event-code="evaluate_management_reject_save"
                           :data-track="
                               JSON.stringify({
                                   evalOrderNo,
                               })
                           "
                           plain
                           size="small"
                           @click="handleReject">
                    驳回
                </el-button>
                <el-button class="cancel-btn"
                           size="small"
                           @click="handleCancel">
                    关闭
                </el-button>
            </div>
        </template>

        <reject-dialog v-if="rejectVisible"
                       ref="rejectDialogRef"
                       :params-obj="paramsObj"
                       :reject-visible="rejectVisible"
                       @dialogClose="dialogClose"
                       @handleAddConfirm="handleAddConfirm">
        </reject-dialog>
    </div>
</template>

<script>
import { checkPriceCar, evaluateCar } from "@/api/usedCarManagement";
import reportTrackPageMixin from "@/mixins/reportTrackPageMixin";
import { evaluateMixin } from "./components/evaluateMixin";

export default {
	mixins: [evaluateMixin, reportTrackPageMixin],
	data() {
		return {
			btnLoding: false,
			loading: false,
			rejectVisible: false,
			paramsObj: {},
			trackBusinessParam: {},
			track_event_code: "evaluate_management_assess",
			track_businessParam_key: "trackBusinessParam",
		};
	},
	mounted() {
		this.loading = true;
		this.trackBusinessParam = { evalOrderNo: this.evalOrderNo };
		this.onPageShow();
	},
	methods: {
		handleReject() {
			this.rejectVisible = !this.rejectVisible;
		},
		dialogClose() {
			this.rejectVisible = !this.rejectVisible;
		},
		handleAddConfirm() {
			const params = {
				vin: this.detailInfo.vin,
				opType: this.scene === "checkPrice" ? 50 : 30, // 10评估师报价,20客户报价,30评估师驳回 ,40核价,50核价驳回
				evalOrderNo: this.evalOrderNo,
				...this.$refs.rejectDialogRef.infoForm,
			};
			this.submitData(params, 2);
		},
		async handleSave() {
			if (this.scene === "checkPrice") {
				const isValid = await this.$refs.checkPriceRef?.confirm?.();
				if (!isValid) {
					return;
				}
				const params = {
					vin: this.detailInfo.vin,
					opType: 40, // 10评估师报价,20客户报价,30评估师驳回 ,40核价,50核价驳回
					evalOrderNo: this.evalOrderNo,
					...this.$refs.checkPriceRef?.assessForm,
				};
				this.submitData(params, 1);
				return;
			}

			const isValid = await this.$refs.assessRef?.confirm?.();
			if (!isValid) {
				return;
			}
			const params = {
				vin: this.detailInfo.vin,
				opType: 10, // 10评估师报价,20客户报价,30评估师驳回
				evalOrderNo: this.evalOrderNo,
				...this.$refs.assessRef?.assessForm,
			};
			this.submitData(params, 1);
		},
		submitData(params, isFlag) {
			this.$confirm("请确认是否要执行当前操作?", "提示", {
				confirmButtonText: "确定",
				cancelButtonText: "取消",
				type: "warning",
			}).then(() => {
				if (isFlag === 1) {
					this.btnLoding = true;
				} else {
					this.$refs.rejectDialogRef
					&& this.$refs.rejectDialogRef?.handleLoading();
				}

				const api = this.scene === "checkPrice" ? checkPriceCar : evaluateCar;
				api(params)
					.then((res) => {
						if (res.data.code === 0) {
							this.$message.success("操作成功");
							this.handleCancel();
							this.$refs.rejectDialogRef
							&& this.$refs.rejectDialogRef?.handleLoading();
							this.rejectVisible = false;
							this.btnLoding = false;
						} else if (res.data.code === 1000) {
							this.refreshPage();
							this.$message.error(res.data.msg);
							this.$refs.rejectDialogRef
							&& this.$refs.rejectDialogRef?.handleLoading();
							this.btnLoding = false;
						} else {
							this.$message.error(res.data.msg);
							this.$refs.rejectDialogRef
							&& this.$refs.rejectDialogRef?.handleLoading();
							this.btnLoding = false;
						}
					})
					.catch(() => {
						this.btnLoding = false;
					});
			});
		},
		refreshPage() {
			// 方式一:重新加载当前路由
			this.$router.go(0);
			this.getEvalOrderDetail();
			this.getEvalOrderPriceHistory();
		},
	},
};
</script>

<style lang="scss" scoped>
.evaluate-wrapper {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	.footer {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 20px;
		.save-btn {
			// width: 60px;
			padding: 5px 14px;
			line-height: 22px;
			border-radius: 4px;
			border: 1px solid #2a58ad;
			background: #2a58ad;
			color: #ffffff;
			font-size: 14px;
			height: 32px;
			box-sizing: border-box;
		}
		.cancel-btn {
			color: #666666;
			font-size: 14px;
			width: 56px;
			height: 32px;
			padding: 5px 14px;
			border-radius: 4px;
			background: #e8e8e8;
			line-height: 22px;
			box-sizing: border-box;
		}
		.reject-btn {
			// width: 60px;
			border-radius: 4px;
			opacity: 1;
			border: 1px solid #2a58ad;
			padding: 5px 14px;
			line-height: 22px;
			height: 32px;
			box-sizing: border-box;
			color: #2a58ad;
			font-size: 14px;
			// margin: 0 10px;
		}
	}
}
.layout {
	height: calc(100% - 65px);
	overflow-y: scroll;
}
</style>