import services from "./service";
import { createSubscribe } from "applet-page-component";
import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
Component(
	createSubscribe({
		onShow() {
			this.saveRef.refresh();
		},
	})({
		props: {},
		tabsShow: false,
		data: {
			typeOptions: [
				{
					value: "normal",
					label: "普通号",
				},
				{
					value: "expert",
					label: "专家号",
				},
				{
					value: "nucleic",
					label: "核酸",
				},
			],
			showInpatient: true,
			hasFilter: false,
			showAll: false,
		},

		didMount() {
			/* 服务预警， 挂号记录查询 */
			reportCmPV_YL({
				title: "挂号记录查询",
			});
		},

		methods: {
			onFilterHandel(filters) {
				// 预约挂号列表不需要这个 filters
				return;
				this.filters = filters;
				this.saveRef.refresh();
			},

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

			/* 分页逻辑 */
			async onService(params) {
				if (!this.hisPatientId || params.pageIndex > 1) return;
				return services.getSubscribeRecordList(
					Object.assign(
						{
							...this.filters,
							...params,
						},
						{ hisPatientId: this.hisPatientId }
					)
				);
			},

			// filter 初始化时设置 hisPatientId
			onAutoFilter(filters) {
				if (filters) {
					this.hisPatientId = filters.hisPatientId;
					this.saveRef.refresh();
				}
			},
		},
	})
);
