var Constant = require('../../utils/constant.js');
|
var app = getApp();
|
var dateTimePickerCtrl = require('../../utils/dateTimePicker.js'); //日期控件
|
var util = require('../../utils/util.js')
|
import Request from "../../utils/api"
|
import constant from "../../utils/constant.js";
|
Page({
|
data: {
|
isSubmited: true, // 0表示未发生提交事件 1表示提交报修
|
isSubmitIng: false,//提交中
|
|
urgencyLevel: 0, //紧急程度 等级5
|
|
searchProductKeyWrd: "",//搜索关键字(站内 站外公用)
|
|
|
selStation: null,
|
selRegion: null,
|
selStationIndexArr: [], //第一个成员是区域index 第二个成员是泵站索引
|
allRegionList: [], // 所有区域
|
allStationList: [], // 所有泵站
|
filterStationList: [], // 联动后的过滤泵站
|
|
selDefaultStationId: 0,
|
selDefaultProductId: 0,
|
|
|
allProductListInStation: [], //所有产品(泵站内)
|
filterProductListInStation: [], //过滤后的产品列表(泵站内)
|
|
allProductListOutStation: [], //全部的仪器仪表(泵站外)
|
filterProductListOutStation: [], //搜索之后的仪器仪表(泵站外)
|
|
|
isShowSelStation: false,
|
isShowFaqView: false, //是否显示faq面板
|
isShowFilterProductViewInStation: false, //是否显示泵站内产品过滤面板
|
isShowFilterProductViewOutStation: false,
|
|
|
isInStation: true, //当前状态是泵站外还是泵站内
|
selProductNameInStation: '', //报修界面显示的名字(泵站内)
|
selProductNameOutStation: '', //报修界面显示的名字(泵站外)
|
|
//站外过滤产品 配置
|
productFilterSetting:{
|
isInitialProductList:false,//是否已初始化数据
|
isShowFilterByScope: false,
|
isShowFilterByType: false,
|
isShowOtherInfoPanel: false,
|
scopeText: "距离",
|
typeText: "类型",
|
scopeSelIndex:0,
|
filterType:0,
|
filterTypeIndex:0,
|
filterScopeDistance:0,
|
isFinishOtherProductInfo:false,
|
otherProductInfo: {
|
productName: '', //设备名称
|
productNO: '', //设备编号
|
productCode: '', //设备型号
|
},
|
productTypeList: [{
|
text: '全部类型',
|
value: 0
|
},
|
{
|
text: '流量计',
|
value: 7501
|
},
|
{
|
text: '压力计',
|
value: 7502
|
},
|
{
|
text: '水质仪',
|
value: 7504
|
}
|
],
|
scopeDistList: [{
|
value: 0,
|
text: "不限距离"
|
},
|
{
|
value: 100,
|
text: "100米"
|
}, {
|
value: 300,
|
text: "300米"
|
}, {
|
value: 500,
|
text: "500米"
|
}, {
|
value: 800,
|
text: "800米"
|
}, {
|
value: 1000,
|
text: "1000米"
|
}
|
]
|
},
|
FaultPhenomenonEum:[{
|
Name:"发动机过热",
|
Code: 1
|
},
|
{
|
Name:"损坏",
|
Code: 2
|
},
|
{
|
Name:"停电",
|
Code: 3
|
},
|
{
|
Name:"遗失",
|
Code: 4
|
}
|
],
|
selFaqCatalogName: "", //选择的产品问题Type
|
faqList: { //产品问题列表
|
// catalogList: [], //左边菜单
|
questionList: [] //右边信息
|
},
|
questionContent: null, //产品问题信息
|
selQuestionCodes: "232", //产品问题Code
|
|
formNote: "", //表单备注
|
reportTime: "", //报修时间
|
|
selProductInStation: null,//产品(站内)
|
selProductOutStation: null ,//产品(站外)
|
|
imageList: [], //图片
|
|
addressInfo: "", //报修地址(设备的地址)
|
longitude: 0, //纬度
|
latitude: 0, //经度
|
userLocAddress: "", //表单提交时, 人的定位的地址(可能不是报修地址)
|
|
currentCorpID: 1,
|
currentEmployeeID: 1 //当前用户ID
|
},
|
|
onLoad: function (options) {
|
//console.log(app.globalData.userInfo, 111);
|
var that = this;
|
|
var userInfo = app.globalData.userInfo;
|
if (userInfo) {
|
that.setData({
|
currentCorpID: userInfo.CorpID,
|
currentEmployeeID: userInfo.EmployeeID,
|
});
|
} else {
|
wx.navigateTo({
|
url: '/login/login/index',
|
});
|
}
|
|
// console.log(options)
|
if(options == undefined){
|
options = {}
|
}
|
//从外部带入的泵站Id
|
var selDefaultStationId = options.StationId; // 外部带入
|
var selDefaultProductId = options.ProductId; // 外部带入
|
if (options.BelongType != null && options.BelongType == 4) { //有的時候通过这种方式传
|
selDefaultStationId = options.BelongId
|
}
|
|
if (selDefaultStationId == null || selDefaultStationId == "")
|
selDefaultStationId = 0;
|
if (selDefaultProductId == null || selDefaultProductId == "")
|
selDefaultProductId = 0;
|
if (selDefaultStationId > 0) {
|
that.setData({
|
selDefaultStationId: selDefaultStationId,
|
selDefaultProductId: selDefaultProductId,
|
isInStation: true
|
});
|
this.intialStationTree();
|
} else {
|
that.setData({
|
selDefaultStationId: 0,
|
selDefaultProductId: selDefaultProductId
|
})
|
}
|
|
//获取当前日期
|
this.intialDateTimePicker();
|
|
//延时执行
|
setTimeout(function () {
|
//获取当前经纬度
|
that.getCurrentLocation();
|
//初始化FAQ
|
// that.initialFAQ();
|
}, 1000);
|
|
},
|
//获取日期
|
intialDateTimePicker: function () {
|
|
// 获取完整的年月日 时分秒,以及默认显示的数组
|
var obj = dateTimePickerCtrl.dateTimePicker("2020", "2050");
|
var dateTimeArray = obj.dateTimeArray;
|
var dateTime = obj.dateTime
|
//console.log(obj)
|
var reportTime = dateTimeArray[0][dateTime[0]]+"-" + dateTimeArray[1][dateTime[1]]+"-" + dateTimeArray[2][dateTime[2]] +" " +dateTimeArray[3][dateTime[3]]+":" +dateTimeArray[4][dateTime[4]]+":" +dateTimeArray[5][dateTime[5]];
|
//console.log(reportTime);
|
this.setData({ reportTime: reportTime });
|
},
|
//表单提交
|
formSubmitCb: function (e) {
|
//var sysinfo = app.globalData.sysinfo;
|
// console.log(this.data.currentEmployeeID);
|
if (this.data.longitude == 0 || this.data.latitude == 0) {
|
this.getCurrentLocation(); //获取当前经纬度
|
}
|
if (this.data.isInStation) {
|
var selStation = this.data.selStation;
|
if (selStation == null) {
|
wx.showToast({
|
title: '提醒:请选择泵站',
|
icon: 'none'
|
})
|
return;
|
}
|
var selProduct = this.data.selProductInStation;
|
if (selProduct == null || selProduct.ID == 0) {
|
wx.showToast({
|
title: '提醒:请选择产品',
|
icon: 'none'
|
})
|
return;
|
}
|
}
|
else{
|
var productFilterSetting = this.data.productFilterSetting;
|
if(!productFilterSetting.isFinishOtherProductInfo){
|
var selProduct = this.data.selProductOutStation;
|
if (selProduct == null || selProduct.ID == 0) {
|
wx.showToast({
|
title: '提醒:请选择产品',
|
icon: 'none'
|
})
|
return;
|
}
|
}
|
}
|
var addressInfo = this.data.addressInfo;
|
if (addressInfo == null || addressInfo.lengh < 3) {
|
wx.showToast({
|
title: '提醒:请选择地址',
|
icon: 'none'
|
})
|
return;
|
}
|
//console.log(this.data.urgencyLevel);
|
//console.log(this.data.reportTime, this.data.longitude + "," + this.data.latitude);
|
if (this.data.questionContent == "") {
|
wx.showToast({
|
title: '提醒:请填写问题描述',
|
icon: 'none'
|
})
|
return;
|
}
|
|
var that = this;
|
if (that.data.isSubmitIng)
|
return;
|
|
that.setData({
|
isSubmitIng: true
|
});
|
|
wx.showModal({
|
title: '提醒',
|
content: '请问是否提交?',
|
confirmColor: '#007aff',
|
cancelColor: '#007aff',
|
confirmText: '是',
|
cancelText: '否',
|
success: function (resDlg) {
|
that.setData({
|
isSubmited: false
|
})
|
//console.log(that.data.isSubmited)
|
wx.disableAlertBeforeUnload({
|
success: res => {
|
// console.log(res);
|
},
|
fail: err => {
|
console.log(err)
|
}
|
})
|
if (resDlg.confirm) {
|
that.formSubmit();
|
} else if (resDlg.cancel) {
|
//wx.showToast({ title: '点击了 否', icon: 'none' });
|
}
|
}
|
});
|
},
|
|
//重置
|
formResetCb: function (e) {
|
//console.log('form发生了reset事件,携带数据为:', e.detail.value)
|
//this.setData({
|
// chosen: ''
|
//})
|
},
|
//提交
|
formSubmit: function () {
|
var that = this;
|
var imageList = that.data.imageList;
|
var sysInfo = app.globalData.sysInfo;
|
var userInfo = app.globalData.userInfo;
|
|
var isInStation = that.data.isInStation //区别是泵站内还是泵站外
|
|
var post_data ={
|
EquipmentID :"",//设备标识
|
FormName:"报修单",//表单名称
|
Faq:that.data.selQuestionCodes,//问题编号
|
Question:that.data.questionContent,//问题描述
|
Urgency:that.data.urgencyLevel,//紧急程度
|
Address:that.data.addressInfo,//地址
|
"Location.Kind":"gao-dei",
|
"Location.Position.Point.X":that.data.longitude,
|
"Location.Position.Point.Y":that.data.latitude,
|
"Location.Position.Address":that.data.addressInfo,
|
}
|
if(isInStation){
|
let selProductInStation = that.data.selProductInStation
|
post_data.BelongType = "泵站";
|
post_data.BelongID = that.data.selStation.ID;
|
post_data.EquipmentID = selProductInStation.ID
|
}
|
else{
|
var productFilterSetting = that.data.productFilterSetting;
|
let selProductInStation = that.data.selProductInStation
|
if(productFilterSetting.isFinishOtherProductInfo){
|
post_data.BelongType = 0;
|
post_data.BelongID = 0;
|
post_data.EquipmentID = selProductInStation.ID
|
}
|
else{
|
post_data.BelongType = 0;
|
post_data.BelongID = 0;
|
post_data.EquipmentID = selProductInStation.ID
|
}
|
}
|
// console.log(post_data)
|
// return;
|
// console.log(imageList, sysInfo, userInfo,143)
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Request/Form/Insert@V1.0",
|
method: 'POST',
|
data: post_data,
|
responseType:"text",
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
fail: function (err) {
|
console.log(err, '请求失败')
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
// console.log(res.data, '请求成功')
|
that.setData({
|
isSubmitIng: false
|
});
|
|
var result = res.data;
|
console.log(result, 408)
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message
|
});
|
return;
|
}
|
|
var formId = res.data.Data;
|
if (formId <= 0) {
|
wx.showModal({
|
title: '',
|
content: "error 236"
|
});
|
return;
|
}
|
// console.log(formId)
|
|
if (imageList.length > 0) { //上传图片
|
wx.showLoading({
|
title: '上传中...',
|
mask: true
|
});
|
that.uploadNextImageFile(formId, 0);
|
} else {
|
that.submitSuccess(formId);
|
return;
|
}
|
}
|
});
|
|
},
|
//迭代上传图片
|
uploadNextImageFile: function (formId, index_image,) {
|
var that = this;
|
let tokenInfo = wx.getStorageSync('AccessToken')
|
// currentformData.FormID = formId
|
// currentformData.DispName = index_image
|
var image_count = this.data.imageList.length;
|
if (index_image >= image_count)
|
return;
|
var url_image = this.data.imageList[index_image];
|
wx.uploadFile({
|
url: Constant.BASE_SERVER_URL + "Repair/Request/Form/UploadFile@V1.0",
|
filePath: url_image,
|
name: 'file',
|
header:{
|
"Authorization":'Bearer ' + tokenInfo.Token
|
},
|
formData: {
|
FormID:formId
|
},
|
success: function (res) {
|
// console.log(JSON.parse(res.data),"图片上传成功")
|
if (index_image < image_count - 1) {
|
index_image++;
|
that.uploadNextImageFile(formId, index_image); //迭代下一张
|
return;
|
}
|
wx.hideLoading();
|
that.submitSuccess(formId);
|
}
|
});
|
},
|
//提交成功退回上一页
|
submitSuccess: function (formId) {
|
wx.showToast({
|
title: "提交成功",
|
icon: 'none'
|
});
|
this.setData({
|
isSubmitIng: false
|
});
|
var pages = getCurrentPages();
|
//console.log('打印查看pages',pages);
|
|
if (pages.length >= 2) {
|
//var currPage = pages[pages.length - 1]; //当前页面
|
var prevPage = pages[pages.length - 2]; //上一个页面
|
//console.log(prevPage.route)
|
if (prevPage) {
|
var fn = prevPage.refreshReportInfo;
|
if (typeof fn == "function")
|
fn(formId, "add");
|
wx.navigateBack({
|
delta: 1
|
});
|
} else {
|
wx.navigateBack({
|
delta: 1
|
});
|
}
|
} else {
|
wx.navigateBack({
|
delta: 1
|
});
|
}
|
//wx.navigateTo({
|
// url: '/repair/myReport/index'
|
//});
|
},
|
//获取输入的报修地址(设备地址)
|
inputAddress: function (e) {
|
// console.log(e)
|
this.setData({
|
addressInfo: e.detail.value
|
})
|
},
|
|
//选中某产品(泵站内)
|
tapChoiceProductInStation: function (e) {
|
var selStation = this.data.selStation;
|
if (selStation == null)
|
return;
|
|
var sel_product = e.currentTarget.dataset.val;
|
// console.log('360', e.currentTarget.dataset);
|
var disp_text = " " + sel_product.Name ;
|
this.setData({
|
isShowFilterProductViewInStation: false,
|
isShowFilterProductViewOutStation: false,
|
selProductInStation: sel_product,
|
selProductNameInStation: disp_text
|
});
|
|
//初始化FAQ
|
this.buildFAQList();
|
// this.initialFAQ(); 以前的数据是从接口掉
|
},
|
//选中某产品(泵站外)
|
tapChoiceProductOutStation: function (e) {
|
var sel_product = e.currentTarget.dataset.info;
|
//console.log(e.currentTarget.dataset);
|
var disp_text = e.currentTarget.dataset.info.Name + " " + e.currentTarget.dataset.info.NO;
|
this.setData({
|
isShowFilterProductViewInStation: false,
|
isShowFilterProductViewOutStation: false,
|
selProductOutStation: sel_product,
|
selProductNameOutStation: disp_text
|
})
|
},
|
|
//
|
inputRepairNote:function(e){
|
var note = e.detail.value;
|
this.setData({formNote:note})
|
},
|
/**清空 onEmpty */
|
onEmptyKeyWrd4SearchInStation:function() {
|
this.setData({
|
searchProductKeyWrd: ''
|
})
|
|
this.searchProductByKeyWrdInStation("");
|
},
|
onEmptyKeyWrd4SearchOutStation:function() {
|
this.setData({
|
searchProductKeyWrd: ''
|
})
|
|
this.filterProductOutStation();
|
},
|
|
//点击报修单上的泵型号, 表示要搜索泵站内的设备
|
tapProductInStation:function(e) {
|
//console.log(this.data.filterProductList, '557')
|
var selStation = this.data.selStation;
|
if (selStation == null) {
|
wx.showModal({
|
title: '提示',
|
content: '请先选择泵站!'
|
})
|
return;
|
}
|
|
var selProductInStation = this.data.selProductInStation;
|
//console.log('395', selProductInStation)
|
if (selProductInStation != null) {
|
this.setData({
|
searchProductKeyWrd: selProductInStation.NO,
|
isShowFilterProductViewInStation: true
|
})
|
this.searchProductByKeyWrdInStation(selProductInStation.NO);
|
return;
|
} else {
|
//初始化产品列表
|
this.initialProductListInStation(selStation.ID, 0);
|
|
this.setData({
|
isShowFilterProductViewInStation: true
|
});
|
}
|
},
|
|
//站外产品搜索(点击)
|
tapSearchProductByKeyWrdOutStation:function(){
|
this.filterProductOutStation();
|
},
|
//赋值选择位置进行 选择当前位置
|
tapChooseLocation:function() {
|
let that = this;
|
wx.chooseLocation({
|
success: function (res) {
|
//console.log("chooseLocation", res)
|
let lat = res.latitude
|
let lon = res.longitude
|
that.setData({
|
addressInfo: res.address,
|
longitude: lon,
|
latitude: lat
|
});
|
if(that.data.isInStation){//重新计算距离
|
that.initialProductListByDistOutStatioin();
|
}
|
}
|
});
|
},
|
|
|
//图片上传
|
chooseImage: function () {
|
var that = this;
|
var imageList = this.data.imageList;
|
wx.chooseImage({
|
sizeType: ['original', 'compressed'],
|
sourceType: ['album', 'camera'],
|
count: 9, //最多
|
success: function (res) {
|
// console.log(res,601)
|
var imgPaths = res.tempFilePaths;
|
for (var i = 0; i < imgPaths.length; i++) {
|
var imgPath = res.tempFilePaths[i];
|
imageList.push(imgPath)
|
};
|
// console.log(imageList, 55)
|
that.setData({
|
imageList: imageList
|
})
|
}
|
})
|
},
|
//查看图片
|
previewImage: function (e) {
|
// console.log(this.data.imageList,e.target.dataset.src)
|
var currentSrc = e.target.dataset.src
|
wx.previewImage({
|
current: currentSrc,
|
urls: this.data.imageList
|
})
|
// console.log(currentSrc, this.data.imageList, "ywg")
|
},
|
//删除图片
|
deleteImage: function (e) {
|
var that = this;
|
var imageList = that.data.imageList;
|
var index = e.currentTarget.dataset.index; //获取当前长按图片下标
|
// console.log(imageList, index)
|
wx.showModal({
|
title: '系统提醒',
|
content: '确定要删除此图片吗?',
|
success: function (res) {
|
if (res.confirm) {
|
imageList.splice(index, 1);
|
} else if (res.cancel) {
|
return false;
|
}
|
that.setData({
|
imageList: imageList
|
});
|
}
|
})
|
},
|
//一键清空
|
onImageDel:function() {
|
var that = this;
|
wx.showModal({
|
title: '系统提醒',
|
content: '确定要删除全部图片吗?',
|
success: function (res) {
|
if (res.confirm) {
|
that.setData({
|
imageList: []
|
});
|
} else if (res.cancel) {
|
return false;
|
}
|
|
}
|
});
|
},
|
|
|
|
//扫一扫
|
scanProductCode: function () {
|
var that = this
|
wx.scanCode({
|
success: function (res) {
|
if (res.result == null || res.result == "")
|
return;
|
//检查是否有对应字段
|
//console.log(res.result)
|
//{ "stationid": 5, "productid": 121 }
|
var model = JSON.parse(res.result);
|
if (model.stationid == null) {
|
wx.showToast({
|
title: '请扫描义维提供的设备二维码',
|
icon: 'none'
|
});
|
}
|
if (model.productid == null) {
|
wx.showToast({
|
title: '请扫描义维提供的设备二维码',
|
icon: 'none'
|
});
|
}
|
wx.showToast({
|
title: '扫描成功',
|
icon: 'none'
|
});
|
//console.log(model)
|
/*var selDefaultStationId = model.stationid;
|
if (selDefaultStationId != null) {
|
that.setSelStation(selDefaultStationId, null);
|
}
|
var selDefaultProductId = model.productid;
|
if (selDefaultProductId != null) {
|
//that.initialProductListInStation(selStation.ID, selProductId);
|
}*/
|
},
|
fail: function (res) {
|
wx.showToast({
|
title: '扫描失败',
|
icon: 'none'
|
})
|
}
|
})
|
},
|
|
|
//加载定位
|
getCurrentLocation: function () {
|
var that = this;
|
wx.getLocation({
|
type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
success(resLoc) {
|
//console.log("getCurrentLocation", resLoc);
|
if (resLoc.longitude == 0 || resLoc.latitude == 0) { //当前位置信号较弱,请换个位置尝试
|
return;
|
}
|
//
|
that.setData({
|
longitude: resLoc.longitude,
|
latitude: resLoc.latitude,
|
})
|
//发送请求通过经纬度反查地址信息
|
var getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + resLoc.latitude + "," + resLoc.longitude + "&key=GFDBZ-D3NKX-LNL4Z-TSWGU-RYCE3-4HB3I";
|
Request({
|
url: getAddressUrl,
|
success: function (result) {
|
//console.log("getAddressUrl", result);
|
wx.showToast({
|
title: '成功获取当前位置',
|
icon: 'none',
|
duration: 1000
|
});
|
that.setData({
|
addressInfo: result.data.result.address,
|
userLocAddress: result.data.result.address
|
})
|
},
|
fail: err => {
|
console.log('获取当前位置失败')
|
}
|
});
|
},
|
fail: err => {
|
console.log(err)
|
wx.getSetting({
|
success: function (res) {
|
if (!res.authSetting['scope.userLocation']) {
|
wx.showModal({
|
title: '',
|
content: '请允许微信小程序获取您的定位',
|
confirmText: '授权',
|
success: function (res) {
|
if (res.confirm) {
|
wx.openSetting({});
|
} else {
|
console.log('get location fail');
|
}
|
}
|
})
|
} else {
|
//用户已授权,但是获取地理位置失败,提示用户去系统设置中打开定位
|
wx.showModal({
|
title: '',
|
content: '请在系统设置中打开定位服务',
|
confirmText: '确定',
|
success: function (res) {}
|
})
|
}
|
}
|
})
|
|
}
|
});
|
},
|
|
|
//初始化泵站列表(和泵站列表用的是同一个缓存)
|
initialStationData: function () {
|
var that = this;
|
var allRegionList = [];
|
var allStationList = [];
|
wx.showLoading({
|
title: '加载中...'
|
});
|
// console.log(that.data,824)
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "SZJT/Logic/Tree/Std/GetTreeListByPolicyID@V1.0",
|
method: 'GET',
|
|
data: {
|
PolicyID: 1
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
console.log(err)
|
wx.hideLoading();
|
wx.showModal({
|
title: '',
|
content: '通讯失败',
|
})
|
}, //请求失败
|
success: function (res) {
|
// console.log(res,363)
|
wx.hideLoading();
|
//console.log(res.data)
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
allRegionList = []
|
allStationList = []
|
result.Data.forEach((ele=>{
|
let node = {
|
ID:ele.LogicID,
|
Name:ele.Name,
|
Description:ele.Description,
|
}
|
allRegionList.push(node)
|
ele.Children.forEach(station => {
|
let stationNode = {
|
RegionID:ele.LogicID,
|
ID:station.LogicID,
|
Name:station.Name,
|
}
|
allStationList.push(stationNode)
|
});
|
}))
|
|
that.setData({
|
allRegionList: allRegionList,
|
allStationList: allStationList,
|
});
|
that.buildStationCombox();
|
}
|
});
|
},
|
//构建泵站Combox
|
buildStationCombox: function () {
|
|
var that = this;
|
//
|
var allStationList = this.data.allStationList;
|
var allRegionList = this.data.allRegionList;
|
|
var selStation = this.data.selStation;
|
|
var selDefaultStationId = this.data.selDefaultStationId;
|
var selDefaultProductId = this.data.selDefaultProductId;
|
|
//console.log(selStation,selDefaultStationId, selDefaultProductId)
|
|
if (selStation == null) { //没有选择过,默认选择的第一个泵站
|
var sel_region_id = allRegionList[0].ID;
|
var filterStationList = []; //选择第一个区域下的泵站
|
//
|
for (var i = 0; i < allStationList.length; i++) {
|
if (sel_region_id == allStationList[i].RegionID) {
|
filterStationList.push(allStationList[i]);
|
}
|
}
|
that.setData({
|
filterStationList: filterStationList
|
});
|
// console.log(filterStationList,922)
|
if (selDefaultStationId > 0)
|
that.setSelStation(selDefaultStationId, function (statioin) {
|
if (statioin == null)
|
return;
|
if (selDefaultProductId <= 0)
|
return;
|
|
that.setSelProductInStation(statioin, selDefaultProductId);
|
});
|
} else {
|
that.setSelStation(selStation.ID, null);
|
}
|
},
|
|
//设置某个产品被选中(泵站内)
|
setSelProductInStation: function (statioin, selProductId) {
|
|
this.setData({
|
isInStation:true
|
})
|
|
this.initialProductListInStation(statioin.ID, selProductId);
|
|
},
|
//
|
closePopUpSelStation: function () {
|
this.setData({
|
isShowSelStation: false
|
})
|
},
|
pickSelStation: function (e) {
|
var that = this;
|
that.setData({
|
isShowSelStation: true
|
});
|
|
this.intialStationTree();
|
},
|
|
intialStationTree: function () {
|
var allRegionList = this.data.allRegionList;
|
var allStationList = this.data.allStationList;
|
if (allRegionList != null && allStationList != null && allStationList.length > 0) {
|
this.buildStationCombox();
|
} else {
|
this.initialStationData();
|
}
|
},
|
|
|
//设置某个泵站为选中状态
|
setSelStation: function (selSationId, success_cb) {
|
var allRegion = this.data.allRegionList;
|
var allStation = this.data.allStationList;
|
|
//默认选择的泵站
|
var sel_region_id = 0;
|
var selStation = null;
|
var selStationIndexArr = [0, 0]; //默认第一个
|
|
//找到所选的泵站所在的区域
|
for (var i = 0; i < allStation.length; i++) {
|
if (selSationId == allStation[i].ID) {
|
for (var j = 0; j < allRegion.length; j++) {
|
if (allRegion[j].ID == allStation[i].RegionID) {
|
selStationIndexArr[0] = j;
|
sel_region_id = allRegion[j].ID;
|
break;
|
}
|
}
|
}
|
}
|
if (sel_region_id == 0)
|
return false;
|
|
var filterStationList = [];
|
// console.log(allStation)
|
for (var i = 0; i < allStation.length; i++) {
|
if (sel_region_id == allStation[i].RegionID) {
|
filterStationList.push(allStation[i]);
|
if (allStation[i].ID == selSationId) {
|
selStationIndexArr[1] = filterStationList.length - 1;
|
selStation = allStation[i];
|
}
|
}
|
}
|
if (selStation == null)
|
return;
|
//console.log(selStation, filterStationList, selStationIndexArr,730)
|
this.setData({
|
selStation: selStation,
|
filterStationList: filterStationList,
|
selStationIndexArr: selStationIndexArr
|
});
|
if (success_cb != null) {
|
success_cb(selStation);
|
}
|
},
|
// 选择了泵站
|
stationChange: function (e) {
|
//
|
var selRegionIndex = e.detail.value[0];
|
//var selStationIndex = e.detail.value[1];
|
|
var allRegion = this.data.allRegionList;
|
var allStation = this.data.allStationList;
|
|
var sel_region_id = allRegion[selRegionIndex].ID;
|
var filterStationList = [];
|
for (var i = 0; i < allStation.length; i++) {
|
if (sel_region_id == allStation[i].RegionID) {
|
filterStationList.push(allStation[i])
|
}
|
}
|
//console.log(e.detail.value)
|
//此时还是选择,还未确认
|
this.setData({
|
selStationIndexArr: e.detail.value,
|
filterStationList: filterStationList
|
});
|
},
|
// 点击选择泵站 取消按钮
|
cancelSelStation: function (e) {
|
this.setData({
|
isShowSelStation: false
|
})
|
},
|
// 点击选择泵站 确定按钮
|
commitSelStation: function (e) {
|
var that = this;
|
this.setData({
|
isShowSelStation: false
|
})
|
|
//
|
var selStationIndexArr = this.data.selStationIndexArr;
|
if (selStationIndexArr.length == 0) {
|
selStationIndexArr = [0, 0]; //可能就是选第一个
|
}
|
var selRegionIndex = selStationIndexArr[0];
|
var selStationIndex = selStationIndexArr[1]; //第一个成员是区域index 第二个成员是泵站索引
|
|
var selRegion = this.data.allRegionList[selRegionIndex];
|
var selStation = this.data.filterStationList[selStationIndex];
|
|
this.setData({
|
selRegion: selRegion,
|
selStation: selStation
|
});
|
|
|
|
//初始化产品列表
|
this.initialProductListInStation(selStation.ID, 0);
|
return;
|
},
|
//初始化产品列表 根据选择的泵站获取设备列表
|
initialProductListInStation: function (selStationID, selProductID) {
|
var that = this;
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "Assets/Equipment/Std/GetTreeListByBelongTypeAndBelongID@V1.0",
|
method: 'GET',
|
data: {
|
BelongType:constant.LOGIC_SITE,
|
BelongID: selStationID
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
// console.log('1149', res)
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
var allProductListInStation = result.Data;
|
// console.log('956', allProductListInStation)
|
that.setData({
|
selProductNameInStation: '',
|
allProductListInStation: allProductListInStation,
|
filterProductListInStation: allProductListInStation,
|
});
|
|
//所选产品
|
if (selProductID > 0) {
|
for (let i in allProductListInStation) {
|
var product = allProductListInStation[i];
|
if (product.ID == selProductID) {
|
that.setData({
|
selProductInStation: product,
|
selProductNameInStation: product.Name + " " + product.NO
|
});
|
break;
|
}
|
}
|
} else {
|
that.searchProductByKeyWrdInStation("");
|
}
|
}
|
});
|
},
|
|
//问题类型 点击事件
|
onQuestionTypeClick: function (e) {
|
// console.log(e)
|
this.setData({
|
selFaqCatalogName: e.currentTarget.dataset.type
|
})
|
},
|
//显示FAQ
|
tapShowFaqView: function () {
|
this.setData({
|
isShowFaqView: true
|
})
|
},
|
//确认问题
|
confirmFaqCb: function () {
|
this.setData({
|
isShowFaqView: false
|
})
|
},
|
//清空
|
clearFaqCb: function () {
|
var that = this;
|
var rdata = that.data.faqList.questionList;
|
for (var i = 0; i < rdata.length; i++) {
|
var rd = rdata[i];
|
rd.checked = false;
|
}
|
that.setData({
|
questionContent: "", //产品问题信息
|
selQuestionCodes: "", //产品问题Code
|
faqList: {
|
questionList: rdata
|
}
|
})
|
},
|
//返回主页面
|
rebackMainPage() {
|
this.setData({
|
isShowFaqView: false,
|
isShowSelStation:false,
|
isShowFilterProductViewInStation: false,
|
isShowFilterProductViewOutStation: false
|
})
|
},
|
|
//初始化常见问题
|
initialFAQ: function () {
|
var that = this;
|
let productID = that.data.selProductInStation.ProductTypeID
|
var cacheName = 'AllProductFaqInfo';
|
var getInfoFromCache = wx.getStorageSync(cacheName);
|
if (getInfoFromCache) {
|
if (getInfoFromCache.timetamp + 24 * 60 * 60 * 4 > Date.parse(new Date())) {
|
that.buildFAQList(getInfoFromCache.data);
|
return;
|
}
|
}
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "Product/ProductTypeFaq/Mobile/GetCatalogListByProductTypeID@V1.0",
|
method: 'GET',
|
data: {
|
CorpID: this.data.currentCorpID,
|
ProductTypeID:productID,
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
wx.showModal({
|
title: '',
|
content: '初始化问题列表失败',
|
})
|
}, //请求失败
|
success: function (res) {
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
// console.log(result,1207)
|
//
|
var allFaq = result.Data;
|
// console.log(allFaq, 1107)
|
var getInfoFromCache = {};
|
getInfoFromCache.data = allFaq;
|
getInfoFromCache.timetamp = Date.parse(new Date()); // util.formatDay(new Date); 用时间戳
|
wx.setStorage({
|
key: cacheName,
|
data: getInfoFromCache
|
});
|
that.buildFAQList(allFaq);
|
}
|
});
|
|
return;
|
},
|
|
buildFAQList: function () {
|
var faqList=this.data.FaultPhenomenonEum
|
console.log(faqList);
|
var questionList = [];
|
|
for (var i = 0; i < faqList.length; i++) {
|
var rd = faqList[i];
|
questionList.push({
|
Code: rd.Code,
|
CatalogName: rd.Name,
|
// Question: question,
|
// Resolvent: element.Solution,
|
checked: false
|
});
|
}
|
console.log(questionList, 337)
|
|
this.setData({
|
faqList: {
|
questionList: questionList
|
},
|
selFaqCatalogName: questionList[0].CatalogName
|
})
|
},
|
//监听用户输入问题的内容
|
inputQuestionContent: function (e) {
|
// console.log(e.detail.value,1330)
|
this.setData({
|
questionContent: e.detail.value
|
})
|
},
|
//清除问题输入框内的内容
|
clearnQuestion: function () {
|
var that = this;
|
var rdata = that.data.faqList.questionList;
|
wx.showModal({
|
title: '提示',
|
content: '确定要删除问题内容吗?',
|
success(res) {
|
if (res.confirm) {
|
for (var i = 0; i < rdata.length; i++) {
|
var rd = rdata[i];
|
rd.checked = false;
|
}
|
that.setData({
|
questionContent: null, //产品问题信息
|
selQuestionCodes: "", //产品问题Code
|
faqList: {
|
questionList: rdata
|
}
|
})
|
} else if (res.cancel) {
|
return;
|
console.log('用户点击取消')
|
}
|
}
|
})
|
|
|
},
|
//产品问题 点击事件
|
tapFaqItemCb: function (e) {
|
var that = this;
|
var values = e.detail.value;
|
var infos = [];
|
var codes = [];
|
var questionContent = that.data.questionContent
|
// infos.push(that.data.questionContent) //先加入用户输入的问题内容
|
for (var i = 0; i < values.length; i++) {
|
var vs = values[i].split(',');
|
codes.push(vs[1]);
|
}
|
var rdata = that.data.faqList.questionList;
|
for (var i = 0; i < rdata.length; i++) {
|
var rd = rdata[i];
|
var bol = false;
|
for (var j = 0; j < codes.length; j++) {
|
var cs = codes[j];
|
|
if (cs == rd.Code) {
|
bol = true;
|
}
|
}
|
rd.checked = bol;
|
if(rd.checked){
|
infos.push(rd.CatalogName)
|
|
}
|
}
|
if (questionContent != null) {
|
infos.push(that.data.questionContent) //先加入用户输入的问题内容
|
}
|
that.setData({
|
faqList: {
|
questionList: rdata
|
}
|
})
|
var newContent = util.unique(infos)
|
that.setData({
|
questionContent: util.unique(newContent.join(",").split(",")).join(","),
|
selQuestionCodes: codes.join(","),
|
faqList: {
|
questionList: rdata
|
}
|
})
|
},
|
//解决方案(暂无)
|
onClickFaqQuestion: function (e) {
|
//var code = e.target.dataset.code;
|
//wx.navigateTo({
|
// url: '/Inspection/index/index?code=' + code,
|
//})
|
},
|
|
//紧急程度
|
tagUrgencyLevel: function (e) {
|
//console.log(e.currentTarget.dataset.value)
|
let urgencyLevel = e.currentTarget.dataset.value
|
this.setData({
|
urgencyLevel: urgencyLevel
|
})
|
},
|
//重置
|
onResetFormInfo: function () {
|
this.setData({
|
urgencyLevel: 0
|
})
|
},
|
|
//选择产品过滤
|
pickProductFilter: function (e) {
|
return;
|
},
|
|
|
|
//切换泵站内、外状态
|
changeProductPosiStatus: function () {
|
var that = this
|
var isInStation = that.data.isInStation
|
that.setData({
|
isInStation: !isInStation
|
})
|
},
|
//根据经纬度、距离获取设备列表(所有):站外
|
initialProductListByDistOutStatioin: function () {
|
var that = this;
|
var request_data = {
|
CorpID:that.data.currentCorpID,
|
Longitude: that.data.longitude,
|
Latitude: that.data.latitude,
|
Scope: 0//(获取所有,暂时数据较少) that.data.distance
|
}
|
|
Request({
|
header: {'content-type': 'application/json'},
|
method: 'GET',
|
url: Constant.BASE_SERVER_URL + "Main/Mobile/Product/Base/GetByPosition",
|
data:request_data,
|
success: res => {
|
//console.log(res)
|
if (res.data.Code != 0) {
|
wx.showToast({
|
title: '数据获取失败',
|
icon: 'none',
|
duration: 2000
|
})
|
}
|
//
|
var allProductListOutStation = res.data.Data;
|
for (let i = 0; i < allProductListOutStation.length; i++) {
|
var product = allProductListOutStation[i];
|
product.imgSrc = "";
|
if(product.Type == 7501 )
|
product.imgSrc = '../../images/icons/liuliangji.svg' ;
|
if(product.Type == 7502 )
|
product.imgSrc ='../../images/icons/yaliji.svg' ;
|
if(product.Type == 7504 )
|
product.imgSrc ='../../images/icons/shuizhiyi.svg';
|
}
|
that.setData({
|
allProductListOutStation: allProductListOutStation,
|
filterProductListOutStation: allProductListOutStation,
|
"productFilterSetting.isInitialProductList":true
|
});
|
|
that.filterProductOutStation();
|
},
|
fail: err => {
|
console.log(err)
|
return;
|
}
|
})
|
},
|
|
//过滤站外产品列表
|
filterProductOutStation: function(){
|
var setting = this.data.productFilterSetting;
|
//console.log(setting)
|
var keyWrd = this.data.searchProductKeyWrd;
|
var allProducts = this.data.allProductListOutStation;
|
//console.log(keyWrd)
|
|
if(setting.filterType == 0 && setting.filterScopeDistance <= 1 && keyWrd == ""){
|
this.setData({
|
filterProductListOutStation: allProducts
|
});
|
return;
|
}
|
if(setting.filterType >0){
|
allProducts = allProducts.filter(function(v){
|
if(v.Type == setting.filterType)
|
return true;
|
else
|
return false;
|
});
|
}
|
if(setting.filterScopeDistance > 10){
|
allProducts = allProducts.filter(function(v){
|
//console.log(v.Distance,setting.filterScopeDistance)
|
if(v.Distance <= setting.filterScopeDistance * 1.01)
|
return true;
|
else
|
return false;
|
});
|
}
|
|
if(keyWrd != "" && keyWrd.length>1){
|
allProducts = allProducts.filter(function(product){
|
if (product.NO != null && product.NO.length > 1 && product.NO.indexOf(keyWrd) >= 0) {
|
return true;
|
} else if (product.Code != null && product.Code.length > 1 && product.Code.indexOf(keyWrd) >= 0) {
|
return true;
|
} else if (product.Name != null && product.Name.length > 1 && product.Name.indexOf(keyWrd) >= 0) {
|
return true;
|
}
|
//console.log(product)
|
return false;
|
});
|
}
|
|
this.setData({
|
filterProductListOutStation: allProducts
|
});
|
},
|
|
//点击产品(站外) , 开始进行产品搜索事件
|
tapProductOutStation: function () {
|
var that = this;
|
this.setData({
|
isShowFilterProductViewOutStation: true,
|
isShowFilterProductViewInStation: false
|
});
|
//初始化列表, 根据位置获取报修的设备
|
var setting = this.data.productFilterSetting;
|
if(!setting.isInitialProductList){//是否初始化
|
this.initialProductListByDistOutStatioin();
|
return;
|
}
|
// console.log(setting)
|
var selProductOutStation = that.data.selProductOutStation;
|
if(selProductOutStation != null){
|
// console.log(selProductOutStation);
|
this.setData({
|
searchProductKeyWrd:selProductOutStation.NO
|
});
|
}
|
},
|
inputKeyWrd4SearchInStatioin:function(e){
|
var key_wrd = e.detail.value;
|
this.setData({
|
searchProductKeyWrd:key_wrd
|
});
|
this.searchProductByKeyWrdInStation(key_wrd);
|
},
|
//监听设备搜索输入的值(站外)
|
inputKeyWrd4SearchOutStatioin: function (e) {
|
//
|
let key_wrd = e.detail.value;
|
//console.log(key_wrd)
|
this.setData({
|
searchProductKeyWrd:key_wrd
|
});
|
this.filterProductOutStation();
|
},
|
|
|
//距离选择(站外)
|
tapChoiceByDistanceItem: function (e) {
|
this.setData({
|
"productFilterSetting.scopeText": e.currentTarget.dataset.text,
|
"productFilterSetting.scopeSelIndex": e.currentTarget.dataset.index,
|
"productFilterSetting.filterScopeDistance": e.currentTarget.dataset.value,
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
})
|
//
|
this.filterProductOutStation();
|
},
|
// 类型选择(站外)
|
choieFilterProductTypeOutStaion: function (e) {
|
//console.log(e.currentTarget.dataset);
|
|
this.setData({
|
"productFilterSetting.filterType": e.currentTarget.dataset.value,
|
"productFilterSetting.filterTypeIndex": e.currentTarget.dataset.index,
|
"productFilterSetting.typeText": e.currentTarget.dataset.text,
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
this.filterProductOutStation();
|
},
|
//点击透明背景隐藏下拉(站外)
|
hideAllFilterPanel: function (event) {
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false
|
})
|
},
|
//显示类型过滤下拉
|
tapShowFilterByType: function () {
|
if(this.data.productFilterSetting.isShowFilterByType){
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
}
|
else{
|
this.setData({
|
"productFilterSetting.isShowFilterByType": true,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
}
|
},
|
//显示距离过滤下拉
|
tapShowFilterByScope: function () {
|
if(this.data.productFilterSetting.isShowFilterByScope){
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
}
|
else{
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": true,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
}
|
},
|
//显示其他界面(自定义)
|
tapShowInputOtherProuctInfo: function () {
|
if(this.data.productFilterSetting.isShowOtherInfoPanel){
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": false
|
});
|
}
|
else{
|
this.setData({
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowOtherInfoPanel": true
|
});
|
}
|
},
|
|
//获取用户输入的设备名称(自定义)
|
intpuOtherProductName: function (e) {
|
this.setData({
|
"productFilterSetting.otherProductInfo.productName": e.detail.value
|
})
|
},
|
//获取用户输入的设备编号(自定义)
|
intpuOtherProductNo: function (e) {
|
this.setData({
|
"productFilterSetting.otherProductInfo.productNO": e.detail.value
|
})
|
},
|
//获取用户输入的设备型号(自定义)
|
intpuOtherProductCode: function (e) {
|
this.setData({
|
"productFilterSetting.otherProductInfo.productCode": e.detail.value
|
})
|
},
|
//获取用户输入的设备信息 (自定义)
|
tapFinishOtherProductInfo: function () {
|
var that = this
|
var otherProductInfo = that.data.productFilterSetting.otherProductInfo
|
var selProductNameOutStation = otherProductInfo.productName + " " + otherProductInfo.productNO;
|
if(otherProductInfo.productName == ""){
|
wx.showToast({
|
title: '提醒:请输入产品型号',
|
icon: 'none'
|
})
|
return;
|
}
|
that.setData({
|
selProductNameOutStation: selProductNameOutStation,
|
"productFilterSetting.isShowFilterByScope": false,
|
"productFilterSetting.isShowFilterByType": false,
|
"productFilterSetting.isShowOtherInfoPanel": false,
|
"productFilterSetting.isFinishOtherProductInfo": true,
|
isShowFilterProductViewInStation:false,
|
isShowFilterProductViewOutStation:false
|
})
|
},
|
|
//查询产品(站内)
|
searchProductByKeyWrdInStation:function(keyWrd) {
|
|
var all_products = this.data.allProductListInStation;
|
if (all_products == null || all_products.length == 0)
|
return;
|
|
if (keyWrd == null || keyWrd == "") {
|
this.setData({
|
filterProductListInStation: all_products
|
});
|
return;
|
}
|
|
|
var arr = []; //临时数组,用于存放匹配到的数组
|
for (let i in all_products) {
|
var product = all_products[i];
|
//console.log(product);
|
if (product.NO != null && product.NO.length > 1 && product.NO.indexOf(keyWrd) >= 0) {
|
arr.push(product)
|
} else if (product.Code != null && product.Code.length > 1 && product.Code.indexOf(keyWrd) >= 0) {
|
arr.push(product)
|
} else if (product.Name != null && product.Name.length > 1 && product.Name.indexOf(keyWrd) >= 0) {
|
arr.push(product)
|
}
|
}
|
this.setData({
|
filterProductListInStation: arr
|
})
|
},
|
|
|
onShareAppMessage: function () {
|
return Constant.Share;
|
}
|
})
|