import { ref, reactive } from 'vue'
export let addMixin = () => {
	const pageTitle = ref('')
	const options = [
		{ label: '国家级', value: '1' },
		{ label: '省级', value: '2' },
		{ label: '市级', value: '3' },
		{ label: '县级', value: '4' }
	]
	const columns = [
		{ title: '品种', width: 130, dataIndex: 'typeTetx', key: 'typeTetx', align: 'center' },
		{ title: '小麦原粮', dataIndex: 'xmyl', key: 'xmyl', align: 'center' },
		{ title: '稻谷原粮', dataIndex: 'dgyl', key: 'dgyl', align: 'center' },
		{ title: '大豆原粮', dataIndex: 'ddyl', key: 'ddyl', align: 'center' },
		{ title: '玉米原粮', dataIndex: 'ymyl', key: 'ymyl', align: 'center' },
		{ title: '其他原粮', dataIndex: 'qtyl', key: 'qtyl', align: 'center' },
		{ title: '小麦粉成品粮', dataIndex: 'xmfcpl', key: 'xmfcpl', align: 'center' },
		{ title: '大米成品粮', dataIndex: 'dmcpl', key: 'dmcpl', align: 'center' },
		{ title: '食用油成品粮', dataIndex: 'syycpl', key: 'syycpl', align: 'center' },
		{ title: '其他成品粮', dataIndex: 'qtcpl', key: 'qtcpl', align: 'center' }
	]

	const formData = ref({
		enterpriseName: '',
		creditCode: '',
		legalRepresentative: '',
		legalContact: '',
		enterpriseContact: '',
		contactNumber: '',
		enterpriseNature: '',
		enterpriseType: '',
		longitude: '',
		latitude: '',
		actualBusinessAddress: '',
		managementAreaProvince: null,
		managementAreaCity: null,
		managementAreaCounty: null,
		emergencyLevel: '',
		actualAddressProvince: null,
		productionStatus: '',
		actualAddressCity: null,
		emergencyCategory: '应急仓储企业',
		actualAddressCounty: null,
		ownVehiclesDailyDeliveryCapacity: '',
		ownTransportVehicles: '',
		ownTransportCapacity: ''
	})
	const tableData = ref([])

	const rulesRef = reactive({
		enterpriseName: [{ required: true, message: '请输入企业名称' }],
		creditCode: [
			{
				required: true,
				message: '请填写统一社会信用代码'
			},
			{
				pattern: /^(([0-9A-Za-z]{15})|([0-9A-Za-z]{18})|([0-9A-Za-z]{20}))$/,
				message: '请输入有效的统一社会信用代码',
				trigger: 'change'
			}
		],
		legalRepresentative: [
			{
				required: true,
				message: '请填写法人姓名'
			}
		],
		legalContact: [
			{
				required: true,
				message: '请填写法人联系方式'
			},
			{
				pattern: /^(1[3456789]\d{9}|\d{7,8})$/,
				message: '请输入有效的联系方式',
				trigger: 'change'
			}
		],
		enterpriseContact: [
			{
				required: true,
				message: '请填写企业联系人'
			}
		],
		contactNumber: [
			{
				required: true,
				message: '请填写联系电话'
			},
			{
				pattern: /^(1[3456789]\d{9}|\d{7,8})$/,
				message: '请输入有效的联系电话',
				trigger: 'change'
			}
		],
		enterpriseNature: [
			{
				required: true,
				message: '请填写企业性质'
			}
		],
		enterpriseType: [
			{
				required: true,
				message: '请填写企业类型'
			}
		],
		longitude: [
			{
				required: true,
				message: '请填写经度'
			}
		],
		latitude: [
			{
				required: true,
				message: '请填写纬度'
			}
		],
		emergencyCategory: [
			{
				required: true,
				message: '请选择应急分类'
			}
		],
		actualBusinessAddress: [
			{
				required: true,
				message: '请填写实际经营地址'
			}
		],
		managementAreaProvince: [
			{
				required: true,
				message: '请选择归口管理地区-省'
			}
		],
		managementAreaCity: [
			{
				required: true,
				message: '请选择归口管理地区-市'
			}
		],
		managementAreaCounty: [
			{
				required: true,
				message: '请选择归口管理地区-县'
			}
		],
		actualAddressProvince: [
			{
				required: true,
				message: '请选择实际经营地址-省'
			}
		],
		actualAddressCity: [
			{
				required: true,
				message: '请选择实际经营地址-市'
			}
		],
		actualAddressCounty: [
			{
				required: true,
				message: '请选择实际经营地址-县'
			}
		],
		emergencyLevel: [
			{
				required: true,
				message: '请选择应急级别'
			}
		],
		productionStatus: [
			{
				required: true,
				message: '请选择生产状态'
			}
		],
		ownVehiclesDailyDeliveryCapacity: [
			{
				required: true,
				message: '请填写自有车辆日配送能力'
			}
		],
		ownTransportVehicles: [
			{
				required: true,
				message: '请填写自有运输车辆数'
			}
		],
		ownTransportCapacity: [
			{
				required: true,
				message: '请填写自有运输能力'
			}
		]
	})
	const labelCol = {
		style: 'width:180px'
	}
	const labelCols = {
		style: 'width:315px'
	}
	return {
		formData,
		tableData,
		pageTitle,
		options,
		columns,
		rulesRef,
		labelCol,
		labelCols
	}
}
