
import { Notification } from 'element-ui';
import request from '@/utils/request';
var baseAPI = process.env.VUE_APP_LOCAL_API + '/';
var DownloadUrl = process.env.VUE_APP_Download + '/';
import { Tools } from './common';
import { Highchart } from '@/assets/js/chartTemplates.js';
import { initData, download } from '@/api/data'

var reqPublic = function(url, type, param, opts){
	type = type.toLowerCase();
	var paramKey = type === 'get' ? 'params' : 'data', opts = opts || {};
	var reqConfig = {
		url: url,
		method: type,
	};
	reqConfig[paramKey] = param;
	opts.responseType && (reqConfig['responseType'] = opts.responseType);
	return request(reqConfig)
};

var reqApis = function(){
	return {
		/* donwloadURl:DownloadUrl,
		getWeather: function(param) {
			var body = {url:'https://i.tianqi.com/', body:param};
			return request({
				url: 'biz/transmitText',
				method: 'post',
				params:body
			})
		}, */
		getRules:function(baseInfo){
			var rules = {};
			for(var key in baseInfo){
				var item = baseInfo[key];
				if(item.must){
					var typeStr = item.type ? '请选择' : '请输入';
					var rule = {required: true, message:typeStr+item.name, trigger:'blur'};
					item.ruleType && (rule.type = item.ruleType)
					rules[key] = [rule];
				};
			};return Object.keys(rules)[0] ? rules : void 0;
		},
		// 根据设备code获取设备字典列表
		sensorListByCode: function(param){
			return reqPublic('/tab/equip/equipnoList', 'get', param)
		},
		// 设备在线状态字典
		getDictDeviceStatus: function(){
			return reqPublic('/dic/alarm/status', 'get', {})
		},
		getBaseParams: function(searchItem){
			var searchItem = searchItem || reqApi.common.getSearchParam(this.form) || {};
			var param = searchItem || {};
			param.page = this.table.page - 1;
			param.size = this.table.size;
			param.sort = 'date,desc';
			return param;
		},

		// 人员呼救接口
		getSos: function(){
			return reqPublic('/tab/sosdata/sos', 'get', {})
		},
		common:{
			requstEdge:function(type, url, param){
				var param = param || {};
				return reqPublic(url, type, param).then((res)=>{
					if(res && res.code === 200){
						return res
					}else{
						Notification({
							title: res.msg,
							type: 'error',
							duration: 2500
						})
					};
				}).catch(function(error) {
					console.log('catch ________________ ', error);
				});
			},
			getRequst: function(searchItem){
				var param = reqApi.getBaseParams.call(this);
				this.table.loading = true;
				this.pageApi.request('get', param).then((res) => {
					this.table.loading = false;
					if(res && res.code){
						var body = res.body || {};
						var list = body.list || [];
						this.table.dataList = list;
						this.table.total = body.total * 1;
					}else{
						this.$notify({
							title: res.msg,
							type: 'error',
							duration: 2500
						})
					};
				}).catch(function(error) {
					this.table.loading = false;
				})
			},
			removeRequst: function(item){
				return this.pageApi.request('delete', item).then((res) => {
					if(res.code === 200){
						this.$notify({
							title: '删除成功！',
							type: 'success',
							duration: 2500
						});
						this.loadData()
					}else{
						this.$notify({
							title: res.msg,
							type: 'error',
							duration: 2500
						})
					};
				});
			},
			addRequst: function(item){
				return this.pageApi.request('post', item).then((res) => {
					this.form.visible = false;
					if(res.code === 200){
						this.$notify({
							title: '添加成功！',
							type: 'success',
							duration: 2500
						});
						this.loadData()
					}else{
						this.$notify({
							title: res.msg,
							type: 'error',
							duration: 2500
						})
					};
				}).catch(function(error) {
					this.form.status.cu = 0
				});
			},
			putRequst: function(item){
				return this.pageApi.request('put', item).then((res) => {
					this.form.visible = false;
					if(res.code === 200){
						this.$notify({
							title: '修改成功！',
							type: 'success',
							duration: 2500
						});
						this.loadData()
					}else{
						this.$notify({
							title: res.msg,
							type: 'error',
							duration: 2500
						})
					};
				}).catch(function(error) {
					this.form.status.cu = 0
				});
			},
			upload:function(e, key){
				var tag = e.target || e.srcElement;
				var file = tag.files[0];
				if(file){
					this.fullLoading = this.$loading({
						lock: true,
						text: 'Loading',
						spinner: 'el-icon-loading',
						background: 'rgba(0, 0, 0, 0.7)'
					});

					var data = new FormData();
					data.append('file', file);
					return this.pageApi.upload(data).then((res) => {
						this.fullLoading.close();
						if(res.code === 200){
							tag.value = '';
							key && (this.form.item[key] = res.body);
							this.$notify({
								title: '提示',
								message: '文件上传成功',
								type: 'success',
								duration: 5000
							})
						};
					}).catch(function(error) {
						this.form.status.cu = 0
					});
				};
			},
			getSearchParam:function(form){
				var search = form.config.search, query = form.query, searchItem = {};
				if(Object.prototype.toString.call(search) === '[object Array]' && Object.keys(query || [])[0]){
					for(var item of search){
						var queryVal = query[item.word];
						if(queryVal && item.type !== "button"){
							var key = item.mode === 0 ? 'vague' : 'exact';
							if(item.type === "daterange"){
								searchItem[item.type] = queryVal.join(',');
							}else{
								var groub = searchItem[key] || (searchItem[key] = {});
								groub[item.word] = queryVal;
							};
						};
					};
				};return searchItem
			},
			toSearch:function(form){
				this.table.page = 1;
				var searchItem = {
					searchName:form.search.key,
					searchValue:form.query[form.search.key],
					limit:form.search.mode
				}
				this.loadData(searchItem)
			},
			toDownload:function(item){
				var download = this.pageApi.download;
				var filePath = download.filePath;
				var fileName = item[download.keyName].indexOf('.') > 0 ? item.[download.keyName] : '';
				if(filePath && fileName){
					window.open(DownloadUrl + filePath + fileName);
				}else{
					this.$notify({
						title: '提示',
						message: '未找到要下载的文件！',
						type: 'warning',
						duration: 5000
					})
				};
			},
			toAdd:function(){		// 添加表单
				this.$refs['form1'] && this.$refs['form1'].clearValidate();
				this.form.title = '添加' + this.form.config.title;
				this.form.status.cu = 0;
				this.form.visible = true;
				this.form.reqType = 'add';
				var item = {}, Dict = this.Dict;
				for(var key in Dict.baseInfo){
					var obj = Dict.baseInfo[key];
					item[key] = obj.default || obj.dataType || '';

					// 兼听 onload
					obj.onload && obj.onload.call(this.$refs['cuForm'], key);
				};
				this.form.item = item;
				Dict.addFormItem && Dict.addFormItem.call(this, item);
			},
			toEdit:function(item){		// 添加表单
				var form = this.form, Dict = this.Dict;
				var cuForm = this.$refs['cuForm'];
				cuForm.$refs['form1'] && cuForm.$refs['form1'].clearValidate();
				form.title = '编辑' + form.config.title;
				form.status.cu = 0;
				form.visible = true;
				form.reqType = 'edit';
				form.item = item;
				Dict.editFormItem && Dict.editFormItem.call(this, item);

				for(var key in Dict.baseInfo){
					var obj = Dict.baseInfo[key];
					// 兼听 onload
					obj.onload && obj.onload.call(cuForm, key);
				};
			},
			toDelete:function(item, opts){		// 删除表单
				opts = opts || {};
				var text = opts.text || '确认删除该条数据吗?';
				this.$confirm(text, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then((e) => {
					reqApi.common.removeRequst.call(this, item);
				}).catch((e) => {
				})
			},
			submitForm:function(form, item){
				if(!this.form.status.cu){
					form.validate(valid => {
						if(valid){
							this.form.status.cu = 2;
							if(this.form.reqType === 'add'){
								reqApi.common.addRequst.call(this, item);
							}else{
								reqApi.common.putRequst.call(this, item);
							}
						}else{
							this.form.status.cu = 0
						}
					});
				};
			},
			toExports:function(item){
				this.$confirm('您确认要导出该页数据吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then((e) => {
					var loading = this.$loading({
						lock: true,
						text: '请稍后.....',
						spinner: 'el-icon-loading',
						background: 'rgba(0, 0, 0, 0.7)'
					});
					var param = reqApi.getBaseParams.call(this);
					this.pageApi.download(param).then((res) => {
						loading.close();
						var name = this.pageApi.name+'数据' + qf.UI.Dates().format('yyyy-MM-dd HH:mm:ss');
						Tools.downloadFile(res, name, 'xlsx')
					})
				})
			},
			downloadTemplet: function(){
				var loading = this.$loading({
					lock: true,
					text: '请稍后.....',
					spinner: 'el-icon-loading',
					background: 'rgba(0, 0, 0, 0.7)'
				});
				var param = reqApi.getBaseParams.call(this);
				this.pageApi.download(param).then((res) => {
					loading.close();
					var name = this.pageApi.name+'模板' + qf.UI.Dates().format('yyyy-MM-dd HH:mm:ss');
					Tools.downloadFile(res, name, 'xlsx')
				})
			},
			openCharts: function(){		// 内页共用图表
				var that = this;
				qf.UI.popupLayer({
					//title:'<div>标题</div>',
					html:'<div style="width:13rem;"></div>',
					onload: function(el){
						var box = el.firstElementChild;
						box.innerHTML = '<div class="p-head" style="padding-top:5px;display:flex;align-items:center;"><div class="select" style="margin:0 15px 0 5px;"><select style="height:25px;min-width:100px;"></select></div><div class="date"></div><button style="margin-left:20px;"class="el-button el-button--small el-button--primary query">查询</button></div><div class="p-body" style="height:7rem;"><div class="chart26" style="height:100%;width:100%;border:1px solid #ccc;margin-top:10px;"></div></div><div style="margin-top:5px;"><button data-type="line" class="switch" style="margin-right:4px;">折线图</button><button data-type="column" class="switch">柱状图</button></div>';

						var headEl = box.firstElementChild;
						var selectEl = headEl.firstElementChild;
						var dateEl = selectEl.nextElementSibling;
						var chartEl = headEl.nextElementSibling.firstElementChild;
						var toDay = qf.UI.Dates().format('yyyy-MM-dd');
						var daterange = [toDay, toDay];
						var query = {daterange:daterange.join(','), sort:'date,desc'};
						var selectData = that.Dict.selectList.equipno;
						Tools.createOnSelect(selectEl.firstElementChild, selectData, {
							value:'equipno',
							name:'equipname',
							fn: function(value){
								query['code'] = value
							},
							onload: function(value){
								query['code'] = value
							},
						});
						
						qf.vue.render({
							el:dateEl,
							datakey:'timeSpace',
							dataType:daterange,
							name:'el-date-picker',
							style: "width:280px",
							attrs: {
								type: "daterange",
								"value-format": "yyyy-MM-dd",
								"range-separator": "至",
								"start-placeholder": "开始日期",
								"end-placeholder": "结束日期",
								clearable: ""
							},
							change: function(value) {
								query.daterange = (value || []).join(',');
							}
						});

						var chartOpts = {};
						box.onclick = function(e){
							var tag = e.target || e.srcElement;
							if(tag.classList.contains('query')){
								that.pageApi.reqchart(query).then((res) => {
									var body = res.body || [];
									chartOpts.cache = Highchart.template.rich(chartEl, body, chartOpts);
								})
							}else if(tag.classList.contains('switch')){
								chartOpts.cache.update({chart:{type:tag.dataset.type}})
							};
						};
						that.pageApi.reqchart(query).then((res) => {
							var body = res.body || [];
							chartOpts.cache = Highchart.template.rich(chartEl, body, chartOpts);
						})
					},
				})
			},
			getPermission: function(item){
				var list = item.permission || [];
				var username = this.$store.state.user.user.username;
				return list.includes(username);
			},
		},

		// pageAPI
		dashboard:{		// 首页
			Carousel2: function(param){
				return reqApi.common.requstEdge('get', 'history/dmData/visual/imgHistory', param);
			},
			Carousel3: function(param){
				return reqApi.common.requstEdge('get', 'history/mpData/visual/image', param);
			},
			Carousel4: function(param){
				return reqApi.common.requstEdge('get', 'tab/people/visual/count', param);
			},
			cards: function(param){
				return reqApi.common.requstEdge('get', 'history/mpData/visual/real', param);
			},
			switchPond: function(param){
				return reqApi.common.requstEdge('post', 'tab/tailpondinfor/usertailpon', param);
			},
		},
		History:{	// 历史数据
			bmwy:{	// 表面位移
				name:'表面位移',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称"},
						"equipno":{name:"设备编号"},
						"disp_x":{name:"x变化量"},
						"disp_y":{name:"y变化量"},
						"disp_h":{name:"z变化量"},
						"state":{name:"是否报警", type:'select',},
						"time":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						equipno:function(){
							return reqApi.sensorListByCode({code:1}).then(function(res){
								return res.body || []
							});
						},
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'success', icon:'el-icon-s-data', name:'图表', 'callback':function(){
							reqApi.common.openCharts.call(this);
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'equipno', 'mode':1, 'width':'160px', val:'equipno', key:'equipname', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/mpData', type, param)
				},
				reqchart:function(param){
					return reqPublic('history/mpData/imgHistory', 'get', param)
				},
				download:function(param){
					return reqPublic('history/mpData/excelExport', 'get', param, {responseType:'blob'})
				},
			},
			nbwy:{	// 内部位移
				name:'内部位移',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称"},
						"equipno":{name:"设备编号"},
						"dispA":{name:"水平位移(mm)"},
						"dispB":{name:"竖向位移(mm)"},
						"state":{name:"是否报警", type:'select',},
						"time":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						equipno:function(){
							return reqApi.sensorListByCode({code:2}).then(function(res){
								return res.body || []
							});
						},
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'success', icon:'el-icon-s-data', name:'图表', 'callback':function(){
							reqApi.common.openCharts.call(this);
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'equipno', 'mode':1, 'width':'160px', val:'equipno', key:'equipname', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/dmData', type, param)
				},
				reqchart:function(param){
					return reqPublic('history/dmData/imgHistory', 'get', param)
				},
				download:function(param){
					return reqPublic('history/dmData/excelExport', 'get', param, {responseType:'blob'})
				},
			},
			nbcj:{	// 内部沉降
				name:'内部沉降',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称"},
						"equipno":{name:"设备编号"},
						"cjvalue":{name:"监测值(mm)"},
						"state":{name:"是否报警", type:'select',},
						"time":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						equipno:function(){
							return reqApi.sensorListByCode({code:4}).then(function(res){
								return res.body || []
							});
						},
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'success', icon:'el-icon-s-data', name:'图表', 'callback':function(){
							reqApi.common.openCharts.call(this);
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'equipno', 'mode':1, 'width':'160px', val:'equipno', key:'equipname', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/Cjdata', type, param)
				},
				reqchart:function(param){
					return reqPublic('history/Cjdata/imgHistory', 'get', param)
				},
				download:function(param){
					return reqPublic('history/Cjdata/excelExport', 'get', param, {responseType:'blob'})
				},
			},
			lfjc:{	// 裂缝监测
				name:'裂缝监测',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称"},
						"equipno":{name:"设备编号"},
						"lfvalue":{name:"监测值"},
						"state":{name:"是否报警", type:'select',},
						"time":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						equipno:function(){
							return reqApi.sensorListByCode({code:3}).then(function(res){
								return res.body || []
							});
						},
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'success', icon:'el-icon-s-data', name:'图表', 'callback':function(){
							reqApi.common.openCharts.call(this);
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'equipno', 'mode':1, 'width':'160px', val:'equipno', key:'equipname', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/lfData', type, param)
				},
				reqchart:function(param){
					return reqPublic('history/lfData/imgHistory', 'get', param)
				},
				download:function(param){
					return reqPublic('data/dm/download', 'get', param, {responseType:'blob'})
				},
			},
			rydw:{	// 人员定位
				name:'人员定位',
				Dict:{
					baseInfo:{
						"peoplename":{name:"人员姓名"},
						"sex":{name:"性别", type:'select',},
						"telephone":{name:"联系电话"},
						"cardid":{name:"安全帽MAC"},
						"latitude":{name:"X坐标"},
						"longitude":{name:"Y坐标"},
						"cjtime":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						sex:[
							{'name':'女','value':0},
							{'name':'男','value':1},
						]
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'人员姓名', 'word':'peoplename', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'string', 'name':'安全帽MAC', 'word':'cardid', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/peopleHistory', type, param)
				},
				download:function(param){
					return reqPublic('history/peopleHistory/exportExcel', 'get', param, {responseType:'blob'})
				},
			},
			cldw:{	// 车辆定位
				name:'车辆定位',
				Dict:{
					baseInfo:{
						"carno":{name:"车牌号"},
						"peoplename":{name:"司机姓名"},
						"telephone":{name:"联系电话"},
						"latitude":{name:"X坐标"},
						"longitude":{name:"Y坐标"},
						"zcoordinate":{name:"Z坐标"},
						"cjtime":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'warning', icon:'el-icon-document', name:'导出', 'callback':function(){
							reqApi.common.toExports.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'车牌号', 'word':'carno', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'string', 'name':'司机姓名', 'word':'peoplename', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('history/carHistory', type, param)
				},
				download:function(param){
					return reqPublic('history/carHistory/exportExcel', 'get', param, {responseType:'blob'})
				},
			},
		},
		deviceManage:{		// 设备管理
			xbgl:{	// 信标管理
				name:'信标管理',
				Dict:{
					baseInfo:{
						"equipname":{name:"信标名称"},
						"cardid":{name:"信标编号"},
						"latitude":{name:"X坐标"},
						"longitude":{name:"Y坐标"},
						"update_time":{name:"更新时间", form:0, type:"tableFormat", tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}},
					},
					selectList:{
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'信标名称', 'word':'equipname', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/xinbiao', type, param)
				},
			},
			bpjc:{	// 边坡在线监测
				name:'边坡在线监测',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称"},
						"eqdanwei":{name:"数值单位"},
						"devicetype":{name:"监测类型"},
						"initial":{name:"初始值"},
						"onelevelalarm":{name:"一级预警值"},
						"twolevelalarm":{name:"二级预警值"},
						"threelevelalarm":{name:"三级预警值"},
						"fourlevelalarm":{name:"四级预警值"},
						"installationdata":{name:"安装时间", form:0, type:"tableFormat", tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}},
					},
					selectList:{
						devicetype:[
							{'name':'表面位移','value':'表面位移'},
							{'name':'内部位移','value':'内部位移'},
							{'name':'裂缝','value':'裂缝'},
						]
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'设备名称', 'word':'equipname', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'select', 'name':'监测类型', 'word':'devicetype', 'mode':1, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/equip', type, param)
				},
			},
			rydwsb:{	// 人员定位
				name:'人员定位',
				Dict:{
					baseInfo:{
						"peoplename":{name:"人员姓名"},
						"sex":{name:"性别", type:'select',},
						"telephone":{name:"联系电话"},
						"cardid":{name:"安全帽MAC"},
						"soc":{name:"电量"},
						"state":{name:"状态", type:'select',},
						"cjtime":{name:"最后一次在线时间", form:0, type:"tableFormat", tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}},
					},
					selectList:{
						state:[
							{'name':'离线','value':0},
							{'name':'在线','value':1},
						],
						sex:[
							{'name':'女','value':0},
							{'name':'男','value':1},
						]
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加人员', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'warning', icon:'el-icon-document', name:'导入数据', 'callback':function(e, key){
							var tag = e.target || e.srcElement, that = this;
							var input = document.createElement("input");
							input.type = 'file';
							input.onchange = function(e, key){
								reqApi.common.upload.call(that, e);
							};
							input.click();
						}},
						{type:'info', icon:'el-icon-document', name:'下载模板', 'callback':function(){
							//reqApi.common.toExports.call(this);
							reqApi.common.downloadTemplet.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'人员姓名', 'word':'peoplename', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'string', 'name':'安全帽MAC', 'word':'cardid', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/people', type, param)
				},
				download:function(param){
					return reqPublic('tab/people/excelExportModel', 'get', param, {responseType:'blob'})
				},
				upload: function(data){
					return reqPublic('tab/people/importExcel', 'post', data)
				},
			},
			rydwyy:{	// 语音播报
				name:'语音播报',
				Dict:{
					baseInfo:{
						//"devicetype":{name:"序号"},
						/* "bjtime":{name:"添加时间", type:"tableFormat", tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}}, */
						"bjtime":{name:"添加时间", type:"datetime", format:'yyyy-MM-dd HH:mm:ss'},
						"cardid":{name:"分配人员", type:'select', multiple:true, key:'cardid', val:'cardid', width:'350px'},
						"content":{name:"播报内容"},
					},
					selectList:{
						cardid:function(){
							return reqPublic('tab/people/cardidList', 'get', {}).then(function(res){
								return res.body || [];
							});
						},
					},
				},
				config:{
					formWidth:'540px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'播报内容', 'word':'content', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/speaker', type, param)
				},
			},
			cldwsb:{	// 车辆定位
				name:'车辆定位',
				Dict:{
					baseInfo:{
						"carno":{name:"车牌号码"},
						"cartype":{name:"卡车"},
						"carequipno":{name:"定位设备"},
						"driver":{name:"司机姓名"},
						"telephone":{name:"手机号"},
						"cjtime":{name:"监测时间", form:0, type:"tableFormat", tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}},
					},
					selectList:{
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加车辆', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'warning', icon:'el-icon-document', name:'导入数据', 'callback':function(e, key){
							var tag = e.target || e.srcElement, that = this;
							var input = document.createElement("input");
							input.type = 'file';
							input.onchange = function(e, key){
								reqApi.common.upload.call(that, e);
							};
							input.click();
						}},
						{type:'info', icon:'el-icon-document', name:'下载模板', 'callback':function(){
							//reqApi.common.toExports.call(this);
							reqApi.common.downloadTemplet.call(this);
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'司机姓名', 'word':'driver', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'string', 'name':'车牌号', 'word':'carno', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/car', type, param)
				},
				download:function(param){
					return reqPublic('tab/car/excelExportModel', 'get', param, {responseType:'blob'})
				},
				upload: function(data){
					return reqPublic('tab/car/importExcel', 'post', data)
				},
			},
			dzwl:{	// 电子围栏
				name:'电子围栏',
				Dict:{
					baseInfo:{
						"enclosurename":{name:"电子围栏名称"},
						"coordinate":{name:"围栏坐标", must:true, type:'customize', style:"display:flex",
							mapWidth:'75%',mapHeight:'450', onload: function(key){
							var item = this.form.item;
							var type = this.form.reqType;

							this.$nextTick(()=>{
								var self = this, view = this.$refs[key][0];
								view.innerHTML = '<div style="position:relative;height:100%;width:100%;"><img src="/static/images/dzwl30cm_dpi.jpg" style="height:100%;width:100%;"/><div style="position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;"></div></div>';

								var imgBox = view.firstElementChild;
								var img = imgBox.firstElementChild;
								var mdBox = view.lastElementChild;

								img.onload = function(){
									var viewHeight = img.offsetHeight;
									var viewWidth = img.offsetWidth;
									var naturalHeight = img.naturalHeight;
									var naturalWidth = img.naturalWidth;
									var hRatio = viewHeight / naturalHeight;
									var wRatio = viewWidth / naturalWidth;

									var events = new qf.UI.eventsHandler();
									var eventMap = events.register({
										eventEl:imgBox,
										start:function(e){
											var tag = e.target || e.srcElement;
											this.sX = e.offsetX, this.sY = e.offsetY;
											if(this.tagEl && tag === this.tagEl){
												
											}else{
												this.createRect({startY:this.sY, startX:this.sX,});
											};
										},
										move: function(e){
											if(this.tagEl){
												if(e.destX > -1){
													this.tagEl.style.width = e.destX + 'px';
												}else{
													var devX = this.sX + e.destX;
													this.tagEl.style.left = devX + 'px';
													this.tagEl.style.width = (0-e.destX) + 'px';
												};

												if(e.destY > -1){
													this.tagEl.style.height = e.destY + 'px';
												}else{
													var devY = this.sY + e.destY;
													this.tagEl.style.top = devY + 'px';
													this.tagEl.style.height = (0-e.destY) + 'px';
												};
											};
										},
										end: function(e){
											var startX = this.tagEl.offsetLeft;
											var startY = this.tagEl.offsetTop;
											var width = this.tagEl.offsetWidth;
											var height = this.tagEl.offsetHeight;
											var endX = startX + width || e.offsetX;
											var endY = startY + height || e.offsetY;
											var info = {startX:startX,startY:startY, endX:endX, endY:endY, width:width, height:height};
											self.form.item['coordinate'] = JSON.stringify(info);
										},
										createRect: function(opts){
											opts = opts || {};
											var startY = ~~opts.startY, startX = ~~opts.startX;
											var height = ~~opts.height, width = ~~opts.width;
											this.tagEl && mdBox.removeChild(this.tagEl);
											this.tagEl = document.createElement("i");
											this.tagEl.style.cssText = 'position:absolute;top:0;left:0;border:2px solid red;';
											mdBox.appendChild(this.tagEl);
											this.tagEl.style.top = startY + 'px';
											this.tagEl.style.left = startX + 'px';
											this.tagEl.style.height = height + 'px';
											this.tagEl.style.width = width + 'px';
										},
									});

									var coordinate = item.coordinate ? JSON.parse(item.coordinate) : {};
									(type==='edit')&&coordinate.startX && eventMap.createRect(coordinate);
								};
							});
						},},

						"bjtype":{name:"报警类型", type:'select'},
						"mapcenter":{name:"地图中心点", form:0, table:0},
						"update_time":{name:"日期", type:"tableFormat", form:0, tableFormat:function(val){
							return val ? qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss') : ''
						}},
					},
					selectList:{
						bjtype:[
							{'name':'进入','value':'进入'},
						]
					},
				},
				config:{
					formWidth:'750px',
					labelWidth:'120',
					operWidth:'180',
					title:'人员',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							reqApi.common.toDelete.call(this.$parent, item);
						}}
					],
					otherBtn:[
						{type:'primary', icon:'el-icon-plus', name:'添加', 'callback':function(){
							reqApi.common.toAdd.call(this);
						}}
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'电子围栏名称', 'word':'enclosurename', 'mode':0, 'width':'160px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/enclosure', type, param)
				},
			},
		},
		alarmManage:{		// 报警管理
			slope:{			// 边坡预警
				name:'边坡预警',
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称", form:0},
						//"devicetype":{name:"设备类型"},
						"state":{name:"状态", type:'select', form:0,},
						"alarmlevel":{name:"报警等级", type:'select', form:0, key:' ', icon:'el-icon-message-solid', color:'red'},
						"evalue":{name:"报警值", form:0},
						"jchours":{name:"解除时长", table:0,},
						"reason":{name:"报警原因"},
						"jcreason":{name:"解除报警原因"},
						"time":{name:"报警时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
						"jcbjtime":{name:"解除报警时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
						alarmlevel:[{"color":"red","id":1,"name":"红色报警","remark":"","value":1},{"color":"orange","id":2,"name":"橙色报警","remark":"","value":2},{"color":"yellow","id":3,"name":"黄色报警","remark":"","value":3},{"color":"blue","id":4,"name":"蓝色报警","remark":"","value":4}],
						equipno:function(){
							return reqApi.sensorListByCode({}).then(function(res){
								return res.body || []
							});
						},
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'140',
					title:'人员',
					buttons:[
						{'type':'primary', 'icon':'el-icon-close-notification', 'isvalid':'state', 'callback':function(item){
							item = Object.assign({}, item);
							item.jchours = '12';
							item.reason = '默认原因';
							item.jcreason = '默认解除报警原因';
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'equipno', 'mode':1, 'width':'160px', val:'equipno', key:'equipname','clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/abnormal', type, param)
				},
			},
			dzwl:{
				name:'电子围栏预警',
				Dict:{
					baseInfo:{
						"enid":{name:"电子围栏名称", type:'select', form:0},
						"cardid":{name:"人员设备", form:0},
						"carno":{name:"车辆", form:0},
						//"devicetype":{name:"设备类型"},
						"state":{name:"状态", type:'select', form:0,},
						"jchours":{name:"解除时长", table:0,},
						"enter_time":{name:"进入时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
						"leave_time":{name:"离开时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						state:function(){
							return reqApi.getDictDeviceStatus({}).then(function(res){
								return res.body || []
							});
						},
						enid:function(){
							return reqPublic('/tab/enclosure/list', 'get', {}).then(function(res){
								return res.body || [];
							});
						},
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'140',
					title:'人员',
					buttons:[
						{'type':'primary', 'icon':'el-icon-close-notification', 'isvalid':'state', 'callback':function(item){
							item = Object.assign({}, item);
							item.jchours = '12';
							item.reason = '默认原因';
							item.jcreason = '默认解除报警原因';
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'select', 'name':'设备', 'word':'enid', 'mode':1, 'width':'160px', val:'value', key:'name','clear':function(){
							this.loadData()
						}},
						{'type':'daterange', 'name':'日期范围', 'word':'timeSpace', 'mode':0, 'width':'240px', },
						{'type':'checkbox', 'name':' ', 'word':'state', 'mode':1, 'label':'报警状态', 'width':'140px', },
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/elrailingalarm', type, param)
				},
			},

			ryhj:{			// 人员呼救
				name:'人员呼救',
				Dict:{
					baseInfo:{
						"peoplename":{name:"呼救者", form:0},
						"cardid":{name:"设备ID", form:0},
						"state":{name:"呼救状态", type:'select'},
						"cjtime":{name:"呼救时间", form:0, type:"tableFormat", tableFormat:function(val){
							return qf.UI.Dates(new Date(val)).format('yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						state:[{name:'解除',value:1,},{name:'呼救',value:0,},],
					},
				},
				config:{
					formWidth:'440px',
					labelWidth:'120',
					operWidth:'140',
					title:'人员',
					buttons:[
						{'type':'primary', 'icon':'el-icon-close-notification', 'isvalid':function(row){
							return !!row.state
						}, 'callback':function(item){
							item = Object.assign({}, item);
							item.jchours = '12';
							item.reason = '默认原因';
							item.jcreason = '默认解除报警原因';
							reqApi.common.toEdit.call(this.$parent, item);
						}}, 
					],
					otherBtn:[
					],
					rightBtn:[
						{type:'primary', icon:'el-icon-refresh', name:'刷新', 'callback':function(){
							this.loadData()
						}},
						{type:'default', icon:'el-icon-printer', name:'打印', 'callback':function(){
							Tools.cuPrint(this.$refs.cuTable);
						}}
					],
					search:[
						{'type':'string', 'name':'设备ID', 'word':'cardid', 'mode':0, 'width':'160px', val:'value', key:'name','clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/sosdata', type, param)
				},
			},
		},
		system:{
			pondManage:{			// 尾矿库管理
				Dict:{
					baseInfo:{
						"province":{name:"所在省份", must:true, type:'select', val:'code', table:0, width:'130px', change:function(val){
							var Dict = this.Dict, slist = Dict.selectList, fitem = this.form.item;
							delete fitem.city; delete fitem.cityarea;
							slist.cityarea = [];
							Dict.getRegion(val).then((res) => {
								slist.city = res;
							});
						}},
						"city":{name:"所在城市", must:true, type:'select', val:'code', table:0, width:'130px', change:function(val){
							var Dict = this.Dict, slist = Dict.selectList, fitem = this.form.item;
							delete fitem.cityarea;
							Dict.getRegion(val).then((res) => {
								slist.cityarea = res;
							});
						}},
						"cityarea":{name:"所在地区", must:true, type:'select', key:'name', val:'code', table:0, width:'130px', change:function(val){
							var Dict = this.Dict, fitem = this.form.item;
							this.$forceUpdate();
							Dict.codeSplitJoint(fitem);
						}},
						"tailingno":{name:"尾矿库编号", must:true, form:0},
						"tailingname":{name:"尾矿库名称", must:true},
						"address":{name:"尾矿库地址", must:true, disabled:true, type:'map', style:"display:flex",
							mapConfig:{
								options:{
									zoom:6,
									center:[107.260044, 36.737982],
									//showLabel: true,
									//pitch: 40,
									onload: function(cmap){
										var item = this.form.item, self = this;
										this.Dict.cmap = cmap;
										if(item.longitude && item.latitude){
											cmap.setCenter([item.longitude, item.latitude]);

											// 添加标记
											cmap.addMarker({
												lnglat:[item.longitude, item.latitude],
												title:'',
												draggable:true,
												dragend: function(e){
													var lnglat = e.lnglat;
													cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
														item.address = addr;
														item.longitude = lnglat.lng;
														item.latitude = lnglat.lat;
														self.$forceUpdate();
													});
												},
											});
										};
									},
									click: function(e, cmap){
										var that = this, lnglat = e.lnglat, form = this.form, item = form.item;
										// 如果为添加
										if(this.form.reqType === 'add'){
											cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
												form.item.address = addr;
												form.item.longitude = lnglat.lng;
												form.item.latitude = lnglat.lat;
											});

											cmap.marker && cmap.removeMarker();

											// 添加标记
											cmap.addMarker({
												lnglat:[lnglat.lng, lnglat.lat],
												title:'',
												draggable:true,
												dragend: function(e){
													var lnglat = e.lnglat;
													cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
														item.address = addr;
														item.longitude = lnglat.lng;
														item.latitude = lnglat.lat;
													});
												},
											});
										};
									},
								},
							},
						},
						"longitude":{name:"经度", must:true, table:0, form:0},
						"latitude":{name:"纬度", must:true, table:0, form:0},
						"altitude":{name:"海拔高度", must:true, table:0, ruleType:'number'},
						"ondutytel":{name:"值班电话", must:true},
						"securityofficer":{name:"安全负责人", must:true, table:0},
						"securityofficertel":{name:"安全负责人电话", must:true},
						"defaults":{name:"默认尾矿库", type:'select'},
						"unifcreditcode":{name:"企业统一信用码", table:0, placeholder:'(gb 32100-2015)'},
						"unitname":{name:"管理单位", table:0},
						"unitadress":{name:"企业所在地", table:0},
						"industrycharacterno":{name:"所属企业类型", type:'select', table:0},
						"unitperson":{name:"法人代表", table:0},
						"unitpersontel":{name:"法人电话", table:0},
						"usedate":{name:"投入使用日期", type:"date", table:0},
						"useyear":{name:"设计服务年限", table:0},
						"operatingstatus":{name:"运行状况", type:'select', table:0},
						"safetytypeno":{name:"安全度", type:'select', table:0},
						"industrytypeno":{name:"所属行业代码", type:'select', table:0},
						"mineralspecies":{name:"所属矿种", type:'select', table:0},
						"top":{name:"是否头顶库", type:'select', table:0},
						"onlinemonitoringsys":{name:"是否安装在线监测系统", type:'select', table:0},
						"geologicalstructure":{name:"地质构造及条件", table:0},
						"topotraphicgradient":{name:"地形坡度(度)", table:0},
						"underlyingsurfacetype":{name:"下垫面类型", table:0},
						"standardizationlevel":{name:"标准化等级代码", type:'select', table:0},
						"standardforensicsdate":{name:"标准化等级证书取证日期", table:0, type:"date"},
						"safetypermitno":{name:"安全生产许可证", table:0},
						"safetypermitdate":{name:"安全生产许可证有效期", type:"date", table:0},
						"safetypermitunit":{name:"安全生产许可证发证机关", table:0},
						"storetypeno":{name:"尾矿库类型", type:'select', table:0},
						"designlevel":{name:"设计等级", type:'select', table:0},
						"grade":{name:"现状等级", type:'select', table:0},
						"designheight":{name:"设计总坝高(米)", table:0, must:true, ruleType:'number'},
						"stackheight":{name:"现状总坝高(米)", table:0, must:true, ruleType:'number'},
						"plancapability":{name:"设计库容(万立方米 )", table:0},
						"nowvolume":{name:"现状库容(万立方米)", table:0},
						"damstocktypeno":{name:"筑坝方式代码", type:'select', table:0},
						"floodequipment":{name:"排洪设施型式", table:0},
						"floodmethod":{name:"库外排洪型式", table:0},
						"floodfacilitydischarge":{name:"排洪设施泄流量(立方米/秒)", table:0},
						"waterarea":{name:"汇水面积(平方公里)", table:0},
						"area":{name:"尾矿库面积(平方公里)", table:0},
						"floodcontrolstandard":{name:"设计防洪标准(年)", table:0},
						"damtype":{name:"初期坝类型", type:'select', table:0},
						"initialdamtype":{name:"初期坝坝型", type:'select', table:0},
						"designinitialdamheight":{name:"设计初期坝高(米)", table:0},
						"currentinitialdamheight":{name:"现状初期坝高(米)", table:0},
						"initialdamlongness":{name:"初期坝长(米)", table:0},
						"initialdamsloperatio":{name:"初期坝坡比", table:0, placeholder:'例如：1：2'},
						"accumulationdamratio":{name:"堆积坝外坡比", table:0, placeholder:'例如：1：2'},
						"designsubdamheight":{name:"设计子坝高度", table:0, placeholder:'单位：米'},
						"designsubdamtopwidth":{name:"设计子坝坝顶宽度", table:0, placeholder:'单位：米'},
						"accumulateddamsnumber":{name:"已堆积子坝数", table:0},
						"earthquake":{name:"设防地震烈度", table:0, placeholder:'单位：度'},
						"tailingsstoragemethod":{name:"尾矿堆存方式", type:'select', table:0},
						"minelaytypeno":{name:"湿式放矿位置", type:'select', table:0},
						"upstreamtailings":{name:"上游式尾矿堆筑方法", type:'select', table:0},
						"drystorage":{name:"干式堆存方式", type:'select', table:0},
						"drystoragewaterratio":{name:"干式堆存入库尾矿含水率", table:0, placeholder:'单位：%'},
						"tailingsparticlesize":{name:"尾矿粒度", table:0, placeholder:'单位：%（-200目占比）'},
						"tailingsaveparticlesize":{name:"尾矿平均粒度", table:0, placeholder:'单位：毫米'},
						"depositiondrybeachslope":{name:"沉积干滩平均坡度", table:0, placeholder:'单位：%'},
						"personnum":{name:"下游1公里内总人数", table:0, placeholder:'单位：人'},
						"buildingnum":{name:"下游1公里内建筑物数量", table:0, placeholder:'单位：栋'},
						"emergencyplanfiled":{name:"应急预案是否备案", type:'select', table:0},
						"primarysafetyunit":{name:"安全预评价单位", table:0},
						"primarysafetylevel":{name:"安全预评价单位资质", table:0},
						"designunit":{name:"安全设施设计单位", table:0},
						"designunitlevel":{name:"安全设施设计单位资质", table:0},
						"constructionunit":{name:"施工单位名称", table:0},
						"constructionlevel":{name:"施工单位资质等级", table:0},
						"supervisoryunit":{name:"工程监理单位名称", table:0},
						"supervisorylevel":{name:"工程监理单位资质等级", table:0},
						"safetycheckunit":{name:"安全验收评价单位", table:0},
						"safetychecklevel":{name:"安全验收评价单位资质", table:0},
								 	 
						"safetyacceptancetime":{name:"安全设施竣工验收时间", type:"date", table:0},
						"safetyevaluationunit":{name:"安全现状评价单位", table:0},
						"safetyevaluationlevel":{name:"安全现状评价单位资质等级", table:0},
						"filingperson":{name:"填写企业（填写人）", table:0},
						"filingdate":{name:"填报日期", type:"date", table:0},
						"fillerphone":{name:"填表人电话", table:0},
						"note":{name:"备注", table:0},
						"in_use":{name:"在用状态", type:'select', table:0},
						"is_sync":{name:"同步状态", type:'select', table:0},
						"subtailingno":{name:"关联地区编码", table:0, form:0},
						"createtime":{name:"创建时间", form:0, type:"tableFormat", tableFormat:function(val){
							return Tools.Dates.format.call(new Date(val), 'yyyy-MM-dd HH:mm:ss')
						}},
						"updatetime":{name:"更新时间", form:0, type:"tableFormat", tableFormat:function(val){
							return Tools.Dates.format.call(new Date(val), 'yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						province: function(a,b){
							return this.getRegion();
						},
						city:[],
						cityarea:[],
						defaults:[{name:'是',value:1,},{name:'否',value:0,},],
						top:[{name:'是',value:1,},{name:'否',value:0,},],
						emergencyplanfiled:[{name:'是',value:1,},{name:'否',value:0,},],
						onlinemonitoringsys:[{name:'是',value:1,},{name:'否',value:0,},],
						in_use:[{name:'是',value:1,},{name:'否',value:0,},],
						is_sync:[{name:'未同步',value:0,},{name:'已同步',value:1,},],
						damstocktypeno:function(){
							var slist = this.selectList;
							return reqPublic('dic', 'get', {}).then(function(res){
								var body = res.body || {};
								for(var key in body){
									var val = body[key];
									slist[key] = val
								}; return body.damstocktypeno;
							});
						},
					},
					getRegion:function(val){
						return reqPublic('dic/areacode/province', 'get', {parentcode:val}).then(function(res){
							var list = (res.body || {}).list || [];
							return list
						});
					},
					// 编号
					codeSplitJoint: function(fitem){
						fitem.subtailingno = fitem.province +'_'+ fitem.city +'_'+ fitem.cityarea;
					},
					addFormItem: function(){
						var Dict = this.Dict, slist = Dict.selectList, info = Dict.baseInfo;
						slist.city = [];
						slist.cityarea = [];
						info.province.disabled = false;
						info.city.disabled = false;
						info.cityarea.disabled = false;
					},
					editFormItem: function(){
						// clearValidate
						this.$refs['cuForm'].$refs['form1'] && this.$refs['cuForm'].$refs['form1'].clearValidate();

						var Dict = this.Dict, slist = Dict.selectList, info = Dict.baseInfo, fitem = this.form.item;
						var codes = fitem.subtailingno.split('_');
						info.province.disabled = true;
						info.city.disabled = true;
						info.cityarea.disabled = true;
						fitem.province = codes[0];
						fitem.city = codes[1];
						fitem.cityarea = codes[2];
						var limit = [{name:'city',value:codes[0]}, {name:'cityarea',value:codes[1]}];
						Tools.asyncLoop.call(this, limit, function(key, panel, next){
							Dict.getRegion(panel.value).then((res) => {
								slist[panel.name] = res;
								//fitem[panel.name] = codes[~~key+1];
								next();
							});
						});
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'尾矿库',
					buttons:[	// tableBtn
						//{'fn':'', 'type':'success', 'icon':'el-icon-more'}, 
						{'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
							var cmap = this.Dict.cmap;
							if(cmap){
								if(item.longitude && item.latitude){
									cmap.setCenter([item.longitude, item.latitude]);
									cmap.marker && cmap.removeMarker();
									// 添加标记
									cmap.addMarker({
										lnglat:[item.longitude, item.latitude],
										title:'',
										draggable:true,
										dragend: function(e){
											var lnglat = e.lnglat;
											cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
												item.address = addr;
												item.longitude = lnglat.lng;
												item.latitude = lnglat.lat;
											});
										},
									});
								};
							};
						}}, 
						{'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							//reqApi.common.toDelete.call(this.$parent, item);
							/* this.$confirm('为避免误操作，请联系运维人员！', '提示', {
								confirmButtonText: '确定',
								cancelButtonText: '',
								type: 'warning'
							}); */
							this.$alert('为避免误操作，请联系运维人员！', {
								confirmButtonText: '确定',
								callback: action => {}
							});
						}}
					],
					otherBtn:[
						{'type':'primary', 'icon':'el-icon-plus', 'name':'添加尾矿库', 'callback':function(){
							reqApi.common.toAdd.call(this);
							
							// 地图
							var cmap = this.Dict.cmap;
							cmap && cmap.removeMarker()
						}, permission:['admin']}, 
					],
					search:[
						{'type':'string', 'name':'尾矿库名称', 'word':'tailingname', 'mode':0, 'width':'200px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/tailpondinfor', type, param)
				},
			},
			deviceManage:{			// 设备管理
				Dict:{
					baseInfo:{
						"equipname":{name:"设备名称", must:true},
						"devicetype":{name:"设备类型", type:'select', must:true},
						"equipno":{name:"设备编号", form:0},
						"eqdanwei":{name:"数值单位", must:true},
						"installationdata":{name:"安装日期", type:"date", must:true},
						"manufacture":{name:"生产厂家", must:true},
						"installationlocate":{name:"安装位置", must:true, disabled:true, type:'map', style:"display:flex",
							mapConfig:{
								options:{
									zoom:6,
									center:[107.260044, 36.737982],
									//showLabel: true,
									//pitch: 40,
									onload: function(cmap){
										var item = this.form.item, self = this;
										this.Dict.cmap = cmap;
										if(item.longitude && item.latitude){
											cmap.setCenter([item.longitude, item.latitude]);

											// 添加标记
											cmap.addMarker({
												lnglat:[item.longitude, item.latitude],
												title:'',
												draggable:true,
												dragend: function(e){
													var lnglat = e.lnglat;
													cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
														item.installationlocate = addr;
														item.longitude = lnglat.lng;
														item.latitude = lnglat.lat;
														self.$forceUpdate();
													});
												},
											});
										};
									},
									click: function(e, cmap){
										var that = this, lnglat = e.lnglat, form = this.form, item = form.item;
										// 如果为添加
										if(this.form.reqType === 'add'){
											// 设置地址
											cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
												item.installationlocate = addr;
												item.longitude = lnglat.lng;
												item.latitude = lnglat.lat;
											});

											cmap.marker && cmap.removeMarker();

											// 添加标记
											cmap.addMarker({
												lnglat:[lnglat.lng, lnglat.lat],
												title:'',
												draggable:true,
												dragend: function(e){
													var lnglat = e.lnglat;
													cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
														item.installationlocate = addr;
														item.longitude = lnglat.lng;
														item.latitude = lnglat.lat;
													});
												},
											});
										};
									},
								},
							},
						},
						//"tailingid":{name:"所属尾矿库", type:'select', must:true, table:0},
						"longitude":{name:"经度", table:0, form:0},
						"latitude":{name:"纬度", table:0, form:0},
						"installheight":{name:"安装高度", table:0},
						"electricitysupply":{name:"供电和通讯方式", table:0},
						"accuracy":{name:"设备精度", table:0},
						"altitude":{name:"海拔高度(米)", table:0},
						"onelevelalarm":{name:"一级预警阈值", table:0},
						"twolevelalarm":{name:"二级预警阈值", table:0},
						"threelevelalarm":{name:"三级预警阈值", table:0},
						"fourlevelalarm":{name:"四级预警阈值", table:0},
						"is_used":{name:"设备在用状态", type:'select', table:0},
						"is_sync":{name:"同步状态", type:'select', table:0},
						//"initialstateno":{name:"设备码", table:0},
						"ipaddress":{name:"设备ip地址", table:0},
						"eqtype":{name:"设备类型", type:'select', table:0},
						"initial":{name:"传感器初始值", table:0},
						"initialx":{name:"初始值x方向", table:0},
						"initialy":{name:"初始值y方向", table:0},
						"initialz":{name:"初始值z方向", table:0},
						"state":{name:"报警状态", type:'select', table:0},
						"burial_depth":{name:"浸润线埋深(米)", table:0},
						"checkperiod":{name:"检验周期", table:0, placeholder:'单位（天）'},
						"jcdid":{name:"所属监测点", type:'select', table:0, form:0,},
						"ksweqtype":{name:"库水位设备类型", type:'select', table:0},
						"bmwy_x":{name:"X位移", table:0},
						"bmwy_y":{name:"Y位移", table:0},
						"bmwy_z":{name:"Z位移", table:0},
						//"jrxburial_depth":{name:"浸润线埋深(米)", table:0},
						"jrx_trepanning":{name:"孔深(浸润线)", table:0},
						"jrx_burial":{name:"设备深度(浸润线)", table:0},
						"jrx_coord_x":{name:"距剖面起始点距离(浸润线)", table:0},
						"kswequipno":{name:"库水位设备编号", table:0, placeholder:'添加干滩设备时使用'},
						"gtwangle":{name:"干滩坡度角", table:0},
						"gtsafeheight":{name:"干滩安全超高", table:0},
						"pslspeed":{name:"排水量流速", table:0, placeholder:'流速（m/s）'},
						"createtime":{name:"创建时间", form:0, type:"tableFormat", tableFormat:function(val){
							return Tools.Dates.format.call(new Date(val), 'yyyy-MM-dd HH:mm:ss')
						}},
						"updatetime":{name:"更新时间", form:0, type:"tableFormat", tableFormat:function(val){
							return Tools.Dates.format.call(new Date(val), 'yyyy-MM-dd HH:mm:ss')
						}},
					},
					selectList:{
						is_used:[{name:'是',value:1,},{name:'否',value:0,},],
						is_sync:[{name:'已同步',value:1,},{name:'未同步',value:0,},],
						eqtype:[{name:'4G设备',value:0,},{name:'IP设备',value:1,},],
						state:[{name:'是',value:1,},{name:'否',value:0,},],
						ksweqtype:[{name:'超声',value:1,},{name:'投入式',value:2,},],
						devicetype:function(){
							var slist = this.selectList;
							return reqPublic('dic/drybeachequipinfor', 'get', {}).then(function(res){
								var body = res.body || {};
								for(var key in body){
									var val = body[key];
									slist[key] = val
								}; return body.devicetype;
							});
						},
					},
				},
				config:{
					formWidth:'840px',
					labelWidth:'120',
					operWidth:'180',
					title:'设备',
					buttons:[
						//{'fn':'', 'type':'success', 'icon':'el-icon-more'}, 
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit', 'callback':function(item){
							item = Object.assign({}, item);
							reqApi.common.toEdit.call(this.$parent, item);
							var cmap = this.Dict.cmap;
							if(cmap){
								if(item.longitude && item.latitude){
									cmap.setCenter([item.longitude, item.latitude]);
									cmap.marker && cmap.removeMarker();

									// 添加标记
									cmap.addMarker({
										lnglat:[item.longitude, item.latitude],
										title:'',
										draggable:true,
										dragend: function(e){
											var lnglat = e.lnglat;
											cmap.deGeocode([lnglat.lng, lnglat.lat], function(addr){
												item.installationlocate = addr;
												item.longitude = lnglat.lng;
												item.latitude = lnglat.lat;
											});
										},
									});
								};
							};
						}}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete', 'callback':function(item){
							//var text = '设备删除后，该设备对应的历史数据将被清空，您确认删除该设备吗?';
							reqApi.common.toDelete.call(this.$parent, item/* , {text:text} */);
						}}
					],
					otherBtn:[
						{fn:'toAdd', type:'primary', icon:'el-icon-plus', name:'添加设备', 'callback':function(){
							reqApi.common.toAdd.call(this);
							
							// 地图
							var cmap = this.Dict.cmap;
							cmap && cmap.removeMarker()
						}}
					],
					search:[
						{'type':'string', 'name':'设备名称', 'word':'equipname', 'mode':0, 'width':'200px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					return reqPublic('tab/drybeachequipinfor', type, param)
				},
			},
			monitorItems:{		//	监测项管理
				name:'监测项管理',
				Dict:{
					baseInfo:{
						"title":{name:"监测名称", must:true, disabled:true},
						"deviceid":{name:"设备名称", must:true, type:'select', val:'value', change:function(val, sitem){
							var Dict = this.Dict, slist = Dict.selectList;
							var info = Dict.baseInfo, fitem = this.form.item, tagInfo = info['deviceid'];

							tagInfo.partName = sitem.name;
							info.subitem.form = 0;
							info.ranges.form = 0;
							info.values.form = 0;
							info.ranges.partName = '';
							info.subitem.partName = '';
							info.values.partName = '';

							reqPublic('/sys/type/sensorid', 'get', {sensorid:val}).then((res) => {
								var body = res.body, subitem = body.subitem, ranges = body.ranges, values = body.values;
								fitem.type = body.type;
								fitem.requrl = body.requrl;
								if(body.type === 't_14'){	// 视频监控 monitor
									this.Dict.setVideoFormStatus(1);
									fitem.title = sitem.name;
								}else{
									// hide video
									info.v_appkey.form && this.Dict.setVideoFormStatus(0);

									slist.subitem = subitem;
									slist.ranges = ranges;
									slist.values = values;

									// show
									info.subitem.form = ~~(!!subitem[0]);
									info.ranges.form = ~~(!!ranges[0]);
									info.values.form = ~~(!!values[0]);

									// 赋值
									for(var ikey in info){
										var obj = info[ikey];
										if(obj.type === 'checkbox' || obj.type === 'radio'){
											var list = slist[ikey];
											if(obj.type === 'checkbox'){
												if(list[0]){
													fitem[ikey] = [list[0][obj.val]];
													//info[ikey].partName = [list[0][obj.key]]
													info[ikey].partName = [list[0][obj.val]]
												}else{
													fitem[ikey] = [];
													info[ikey].partName = []
												};
											}else{
												if(list[0]){
													fitem[ikey] = list[0][obj.val]
													info[ikey].partName = list[0][obj.key]
												}
											};
										};
									};
									fitem.title = Dict.nameSplitJoint();
								};
							})
						}},
						"subitem":{name:"监测类型", type:'radio', form:0, style:"display:block", key:'name', val:'value', change:function(val, item){
							var Dict = this.Dict, info = Dict.baseInfo, iitem = info["subitem"], fitem = this.form.item;
							iitem.partName = item.name;
							fitem.title = Dict.nameSplitJoint();
						}},
						"ranges":{name:"监测范围", type:'radio', form:0, style:"display:block", key:'name', val:'key', change:function(val, item){
							var Dict = this.Dict, info = Dict.baseInfo, iitem = info["ranges"], fitem = this.form.item;
							iitem.partName = item.name;
							fitem.title = Dict.nameSplitJoint();
						}},
						"values":{name:"监测值", must:true, type:'checkbox', dataType:[], key:'unit', val:'value', form:0, change:function(val, item){
							var Dict = this.Dict, info = Dict.baseInfo, iitem = info["values"], fitem = this.form.item;
							iitem.partName = val;
							fitem.title = Dict.nameSplitJoint();
						}},
						"updatetime":{name:"更新时间", must:true, form:0, type:"tableFormat", tableFormat:function(val){return Tools.Dates.format.call(new Date(val), 'yyyy-MM-dd HH:mm:ss')}},
						"titlePart":{form:0, table:0, dataType:{}},
						"v_name":{name:'视频名称', must:true, form:0, table:0, input: function(val){
							var Dict = this.Dict, info = Dict.baseInfo, fitem = this.form.item;
							fitem.title = info.deviceid.partName + '('+val+')';
						},},
						"v_id":{name:'视频ID', must:true, form:0, table:0},
						"v_appkey":{name:'appkey', must:true, form:0, table:0},
						"v_appsecret":{name:'appsecret', must:true, form:0, table:0},
						"v_channel":{name:'通道名称', must:true, form:0, table:0},
						"v_captcha":{name:'验证码', form:0, table:0},
					},
					selectList:{
						deviceid: function(){
							return reqPublic('tab/drybeachequipinfor/ids', 'get', {}).then(function(res){
								return res
							});
						},
						subitem:[],
						ranges:[	// 关联日期范围表
						],
						tvalues:[
						],
					},
					// 拼接名称
					nameSplitJoint: function(){
						var info = this.baseInfo;
						var values = info.values.partName ? info.values.partName.join(',') : '';
						var rangesName = info.ranges.partName ? '('+info.ranges.partName+')' : '';
						var subitemName = info.subitem.partName || '';
						return info.deviceid.partName +" "+ values + subitemName + rangesName;
					},
					addFormItem: function(){
						var Dict = this.Dict, info = Dict.baseInfo;
						info.deviceid.disabled = false;

						info.subitem.form = 0;
						info.subitem.partName = '';
						info.ranges.form = 0;
						info.ranges.partName = '';
						info.values.form = 0;
						info.values.partName = '';

						// 视频监控
						info.v_name.form && this.Dict.setVideoFormStatus(0);

						// 刷新监测类型列表
						Dict.getMonitorItem().then(function(res){
							Dict.selectList.deviceid = res;
						});
					},
					editFormItem: function(item){
						var Dict = this.Dict, slist = Dict.selectList, info = Dict.baseInfo, fitem = this.form.item;
						item.values = item.values.split(',');
						
						// hide
						info.deviceid.disabled = true;
						info.subitem.form = 0;
						info.ranges.form = 0;
						info.values.form = 0;
						// 视频监控
						info.v_name.form = 0;
						info.v_id.form = 0;
						info.v_appkey.form = 0;
						info.v_appsecret.form = 0;
						info.v_channel.form = 0;
						info.v_captcha.form = 0;

						// req
						reqPublic('/sys/type/sensorid', 'get', {sensorid:item.deviceid, id:item.id}).then((res) => {
							var body = res.body, subitem = body.subitem, ranges = body.ranges, values = body.values;
							info.deviceid.partName = body.name;
							if(body.type === 't_14'){	// 视频监控
								var monitor = body.monitor;
								for(var sKey in monitor){
									var value = monitor[sKey];
									fitem[sKey] = value;
									info[sKey].form = 1;
								};
							}else{
								slist.subitem = subitem;
								slist.ranges = ranges;
								slist.values = values;

								// show
								info.subitem.form = ~~(!!subitem[0]);
								info.ranges.form = ~~(!!ranges[0]);
								info.values.form = ~~(!!values[0]);
							};
						})
					},
					setVideoFormStatus: function(status){
						var info = this.baseInfo;
						var monitor = {
							"v_appkey":"",
							"v_appsecret":"",
							"v_captcha":"",
							"v_channel":"",
							"v_id":"",
							"v_name":""
						};
						for(var key in monitor){
							info[key].form = status;
						};
					},
					getMonitorItem: function(){
						return reqPublic('tab/drybeachequipinfor/ids', 'get', {})
					},
				},
				config:{
					formWidth:'520px',
					labelWidth:'120',
					operWidth:'180',
					title:'监测项',
					buttons:[
						{'fn':'toEdit', 'type':'primary', 'icon':'el-icon-edit'}, 
						{'fn':'toDelete', 'type':'danger', 'icon':'el-icon-delete'}
					],
					otherBtn:[
						{fn:'toAdd', type:'primary', icon:'el-icon-plus', name:'添加监测项'}
					],
					search:[
						{'type':'string', 'name':'监测名称', 'word':'title', 'mode':0, 'width':'200px', 'clear':function(){
							this.loadData()
						}},
						{'type':'button', 'label':'搜索', 'width':'140px', 'icon':'el-icon-search', 'click':function(e){
							this.table.page = 1;
							this.loadData()
						}},
					],
				},
				request:function(type, param){
					if(type === 'post' || type === 'put'){
						param.values = param.values.join(',');
					};
					return reqPublic('sys/summary', type, param)
				},
			},
			moduleConfig:{		// 模块数据配制
				name:'模块数据配制',
				getMonitorList: function(param){
					return reqPublic('sys/summary/code', 'get', param).then(function(res){
						return res
					});
				},
				getAreaModule:function(param){
					return reqApi.common.requstEdge('get', 'sys/Area', param);
				},
				getSelectItem:function(type, param){
					return reqApi.common.requstEdge(type, 'sys/Select', param);
				},
				reqScreenTitle:function(type, param){
					return reqApi.common.requstEdge(type, 'sys/Area/title', param);
				},
			},
			monitorPointConfig:{	// 监测点
				name:'监测点管理',
				getMonitorPoints: function(param){	// 查询
					return reqPublic('web/monitorchart', 'get', param).then(function(res){
						return res
					});
				},
				postBackground:function(param){
					return reqApi.common.requstEdge('post', 'web/monitorchart', param);
				},
				submitInfos:function(param){
					return reqApi.common.requstEdge('post', 'web/monitorpoints', param);
				},
				deletePoints:function(param){
					return reqApi.common.requstEdge('delete', 'web/monitorpoints', param);
				},
			},
			dbaseManage:{	// 数据库备份
				name:'数据库备份',
				backupDatabase:function(param){
					return reqApi.common.requstEdge('post', 'tab/back', param);
				},
			},
		},
	};
};

// 配制信息
var Config = function(){
	// 获取单元信息
	var getModuleInfo = function(that){
		var path = that.$route.path || '';
		var parts = path.replace('/', '').split('/');
		var i = 0;
		// 递归遍历
		return (function loop(json){
			var key = parts[i]; i++;
			return json[key] ? loop(json[key]) : json;
		})(reqApi);
	};
	return {getModuleInfo:getModuleInfo}
};


//export var tailingPond = tailingPond();
export var reqApi = reqApis();
export var Config = Config();

// WEBPACK FOOTER //
// ./src/common/js/common.js