index.vue 8.82 KB
<template>
  <el-drawer class="strategy-drawer"
             size="69.44vw"
             :visible.sync="dialogShow"
             :wrapper-closable="false"
             @close="close">
    <template #title>
      <div class="strategy-drawer-title">
        查看详情
      </div>
    </template>
    <div class="drawer-content">
      <el-scrollbar class="scrollbar-wrapper">
        <div class="detail-container">
          <el-row class="section-content">
            <el-col v-for="(item, idx) in detailData"
                    :key="idx"
                    class="info-item"
                    :span="item.fullRow ? 24 : 12">
              <div class="info-label">
                {{ item.subtitle }}:
              </div>
              <div class="info-value">
                <template v-if="!item.isImage">
                  {{ item.value || '-' }}
                </template>
                <template v-else>
                  <div v-if="item.value && item.value.length > 0" class="image-list">
                    <el-image v-for="(img, imgIdx) in item.value"
                              :key="imgIdx"
                              fit="cover"
                              style="width: 80px; height: 80px; margin-right: 10px; border-radius: 4px;"
                              :preview-src-list="item.value"
                              :src="img">
                    </el-image>
                  </div>
                  <div v-else>
                    -
                  </div>
                </template>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-scrollbar>
      <div class="footer">
        <el-button v-preventReClick
                   :size="size"
                   @click="close">
          返回
        </el-button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
import { queryStrategyStudyDetailById } from "@/api/earlyWarningManager";
import { mentoringMethod_offline, mentoringMethod_online, mentoringTopic_options, TASK_OPTIONS } from "./contant.js";

export default {
	name: "TaskDetail",
	props: {
		visibleSync: {
			type: Boolean,
			default: false,
		},
		item: {
			type: Object,
			default: () => ({}),
		},
	},
	data() {
		return {
			size: "small",
			detailData: [],
		};
	},
	computed: {
		dialogShow: {
			get() {
				return this.visibleSync;
			},
			set(val) {
				this.$emit("update:visibleSync", val);
			},
		},
	},
	watch: {
		visibleSync(val) {
			if (val) {
				this.initData();
			}
		},
	},
	methods: {
		close() {
			this.dialogShow = false;
		},
		async initData() {
			this.detailData = [];
			if (!this.item.id) {
				return;
			}
			try {
				const res = await queryStrategyStudyDetailById({ id: this.item.id });
				if (res) {
					this.formatDetailData(res);
				}
			} catch (error) {
				console.error(error);
			}
		},
		formatDetailData(data) {
			const staffList = data.staffList || [];
			const { strategyType, strategyExtension, biz } = data;
			const mentoringApplicationDetail = data.mentoringApplicationDetail || {};
			// 问题人员:userPosition=0
			const problemStaffs = staffList.filter(e => e.userPosition === 0).map(e => e.userName).join("、");
			// 执行人员:userPosition=8 或 9
			const executorStaffs = staffList.filter(e => e.userPosition === 8 || e.userPosition === 9).map(e => e.userName).join("、");

			const targetValue = strategyExtension?.targetValue;

			const taskTypeName = TASK_OPTIONS[strategyType] || "-";

			const collabDetail = data?.collaborativeTaskDetail || {};

			const taskStatusName = collabDetail?.taskStatus == "FINISHED" ? "已完成" : "未完成";

			const detailData = [
				{ subtitle: "任务类型", value: taskTypeName, fullRow: false },
				{ subtitle: "操作人", value: data.createdBy || "-", fullRow: false },
				{ subtitle: "操作时间", value: data.createdDate || "-", fullRow: false },
			];
			if (strategyType != 8) {
				let isFinished = collabDetail?.taskStatus == "FINISHED";
				// 仅 strategyType=9 时展示问题人员
				if (strategyType === 9) {
					detailData.push({ subtitle: "问题人员", value: problemStaffs || "-", fullRow: true });
				}
				if (strategyType === 12) {
					detailData.push({ subtitle: "目标触客率", value: (targetValue != "" && targetValue != null && targetValue != undefined) ? `${targetValue}%` : "-", fullRow: true });
				}
				// 剩余基础字段
				detailData.push(
					{ subtitle: "执行人员", value: executorStaffs || "-", fullRow: true },
					{ subtitle: "任务说明", value: data.description || "-", fullRow: true },
					{ subtitle: "任务状态", value: taskStatusName, fullRow: true },
				);
				if ([9, 13, 14].includes(strategyType)) {
					detailData.push({ subtitle: "任务执行结果", value: isFinished ? collabDetail.executionResultName || "-" : "-", fullRow: true });
					if (strategyType === 9) {
						let { personnelChangeTypeCode, personnelChangeTypeName, replacementStaffName, recruitmentQuantity, recruitmentApplyTime } = collabDetail;
						let personnelText = "-";
						if (isFinished) {
							if (["CREATE_RECRUITMENT_DEMAND", "LINK_EXISTING_RECRUITMENT_DEMAND"].includes(personnelChangeTypeCode)) {
								personnelText = `${data.merchantName}${recruitmentQuantity || 0}人${recruitmentApplyTime || ""}`;
							} else if (personnelChangeTypeCode == "LINK_REPLACEMENT_STAFF") {
								personnelText = replacementStaffName || "-";
							} else {
								personnelText = personnelChangeTypeName || "-";
							}
						}
						detailData.push({ subtitle: "关联招聘或人员", value: personnelText, fullRow: true });
					}
				}
				// 协同任务专有详情 (collaborativeTaskDetail)

				detailData.push(
					{ subtitle: "完成描述", value: collabDetail.completionDescription || "-", fullRow: true },
					{ subtitle: "完成人", value: isFinished ? collabDetail.completedBy || "-" : "-", fullRow: false },
					{ subtitle: "完成时间", value: isFinished ? collabDetail.completedTime || "-" : "-", fullRow: false },
				);
			} else {
				let persontoBeMentored = staffList.filter(e => e.relType === 2).map(e => e.userName).join("/");
				let supervisor = staffList.filter(e => e.relType === 1).map(e => e.userName).join("/");
				let prevText = biz == 2 ? "平均客单价" : "转化率";
				let unit = biz == 2 ? "" : "%";
				let taskDetail = mentoringApplicationDetail?.taskDetail || {};
				let { mentoringScene, mentoringTime, mentoringMethod, mentoringTopic, pushCourses, contentSummary, evidenceImages } = taskDetail;

				let mentoringMethodText = mentoringMethod ? mentoringScene == 1 ? mentoringMethod_online[mentoringMethod] : mentoringMethod_offline[mentoringMethod] : "-";
				detailData.push(
					{ subtitle: "需带教人员", value: persontoBeMentored, fullRow: true },
					{ subtitle: "指定带教督导", value: supervisor, fullRow: true },
					{ subtitle: "带教目标", value: (targetValue != "" && targetValue != null && targetValue != undefined) ? `${prevText}=${targetValue}${unit}` : "-", fullRow: true },
					{ subtitle: "任务状态", value: taskStatusName, fullRow: true },
					{ subtitle: "带教场景", value: {
						1: "线上",
						2: "线下",
					}[mentoringScene] || "-", fullRow: true },
					{ subtitle: "带教时间", value: mentoringTime, fullRow: true },
					{ subtitle: "带教方式", value: mentoringMethodText, fullRow: true },
					{ subtitle: "带教主题", value: mentoringTopic ? mentoringTopic_options[mentoringTopic] : "-", fullRow: true },
					{ subtitle: "推送课程", value: pushCourses || "-", fullRow: true },
					{ subtitle: "带教内容摘要", value: contentSummary || "-", fullRow: true },
					{ subtitle: "带教招聘佐证取", value: evidenceImages, fullRow: true, isImage: true },
				);
			}

			this.detailData = detailData;
		},
	},
};
</script>

<style scoped lang="scss">
::v-deep.strategy-drawer {
	.el-drawer__header {
		padding: 0;
		margin: 0;
		border-bottom: 1px solid #e5e5e5;
	}

	.el-drawer__close-btn {
		padding: 0 20px;

		.el-dialog__close {
			font-weight: 700;
			font-size: 24px;
		}
	}

	&-title {
		height: 26px;
		line-height: 26px;
		color: #333333;
		font-size: 18px;
		padding: 17px 20px;
		font-weight: bold;
	}
	.el-drawer__body {
		height: calc(100% - 55px);
		overflow: hidden;
	}
}

.drawer-content {
	height: 100%;
	display: flex;
	flex-direction: column;

	.scrollbar-wrapper {
		flex: 1;
		overflow: hidden;
		::v-deep .el-scrollbar__wrap {
			overflow-x: hidden;
		}
	}

	.detail-container {
		padding: 20px;
	}

	.info-item {
		display: flex;
		margin-bottom: 16px;
		line-height: 20px;
		font-size: 14px;

		.info-label {
			color: #666;
			width: 120px;
			flex-shrink: 0;
			text-align: right;
		}

		.info-value {
			color: #333;
			flex: 1;
			word-break: break-all;

			.image-list {
				display: flex;
				flex-wrap: wrap;
			}
		}
	}

	.footer {
		padding: 14px 0;
		border-top: 1px solid #e5e5e5;
		display: flex;
		justify-content: flex-end;
		padding-right: 20px;
	}
}
</style>