// pages/problemReport/proRep.js
|
import {GetManagementClass, GetCompany} from '../../utils/network'
|
|
const app = getApp()
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
firstallArr: [],
|
pingDingArray: '',
|
value1: '',
|
// 二级联动选择
|
allarr: '',
|
onearr: '',
|
index2: '',
|
|
lastarr: [],
|
twoarr: '',
|
index3: '',
|
//
|
dis: true,
|
//
|
Reported_Remark: '',//安全问题
|
Dispost_Question: '',//派单审核意见
|
shangbao: '',
|
beizhu: '',
|
// 图片
|
FTimageUrl: '',
|
imageUrl: '',
|
// map
|
locmap: '',
|
markers: '',
|
// 所在地址
|
address: '',
|
// 详细地址
|
detailedaddress: '',
|
listid: '',
|
//
|
youkecenter: '',
|
youkeindex: ''
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
console.log(321, JSON.parse(options.data))
|
this.setData({
|
firstallArr: app.firstallArr,
|
pingDingArray: app.pingDingArray,
|
allarr: app.allarr,
|
onearr: app.onearr,
|
youkecenter: app.youkecenter,
|
shangbao: JSON.parse(options.data).Reported_Question,
|
beizhu: JSON.parse(options.data).Reported_Remark,
|
FTimageUrl: JSON.parse(options.data).Reported_Img.replace('..', '').split(","),
|
listid: JSON.parse(options.data).id,
|
Dispost_Question: JSON.parse(options.data).Dispost_Question,
|
Reported_Remark: JSON.parse(options.data).Reported_Remark ? true : false,
|
})
|
|
// 反填游客归属中心
|
this.data.youkecenter.forEach((e) => {
|
if (e.pk_TypeId === JSON.parse(options.data).fk_Role_Type) {
|
var index = this.data.youkecenter.indexOf(e)
|
console.log(index)
|
this.setData({
|
youkeindex: index
|
})
|
}
|
})
|
|
// 反填评定项目
|
this.data.firstallArr.forEach((e) => {
|
if (e.pk_Management === JSON.parse(options.data).fk_Management) {
|
var index = this.data.firstallArr.indexOf(e)
|
// console.log(index)
|
this.setData({
|
index1: index
|
})
|
}
|
})
|
//
|
this.data.allarr.forEach((e) => {
|
if (e.pk_Company === JSON.parse(options.data).FirstCompanyId) {
|
var indx2 = this.data.allarr.indexOf(e)
|
console.log(indx2)
|
this.setData({
|
index2: indx2
|
})
|
var arr1 = []
|
e.CompanyList.forEach((element) => {
|
arr1.push(element.CompanyName)
|
})
|
this.setData({
|
dis: false,
|
twoarr: arr1,
|
lastarr: e.CompanyList
|
})
|
e.CompanyList.forEach((element) => {
|
if (element.pk_Company === JSON.parse(options.data).SecondCompanyId) {
|
var inde3 = e.CompanyList.indexOf(element)
|
this.setData({
|
index3: inde3
|
})
|
}
|
})
|
}
|
})
|
|
//
|
this.setData({
|
detailedaddress: JSON.parse(options.data).Reported_Address
|
})
|
|
wx.request({
|
url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + JSON.parse(options.data).Reported_Address + '&key=KCQBZ-RWX3F-KKHJ2-NTS35-M6KVV-XFFTM',
|
success: ((res) => {
|
// console.log(res.data.result)
|
var lo = {
|
latitude: res.data.result.location.lat,
|
longitude: res.data.result.location.lng
|
}
|
this.setData({
|
locmap: lo,
|
markers: [{
|
id: 0,
|
latitude: lo.latitude,
|
longitude: lo.longitude,
|
iconPath: '/images/ProRep/weizhi.png',
|
width: '50rpx',
|
height: '50rpx'
|
}],
|
})
|
})
|
})
|
},
|
// 选择
|
bindPicker(e) {
|
this.setData({
|
index1: e.detail.value
|
})
|
},
|
bindPicker2(e) {
|
this.setData({
|
index2: e.detail.value,
|
index3: ''
|
})
|
//
|
if (this.data.index2) {
|
this.setData({
|
dis: false
|
})
|
} else {
|
this.setData({
|
dis: true
|
})
|
}
|
|
var arr = []
|
this.setData({
|
lastarr: this.data.allarr[e.detail.value].CompanyList
|
})
|
this.data.allarr[e.detail.value].CompanyList.forEach((element) => {
|
arr.push(element.CompanyName)
|
})
|
this.setData({
|
twoarr: arr
|
})
|
},
|
bindPicker3(e) {
|
this.setData({
|
index3: e.detail.value
|
})
|
},
|
choseArea(e) {
|
this.setData({
|
youkeindex: e.detail.value
|
})
|
},
|
|
// 选择图片
|
chooseImage() {
|
wx.chooseImage({
|
count: 1,
|
sizeType: ['original', 'compressed'],
|
sourceType: ['album', 'camera'],
|
success: res => {
|
this.setData({
|
imageUrl: res.tempFilePaths
|
})
|
}
|
})
|
},
|
// 派单审核意见
|
Dispost_Question(e) {
|
console.log(12345, e.detail.value)
|
this.setData({
|
Dispost_Question: e.detail.value
|
})
|
},
|
// 安全问题
|
choseRemark(e) {
|
console.log('安全问题', e.detail.value)
|
this.setData({
|
Reported_Remark: e.detail.value
|
})
|
},
|
// 上报问题
|
shangbao(e) {
|
// console.log(e.detail.value)
|
this.setData({
|
shangbao: e.detail.value
|
})
|
},
|
// 录入备注
|
beizhu(e) {
|
this.setData({
|
beizhu: e.detail.value
|
})
|
},
|
// 选择位置
|
choseLocation() {
|
wx.chooseLocation({
|
success: (res) => {
|
// console.log(res)
|
this.setData({
|
address: res.name,
|
detailedaddress: res.address,
|
locmap: {
|
latitude: res.latitude,
|
longitude: res.longitude
|
},
|
markers: [{
|
id: 0,
|
latitude: res.latitude,
|
longitude: res.longitude,
|
iconPath: '/images/ProRep/weizhi.png',
|
width: '50rpx',
|
height: '50rpx'
|
}]
|
})
|
},
|
fail: () => {
|
wx.getSetting({
|
success: (res) => {
|
var statu = res.authSetting;
|
if (!statu['scope.userLocation']) { //未授权
|
wx.showModal({
|
title: '授权定位',
|
content: '需要获取您的地理位置,请先设置授权',
|
// cancelColor: 'skyblue',
|
confirmText: "去设置",
|
success: (res) => {
|
if (res.cancel) {
|
//点击取消,默认隐藏弹框
|
} else {
|
//点击确定
|
wx.openSetting({
|
withSubscriptions: true,
|
success: (res) => {
|
this.onLoad()
|
}
|
})
|
}
|
}
|
})
|
}
|
}
|
})
|
}
|
})
|
},
|
showT() {
|
if (this.data.dis) {
|
wx.showToast({
|
title: '请先选择一级公司',
|
icon: 'none'
|
})
|
}
|
},
|
// 取消
|
Cancel() {
|
wx.navigateBack({
|
delta: 0,
|
})
|
},
|
// 提交 (稍作调整)
|
Yes() {
|
var data = {
|
_Reported_User: wx.getStorageSync('user').pk_User,
|
_fk_Management: this.data.firstallArr[this.data.index1] ? this.data.firstallArr[this.data.index1].pk_Management : '',
|
_FirstCompanyId: this.data.allarr[this.data.index2] ? this.data.allarr[this.data.index2].pk_Company : '',
|
_SecondCompanyId: this.data.lastarr[this.data.index3] ? this.data.lastarr[this.data.index3].pk_Company : '',
|
_Reported_Question: this.data.shangbao,
|
Dispost_Question: this.data.Dispost_Question,//派单审核意见
|
_Reported_Address: this.data.detailedaddress,
|
_Reported_Remark: this.data.Reported_Remark ? '安全问题' : '',
|
Tag: this.data.listid,
|
_Reported_lnglat: this.data.locmap.latitude + ',' + this.data.locmap.longitude,
|
_fk_Role_Type: this.data.youkecenter[this.data.youkeindex] ? this.data.youkecenter[this.data.youkeindex].pk_TypeId : '',
|
token: wx.getStorageSync('token')
|
}
|
// console.log(this.data.imageUrl[0])
|
console.log(data)
|
switch ('') {
|
case data._fk_Management:
|
// console.log('评定项目为空')
|
wx.showToast({
|
title: '未选择评定项目',
|
icon: 'none'
|
})
|
break;
|
// case data._FirstCompanyId:
|
// // console.log('公司名称为空')
|
// wx.showToast({
|
// title: '未选择一级单位',
|
// icon: 'none'
|
// })
|
// break;
|
// case data._SecondCompanyId:
|
// // console.log('公司项目为空')
|
// wx.showToast({
|
// title: '未选择二级单位',
|
// icon: 'none'
|
// })
|
// break;
|
case data._Reported_Question:
|
wx.showToast({
|
title: '未填写上报问题',
|
icon: 'none'
|
})
|
break;
|
case data._fk_Role_Type:
|
// console.log('公司项目为空')
|
wx.showToast({
|
title: '未选择归属游客中心',
|
icon: 'none'
|
})
|
break;
|
default:
|
wx.showLoading({
|
title: '提交中',
|
})
|
// 判断是否传图片文件
|
if (this.data.imageUrl) {
|
wx.uploadFile({
|
filePath: this.data.imageUrl[0],
|
name: 'upload',
|
header: {
|
'content-type': 'multipart/form-data'
|
},
|
formData: data,
|
url: 'http://101.133.134.71:9002/CheckEdit/Post',
|
success: function (res) {
|
wx.hideLoading()
|
if (res.data) {
|
wx.showToast({
|
title: JSON.parse(res.data).Msg,
|
})
|
wx.navigateBack({
|
delta: 0,
|
})
|
} else {
|
wx.showToast({
|
title: JSON.parse(res.data).Msg,
|
})
|
}
|
},
|
fail: function (err) {
|
console.log(err)
|
}
|
})
|
} else {
|
wx.request({
|
url: 'http://101.133.134.71:9002/CheckEdit/Post',
|
data: data,
|
success: (res) => {
|
if (res.data) {
|
wx.showToast({
|
title: res.data.Msg,
|
})
|
wx.navigateBack({
|
delta: 0,
|
})
|
} else {
|
wx.showToast({
|
title: res.data.Msg,
|
})
|
}
|
}
|
})
|
}
|
break;
|
}
|
},
|
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function () {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage: function () {
|
|
}
|
})
|