<template>
	<view>
		<view class="font-md text-dark font-weight">企业信息</view>
		<view class="border-bottom py-2 d-flex j-sb">
			<view class="d-flex a-center w-100">
				<text class="text-primary">企业名称：</text>
				<song-data-picker class="flex-1" style="width: 100%;" @click.native="songClick" :clearIcon="false"
					:readonly="!(!readOnlyFlag && userData.enterpriseCadreFlag)" :localdata="companyColumn" placeholder="请选择企业"
					popup-title="请选择企业" @nodeclick="onnodeclick">
					<slot>
						<view class="d-flex a-center j-sb">
							<view class="">
								<text v-show="itemDate.companyName" class="text-secondary">{{itemDate.companyName}}</text>
								<text v-show="!itemDate.companyName" class="font-md" style="color: rgb(192, 196, 204);">请选择企业</text>
							</view>
							<u-icon v-if="!readOnlyFlag && userData.enterpriseCadreFlag" name="arrow-down" color="#666666 " size="20">
							</u-icon>
						</view>
					</slot>
				</song-data-picker>
			</view>

		</view>
		<view class="border-bottom py-2">
			<text class="text-primary">属地：</text>
			<text class="text-secondary">{{itemDate.areaChargeNameLabel}}</text>
		</view>
		<view class="border-bottom py-2">
			<text class="text-primary">企业负责人：</text>
			<text class="text-secondary">{{itemDate.userName}}</text>
		</view>
		<view class="border-bottom py-2">
			<text class="text-primary">负责人号码：</text>
			<text class="text-secondary">{{itemDate.userMobile}}</text>
		</view>
	</view>
</template>

<script>

	import {enterpriseVisit} from "@/api/dzf/enterpriseVisit.js";
	export default {
		props: {
			enterpriseInfoData: {
				type: Object,
				default: () => {}
			},
			readOnlyFlag: {
				type: Boolean,
				default: false
			},
			status: {
				type: String,
				default: ''
			},
			userInfo: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				companyColumn: []
			}
		},
		computed: {
			itemDate() {
				return this.enterpriseInfoData
			},
			userData() {
				return this.userInfo
			}
		},
		mounted() {
			if (this.readOnlyFlag) return
			this.getCompanyList()
		},
		methods: {
			// 检索功能
			mySearchFn(searchList, searchWord) {
				// console.log(searchList)
				// console.log(searchWord)
				// if(!searchWord){
				// 	return searchList
				// }
				return searchList.filter(x => x.text.includes(searchWord));
			},
			// 获取挂钩干部企业列表
			async getCompanyList() {
				const data = await enterpriseVisit.fetchOwnManagerEnterprise()
				const tempData = (data || []).map(ele => {
					const obj = ele
					Object.assign(obj, {
						text: ele.companyName,
						value: ele.enterpriseId
					})
					return obj
				})
				this.companyColumn = data || []
				if (this.status) return
				this.$emit('updateCompanyInfo', tempData[0])
			},
			// 企业选择确认操作
			onnodeclick(ele) {
				console.log('ele', ele);
				this.$emit('updateCompanyInfo', ele)
			},
			// 问题类型--->点击
			songClick() {
				uni.hideKeyboard()
			},
		}
	}
</script>

<style>
</style>