shortDetailDialog.vue 10.1 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">
                                <template v-for="(item, key) in detail.infoData">
                                    <el-col :key="key" :span="item.col ? item.col : 12">
                                        <el-form-item :label="item.title">
                                            <div v-if="item.className"
                                                 :class="[item.className(shortInfo)]">
                                            </div>
                                            <template v-if="
                                                item.key == 'merchantName' || item.key == 'superiors'
                                            ">
                                                <template v-if="
                                                    shortInfo[item.key]
                                                        && shortInfo[item.key].split(',').length > 1
                                                ">
                                                    <span>
                                                        {{
                                                            shortInfo[item.key].split(",").slice(0, 1).join("")
                                                        }}
                                                    </span>
                                                    <el-popover placement="top"
                                                                trigger="hover"
                                                                width="fit-content">
                                                        <div :class="{
                                                            serverHeight:
                                                                shortInfo[item.key].split(',').length >= 10,
                                                        }">
                                                            <div v-for="(item, index) in shortInfo[
                                                                     item.key
                                                                 ].split(',')"
                                                                 :key="index">
                                                                {{ item }}
                                                            </div>
                                                        </div>
                                                        <template #reference>
                                                            <span class="more-info">
                                                                ...({{
                                                                    shortInfo[item.key].split(",").length
                                                                }})
                                                            </span>
                                                        </template>
                                                    </el-popover>
                                                </template>
                                                <template v-else>
                                                    <span>
                                                        {{
                                                            shortInfo[item.key] ? shortInfo[item.key] : "-"
                                                        }}
                                                    </span>
                                                </template>
                                            </template>
                                            <template v-else>
                                                {{
                                                    item.formatter
                                                        ? item.formatter(shortInfo)
                                                        : shortInfo[item.key]
                                                            ? shortInfo[item.key]
                                                            : "-"
                                                }}
                                            </template>
                                        </el-form-item>
                                    </el-col>
                                </template>
                            </el-row>
                        </el-form>
                    </div>
                    <div v-else style="margin-top: 20px">
                        <d2-table ref="recordTable"
                                  :has-page="false"
                                  :table-data="detailInfo.tableData"
                                  :table-params="detail.tableParams">
                        </d2-table>
                    </div>
                </div>
            </div>
        </baseDialog>
    </div>
</template>

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

export default {
	props: {
		shortVisible: {
			type: Boolean,
			default: false,
		},
		shortInfo: {
			type: Object,
			default: () => {},
		},
	},
	data() {
		return {
			dialogConfig: {
				title: "任务详情",
				width: "720px",
			},
			configData: [
				{
					title: "个人信息",
					infoData: [
						{
							title: "姓名:",
							key: "staffName",
							formatter(cellValue) {
								return cellValue.staffName;
							},
						},
						{
							title: "门店:",
							key: "merchantName",
						},
						{
							title: "上级:",
							key: "superiors",
						},
						{
							title: "导师:",
							key: "mentors",
						},
					],
				},
				{
					title: "任务信息",
					infoData: [
						{
							title: "复盘日期:",
							key: "checkDate",
						},
						{
							title: "任务状态:",
							key: "taskStatus",
							formatter: (cellValue) => {
								return {
									1: "进行中",
									2: "已结束",
								}[cellValue.taskStatus];
							},
							className: (cellValue) => {
								return {
									1: "orgenSpot",
									2: "ashSpot",
								}[cellValue.taskStatus];
							},
						},
						{
							title: "课程完成时间:",
							formatter: (cellValue) => {
								return cellValue.completeTime
									? Util.dateFormate(
											cellValue.completeTime,
											"YYYY-MM-DD HH:mm:ss",
										)
									: "-";
							},
						},
						{
							title: "课程结束时间:",
							formatter: (cellValue) => {
								return cellValue.deadline
									? Util.dateFormate(cellValue.deadline, "YYYY-MM-DD HH:mm:ss")
									: "-";
							},
						},
					],
				},
				{
					title: "标签列表",
					tableParams: {
						btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
						tableColumns: [
							{
								label: "学习标签",
								prop: "tagName",
							},

							{
								label: "考核结果",
								prop: "status",
								formatter: (cellValue) => {
									return {
										1: "进行中",
										2: "通过",
									}[cellValue.status];
								},
								className: (cellValue) => {
									return {
										1: "orgenSpot",
										2: "greenSpot",
									}[cellValue.status];
								},
							},
							{
								label: "完成时间",
								prop: "tradeNo",
								width: "200",
								formatter: (cellValue) => {
									return cellValue.finishTime
										? Util.dateFormate(
												cellValue.finishTime,
												"YYYY-MM-DD HH:mm:ss",
											)
										: "-";
								},
							},
						],
					},
				},
			],
			detailInfo: {
				tableData: [],
			},
		};
	},
	computed: {
		visible: {
			get() {
				return this.shortVisible;
			},
			set(newVal) {
				this.$emit("dialogClose", {
					flag: newVal,
					attrName: "shortVisible",
				});
			},
		},
	},
	watch: {
		shortInfo: {
			handler(newVal) {
				if (newVal) {
					this.getSopDetailTagListData(newVal);
				}
			},
			deep: true,
		},
	},
	created() {},
	mounted() {
		this.getSopDetailTagListData();
		this.getStaffInfoData();
	},
	methods: {
		getSopDetailTagListData() {
			let { staffPhone, checkDate } = this.shortInfo;

			getSopDetailTagList({
				checkDate,
				staffPhone,
			}).then((res) => {
				this.detailInfo.tableData = res;
				console.log(res);
			});
		},
		getStaffInfoData() {
			getStaffInfo({
				staffPhone: this.shortInfo.staffPhone,
				currentPage: 1,
				pageSize: 10,
			}).then((res) => {
				Object.assign(this.shortInfo, res);
			});
		},
		handleClose() {
			this.visible = false;
		},
		handleConfirm() {
			this.visible = false;
		},
	},
};
</script>

<style scoped lang="scss">
.detail-dialog {
	.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>