shortLightDetail.vue 11.3 KB
<!-- 查看(轻改业务详情) -->
<template>
    <div class="detail-dialog">
        <baseDialog :dialog-config="dialogConfig"
                    :is-show.sync="visible"
                    @closeDialog="handleClose"
                    @handleClick="handleConfirm">
            <div v-for="(detail, index) in configData"
                 :key="index"
                 class="item">
                <div class="title">
                    {{ detail.title }}
                </div>
                <div class="detail-content">
                    <div v-if="detail.infoData && detail.infoData.length"
                         class="form_div">
                        <el-form class="edit-sub-block"
                                 :inline="true"
                                 label-width="110px">
                            <el-row :gutter="20">
                                <el-col v-for="(item, key) in detail.infoData"
                                        :key="key"
                                        :span="item.col ? item.col : 12">
                                    <el-form-item :label="item.title">
                                        <div v-if="item.className"
                                             :class="[item.className(info)]">
                                        </div>
                                        <template v-if="
                                            item.key === 'merchantName' || item.key === 'superiors'
                                        ">
                                            <template v-if="
                                                info[item.key]
                                                    && info[item.key].split(',').length > 1
                                            ">
                                                <span>
                                                    {{
                                                        info[item.key].split(',').slice(0, 1).join('')
                                                    }}
                                                </span>
                                                <el-popover placement="top"
                                                            trigger="hover"
                                                            width="fit-content">
                                                    <div :class="{
                                                        serverHeight:
                                                            info[item.key].split(',').length >= 10,
                                                    }">
                                                        <div v-for="(txt, i) in info[item.key].split(',')"
                                                             :key="i">
                                                            {{ txt }}
                                                        </div>
                                                    </div>
                                                    <template #reference>
                                                        <span class="more-info">
                                                            ...({{
                                                                info[item.key].split(',').length
                                                            }})
                                                        </span>
                                                    </template>
                                                </el-popover>
                                            </template>
                                            <template v-else>
                                                <span>
                                                    {{
                                                        info[item.key] ? info[item.key] : "-"
                                                    }}
                                                </span>
                                            </template>
                                        </template>
                                        <template v-else>
                                            {{
                                                item.formatter
                                                    ? item.formatter(info)
                                                    : info[item.key]
                                                        ? info[item.key]
                                                        : "-"
                                            }}
                                        </template>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
                    </div>
                    <div v-else style="margin-top: 20px">
                        <d2-table :has-page="false"
                                  :header-cell-style="headerCellStyle"
                                  :table-data="detailInfo.tableData"
                                  :table-params="detail.tableParams">
                            <template #tagNamesHtml="scope">
                                <div>
                                    <template v-if="scope.scope.tagNames">
                                        <el-tooltip :content="scope.scope.tagNames"
                                                    placement="top"
                                                    effect="dark">
                                            <span class="two-line-ellipsis">
                                                {{ scope.scope.tagNames }}
                                            </span>
                                        </el-tooltip>
                                    </template>
                                    <template v-else>
                                        <span>-</span>
                                    </template>
                                </div>
                            </template>
                        </d2-table>
                    </div>
                </div>
            </div>
        </baseDialog>
    </div>
</template>

<script>
import { getLightChangeDetail, getStaffInfo } from "@api/serviceCentre";
import { Util } from "@/common/util";

/** 表头背景色(同 whiteStaffList) */
const HEADER_BG = "#F2F4F7";

export default {
	props: {
		shortVisible: {
			type: Boolean,
			default: false,
		},
		shortInfo: {
			type: Object,
			default: () => ({}),
		},
	},
	data() {
		return {
			dialogConfig: {
				title: "轻改任务详情",
				width: "720px",
			},
			configData: [
				{
					title: "个人信息",
					infoData: [
						{ title: "姓名:", key: "staffName" },
						{ title: "门店:", key: "merchantName" },
						{ title: "上级:", key: "superiors" },
						{ title: "导师:", key: "mentors" },
					],
				},
				{
					title: "任务信息",
					infoData: [
						{ title: "复盘日期:", key: "checkDate" },
						{
							title: "任务状态:",
							key: "taskStatus",
							formatter: (cellValue) => {
								return { 0: "进行中", 1: "已结束" }[cellValue.taskStatus] || "-";
							},
							className: (cellValue) => {
								return { 0: "orgenSpot", 1: "ashSpot" }[cellValue.taskStatus];
							},
						},
						{
							title: "涉及客户数:",
							key: "defeatCustomerDetail",
							formatter: (cellValue) => {
								return `${cellValue.detailList.length || 0}单`;
							},
						},
						{
							title: "课程结束时间:",
							formatter: (cellValue) => {
								return cellValue.deadline
									? Util.dateFormate(cellValue.deadline, "YYYY-MM-DD HH:mm:ss")
									: "-";
							},
						},
						{
							title: "整体完成时间:",
							formatter: (cellValue) => {
								return cellValue.completeTime
									? Util.dateFormate(cellValue.completeTime, "YYYY-MM-DD HH:mm:ss")
									: "-";
							},
						},
					],
				},
				{
					title: "客流复盘明细",
					tableParams: {
						btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
						tableColumns: [
							{ label: "客户姓名", prop: "customerName" },
							{ label: "意向车型", prop: "carModel" },
							{ label: "靶向学习维度", prop: "tagNames", addHtml: "tagNamesHtml" },
							{
								label: "对练考核结果",
								prop: "reviewStatus",
								formatter: (cellValue) => {
									// 复盘状态/考核结果,0-待复盘/待对练,1-已结案/已通过
									return { 0: "待对练", 1: "已通过" }[cellValue.reviewStatus] || "-";
								},
								className: (cellValue) => {
									return { 0: "orgenSpot", 1: "greenSpot" }[cellValue.reviewStatus];
								},
							},
							{
								label: "完成时间",
								prop: "completeTime",
								formatter: (cellValue) => {
									return cellValue.completeTime
										? Util.dateFormate(cellValue.completeTime, "YYYY-MM-DD HH:mm:ss")
										: "-";
								},
							},
						],
					},
				},
			],
			detailInfo: { tableData: [] },
			info: {},
			headerCellStyle: {
				background: HEADER_BG,
			},
		};
	},
	computed: {
		visible: {
			get() {
				return this.shortVisible;
			},
			set(newVal) {
				this.$emit("dialogClose", { flag: newVal, attrName: "shortVisible" });
			},
		},
	},
	watch: {
		shortInfo: {
			handler(newVal) {
				this.info = newVal || {};
				if (!newVal?.staffPhone || !newVal?.checkDate) {
					return;
				}
				this.getSopDetailTagListData();
				// this.getStaffInfoData();
			},
			deep: true,
			immediate: true,
		},
	},
	methods: {
		getSopDetailTagListData() {
			const { staffPhone, checkDate, id, punishFlag } = this.shortInfo || {};
			console.log(this.shortInfo, "shortInfo");
			if (!staffPhone || !checkDate) {
				return;
			}
			// getSopDetailTagList({ checkDate, staffPhone }).then((res) => {
			// 	this.detailInfo.tableData = res || [];
			// });
			getLightChangeDetail({ id, punishFlag }).then((res) => {
				this.detailInfo.tableData = res.detailList || [];
				this.info = res || {};
			});
		},
		getStaffInfoData() {
			const { staffPhone } = this.shortInfo || {};
			if (!staffPhone) {
				return;
			}
			getStaffInfo({ staffPhone, currentPage: 1, pageSize: 10 }).then((res) => {
				if (res && typeof res === "object") {
					Object.assign(this.info, res);
				}
			});
		},
		handleClose() {
			this.visible = false;
		},
		handleConfirm() {
			this.visible = false;
		},
	},
};
</script>

<style scoped lang="scss">
.detail-dialog {
	.two-line-ellipsis {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		line-clamp: 2;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		word-break: break-all;
	}
	.item {
		margin-bottom: 20px;
		.title {
			color: #111111;
			font-size: 16px;
			font-weight: 500;
			padding: 10px 0;
			border-bottom: 1px solid #e5e5e5;
		}
		.form_div {
			color: #333333;
			padding: 20px 30px;

			.edit-sub-block {
				.el-form-item {
					width: 100%;
					margin-bottom: 0px;
				}
				.itemDiv {
					display: flex;
					.halfItem {
						width: 50%;
					}
				}
				.detail-txt {
					display: inline-block;
					width: 200px;
					vertical-align: bottom;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				::v-deep .el-form-item__content {
					max-width: calc(100% - 110px);
					word-break: break-all;
				}
			}

			.edit-sub-block-two {
				.el-form-item {
					margin-bottom: 0px;
				}
			}
		}
	}
}
</style>