<template>
	<screenHeader :currentKey="currentKey">
		<div class="breadcrumb">
			<div class="left">
				{{ $i18n.locale === 'zh-CN'?'当前位置':'Current position'}}：
				<div class="crumb-item-active">
					<span> {{ $i18n.locale === 'zh-CN'?'资金主题':'Fund Theme'}}</span>
				</div>
			</div>
			<el-cascader popper-class="cascader" :options="allList" v-model="poolCode" :props='propsData'
				v-if="FundtabActive==0" placeholder="请选择企业" @change="toggleFirm" :show-all-levels="false">
				<template slot-scope="{ node, data }">
					<span v-if="data.id"> {{ data.code }} </span>
					<span v-else>{{ data.continent }}</span>
				</template>
			</el-cascader>
		</div>
		<div class="tab">
			<div v-for="(item,index) in tabList" :class="FundtabActive==index?'item-active':'item'"
				@click="clickTab(index)">
				{{ $i18n.locale === 'zh-CN'?item.name:item.nameEn}}
			</div>
		</div>
		<div class="divider">
		</div>
		<assetsLiabilities ref="assetsLiabilities" v-if="FundtabActive==0" :poolCode="poolCode"></assetsLiabilities>
		<weeklyFund ref="weeklyFund" v-if="FundtabActive==1"></weeklyFund>
	</screenHeader>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import * as echarts from 'echarts'
	import moment from "moment"
	import dictUtils from '@/components/dict/DictSelectUtils.js'
	import weeklyFund from '@/views/BigScrenn/fundTheme/components/weeklyFund.vue' //周资金计划
	import assetsLiabilities from '@/views/BigScrenn/fundTheme/components/assetsLiabilities.vue' //资产负债
	import screenHeader from '@/views/BigScrenn/components/screenHeader.vue'
	import financialTheme from '@/api/bigScrenn/financialTheme.js'
	export default {
		components: {
			screenHeader,
			weeklyFund,
			assetsLiabilities,
		},
		data() {
			return {
				currentKey: 'fundTheme',
				tabList: [{
						name: "资产负债",
						nameEn:'Assets and liabilities',
						value: 0
					},
					{
						name: "周资金计划",
						nameEn:'Weekly funding plan',
						value: 1
					}
				],
				FundtabActive: 0,
				allList: [],
				poolCode: [],
				propsData: {
					children: 'list',
					label: 'code',
					value: 'code',
					expandTrigger: 'hover'
				},
				params: {
					pageBean: {
						page: 1,
						pageSize: -1,
					},
					querys: []
				},
			}
		},
		created() {
			window.localStorage.setItem('activeIndex', this.currentKey);
			window.localStorage.setItem("pageName", '资金主题');
			this.zbList = dictUtils.getDictItemsFromCache('zb_en')
			this.dpzbList = dictUtils.getDictItemsFromCache('dpzb')
			this.getAreaTree()
			console.log(window.localStorage.getItem('FundFundtabActive'));
			if (window.localStorage.getItem('FundtabActive')) {
				this.FundtabActive = window.localStorage.getItem('FundtabActive')
			}else{
				this.FundtabActive=0
			}

		},
		mounted() {},
		methods: {
			//切换企业
			toggleFirm() {
				// console.log(this.poolCode);
				// this.$refs.assetsLiabilities.getData(this.poolCode)
			},
			//获取企业
			getAreaTree() {
				this.params.querys[{
					group: "main",
					operation: "EQUAL",
					parentGroup: "",
					property: "pool_type_",
					relation: "AND",
					value: 1
				}, {
					group: "main",
					operation: "EQUAL",
					parentGroup: "",
					property: "run_status_",
					relation: "AND",
					value: 1
				}]
				financialTheme.getAreaTree(this.params, res => {
					if (res) {
						res.value.forEach(e => {
							this.dpzbList.forEach(s => {
								if (e.continent == s.name) {
									e.code = s.value
								}
							})
						})
						this.allList = res.value
						let enterpriseCode = window.localStorage.getItem('enterpriseCode')
						if (enterpriseCode) {
							this.poolCode = enterpriseCode.split(',')
						} else {
							this.poolCode = [res.value[0].code, res.value[0].list[0].code]
						}
						// this.$refs.assetsLiabilities.getData(this.poolCode)
						// this.getData()
					}
				})
			},
			clickTab(val) {
				window.localStorage.setItem('FundtabActive', val)
				this.FundtabActive = val
			},
		}
	}
</script>

<style lang="scss" scoped>
	@font-face {
		font-family: 'YouSheBiaoTiHei';
		src: url(~@/assets/fonts/YouSheBiaoTiHei-2.ttf);
	}

	@keyframes rotateImage {
		from {
			transform: rotate(0deg)
		}

		to {
			transform: rotate(360deg)
		}
	}

	@keyframes breath {
		from {
			opacity: 0.1;
		}

		50% {
			opacity: 1;
		}

		to {
			opacity: 0.1;
		}
	}

	@-webkit-keyframes breath {
		from {
			opacity: 0.1;
		}

		50% {
			opacity: 1;
		}

		to {
			opacity: 0.1;
		}
	}

	.full {
		margin-top: 10px;
		height: calc(100% - 60px);
	}

	.full2 {
		margin-top: 5px;
		height: calc(100% - 85px);
	}

	.breadcrumb {
		width: 100%;
		height: 45px;
		font-size: 12px;
		font-family: Microsoft YaHei;
		font-weight: 400;
		line-height: 30px;
		padding: 0 20px;
		box-sizing: border-box;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: space-between;

		// border: 1px solid #fff;
		.left {
			height: 30px;
			display: flex;
			align-items: center;

			.crumb-item {
				height: 22px;
				line-height: 22px;
				padding: 0 20px;
				box-sizing: border-box;
				font-size: 12px;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #ADC9E9;
				margin-left: 5px;
				transform: skew(-25deg);
				cursor: pointer;
				background: url('~@/assets/img/breadcrumb.png') center / 100% 100% no-repeat;

				span {
					display: inline-block;
					transform: skew(25deg);
				}
			}

			.crumb-item:hover {
				height: 22px;
				line-height: 22px;
				padding: 0 20px;
				box-sizing: border-box;
				font-size: 12px;
				font-family: Microsoft YaHei;
				font-weight: 400;
				margin-left: 5px;
				color: #FFFFFF;
				cursor: pointer;
				background: url('~@/assets/img/breadcrumb-active.png') center / 100% 100% no-repeat;
			}

			.crumb-item-active {
				height: 22px;
				line-height: 22px;
				padding: 0 20px;
				box-sizing: border-box;
				font-size: 12px;
				font-family: Microsoft YaHei;
				font-weight: 400;
				margin-left: 5px;
				transform: skew(-25deg);
				color: #FFFFFF;
				cursor: pointer;
				background: url('~@/assets/img/breadcrumb-active.png') center / 100% 100% no-repeat;

				span {
					display: inline-block;
					transform: skew(25deg);
				}
			}
		}


	}


	.tab {
		width: 402px;
		height: 45px;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
		background: url('~@/assets/img/operation-tab-bg.png') center / 100% 100% no-repeat;

		.item {
			width: 201px;
			height: 44px;
			line-height: 44px;
			background: url('~@/assets/img/operation-tab.png') center / 100% 100% no-repeat;
			color: #fff;
			font-size: 16px;
			text-align: center;

		}

		.item-active {
			width: 201px;
			height: 44px;
			line-height: 44px;
			// background: linear-gradient(180deg, rgba(230, 129, 83, 1) 0%, rgba(74, 47, 31, 1) 100%);
			background: url('~@/assets/img/operation-tab-active.png') center / 100% 100% no-repeat;
			color: #fff;
			font-size: 16px;
			text-align: center;
		}
	}

	.divider {
		width: 100%;
		height: 1px;
		background: #5C83C6;
		margin-bottom: 10px;
	}

	/deep/ .el-input {
		height: 35px !important;
	}

	/deep/ .el-input__inner {
		height: 35px !important;
		color: #eee;
		border-color: #0F3662;
		background-color: rgba(1, 28, 82, 0.8);
	}

	/deep/ .search .el-input__inner {
		height: 35px !important;
		color: #eee;
		border: none;
		background-color: rgba(1, 28, 82, 0);
	}

	//聚焦时的样式
	.el-select .el-input.is-focus .el-input__inner {
		border-color: #0B61AA;
		background-color: rgba(1, 28, 82, 0.8);
		color: #00D3E9;
	}

	//下拉框选中
	.el-select-dropdown__item {
		color: #eee;
	}

	//鼠标经过下拉框
	.el-select-dropdown__item.hover,
	.el-select-dropdown__item:hover {
		color: #00D3E9;
		background-color: #0F3360;
	}
</style>

<style>
	.cascader .el-cascader-panel {
		background-color: #0F3360;
		border: none !important;
	}

	.cascader .el-cascader-menu {
		color: #fff !important;
		border: none !important;
	}

	.cascader .el-scrollbar__wrap {
		overflow: hidden
	}

	.el-popper[x-placement^="bottom"] {
		border: 1px solid #0B61AA;
	}

	.cascader .el-cascader-menu .el-cascader-node:hover {
		background-color: #0B61AA;
	}
</style>