index.vue 8.69 KB
<!-- 标签课程 -->
<template>
    <d2-container class="customer-tags">
        <template #header>
            <div class="header">
                <d2-search ref="showSearch"
                           class="show-search"
                           :form-data="showFormData"
                           label-width="100px"
                           :search-form="searchForm">
                </d2-search>
                <div class="up-btns">
                    <el-button size="small"
                               type="primary"
                               @click="handleSearch">
                        查询
                    </el-button>
                    <el-button size="small" @click="handleReset">
                        重置
                    </el-button>
                </div>
            </div>
        </template>
        <div class="d2-container-content">
            <d2-table-header>
                <el-button size="small"
                           type="primary"
                           @click="addLabelCourse">
                    新增课程标签
                </el-button>
            </d2-table-header>
            <d2-table ref="table"
                      :before-search-fn="beforeSearchFn"
                      :get-list-api="getListApi"
                      :search-form="searchFormSearch"
                      :table-params="tableParams">
                <template #tagName="scope">
                    <!-- <div v-for="(item, index) in scope.scope.tagList.split(',')" :key="index">
            {{ item }}
          </div> -->
                    <el-tooltip class="item"
                                effect="dark"
                                placement="top">
                        <template #content>
                            <div class="tag-name">
                                <div v-for="(item, index) in scope.scope.tagList.split(',')" :key="index">
                                    {{ item }}
                                </div>
                            </div>
                        </template>
                        <div>
                            {{ `${scope.scope.tagList.split(',')[0] + (scope.scope.tagList.split(',').length == 1 ? '' : '...')} `
                                + `(${scope.scope.tagList.split(',').length}条)` }}
                        </div>
                    </el-tooltip>
                </template>
                <template #courseList="scope">
                    <el-tooltip v-for="(item, index) in scope.scope.courseList.split(',')"
                                :key="index"
                                class="item"
                                :content="item"
                                effect="dark"
                                placement="top">
                        <div class="one-line-ellipsis">
                            {{ item }}
                        </div>
                    </el-tooltip>

                </template>
                <template #auth-button="scope">
                    <auth-button :data="scope.scope" />
                </template>
            </d2-table>
        </div>
        <LabelCourseDialog v-if="dialogVisible"
                           :dialogVisible.sync="dialogVisible"
                           :record-info="recordInfo"
                           @confirmDialogFn="confirmDialogFn">
        </LabelCourseDialog>
    </d2-container>
</template>

<script type="text/ecmascript-6">
import {
	deletecourserelation,
	findStaffTagCourseRelationPage,
} from "@api/contentManager";
import noDataImg from "@/assets/empty.png";
import { deepClone, Util } from "@/common/util";
import labelCourseDialog from "./labelCourseDialog";

export default {
	name: "LabelCourse",
	components: {
		LabelCourseDialog: labelCourseDialog,
	},
	data() {
		return {
			recordInfo: null,
			dialogVisible: false,
			noDataImg,
			classifyVisible: false,
			searchForm: {
				courseName: "",
				tagName: "",
				// bussinessScene: "",
				// merchantId: "",
				// scriptMatching: "",
				// receptionist: "",
				// solutionBrowsing: "",
				// searchdate: [new Date(), new Date()]
			},
			searchFormSearch: {},
			currentItem: {},
			showFormData: [
				{
					label: "标签名",
					name: "tagName",
					type: "input",
					isClear: true,
					maxlength: 50,
				},
				{
					label: "课程名称",
					name: "courseName",
					type: "input",
					isClear: true,
					maxlength: 50,
				},
			],
			getListApi: findStaffTagCourseRelationPage,
			// 表格参数
			tableParams: {
				listName: "list",
				tableOption: {
					width: "100",
				},
				tableColumns: [
					{
						label: "标签",
						prop: "tagList",
						addHtml: "tagName",
					},
					{
						label: "课程列表",
						// minWidth: 144,
						addHtml: "courseList",
					},
					// {
					//   label: "销售姓名",
					//   prop: "receptionist"
					// },
					// {
					//   label: "客户姓名",
					//   prop: "ownerName",
					//   minWidth: 140
					// },
					// {
					//   label: "品牌车型",
					//   prop: "brandModel",
					//   minWidth: 140
					// },
					// {
					//   label: "接待场景",
					//   prop: "receptionSceneName"
					// },
					// {
					//   label: "话术匹配",
					//   formatter: (cellValue) => {
					//     return cellValue.scriptMatchingCount || 0
					//   }
					// },
					// {
					//   label: "方案浏览",
					//   formatter: (cellValue) => {
					//     return cellValue.solutionBrowsingCount || 0
					//   }
					// },
					// {
					//   label: "客户标签",
					//   minWidth: 270,
					//   addHtml: "customerTagName"
					// },
					{
						label: "创建时间",
						formatter: (cellValue) => {
							return cellValue.createdDate
								? Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss")
								: "-";
						},
						width: 140,
					},
					{
						label: "最后更新时间",
						formatter: (cellValue) => {
							return cellValue.updatedDate
								? Util.dateFormate(cellValue.updatedDate, "YYYY-MM-DD HH:mm:ss")
								: "-";
						},
						width: 140,
					},
				],
			},
		};
	},
	created() { },
	mounted() {
		// this.getCustomerFileStatic()
	},
	methods: {
		beforeSearchFn(type = 1) {
			return new Promise((resolve, reject) => {
				this.searchFormSearch = deepClone(this.searchForm);
				resolve();
			});
		},
		handleSearch() {
			this.page = this.$options.data.call(this).page;
			this.$refs.table.refreshTable(true, true);
			// this.getCustomerFileStatic()
		},
		handleReset() {
			this.searchForm = this.$options.data.call(this).searchForm;
			this.handleSearch();
		},
		addLabelCourse() {
			this.recordInfo = null;
			this.dialogVisible = true;
		},
		customerTagName(list) {
			let tag = [];
			list.map((e) => {
				tag.push(e.labelName);
			});
			return tag.join("|");
		},
		handleEdit(row) {
			console.log(row);
			this.recordInfo = row;
			this.dialogVisible = true;
		},
		confirmDialogFn(e) {
			this.handleSearch();
		},
		// 删除
		handleDelete(row) {
			this.$confirm("是否确认删除该课程?", "提示", {
				confirmButtonText: "确定",
				cancelButtonText: "取消",
				type: "error",
			}).then(() => {
				deletecourserelation({ id: row.id }).then((res) => {
					this.notice.okTips();
					this.$refs.table.refreshTable();
				});
			}).catch((err) => {
				console.log(err);
			});
		},
		// jumpDetail(row) {
		//   this.$router.push({
		//     name: "customerFileDetails",
		//     query: {
		//       id: row.id,
		//       receptionSceneName: row.receptionSceneName,
		//       receptionScene: row.receptionScene,
		//       scene: row.bussinessScene
		//     }
		//   })
		// }
	},
};
</script>

<style scoped lang="scss">
.emptyBg {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 120px 0;

	.noDataImg {
		width: 64px;
		height: 40px;
	}
}

.error-input {
	::v-deep.el-input__inner {
		border-color: red;
	}
}

.tag-item {
	display: flex;
	align-items: center;
	padding: 0 10px;
	justify-content: center;

	.tag {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.more-info {
		white-space: nowrap;
		color: #2a58ad;
		cursor: pointer;
		margin-left: 2px;
	}
}

::v-deep.tags-popover {
	max-width: 50vw;
}

.static-box {
	display: flex;
	gap: 0 16px;
	margin-bottom: 12px;

	.static-item {
		flex: 1;
		flex-shrink: 0;
		height: 82px;
		background: #f8faff;
		border-radius: 5px;
		box-sizing: border-box;
		padding: 16px 20px;

		.static-title {
			font-size: 14px;
			color: #333333;
			line-height: 20px;
			margin-bottom: 4px;
		}

		.static-value {
			display: flex;
			font-weight: 700;
			font-size: 24px;
			line-height: 30px;
			align-items: baseline;

			::v-deep.static-unit {
				font-weight: 600;
				font-size: 14px;
				margin: 0 2px;
			}
		}
	}
}

.tag-name {
	max-height: 300px;
	overflow-y: scroll;
}
</style>