<template>
	<div>
		<el-dialog :title="title" :visible.sync="showFormDia" width="85%" height="600px" :before-close="handleClose"
			custom-class="bbsl-location-dialog" top="1.7vh">
			<el-tabs v-model="activeName" @tab-click="handleClick">
				<el-tab-pane label="基础信息" name="form">
					<div class="bbsl-scroll-pane">
						<el-form ref="formInfo" style="width:100%" :rules="rules" :model="params" label-width="150px"
							class="bbsl-scroll-form">
							<p class="from-title" id="step1">
								<i class="el-icon-info"></i>
								<span>基础信息</span>
							</p>
							<el-row>

								<el-col :span="8">
									<el-form-item label="测站编码：" prop="stcd">
										<el-input maxlength="18" size="mini" placeholder="请输入测站编码"
											v-model="params.stcd"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="测站名称：" prop="stnm">
										<el-input size="mini" placeholder="请输入测站名称" v-model="params.stnm"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="测站岸别：" prop="stbk">
										<el-select style="width: 100%" size="mini" v-model="params.stbk" clearable
											placeholder="请选择测站岸别">
											<el-option v-for="item in stbks" :key="item.id" :label="item.name"
												:value="item.value"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="8">
									<el-form-item label="测站类型：" prop="sttp">
										<el-select style="width: 100%" size="mini" v-model="params.sttp" clearable
											placeholder="请选择测站类型">
											<el-option v-for="item in sttps" :key="item.id" :label="item.name"
												:value="item.value"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="测站应用分类：" prop="appType">
										<el-select style="width: 100%" size="mini" v-model="params.appType" clearable
											placeholder="请选择测站应用分类">
											<el-option v-for="item in appTypes" :key="item.id" :label="item.name"
												:value="item.value"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="所在行政区划：" prop="addvcd">
										<el-cascader filterable :show-all-levels="false" style="width: 100%" size="mini"
											:options="basAdNames" v-model="params.addvcd" :props="{
                      value: 'code',
                      label: 'name',
                      children: 'children',
                    }" @change="onhouChange" placeholder="请选择所属行政区划" clearable></el-cascader>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="8">
									<el-form-item label="河流名称：" prop="rvcd">
										<el-cascader filterable :show-all-levels="false" style="width: 100%" size="mini"
											:options="rvcds" v-model="params.rvcd" :props="{
                      value: 'code',
                      label: 'name',
                      children: 'children',
                      checkStrictly: true
                    }" @change="rvcdChange" placeholder="请选择所在河流" clearable></el-cascader>
										<!-- <el-select
                    style="width: 100%"
                    size="mini"
                    v-model="params.rvcd"
                    clearable
                    placeholder="请选择河流名称"
                  >
                    <el-option
                      v-for="item in rvcds"
                      :key="item.id"
                      :label="item.name"
                      :value="item.code"
                    ></el-option>
                  </el-select> -->
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="流域名称：" prop="bscd">
										<el-select style="width: 100%" size="mini" v-model="params.bscd" clearable
											placeholder="请选择流域名称">
											<el-option v-for="item in bscds" :key="item.id" :label="item.basName"
												:value="item.basCode"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="水系名称：" prop="hnnm">
										<el-input size="mini" placeholder="请输入水系名称" v-model="params.hnnm"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="8">
									<el-form-item label="拼音码：" prop="phcd">
										<el-input @input="dmcrels" size="mini" placeholder="请输入拼音码"
											v-model="params.phcd"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="建站年月：" prop="esstym">
										<el-date-picker style="width: 100%" size="mini" v-model="params.esstym"
											value-format="yyyyMM" type="month" placeholder="选择建站年月">
										</el-date-picker>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="始报年月：" prop="bgfrym">
										<el-date-picker style="width: 100%" size="mini" v-model="params.bgfrym"
											value-format="yyyyMM" type="month" placeholder="选择始报年月">
										</el-date-picker>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="8">
									<el-form-item label="基面名称：" prop="dtmnm">
										<el-input size="mini" placeholder="请输入基面名称" v-model="params.dtmnm"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="基面高程：" prop="dtmel">
										<el-input size="mini" placeholder="请输入基面高程" v-model="params.dtmel"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="基面修正值：" prop="dtpr">
										<el-input size="mini" placeholder="请输入基面修正值" v-model="params.dtpr"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="8">
									<el-form-item label="集水面积(Km2)：" prop="drna">
										<el-input @input="deadLevs('3')" size="mini" placeholder="请输入集水面积"
											v-model="params.drna"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="关联对象：">
										<el-row>
											<el-col :span="16"><span>
													<el-input size="mini" :disabled="true"
														v-model="params.stStbprpRe.name"></el-input>
												</span>
											</el-col>
											<el-col :span="1"><span>&emsp;</span></el-col>
											<el-col :span="7"><span>
													<el-button style="height: 26px" @click="openFormDiao" type="primary"
														size="mini">选择关联</el-button>
												</span></el-col>
										</el-row>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="设备管理人员：" prop="admaur">
										<el-input size="mini" placeholder="请输入设备管理人员名称" v-model="params.admaur">
										</el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="8">
									<el-form-item label="设备管理人员电话：" prop="admaurtel">
										<el-input size="mini" placeholder="请输入设备管理人员电话"
											oninput="value=value.replace(/[^\d]/g,'')" v-model="params.admaurtel">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="设备维护人员：" prop="matenur">
										<el-input size="mini" placeholder="请输入设备维护人员名称" v-model="params.matenur">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="设备维护人员电话：" prop="matenurtel">
										<el-input size="mini" placeholder="请输入设备维护人员电话"
											oninput="value=value.replace(/[^\d]/g,'')" v-model="params.matenurtel">
										</el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="8">
									<el-form-item label="重点关注：" prop="phcd">
										<el-radio v-model="params.isImportant" label="1">是</el-radio>
										<el-radio v-model="params.isImportant" label="0">否</el-radio>

									</el-form-item>
								</el-col>
								<!-- <el-col :span="8">
                  <el-form-item label="是否根据高程计算："
                                prop="phcd">
                    <el-radio v-model="params.isElevation"
                              label="1">是</el-radio>
                    <el-radio v-model="params.isElevation"
                              label="0">否</el-radio>

                  </el-form-item>
                </el-col> -->
							</el-row>

							<el-row>
								<el-col>
									<el-form-item label="备注：" prop="comments">
										<el-input type="textarea" size="mini" :autosize="{minRows: 2, maxRows: 4}"
											placeholder="请输入内容" v-model="params.comments">
										</el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<p class="from-title" id="step1">
								<i class="el-icon-s-tools"></i>
								<span>安装信息</span>
							</p>
							<el-row>
								<el-col :span="8">
									<el-form-item label="经度：" prop="lgtd">
										<el-input @input="deadLevs('1')" size="mini" placeholder="请输入经度"
											v-model="params.lgtd"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="纬度：" prop="lttd">
										<el-input @input="deadLevs('2')" size="mini" placeholder="请输入纬度"
											v-model="params.lttd"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="隶属行业单位:" prop="atcunit">
										<el-input size="mini" placeholder="请输入单位名称" v-model="params.atcunit"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="8">
									<el-form-item label="信息管理单位：" prop="admauth">
										<el-input size="mini" placeholder="请输入单位名称" v-model="params.admauth"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="交换管理单位：" prop="locality">
										<el-input size="mini" placeholder="请输入单位名称" v-model="params.locality">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="测站方位(度)：" prop="stazt">
										<el-input oninput="value=value.replace(/[^\d.]/g,'')" size="mini"
											placeholder="请输入测站方位" v-model="params.stazt"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="8">
									<el-form-item label="至河口距离(Km)：" prop="dstrvm">
										<el-input oninput="value=value.replace(/[^\d.]/g,'')" size="mini"
											placeholder="请输入至河口距离" v-model="params.dstrvm"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="安装详细地址：" prop="stlc">
										<el-input size="mini" placeholder="请输入详细地址" v-model="params.stlc"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
				<el-tab-pane label="测站管理责任人" name="persons">
					<div style="margin: 10px 0">
						<el-button size="mini" icon="el-icon-plus" type="primary" @click="addAcounts">添加</el-button>
						<el-button size="mini" icon="el-icon-delete" type="danger" @click="deletAcounts">删除</el-button>
					</div>
					<el-table :row-key="getRowKey" ref="multipleSelections" border :data="params.persons"
						:row-style="{height: '61px'}" style="width: 100%" size="mini" @selection-change="handleChanges"
						:header-cell-style="{'text-align': 'center'}" :cell-style="{'text-align': 'center'}">
						<el-table-column type="selection" width="55" :reserve-selection="true">
						</el-table-column>

						<el-table-column prop="orgId" label="责任人组织">
							<template slot-scope="scope">
								<el-select @change="changeOrgIds(scope.row)" style="width: 100%" size="mini"
									v-model="scope.row.orgId" :class="scope.row.orgId ? '' : 'redBull'"
									:placeholder="scope.row.orgId ? '' : '请选择责任人组织'" clearable>
									<el-option v-for="item in orgIds" :key="item.id" :label="item.name"
										:value="item.id"></el-option>
								</el-select>
							</template>
						</el-table-column>
						<el-table-column prop="personId" label="责任人人员">
							<template slot-scope="scope">
								<el-select @change="changePid(scope.row)" :disabled="scope.row.orgId ? false : true"
									style="width: 100%" size="mini" v-model="scope.row.personId"
									:class="scope.row.personId ? '' : 'redBull'"
									:placeholder="scope.row.personId ? '' : '请选择责任人人员'" clearable>
									<el-option v-for="item in personIds" :key="item.id" :label="item.name"
										:value="item.id"></el-option>
								</el-select>
							</template>
						</el-table-column>
						<el-table-column prop="isHead" label="是否负责人">
							<template slot-scope="scope">
								<el-radio v-model="scope.row.isHead" label="1">是</el-radio>
								<el-radio v-model="scope.row.isHead" label="0">否</el-radio>
							</template>
						</el-table-column>
					</el-table>
				</el-tab-pane>
				<!-- <el-tab-pane label="汛限水位" name="resInsList">
          <div style="margin: 10px 0">
            <el-button
              size="mini"
              icon="el-icon-plus"
              type="primary"
              @click="addAcount"
              >添加</el-button
            >
            <el-button
              size="mini"
              icon="el-icon-delete"
              type="danger"
              @click="deletAcount"
              >删除</el-button
            >
          </div>
          <el-table
            :row-key="getRowKey"
            ref="multipleSelection"
            border
            :data="params.fsrList"
            :row-style="{height: '61px'}"
            style="width: 100%"
            @selection-change="handleSelectionChange"
            :header-cell-style="{'text-align': 'center'}"
            :cell-style="{'text-align': 'center'}"
          >
            <el-table-column
              type="selection"
              width="55"
              :reserve-selection="true"
            >
            </el-table-column>
            <el-table-column prop="bgmd" label="开始月日">
              <template slot-scope="scope">
                <DateMonthDay
                  style="width: 100%"
                  :date.sync="scope.row.bgmd"
                  :dateDefault="scope.row.bgmd"
                  v-model="scope.row.bgmd"
                  :class="scope.row.bgmd ? '' : 'redBull'"
                  :placeholder="scope.row.bgmd ? '' : '请选择结束月日'"
                ></DateMonthDay>
              </template>
            </el-table-column>
            <el-table-column prop="edmd" label="结束月日">
              <template slot-scope="scope">
                <DateMonthDay
                  style="width: 100%"
                  :date.sync="scope.row.edmd"
                  :dateDefault="scope.row.edmd"
                  v-model="scope.row.edmd"
                  :class="scope.row.edmd ? '' : 'redBull'"
                  :placeholder="scope.row.edmd ? '' : '请选择结束月日'"
                ></DateMonthDay>
              </template>
            </el-table-column>
            <el-table-column prop="fsltdw" label="汛限库容">
              <template slot-scope="scope">
                <el-input v-model="scope.row.fsltdw" />
              </template>
            </el-table-column>
            <el-table-column prop="fsltdz" label="汛限水位">
              <template slot-scope="scope">
                <el-input v-model="scope.row.fsltdz" />
              </template>
            </el-table-column>
            <el-table-column prop="fstp" label="汛期类别">
              <template slot-scope="scope">
                <el-select
                  style="width: 100%"
                  size="mini"
                  v-model="scope.row.fstp"
                  clearable
                  placeholder="请选择汛期类别"
                >
                  <el-option
                    v-for="item in fstps"
                    :key="item.id"
                    :label="item.name"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane> -->
			</el-tabs>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="goInfo">保 存</el-button>
				<el-button @click="handleClose">取 消</el-button>
			</span>

			<stStbprpResFroms @func="getClickData" v-if="stStbprpResFrom" @closestStbprpResFrom="closestStbprpResFrom"
				:stStbprpResFrom="stStbprpResFrom"></stStbprpResFroms>
		</el-dialog>
	</div>
</template>
<script>
	import syqStation from '@/api/stManager/syqStation.js'
	import stStbprpResFroms from './components/stStbprpResFrom.vue'
	// import DateMonthDay from './components/dataMoutnDay.vue'
	import dictUtils from '@/components/dict/DictSelectUtils.js'
	import latitude from '@/mixins/latitude'
	import req from '@/request.js'
	export default {
		name: 'syqStationFromdialog',
		components: {
			stStbprpResFroms,
			// DateMonthDay,
		},
		props: {
			showFormDia: {
				type: Boolean,
				default: false,
			},
			title: {
				type: String,
				default: '',
			},
			pId: {
				type: String,
				default: '',
			},
		},
		data() {
			return {
				popList: [],
				stStbprpResFrom: false,
				activeName: 'form',
				fstps: [], //汛期类别字典
				orgIds: [], //组织下拉
				personIds: [], //组织人员下拉
				isHeads: [{
						name: '是',
						value: '1'
					},
					{
						name: '否',
						value: '0'
					},
				], //是否负责人
				tableData: [],
				sttps: [], //测站类型
				stStbprpRe: {
					stnm: null,
				},
				params: {
					// fsrList: [], //汛限水位
					persons: [], //责任人
					stStbprpRe: {
						name: ''
					}, //测站关联对象相关信息
					addvcd: null, //水库代码
					admauth: null, //水库名称
					appType: null, //测站类型
					atcunit: null, //行政区
					bgfrym: null, //主管部门电话
					bscd: null, //建成年月
					bsnm: null, //所在流域代码
					comments: null, //备注
					drna: null, //坝顶高程
					dstrvm: null, //设计洪水位
					dtmel: null, //水面基准
					dtmnm: null, //水库位置坐标_东经
					dtpr: null, //防洪库容
					isImportant: '1', //重点关注
					isElevation: '0', //高程计算
					esstym: null,
					hnnm: null,
					lgtd: null,
					locality: null,
					lttd: null,
					phcd: null,
					rvcd: null,
					rvnm: null,
					stazt: null,
					stbk: null,
					stcd: null,
					stlc: null,
					stnm: null,
					sttp: null,
					sstp: null,
					admaur: null, //设备管理人员
					admaurtel: null, //设备管理人员电话
					matenur: null, //设备维护人员
					matenurtel: null, //设备维护人员电话
				},
				rsr: [],
				rvcds: [], //下拉
				ctcds: [], //下拉
				count: 0,
				appTypes: [], //设备应用分类
				stbks: [{
						name: '左岸',
						value: '0'
					},
					{
						name: '右岸',
						value: '1'
					},
				], //测站岸别
				dtpls: [], //水面基准
				listPop: [],
				// multipleSelection: [],
				multipleSelections: [],
				cmdps: [], //管理单位数组
				accound: 0,
				basGrads: [], //流域级别字典类型
				basAdNames: [], //行政下拉
				AdName: null, //接受每次选中的值
				bscds: [],
				counts: 0,
				sstpList: [],
				rules: {
					stnm: [{
						required: true,
						message: '请输入测站名称',
						trigger: 'blur'
					}],
					sttp: [{
						required: true,
						message: '请选择测站类型',
						trigger: 'blur'
					}],
					stcd: [{
						required: true,
						message: '请输入测站编码',
						trigger: 'blur'
					}],
					appType: [{
						required: true,
						message: '请选择测站应用分类',
						trigger: 'blur'
					}, ],
					addvcd: [{
						required: true,
						message: '请选择所在行政区划',
						trigger: 'blur'
					}]
				},
			}
		},
		created() {
			this.sstpList = dictUtils.getDictItemsFromCache('czlb-stzlx')
			this.getDetailInfo()
			this.getSysDict()
			this.getTreets()
			syqStation.getList({}, (res) => {
				this.popList = res.value
			})
		},
		methods: {
			deadLevs(val) {
				switch (val) {
					case '1':
						this.params.lgtd = latitude.TreeFour(this.params.lgtd)
						break
					case '3':
						this.params.drna = latitude.SixTwo(this.params.drna)
						break
					default:
						this.params.lttd = latitude.TreeFour(this.params.lttd)
				}
			},
			getClickData(data) {
				//获取子组件传的值
				this.params.stStbprpRe = data
			},
			openFormDiao() {
				// this.title = '新增';
				this.stStbprpResFrom = true
			},

			closestStbprpResFrom() {
				this.stStbprpResFrom = false
			},
			rvcdChange(val) {
				if (val) {
					this.params.rvcd = val[val.length - 1]
				}
			},
			onhouChange(val) {
				if (val) {
					this.params.addvcd = val[val.length - 1]
				}
			},
			getTreets() {
				syqStation.getRvcds({}, (res) => {
					this.rvcds = res.value //河流下拉
				})
				syqStation.getCtcds({}, (res) => {
					this.bscds = res.value //流域下拉
				})
				// 行政区查询
				syqStation.getbasAdName({}, (res) => {
					this.basAdNames = res.value
				})
				// 管理树
				syqStation.getrgTree({}, (res) => {
					this.cmdps = res.value
				})
				//组织树
				syqStation.getorgId({}, (res) => {
					this.orgIds = res.value
				})
			},
			changeOrgIds(val) {
				if (val.orgId) {
					val.personId = null
					val.orgId = val.orgId
					syqStation.getpersonId({
						val
					}, (res) => {
						this.personIds = res.value
						this.$set(this.personIds)
					})
				} else {
					this.personIds = []
					val.orgId = ''
					this.$set(this.personIds)
				}
			},
			changePid(val) {
				if (val.personId) {
					val.personId = val.personId
				} else {
					val.personId = ''
				}
			},
			handleClick(tab, event) {
				console.log(tab)
			},
			// handleSelectionChange(val) {
			//   this.multipleSelection = val.map((item, index) => {
			//     return item
			//   })
			// },
			handleChanges(val) {
				this.multipleSelections = val.map((item, index) => {
					return item
				})
			},
			//指定一个key标识这一行的数据
			getRowKey(row) {
				return row.id
			},
			dmcrels() {
				this.params.phcd = this.SixTwo(this.params.phcd)
			},
			SixTwo(value) {
				value = value.replace(/^0*(0\.|[1-3])/, '$1')
				value = value.replace(/[^\d.]/g, '') //清除"数字"和"."以外的字符
				value = value.replace(/^\./g, '') //验证第一个字符是数字而不是字符
				value = value.replace(/\.{1,}/g, '.') //只保留第一个.清除多余的
				value = value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
				value = value.replace(/^(\-)*(\d*)\.(\d\d).*$/, '$1$2.$3') //只能输入两个小数
				value =
					value.indexOf('.') > 0 ?
					value.split('.')[0].substring(0, 4) + '.' + value.split('.')[1] :
					value.substring(0, 4)
				return value
			},
			// addAcount() {
			//   const num = this.count++
			//   this.params.fsrList.push({
			//     ident: num,
			//     bgmd: '',
			//     edmd: '',
			//     fsltdw: '',
			//     fsltdz: '',
			//     fstp: '', //汛期类别（字典）
			//   })
			// },
			// deletAcount() {
			//   if (this.multipleSelection.length != 0) {
			//     const list = this.arrayRepeat(
			//       this.multipleSelection,
			//       this.params.fsrList
			//     )
			//     this.params.fsrList = JSON.parse(JSON.stringify(list))
			//     this.$refs.multipleSelection.clearSelection()
			//   }
			// },
			addAcounts() {
				const num = this.counts++
				this.params.persons.push({
					ident: num,
					personId: '',
					orgId: '',
					isHead: '0',
				})
			},
			arrayRepeat(array1, array2) {
				var result = []
				for (var i = 0; i < array2.length; i++) {
					var obj = array2[i]
					var num = obj.ident
					var isExist = false
					for (var j = 0; j < array1.length; j++) {
						var aj = array1[j]
						var n = aj.ident
						if (n === num) {
							isExist = true
							break
						}
					}
					if (!isExist) {
						result.push(obj)
					}
				}
				return result
			},
			deletAcounts() {
				if (this.multipleSelections.length != 0) {
					const list = this.arrayRepeat(
						this.multipleSelections,
						this.params.persons
					)
					this.params.persons = JSON.parse(JSON.stringify(list))
					this.$refs.multipleSelections.clearSelection()
				}
			},
			// 根据ID查询
			getDetailInfo() {
				if (this.title === '修改') {
					syqStation.detailId(this.pId, (res) => {
						this.params = res.value
						if (res.value.sstp) {
							this.params.sstp = String(res.value.sstp)
						}
						if (!res.value.stStbprpRe) {
							this.params.stStbprpRe = {
								name: ''
							}
						} else {
							// this.params.stStbprpRe.name = res.value.stStbprpRe.stnm
						}
						if (this.params.stStbprpRe.reType) {
							syqStation.getList({}, (res) => {
								this.popList = res.value
								this.popList.forEach((e) => {
									if (this.params.stStbprpRe.reType == e.reType) {
										e.children.forEach((s) => {
											if (this.params.stStbprpRe.reCode == s
												.reCode) {
												this.params.stStbprpRe.name = s.name
												this.$set(
													this.params,
													'stStbprpR',
													this.params.stStbprpRe
												)
											}

										})
									}
								})

							})
						} else {
							this.params.stStbprpRe.name = ''
						}
					})
				}
			},
			handleClose() {
				this.params = {
					// fsrList: [], //汛限水位
					persons: [], //责任人
					stStbprpRe: {}, //测站关联对象相关信息
					addvcd: null, //水库代码
					admauth: null, //水库名称
					appType: null, //测站类型
					atcunit: null, //行政区
					bgfrym: null, //主管部门电话
					bscd: null, //建成年月
					bsnm: null, //所在流域代码
					comments: null, //备注
					drna: null, //坝顶高程
					dstrvm: null, //设计洪水位
					dtmel: null, //水面基准
					dtmnm: null, //水库位置坐标_东经
					dtpr: null, //防洪库容
					esstym: null,
					hnnm: null,
					lgtd: null,
					locality: null,
					lttd: null,
					phcd: null,
					rvcd: null,
					rvnm: null,
					stazt: null,
					stbk: null,
					stcd: null,
					stlc: null,
					stnm: null,
					sttp: null,
					admaur: null, //设备管理人员
					admaurtel: null, //设备管理人员电话
					matenur: null, //设备维护人员
					matenurtel: null, //设备维护人员电话
				}
				this.$emit('closeFormDiao')
			},
			goInfo(e) {
				this.$refs.formInfo.validate((valid) => {
					if (valid) {
						if (this.title === '新增') {
							let canAdd = true
							if (canAdd) {
								syqStation.addSave(this.params, (response) => {
									if (response.state) {
										this.$notify({
											type: 'success',
											message: '新增成功',
											duration: 2000,
											// offset: 80
										})
										this.$emit('closeFormDiao')
										this.$emit('refList')
									} else {}
									// this.$emit('closeFormDiao')
								})
							}
						}
						if (this.title === '修改') {
							// this.params.stStbprpRe为空的时候就删除该对象
							if (this.params.stStbprpRe === "") {
								delete this.params.stStbprpRe
							}
							syqStation.upData(this.params, (response) => {
								if (response.state) {
									this.$notify({
										type: 'success',
										message: '修改成功',
										duration: 2000,
										// offset: 80
									})
									this.$emit('closeFormDiao')
									this.$emit('refList')
									// this.$message.success(response.message)
								} else {
									//  this.$message.success(response.message)
								}
								// this.$emit('closeFormDiao')
								// this.$router.go(-1)
							})
						}
					} else {
						return false
					}
				})
			},
			//获取字典数据
			getSysDict() {
				let portal = window.context.portal
				return new Promise((resolve, reject) => {
					req.post(portal + '/sys/sysDictionary/v1/queryAllDictItems').then(
						(response) => {
							resolve(response.data)
							this.fstps = response.data.xqlb
							this.appTypes = response.data.czyyfl
							// this.sttps =this.sstps.slice(0,-1);
							let a=response.data.czzl
							this.sttps=a.slice(0,-1)
							if (this.title == '新增') {
								this.params.appType = this.appTypes[0].value
								this.params.sttp = this.sttps[0].value
							}

							// this.prgrs = response.data.gcdb;
							// this.prscs = response.data.gcgm;
							// this.basGrads = response.data.lyjb;
							// this.dtpls = response.data.szjm;
							// this.rsrs = response.data.skgn;
							// this.params.resType=this.resTypes[0].value;
						},
						(error) => {
							reject(error)
						}
					)
				})
			},
		},
	}
</script>
<style lang="scss" scoped>
	.el-divider--horizontal {
		margin: 24px 0 5px 0;
		height: 7px !important;
		background: #88b4dd !important;

		.el-divider__text {
			font-size: 16px !important;
		}
	}

	.redBull {
		border: 1px solid red;
	}

	.cell {
		display: flex !important;
	}

	.v-modal {
		z-index: 11 !important;
	}
</style>
