<template>
	<view class="jnpf-wrap jnpf-wrap-form" v-if="!loading">
		<u-form :model="dataForm" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
			label-align="left" :label-width="labelwidth" class="jnpf-form">
			<view class="u-p-l-20 u-p-r-20 ">
				<u-form-item>
					<jnpf-group value="基础信息" content="基础信息" contentPosition="left">
					</jnpf-group>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('code')" :required="requiredList.code" label="生产线编号" prop="code">
					<u-input v-model="dataForm.code" disabled @change="changeData('code',-1)" input-align='right'
						placeholder="系统自动生成" :style='{"width":"100%"}' readonly>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('name')" :required="requiredList.name" label="生产线名称" prop="name">
					<u-input v-model="dataForm.name" :disabled="judgeWrite('name')" @change="changeData('name',-1)"
						input-align='right' clearable placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('simpleName')" :required="requiredList.simpleName" label=" 简称/英文名"
					prop="simpleName">
					<u-input v-model="dataForm.simpleName" :disabled="judgeWrite('simpleName')"
						@change="changeData('simpleName',-1)" input-align='right' clearable placeholder="请输入"
						:style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('type')" :required="requiredList.type" label="类型" prop="type">
					<jnpf-select v-model="dataForm.type" :disabled="judgeWrite('type')" @change="changeData('type',-1)"
						clearable placeholder="请选择" :props="typeProps" :options="typeOptions" :style='{"width":"100%"}'>
					</jnpf-select>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('parentId')" :required="requiredList.parentId" label="所属工厂"
					prop="parentId">
					<jnpf-select v-model="dataForm.parentId" :disabled="judgeWrite('parentId')"
						@change="changeData('parentId',-1)" clearable placeholder="请选择" :props="parentIdProps"
						:options="parentIdOptions" :style='{"width":"100%"}'>
					</jnpf-select>
				</u-form-item>
			</view>
			<!-- <view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('workshopId')" :required="requiredList.workshopId" label="所属车间"
					prop="workshopId">
					<jnpf-select v-model="dataForm.workshopId" :disabled="judgeWrite('workshopId')"
						@change="changeData('workshopId',-1)" clearable placeholder="请选择" :props="workshopIdProps"
						:options="workshopIdOptions" :style='{"width":"100%"}'>
					</jnpf-select>
				</u-form-item>
			</view> -->
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('workshopId')" :required="requiredList.workshopId" label="所属车间"
					prop="workshopId">
					<jnpf-popup-select v-model="dataForm.workshopId" :disabled="judgeWrite('workshopId')"
						@change="changeData('workshopId',-1)" :rowIndex="null" :formData="dataForm"
						:templateJson="interfaceRes.workshopId" hasPage clearable propsValue="id" popupWidth="800px"
						popupTitle="选择数据" popupType="dialog" relationField='name' vModel='workshopId'
						:columnOptions="workshopIdColumnOptions" interfaceId="521948662406847621" :pageSize="20"
						placeholder="请选择" type="popup" :style='{"width":"100%"}'>
					</jnpf-popup-select>
				</u-form-item>
			</view>

			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('status')" :required="requiredList.status" label="状态" prop="status">
					<jnpf-radio v-model="dataForm.status" :disabled="judgeWrite('status')"
						@change="changeData('status',-1)" optionType="button" direction="horizontal"
						:props="statusProps" :options="statusOptions" :style='{"width":"100%"}'>
					</jnpf-radio>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('description')" :required="requiredList.description" label="描述"
					prop="description">
					<u-input v-model="dataForm.description" :disabled="judgeWrite('description')"
						@change="changeData('description',-1)" input-align='right' clearable placeholder="请输入"
						type="textarea" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 ">
				<u-form-item>
					<jnpf-group value="联系人信息" content="联系人信息" contentPosition="left">
					</jnpf-group>
				</u-form-item>
			</view>
			<view class="jnpf-table" v-if="judgeShow('businesscontact1List')">
				<view class="jnpf-table-item" v-for="(item,i) in dataForm.businesscontact1List" :key="i">
					<view class="jnpf-table-item-title u-flex u-row-between">
						<text class="jnpf-table-item-title-num">({{i+1}})</text>
						<view class="jnpf-table-item-title-action"
							v-if=" !judgeWrite('businesscontact1List') && dataForm.businesscontact1List.length>0"
							@click="delbusinesscontact1List(i)">删除</view>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-contactType')"
							:required="requiredList['businesscontact1List-contactType']" label="类型">
							<jnpf-select v-model="dataForm.businesscontact1List[i].contactType"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-contactType')"
								@change="changeData('businesscontact1-contactType',i)" clearable placeholder="请选择"
								:props="businesscontact1contactTypeProps" :options="businesscontact1contactTypeOptions"
								:style='{"width":"100%"}'>
							</jnpf-select>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-name')"
							:required="requiredList['businesscontact1List-name']" label="姓名">
							<u-input v-model="dataForm.businesscontact1List[i].name"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-name')"
								@change="changeData('businesscontact1-name',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-phone')"
							:required="requiredList['businesscontact1List-phone']" label="手机号">
							<u-input v-model="dataForm.businesscontact1List[i].phone"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-phone')"
								@change="changeData('businesscontact1-phone',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-landline')"
							:required="requiredList['businesscontact1List-landline']" label="座机">
							<u-input v-model="dataForm.businesscontact1List[i].landline"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-landline')"
								@change="changeData('businesscontact1-landline',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-email')"
							:required="requiredList['businesscontact1List-email']" label="邮箱">
							<u-input v-model="dataForm.businesscontact1List[i].email"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-email')"
								@change="changeData('businesscontact1-email',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-fax')"
							:required="requiredList['businesscontact1List-fax']" label="传真">
							<u-input v-model="dataForm.businesscontact1List[i].fax"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-fax')"
								@change="changeData('businesscontact1-fax',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('businesscontact1List-lastModifyTime')"
							:required="requiredList['businesscontact1List-lastModifyTime']" label="更新时间">
							<u-input v-model="dataForm.businesscontact1List[i].lastModifyTime"
								:disabled="judgeWrite('businesscontact1List')||judgeWrite('businesscontact1List-lastModifyTime')"
								@change="changeData('businesscontact1-lastModifyTime',i)" input-align='right' clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
				</view>
				<view class="jnpf-table-addBtn" @click="addbusinesscontact1List"
					v-if="!judgeWrite('businesscontact1List')">
					<u-icon name="plus" color="#2979ff"></u-icon>
					<span>{{dataForm.businesscontact1List.length==0?"添加":"添加"}}</span>
				</view>
			</view>
		</u-form>
		<u-modal v-model="show" :content="content" width='70%' border-radius="16"
			:content-style="{fontSize: '28rpx',padding: '20rpx',lineHeight: '44rpx',textAlign: 'left'}"
			:titleStyle="{padding: '20rpx'}" :confirm-style="{height: '80rpx',lineHeight: '80rpx'}" :title="title"
			confirm-text="确定">
		</u-modal>
	</view>
</template>

<script>
	import {
		getDictionaryDataSelector,
		getDataInterfaceRes,
		getDefaultCurrentValueUserId,
		getDefaultCurrentValueDepartmentId
	} from '@/api/common'
	import comMixin from '../../../workFlow/workFlowForm/mixin'
	import {
		getDateDay,
		getLaterData,
		getBeforeData,
		getBeforeTime,
		getLaterTime
	} from '@/components/index.js'
	import request from '@/utils/request'
	export default {
		mixins: [comMixin],
		data() {
			return {
				idList: [],
				index: 0,
				actionList: [],
				actionListLength: false,
				showAction: false,
				btnLoading: false,
				loading: false,
				text: '提示：测试文本',
				tableKey: '',
				dataForm: {
					id: "",
					code: '',
					name: '',
					simpleName: '',
					type: "",
					parentId: "",
					workshopId: "",
					status: "",
					description: '',
					businesscontact1List: [],
				},
				rules: {
					name: [{
						required: true,
						message: '生产线名称请输入',
					}, ],
					type: [{
						required: true,
						message: '类型请选择',
					}, ],
					parentId: [{
						required: true,
						message: '所属工厂请选择',
					}, ],
					workshopId: [{
						required: true,
						message: '所属车间请选择',
					}, ],
					status: [{
						required: true,
						message: '状态不能为空',
					}, ],
				},
				typeOptions: [],
				typeProps: {
					"label": "fullName",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				parentIdOptions: [],
				parentIdProps: {
					"label": "name",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				workshopIdOptions: [],
				workshopIdProps: {
					"label": "name",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				      workshopIdColumnOptions:[
				        {
				        "label":"车间",
				        "value":"name"
				        },
				        {
				        "label":"编码",
				        "value":"code"
				        },
				    ],
				statusOptions: [{
					"fullName": "启用",
					"id": "1"
				}, {
					"fullName": "禁用",
					"id": "2"
				}],
				statusProps: {
					"label": "fullName",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				businesscontact1contactTypeOptions: [],
				businesscontact1contactTypeProps: {
					"label": "fullName",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				labelwidth: 100 * 1.5,
				menuId: '',
				jurisdictionType: '',
				ruleList: {
					businesscontact1List: {
						'contactType': '类型不能为空',
						'name': '姓名不能为空',
						'phone': '手机号不能为空',
						'email': '邮箱不能为空',
					},
				},
				interfaceRes: {
					code: [],
					name: [],
					simpleName: [],
					type: [],
					parentId: [],
					workshopId: [],
					status: [],
					description: [],
					businesscontact1contactType: [],
					businesscontact1name: [],
					businesscontact1phone: [],
					businesscontact1landline: [],
					businesscontact1email: [],
					businesscontact1fax: [],
					businesscontact1lastModifyTime: [],
				},
				regList: {
					businesscontact1List: {
						contactType: [],
						name: [],
						phone: [],
						landline: [],
						email: [],
						fax: [],
						lastModifyTime: [],
					},
				},
				ableAll: {},
				childIndex: -1,
				dataValue: {},
				isEdit: false,
				userInfo: {},
				formatType: {
					"yyyy": "yyyy",
					"yyyy-MM": "yyyy-mm",
					"yyyy-MM-dd": "yyyy-mm-dd",
					"yyyy-MM-dd HH:mm": "yyyy-mm-dd hh:MM",
					"yyyy-MM-dd HH:mm:ss": "yyyy-mm-dd hh:MM:ss",
					"HH:mm:ss": "hh:MM:ss",
					"HH:mm": "hh:MM"
				},
				content: '',
				title: '',
				show: false,
			}
		},
		onLoad(option) {
			uni.$on('linkPageConfirm', (subVal) => {
				if (this.tableKey) {
					for (let i = 0; i < subVal.length; i++) {
						let t = subVal[i]
						if (this['get' + this.tableKey]) {
							this['get' + this.tableKey](t)
						}
					}
					this.childIndex = -1
					this.collapse()
				}
			})
			this.jurisdictionType = option.jurisdictionType
			this.menuId = option.menuId
			this.userInfo = uni.getStorageSync('userInfo') || {}
			this.dataForm.id = option.id || 0
			let _title = ""
			if (option.jurisdictionType == 'btn_edit') {
				_title = "编辑"
			}
			if (option.jurisdictionType == 'btn_detail') {
				_title = "详情"
			}
			if (option.jurisdictionType == 'btn_add') {
				_title = "新增"
			}
			if (_title) {
				uni.setNavigationBarTitle({
					title: _title
				})
			}
			this.selfInit()
			this.initDefaultData()
			this.dataAll()
			this.initData()
			this.dataValue = JSON.parse(JSON.stringify(this.dataForm))
			this.idList = option.idList ? option.idList.split(",") : []
			for (let i = 0; i < this.idList.length; i++) {
				if (this.idList[i] == option.id) {
					this.index = i;
				}
			}
			if (!option.id) {
				this.actionList.push({
					text: '确定并新增',
					id: 'save_add'
				})
			} else {
				let upper = {
					text: '上一条',
					id: 'upper',
					disabled: this.index == 0 ? true : false
				}
				this.actionList.push(upper)
				let lower = {
					text: '下一条',
					id: 'lower',
					disabled: this.index == this.idList.length - 1 ? true : false
				}
				this.actionList.push(lower)
				this.actionList.push({
					text: '确定并继续',
					id: 'save_proceed'
				})
				this.collapse()
			}
		},
		onReady() {
			this.$nextTick(() => {
				setTimeout(() => {
					this.$refs.dataForm.setRules(this.rules);
				}, 100)
			})
		},
		watch: {
			dataForm: {
				handler(val, oldVal) {
					this.businesscontact1()
				},
				deep: true
			}
		},
		methods: {
			handleAction(index) {
				if (this.actionList[index].id === 'save_add' || this.actionList[index].id === 'save_proceed') {
					this.submitForm(1)
				} else {
					this.calculation(this.actionList[index].id, index)
				}
			},
			calculation(type, index) {
				if (type === 'upper') {
					this.index--
					this.actionList[index + 1].disabled = false
					if (this.index == 0) this.actionList[index].disabled = true
				} else {
					this.index++
					this.actionList[index - 1].disabled = false
					if (this.index == this.idList.length - 1) this.actionList[index].disabled = true
				}
				this.dataForm.id = this.idList[this.index]
				this.initData()
			},
			changeData(model, index) {
				this.isEdit = false
				this.childIndex = index
				let modelAll = model.split("-");
				let faceMode = "";
				for (let i = 0; i < modelAll.length; i++) {
					faceMode += modelAll[i];
				}
				for (let key in this.interfaceRes) {
					if (key != faceMode) {
						let faceReList = this.interfaceRes[key]
						for (let i = 0; i < faceReList.length; i++) {
							if (faceReList[i].relationField == model) {
								let options = 'get' + key + 'Options';
								if (this[options]) {
									this[options]()
								}
								this.changeData(key, index)
							}
						}
					}
				}
			},
			changeDataFormData(type, data, model, index, defaultValue, edit) {
				if (!edit) {
					if (type == 2) {
						for (let i = 0; i < this.dataForm[data].length; i++) {
							if (index == -1) {
								this.dataForm[data][i][model] = defaultValue
							} else if (index == i) {
								this.dataForm[data][i][model] = defaultValue
							}
						}
					} else {
						this.dataForm[data] = defaultValue
					}
				}
			},
			clickIcon(label, tipLabel) {
				this.content = tipLabel
				this.title = label
				this.show = true
			},
			exist() {
				let title = [];
				let _ruleList = this.ruleList
				for (let k in _ruleList) {
					let childData = this.dataForm[k]
					childData.forEach((item, index) => {
						for (let model in _ruleList[k]) {
							if (item[model] instanceof Array) {
								if (item[model].length == 0) {
									title.push(_ruleList[k][model])
								}
							} else if (!item[model]) {
								title.push(_ruleList[k][model])
							}
						}
					})
				}
				let _regList = this.regList
				for (let k in _regList) {
					let childData = this.dataForm[k]
					for (let n in _regList[k]) {
						for (let i = 0; i < _regList[k][n].length; i++) {
							const element = _regList[k][n][i]
							if (element.pattern) {
								element.pattern = element.pattern.toString()
								let start = element.pattern.indexOf('/')
								let stop = element.pattern.lastIndexOf('/')
								let str = element.pattern.substring(start + 1, stop)
								let reg = new RegExp(str)
								element.pattern = reg
							}
							childData.forEach((item, index) => {
								if (item[n] && !element.pattern.test(item[n])) {
									title.push(element.message)
								}
							})
						}
					}
				}
				if (title.length > 0) {
					return title[0]
				}
			},
			resetForm() {
				uni.navigateBack()
			},
			dataAll() {
				this.gettypeOptions()
				this.getparentIdOptions()
				this.getworkshopIdOptions()
				this.getbusinesscontact1contactTypeOptions()
				this.collapse()
			},
			dateTime(timeRule, timeType, timeTarget, timeValueData, dataValue) {
				let timeDataValue = null;
				let timeValue = Number(timeValueData)
				if (timeRule) {
					if (timeType == 1) {
						timeDataValue = timeValueData ? timeValue : null
					} else if (timeType == 2) {
						timeDataValue = dataValue
					} else if (timeType == 3) {
						timeDataValue = new Date().getTime()
					} else if (timeType == 4) {
						let previousDate = '';
						if (timeTarget == 1 || timeTarget == 2) {
							previousDate = getDateDay(timeTarget, timeType, timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else if (timeTarget == 3) {
							previousDate = getBeforeData(timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else {
							timeDataValue = getBeforeTime(timeTarget, timeValue).getTime()
						}
					} else if (timeType == 5) {
						let previousDate = '';
						if (timeTarget == 1 || timeTarget == 2) {
							previousDate = getDateDay(timeTarget, timeType, timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else if (timeTarget == 3) {
							previousDate = getLaterData(timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else {
							timeDataValue = getLaterTime(timeTarget, timeValue).getTime()
						}
					}
				}
				return timeDataValue;
			},
			time(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
				let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType
				let timeDataValue = null
				if (timeRule) {
					if (timeType == 1 && timeValue) {
						timeDataValue = timeValue || '00:00:00'
						if (timeDataValue.split(':').length == 3) {
							timeDataValue = timeDataValue
						} else {
							timeDataValue = timeDataValue + ':00'
						}
					} else if (timeType == 2) {
						timeDataValue = dataValue
					} else if (timeType == 3) {
						timeDataValue = this.jnpf.toDate(new Date(), format)
					} else if (timeType == 4) {
						let previousDate = '';
						previousDate = getBeforeTime(timeTarget, timeValue)
						timeDataValue = this.jnpf.toDate(previousDate, format)
					} else if (timeType == 5) {
						let previousDate = '';
						previousDate = getLaterTime(timeTarget, timeValue)
						timeDataValue = this.jnpf.toDate(previousDate, format)
					}
				}
				return timeDataValue;
			},
			gettypeOptions() {
				getDictionaryDataSelector('521639458429212677').then(res => {
					this.typeOptions = res.data.list
				})
			},
			getparentIdOptions() {
				const edit = this.isEdit
				const index = this.childIndex
				let templateJsonList = JSON.parse(JSON.stringify(this.interfaceRes.parentId))
				for (let i = 0; i < templateJsonList.length; i++) {
					let json = templateJsonList[i];
					if (json.relationField) {
						let relationFieldAll = json.relationField.split("-");
						let val = json.defaultValue;
						if (relationFieldAll.length > 1 && index > -1) {
							val = this.dataForm[relationFieldAll[0] + 'List'] && this.dataForm[relationFieldAll[0] +
								'List'].length ? this.dataForm[relationFieldAll[0] + 'List'][index][relationFieldAll[
								1]] : ''
						} else {
							val = this.dataForm[relationFieldAll]
						}
						json.defaultValue = val
					}
				}
				let template = {
					paramList: templateJsonList
				}
				getDataInterfaceRes('521651055751075845', template).then(res => {
					let data = res.data
					this.parentIdOptions = data
					if (!edit) return
					this.changeDataFormData(1, 'parentId', 'parentId', index, '', edit)
				})
			},
			getworkshopIdOptions() {
				const edit = this.isEdit
				const index = this.childIndex
				let templateJsonList = JSON.parse(JSON.stringify(this.interfaceRes.workshopId))
				for (let i = 0; i < templateJsonList.length; i++) {
					let json = templateJsonList[i];
					if (json.relationField) {
						let relationFieldAll = json.relationField.split("-");
						let val = json.defaultValue;
						if (relationFieldAll.length > 1 && index > -1) {
							val = this.dataForm[relationFieldAll[0] + 'List'] && this.dataForm[relationFieldAll[0] +
								'List'].length ? this.dataForm[relationFieldAll[0] + 'List'][index][relationFieldAll[
								1]] : ''
						} else {
							val = this.dataForm[relationFieldAll]
						}
						json.defaultValue = val
					}
				}
				let template = {
					paramList: templateJsonList
				}
				// getDataInterfaceRes('521948662406847621', template).then(res => {
				// 	let data = res.data
				// 	this.workshopIdOptions = data
				// 	if (!edit) return
				// 	this.changeDataFormData(1, 'workshopId', 'workshopId', index, '', edit)
				// })
			},
			businesscontact1() {
				let table = this.dataForm.businesscontact1List
				let summaryField = []
				let summaryFieldName = {}
				let data = {}
				let thousandsField = []
				for (let i in summaryField) {
					let map = {}
					let val = 0
					for (let j = 0; j < table.length; j++) {
						let summary = table[j][summaryField[i]];
						if (summary) {
							let data = isNaN(summary) ? 0 : Number(summary)
							val += data
						}
					}
					map.id = summaryField[i];
					map.name = summaryFieldName[summaryField[i]];
					map.val = (thousandsField.includes(summaryField[i])) ? Number(val).toLocaleString('zh', {
						maximumFractionDigits: '2'
					}) : val;
					data[summaryField[i]] = map;
				}
				return data;
			},
			getbusinesscontact1contactTypeOptions() {
				getDictionaryDataSelector('517959233023509701').then(res => {
					this.businesscontact1contactTypeOptions = res.data.list
				})
			},
			initData() {
				this.$nextTick(function() {
					if (this.dataForm.id) {
						this.loading = true
						request({
							url: '/api/scm/BusinessLine1/' + this.dataForm.id,
							method: 'get',
						}).then(res => {
							this.dataInfo(res.data)
							this.loading = false
						})
					} else {
						this.initDefaultData()
					}
				})
			},
			beforeSubmit() {
				const _data = this.dataList()
				return _data
			},
			initDefaultData() {},
			selfInit() {
				this.$store.commit('base/UPDATE_RELATION_DATA', {})
				this.dataAll()
				this.initDefaultData()
				this.collapse()
			},
			selfGetInfo(dataForm) {
				this.dataForm.id = this.dataForm.id
				this.dataInfo(dataForm)
			},
			addbusinesscontact1List() {
				let value = {}
				this.tableKey = 'businesscontact1List';
				this.getbusinesscontact1List(value)
				this.childIndex = -1
				this.collapse()
			},
			delbusinesscontact1List(index) {
				var that = this
				uni.showModal({
					title: '提示',
					content: '确认删除该条信息吗？',
					success: function(res) {
						if (res.confirm) {
							that.dataForm.businesscontact1List.splice(index, 1);
							that.collapse()
						}
					}
				})
			},
			getbusinesscontact1List(value) {
				let item = {
					contactType: "",
					contactTypeOptions: [],
					name: '',
					phone: '',
					landline: '',
					email: '',
					fax: '',
					lastModifyTime: '',
				}
				let result = {
					...item,
					...value
				}
				this.dataForm.businesscontact1List.push(result)
				this.childIndex = this.dataForm.businesscontact1List.length - 1
				this.isEdit = true
				this.isEdit = false
			},
			dataList() {
				var _data = this.dataForm;
				return _data;
			},
			dataInfo(dataAll) {
				let _dataAll = dataAll
				this.dataForm = _dataAll
				this.isEdit = true
				this.dataAll()
				for (let i = 0; i < _dataAll.businesscontact1List.length; i++) {
					this.childIndex = i
				}
				this.childIndex = -1
				this.collapse()
			},
			collapse() {
				setTimeout(() => {}, 1000);
			},
		},
	}
</script>
<style>
	page {
		background-color: #f0f2f6;
	}
</style>