|
@@ -1,4 +1,6 @@
|
|
// component/teacher/teacherFault/teacherFault.ts
|
|
// component/teacher/teacherFault/teacherFault.ts
|
|
|
|
+import { ConstsData } from "../../../utils/const"
|
|
|
|
+import { httpUtil } from "../../../utils/restful";
|
|
Component({
|
|
Component({
|
|
/**
|
|
/**
|
|
* 组件的属性列表
|
|
* 组件的属性列表
|
|
@@ -15,18 +17,51 @@ Component({
|
|
pageState: 0,
|
|
pageState: 0,
|
|
pageStateText: ['故障报修', '报修记录'],
|
|
pageStateText: ['故障报修', '报修记录'],
|
|
//故障报修界面所用数据
|
|
//故障报修界面所用数据
|
|
- fault: ['紧急', '不紧急'],
|
|
|
|
|
|
+ fault: ['普通', '待查', '紧急'],
|
|
faultIndex: 0,
|
|
faultIndex: 0,
|
|
- region: ['北京市', '北京市', '海淀区'],
|
|
|
|
- schoolArray: ['中国', '美国', '巴西', '日本'],
|
|
|
|
|
|
+ regionOne: Array<String>(),
|
|
|
|
+ regionTwo: Array<String>(),
|
|
|
|
+ regionThree: Array<String>(),
|
|
|
|
+ regionOneIndex: 0,
|
|
|
|
+ regionTwoIndex: 0,
|
|
|
|
+ regionThreeIndex: 0,
|
|
|
|
+ region: [
|
|
|
|
+ Array<String>(),
|
|
|
|
+ Array<String>(),
|
|
|
|
+ Array<String>()
|
|
|
|
+ ],
|
|
|
|
+ regionIndex: [0, 0, 0],
|
|
|
|
+ schoolArray: [['暂无学校']],
|
|
schoolIndex: 0,
|
|
schoolIndex: 0,
|
|
- classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
|
|
|
|
|
|
+ classArray: ['暂无班级'],
|
|
classIndex: 0,
|
|
classIndex: 0,
|
|
|
|
+ provinceValue: '',//省份value
|
|
|
|
+ regionValue: '',//地区value
|
|
|
|
+ cityValue: '',
|
|
|
|
+ schoolData: [{ 'id': '' }],
|
|
|
|
+ schoolId: '',
|
|
|
|
+ classData: [{ 'id': '' }],
|
|
|
|
+ classId: '',
|
|
|
|
+ initFirst: true,
|
|
deviceId: '',
|
|
deviceId: '',
|
|
- faultText: ""
|
|
|
|
|
|
+ describe: ""
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ lifetimes: {
|
|
|
|
+ attached: function () {
|
|
|
|
+ // 在组件实例被从页面节点树添加时执行
|
|
|
|
+
|
|
|
|
+ this.changeOrganizeInfo();
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ detached: function () {
|
|
|
|
+ // 在组件实例被从页面节点树移除时执行
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 组件的方法列表
|
|
* 组件的方法列表
|
|
*/
|
|
*/
|
|
@@ -48,53 +83,215 @@ Component({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- //选择地区回调
|
|
|
|
- bindRegionChange: function (event: any) {
|
|
|
|
|
|
+
|
|
|
|
+ changeOrganizeInfo: function () {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //设置名字
|
|
|
|
+ this.setData({
|
|
|
|
+ userName: ConstsData.AppData.myInfoData.name
|
|
|
|
+ })
|
|
|
|
+ //切换地区
|
|
|
|
+ this.setData({
|
|
|
|
+ regionOne: [],
|
|
|
|
+ regionTwo: [],
|
|
|
|
+ regionThree: []
|
|
|
|
+ })
|
|
|
|
+ ConstsData.AppData.organizeInfo.data.children.forEach((item, index) => {
|
|
|
|
+ if (this.data.initFirst) {
|
|
|
|
+ if (item.value == ConstsData.AppData.myInfoData.province) {
|
|
|
|
+ //如果是当前的
|
|
|
|
+ this.setData({
|
|
|
|
+ regionOneIndex: index
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.data.regionOne.push(item.title)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item, index) => {
|
|
|
|
+ if (this.data.initFirst) {
|
|
|
|
+ if (item.value == ConstsData.AppData.myInfoData.city) {
|
|
|
|
+ this.setData({
|
|
|
|
+ regionTwoIndex: index
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.data.regionTwo.push(item.title)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item, index) => {
|
|
|
|
+ if (this.data.initFirst) {
|
|
|
|
+ if (item.value == ConstsData.AppData.myInfoData.region) {
|
|
|
|
+ this.setData({
|
|
|
|
+ regionThreeIndex: index
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.data.regionThree.push(item.title)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
- region: event.detail.value
|
|
|
|
|
|
+ region: [this.data.regionOne, this.data.regionTwo, this.data.regionThree],
|
|
|
|
+ regionIndex: [this.data.regionOneIndex, this.data.regionTwoIndex, this.data.regionThreeIndex],
|
|
|
|
+ provinceValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].value.toString(),
|
|
|
|
+ cityValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].value.toString(),
|
|
|
|
+ regionValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children[this.data.regionThreeIndex].value.toString(),
|
|
|
|
+ initFirst: false
|
|
|
|
+
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //切换学校
|
|
|
|
+ this.changeSchool();
|
|
|
|
+
|
|
},
|
|
},
|
|
- //选择学校回调
|
|
|
|
- bindSchoolPicker: function (event: any) {
|
|
|
|
- let newArray;
|
|
|
|
- switch (Number(event.detail.value)) {
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //查询学校
|
|
|
|
+ changeSchool: function () {
|
|
|
|
+
|
|
|
|
+ //查询学校
|
|
|
|
+ let params = {
|
|
|
|
+ city: this.data.cityValue,
|
|
|
|
+ province: this.data.provinceValue,
|
|
|
|
+ region: this.data.regionValue,
|
|
|
|
+ type: 1,
|
|
|
|
+ }
|
|
|
|
+ httpUtil.wxGet(httpUtil.interfaces.getSchoolOrClass, params).then((res: any) => {
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ schoolArray: [],
|
|
|
|
+ schoolIndex: 0,
|
|
|
|
+ schoolData: res.data.data,
|
|
|
|
+ schoolId: res.data.data[0].id
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ let newArray: string[] = [];
|
|
|
|
+ res.data.data.forEach((element, index) => {
|
|
|
|
+ if (ConstsData.AppData.myInfoData.schoolId == element.id) {
|
|
|
|
+ this.setData({
|
|
|
|
+ schoolIndex: index,
|
|
|
|
+ schoolId: this.data.schoolData[index].id
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ newArray.push(element.title)
|
|
|
|
+ });
|
|
|
|
+ this.data.schoolArray.push(newArray)
|
|
|
|
+ this.setData({
|
|
|
|
+ schoolArray: this.data.schoolArray
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //切换班级
|
|
|
|
+ this.changeClass()
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ console.log("查询学校error:", res)
|
|
|
|
+ this.setData({
|
|
|
|
+ schoolArray: [['暂无学校']],
|
|
|
|
+ schoolId: '',
|
|
|
|
+ classArray: ['暂无班级'],
|
|
|
|
+ classId: ''
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //查询班级
|
|
|
|
+ changeClass: function () {
|
|
|
|
+ let params = {
|
|
|
|
+ "city": this.data.cityValue,
|
|
|
|
+ "father": this.data.schoolId,//学校ID
|
|
|
|
+ "province": this.data.provinceValue,
|
|
|
|
+ "region": this.data.regionValue,
|
|
|
|
+ "type": 2,
|
|
|
|
+ }
|
|
|
|
+ httpUtil.wxGet(httpUtil.interfaces.getSchoolOrClass, params).then((res: any) => {
|
|
|
|
+ this.setData({
|
|
|
|
+ classArray: [],
|
|
|
|
+ classIndex: 0
|
|
|
|
+ })
|
|
|
|
+ this.setData({
|
|
|
|
+ classData: res.data.data,
|
|
|
|
+ classId: res.data.data[0].id
|
|
|
|
+ })
|
|
|
|
+ console.log("classData:", this.data.classData)
|
|
|
|
+ res.data.data.forEach((element: { id: number; title: string; }, index: number) => {
|
|
|
|
+ if (element.id == ConstsData.AppData.myInfoData.classId) {
|
|
|
|
+ this.setData({
|
|
|
|
+ classIndex: index,
|
|
|
|
+ classId: res.data.data[index].id
|
|
|
|
+ })
|
|
|
|
+ console.log("this.data.classIndex:", this.data.classIndex)
|
|
|
|
+ }
|
|
|
|
+ this.data.classArray.push(element.title)
|
|
|
|
+ });
|
|
|
|
+ this.setData({
|
|
|
|
+ classArray: this.data.classArray,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ console.log("查询班级error:", res)
|
|
|
|
+ this.setData({
|
|
|
|
+ classArray: ['暂无班级'],
|
|
|
|
+ classId: ''
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ bindMultiPickerColumnChange: function (event: any) {
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ switch (Number(event.detail.column)) {
|
|
case 0:
|
|
case 0:
|
|
- newArray = ["一", "二", "三"];
|
|
|
|
|
|
+ //代表第一列
|
|
this.setData({
|
|
this.setData({
|
|
- classArray: newArray,
|
|
|
|
- classIndex: 0
|
|
|
|
|
|
+ regionOneIndex: event.detail.value,
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- newArray = ["4", "5", "6"];
|
|
|
|
|
|
+ //代表第二列
|
|
this.setData({
|
|
this.setData({
|
|
- classArray: newArray,
|
|
|
|
- classIndex: 0
|
|
|
|
|
|
+ regionTwoIndex: event.detail.value,
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
- newArray = ["as", "ad", "af"];
|
|
|
|
|
|
+ //代表第三列
|
|
this.setData({
|
|
this.setData({
|
|
- classArray: newArray,
|
|
|
|
- classIndex: 0
|
|
|
|
- })
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- newArray = ["b1", "b2", "b3"];
|
|
|
|
- this.setData({
|
|
|
|
- classArray: newArray,
|
|
|
|
- classIndex: 0
|
|
|
|
|
|
+ regionThreeIndex: event.detail.value
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ this.changeOrganizeInfo();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ bindRegionChange: function (event: any) {
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ regionIndex: event.detail.value
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ bindSchoolPicker: function (event: any) {
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
- schoolIndex: event.detail.value
|
|
|
|
|
|
+ schoolIndex: event.detail.value,
|
|
|
|
+ schoolId: this.data.schoolData[event.detail.value].id
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ this.changeClass();
|
|
|
|
+
|
|
},
|
|
},
|
|
- //选择班级回调
|
|
|
|
bindClssPicker: function (event: any) {
|
|
bindClssPicker: function (event: any) {
|
|
this.setData({
|
|
this.setData({
|
|
- classIndex: event.detail.value
|
|
|
|
|
|
+ classIndex: event.detail.value,
|
|
|
|
+ classId: this.data.classData[event.detail.value].id
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
@@ -109,7 +306,7 @@ Component({
|
|
//获取故障描述输入
|
|
//获取故障描述输入
|
|
bindFaultText: function (event: any) {
|
|
bindFaultText: function (event: any) {
|
|
this.setData({
|
|
this.setData({
|
|
- faultText: event.detail.value
|
|
|
|
|
|
+ describe: event.detail.value
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
@@ -123,7 +320,7 @@ Component({
|
|
})
|
|
})
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (!this.data.faultText) {
|
|
|
|
|
|
+ if (!this.data.describe) {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '请输入故障描述',
|
|
title: '请输入故障描述',
|
|
icon: 'none', //如果要纯文本,不要icon,将值设为'none'
|
|
icon: 'none', //如果要纯文本,不要icon,将值设为'none'
|
|
@@ -133,31 +330,46 @@ Component({
|
|
}
|
|
}
|
|
|
|
|
|
let params = {
|
|
let params = {
|
|
- address: this.data.region[0] + "--" + this.data.region[1] + "--" + this.data.region[2],
|
|
|
|
- school: this.data.schoolArray[this.data.schoolIndex],
|
|
|
|
- class: this.data.classArray[this.data.classIndex],
|
|
|
|
|
|
+
|
|
|
|
+ city: this.data.cityValue,
|
|
|
|
+ classId: this.data.classId,
|
|
|
|
+ province: this.data.provinceValue,//省份
|
|
|
|
+ region: this.data.regionValue,//地区
|
|
|
|
+ schoolId: this.data.schoolId,
|
|
deviceId: this.data.deviceId,
|
|
deviceId: this.data.deviceId,
|
|
- fault: this.data.fault[this.data.faultIndex],
|
|
|
|
- faultText: this.data.faultText
|
|
|
|
|
|
+ faultLevel: this.data.faultIndex,
|
|
|
|
+ describe: this.data.describe,
|
|
|
|
+ userId: httpUtil.httpData.userId
|
|
|
|
|
|
}
|
|
}
|
|
- let that = this;
|
|
|
|
- wx.showModal({
|
|
|
|
- title: '',
|
|
|
|
- content: '报修成功',
|
|
|
|
- success: function (res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- console.log('点击确认回调')
|
|
|
|
- that.setData({
|
|
|
|
- pageState: 1
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- console.log('点击取消回调')
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ console.log("params:", params)
|
|
|
|
+ httpUtil.wxPost(httpUtil.interfaces.postDeviceFault, params).then((res: any) => {
|
|
|
|
+ console.log("设备报修成功:", res)
|
|
|
|
+ if (res.data.success) {
|
|
|
|
+ let that = this;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '',
|
|
|
|
+ content: '报修成功',
|
|
|
|
+ success: function (res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ console.log('点击确认回调')
|
|
|
|
+ that.setData({
|
|
|
|
+ pageState: 1
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ console.log('点击取消回调')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else { }
|
|
|
|
+
|
|
|
|
+ }).catch((res) => {
|
|
|
|
+ console.log("设备报修失败:", res)
|
|
})
|
|
})
|
|
|
|
|
|
- console.log("params:", params)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|