e-correspondence-head-list.js 4.73 KB
/**
 * 组件描述:保单查询列表
 */

import api from '@/api/api';
import {
	httpPost,
	requestDomain
} from '@/api/fetch-api.js';

import {
	mapState
} from 'vuex';
import {
	formatMoney,
	getInsuredPeriod,
	getInsuredState,
	getPolicyName
} from "@/utils/biz.js";
import Modal2Comp from '@/components/modal2-comp/modal2-comp.vue';
import FilterComp from '@/components/filter-comp/filter-comp.vue';

export default {
	props: {
		multiSelectable: {
			type: Boolean,
			default: false
		},
		model: {
			type: String,
			default: "download"
		},
	},
	name: "LetterListHeader",
	data() {
		return {
			originalList: [],
			contentList: [],
			maxShow: 2,
			selectPolicyCode: "",
			selectPolicyCodes: {},
			hide: false,
			showDownloadError: false,
			filterVisible: false,
			checkList: [],
			filterKey: ""
		}
	},
	computed: {
		lan() {
			return this.$i18n.locale;
		},
		i18n() {
			return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
		},
	},
	methods: {
		initData() {
			httpPost({
				url: api.letterRecordList,
				sid: true
			}).then(res => {
				// if (window.global.mockData) {
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000318", "letterType": "2", "printTime": "2020-05-03 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "N" })
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000319", "letterType": "2", "printTime": "2020-05-04 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "N" })
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000320", "letterType": "2", "printTime": "2020-05-05 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000321", "letterType": "2", "printTime": "2020-05-06 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000322", "letterType": "2", "printTime": "2020-05-07 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
				// 	res.push({ "recordId": "10", "bizNo": "P000000000000323", "letterType": "2", "printTime": "2020-05-08 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
				// }
				for (let index = 0; index < res.length; index++) {
					let letter = res[index];
					if (letter.letterType == "2") {
						this.originalList.push(letter);
						this.contentList.push(letter);
					}
				}
			});
		},
		onShowTipsOverHandler(event, item, index) {
			let child = event.currentTarget.childNodes[0];
			child.style.display = "block";
		},
		onShowTipsOutHandler(event, item, index) {
			let child = event.currentTarget.childNodes[0];
			child.style.display = "none";
		},
		// 过滤筛选
		onFilterHandler(key) {
			if (this.originalList.length <= 0) return;
			let filter = [];
			this.checkList = [];
			this.filterKey = key;
			for (let index in this.originalList) {
				let letter = this.originalList[index];
				// 筛选的值
				let value = letter[key];
				console.log(key, value, letter);
				// 显示的值
				let name = "";
				switch (key) {
					// 通知书类型
					case "letterType":
						name = this.i18n.eCorrespondenceEnquiry.letterName;
						break;
						// 发出时间
					case "printTime":
						value = value.split(" ")[0];
						name = value;
						break;
						// 状况
					case "isRead":
						name = value == "N" ? this.i18n.eCorrespondenceEnquiry.UnRead : this.i18n.eCorrespondenceEnquiry.Read;
						break;
					default:
						name = value;
						break;
				}
				// 过滤重复的值
				if (filter.indexOf(value) > -1) {
					continue;
				}
				filter.push(value);
				this.checkList.push({
					value: value,
					label: name
				});
			}

			// 显示模态窗
			this.filterVisible = true;
		},
		/**
		 * 多选确认
		 */
		onCheckConfirmHandler(values) {
			let newList = [];
			for (let index in this.originalList) {
				let letter = this.originalList[index];
				let v = letter[this.filterKey];
				if (this.filterKey == "printTime") {
					v = v.split(" ")[0];
				}
				if (values.indexOf(v) > -1) {
					newList.push(letter);
				}
			}
			this.contentList = newList;
		},
		changeLetterType(letterNo) {
			return this.i18n.eCorrespondenceEnquiry.LetterMap[letterNo];
		},
		toContactUs() {
			this.$router.push({
				path: "/custom/service",
				query: {
					q: "m1"
				}
			});
		},
		downloadPolicy(item) {
			httpPost({
				url: api.getDownloadPath,
				sid: true,
				data: {
					policyCode: item.bizNo,
					recordId: item.recordId
				}
			}).then(res => {
				if (res) {
					let url = requestDomain() + api.downloadPolicy + "/" + res;
					window.open(url);
				} else {
					this.showDownloadError = true;
				}
			});
		}
	},
	components: {
		Modal2Comp,
		FilterComp
	},
	mounted() {
		this.initData();
	},
}