import services from "./service";
import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
Component({
	props: {
		componentData: {},
	},
	data: {
		typeOptions: [
			{
				value: "检查报告",
				label: "检查报告",
			},
			{
				value: "检验报告",
				label: "检验报告",
			},
		],
		defaultName: "检查报告",
		showAll: false,
		showTimeSelector: false,
	},

	didMount() {
		/* 服务预警，检查检验报告查询 */
		reportCmPV_YL({
			title: "检查检验报告查询",
		});
	},

	methods: {
		onFilterHandel(filters) {
			this.filters = filters;
			if (!filters.type) {
				this.filters.type = "检查报告";
			}
			this.flatRef.refresh();
		},

		saveRef(ref) {
			this.flatRef = ref;
		},

		/* 分页逻辑 */
		async onService(params) {
			if (!this.filters) return;
			return services.getReportList({
				...this.filters,
				...params,
				hisPatientId: this.hisPatientId,
			});
		},

		onAutoFilter(patient) {
			if (patient) {
				this.hisPatientId = patient.hisPatientId;
			}
			if (!this.filters && patient) {
				this.filters = {
					type: "检查报告",
					hisPatientId: patient.hisPatientId || "",
				};
				this.flatRef.refresh();
			}
		},
	},
});
