|
@@ -5,13 +5,22 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
shr.custom.WaterPowerMeterReadingEdit.superClass.initalizeDOM.call(this);
|
|
shr.custom.WaterPowerMeterReadingEdit.superClass.initalizeDOM.call(this);
|
|
|
_self.getLastMonth();
|
|
_self.getLastMonth();
|
|
|
_self.changeAction()
|
|
_self.changeAction()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// $('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
// $('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
|
// $('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
// $('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
|
var calcInterval = $('#calcInterval').shrCheckbox('getValue');//是否取消自动计算当月水电
|
|
var calcInterval = $('#calcInterval').shrCheckbox('getValue');//是否取消自动计算当月水电
|
|
|
if (calcInterval != true) {
|
|
if (calcInterval != true) {
|
|
|
- _self.getThisMonthWaterPowerTonsAction();
|
|
|
|
|
$('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
$('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
|
$('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
$('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
|
|
|
+ $('#waterBaseRead').shrTextField('option','required',true);
|
|
|
|
|
+ $('#elecBaseRead').shrTextField('option','required',true);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $('#waterBaseRead').shrTextField('option','required',false);
|
|
|
|
|
+ $('#elecBaseRead').shrTextField('option','required',false);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
@@ -20,9 +29,10 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
saveAction: function (event) {
|
|
saveAction: function (event) {
|
|
|
var _self = this;
|
|
var _self = this;
|
|
|
if (_self.validate() && _self.verify()) {
|
|
if (_self.validate() && _self.verify()) {
|
|
|
- if (_self.getThisMonthWaterPowerTonsAction()) {
|
|
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
_self.doSave(event, 'save');
|
|
_self.doSave(event, 'save');
|
|
|
- };
|
|
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
if (_self != top) {// in iframe
|
|
if (_self != top) {// in iframe
|
|
|
shr.setIframeHeight(window.name);
|
|
shr.setIframeHeight(window.name);
|
|
@@ -42,64 +52,86 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计算当月水电
|
|
|
|
|
+ * 20251125
|
|
|
|
|
+ */
|
|
|
|
|
+ calHydropower(){
|
|
|
|
|
+ var calcInterval = $('#calcInterval').shrCheckbox('getValue');//是否取消自动计算当月水电
|
|
|
|
|
+ if (calcInterval == 'false' || calcInterval == false) {
|
|
|
|
|
+ var totalWaterTons = $("#totalWaterTons").val(); //本次水表读数(吨)
|
|
|
|
|
+ var totalElecDegrees = $("#totalElecDegrees").val(); //本次电表读数
|
|
|
|
|
+ var waterBaseRead = $("#waterBaseRead").val(); //水基准读数
|
|
|
|
|
+ var elecBaseRead = $("#elecBaseRead").val(); //电基准读数
|
|
|
|
|
+ // 直接转换(省略封装函数,适合确定变量是数字字符串的场景)
|
|
|
|
|
+ const totalWaterTonsNum = Number(totalWaterTons) || 0;
|
|
|
|
|
+ const waterBaseReadNum = Number(waterBaseRead) || 0;
|
|
|
|
|
+ const totalElecDegreesNum = Number(totalElecDegrees) || 0;
|
|
|
|
|
+ const elecBaseReadNum = Number(elecBaseRead) || 0;
|
|
|
|
|
+
|
|
|
|
|
+ // 计算逻辑不变
|
|
|
|
|
+ const waterVal = totalWaterTonsNum - waterBaseReadNum >= 0
|
|
|
|
|
+ ? totalWaterTonsNum - waterBaseReadNum
|
|
|
|
|
+ : totalWaterTonsNum + 100000 - waterBaseReadNum;
|
|
|
|
|
+
|
|
|
|
|
+ const elecVal = totalElecDegreesNum - elecBaseReadNum >= 0
|
|
|
|
|
+ ? totalElecDegreesNum - elecBaseReadNum
|
|
|
|
|
+ : totalElecDegreesNum + 100000 - elecBaseReadNum;
|
|
|
|
|
+ $('#curMonthWater').shrTextField('setValue',waterVal );//或者设为enable disable
|
|
|
|
|
+ //当月电度数
|
|
|
|
|
+ $('#curMonthElecDegrees').shrTextField('setValue',elecVal );//或者设为enable disable
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 监听事件
|
|
* 监听事件
|
|
|
*/
|
|
*/
|
|
|
changeAction() {
|
|
changeAction() {
|
|
|
var _self = this;
|
|
var _self = this;
|
|
|
|
|
+ $('#waterBaseRead').change(function () {
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ $('#elecBaseRead').change(function () {
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
$('#dormitory').shrPromptBox('option', {
|
|
$('#dormitory').shrPromptBox('option', {
|
|
|
onchange: function (e, value) {
|
|
onchange: function (e, value) {
|
|
|
var data = value.current || [];
|
|
var data = value.current || [];
|
|
|
var number = data.number;
|
|
var number = data.number;
|
|
|
$("#dormNumber").shrTextField('setValue', number);
|
|
$("#dormNumber").shrTextField('setValue', number);
|
|
|
|
|
+ _self.getLastWaterAndEleVal(data);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
//用水总吨数监听事件
|
|
//用水总吨数监听事件
|
|
|
$('#totalWaterTons').change(function () {
|
|
$('#totalWaterTons').change(function () {
|
|
|
- _self.getThisMonthWaterPowerTonsAction();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
//用电总度数监听事件
|
|
//用电总度数监听事件
|
|
|
$('#totalElecDegrees').change(function () {
|
|
$('#totalElecDegrees').change(function () {
|
|
|
- _self.getThisMonthWaterPowerTonsAction();
|
|
|
|
|
- // var years = $("#years").val(); //年月
|
|
|
|
|
- // var totalWaterTons = $("#totalWaterTons").val();//用水总吨数
|
|
|
|
|
- // var totalElecDegrees = $("#totalElecDegrees").val(); //用电总度数
|
|
|
|
|
- // var dormNumber = $("#dormNumber").val();//宿舍编码
|
|
|
|
|
- // var calcInterval = $('#calcInterval').shrCheckbox('getValue');//是否取消自动计算当月水电
|
|
|
|
|
- // if (calcInterval == false) {
|
|
|
|
|
-
|
|
|
|
|
- // if (years == null || dormNumber == "") {
|
|
|
|
|
- // shr.showError({
|
|
|
|
|
- // message: "请先填写宿舍!!"
|
|
|
|
|
- // });
|
|
|
|
|
- // return;
|
|
|
|
|
- // }
|
|
|
|
|
- // _self.remoteCall({
|
|
|
|
|
- // type: "post",
|
|
|
|
|
- // method: "getThisMonthWaterPowerTons",
|
|
|
|
|
- // param: {
|
|
|
|
|
- // years: years,
|
|
|
|
|
- // totalWaterTons: totalWaterTons,
|
|
|
|
|
- // totalElecDegrees: totalElecDegrees,
|
|
|
|
|
- // dormNumber: dormNumber,
|
|
|
|
|
- // calcInterval: calcInterval,
|
|
|
|
|
- // },
|
|
|
|
|
- // success: function (data) {
|
|
|
|
|
- // // $("#curMonthWater").shrTextField('setValue', data.curMonthWater);
|
|
|
|
|
- // $("#curMonthElecDegrees").shrTextField('setValue', data.curMonthElecDegrees);
|
|
|
|
|
- // console.log(data);
|
|
|
|
|
- // }, error: function (response) {
|
|
|
|
|
- // shr.showError({
|
|
|
|
|
- // message: response
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
- // } else {
|
|
|
|
|
- // $("#curMonthElecDegrees").shrTextField('setValue', null);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ _self.getField("years").shrDateTimePicker("onChange",function(){
|
|
|
|
|
+ _self.getLastWaterAndEleVal();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//是否取消自动计算当月水电
|
|
//是否取消自动计算当月水电
|
|
|
$('#calcInterval').change(function () {
|
|
$('#calcInterval').change(function () {
|
|
|
$('#curMonthWater').shrTextField('enable');//或者设为enable disable
|
|
$('#curMonthWater').shrTextField('enable');//或者设为enable disable
|
|
@@ -108,15 +140,22 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
if (calcInterval == true) {
|
|
if (calcInterval == true) {
|
|
|
$("#curMonthWater").shrTextField('setValue', null);
|
|
$("#curMonthWater").shrTextField('setValue', null);
|
|
|
$("#curMonthElecDegrees").shrTextField('setValue', null);
|
|
$("#curMonthElecDegrees").shrTextField('setValue', null);
|
|
|
-
|
|
|
|
|
|
|
+ $('#waterBaseRead').shrTextField('option','required',false);
|
|
|
|
|
+ $('#elecBaseRead').shrTextField('option','required',false);
|
|
|
} else {
|
|
} else {
|
|
|
- _self.getThisMonthWaterPowerTonsAction();
|
|
|
|
|
|
|
+ //计算本次用水电数
|
|
|
|
|
+ _self.calHydropower();
|
|
|
$('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
$('#curMonthWater').shrTextField('disable');//或者设为enable disable
|
|
|
$('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
$('#curMonthElecDegrees').shrTextField('disable');//或者设为enable disable
|
|
|
|
|
+ $('#waterBaseRead').shrTextField('option', 'required', true);
|
|
|
|
|
+ $('#elecBaseRead').shrTextField('option','required',true);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //作废
|
|
|
getThisMonthWaterPowerTonsAction() {
|
|
getThisMonthWaterPowerTonsAction() {
|
|
|
var years = $("#years").val(); //年月
|
|
var years = $("#years").val(); //年月
|
|
|
var totalWaterTons = $("#totalWaterTons").val();//用水总吨数
|
|
var totalWaterTons = $("#totalWaterTons").val();//用水总吨数
|
|
@@ -132,18 +171,16 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
}
|
|
}
|
|
|
_self.remoteCall({
|
|
_self.remoteCall({
|
|
|
type: "post",
|
|
type: "post",
|
|
|
- method: "getThisMonthWaterPowerTons",
|
|
|
|
|
|
|
+ method: "getLastMWaterPower",
|
|
|
param: {
|
|
param: {
|
|
|
years: years,
|
|
years: years,
|
|
|
- totalWaterTons: totalWaterTons,
|
|
|
|
|
- totalElecDegrees: totalElecDegrees,
|
|
|
|
|
dormNumber: dormNumber,
|
|
dormNumber: dormNumber,
|
|
|
- calcInterval: calcInterval,
|
|
|
|
|
},
|
|
},
|
|
|
async: false, // 设置为同步请求
|
|
async: false, // 设置为同步请求
|
|
|
success: function (data) {
|
|
success: function (data) {
|
|
|
- $("#curMonthWater").shrTextField('setValue', data.curMonthWater);
|
|
|
|
|
- $("#curMonthElecDegrees").shrTextField('setValue', data.curMonthElecDegrees);
|
|
|
|
|
|
|
+ $("#lastMeterDate").shrTextField('setValue', data.createDate);
|
|
|
|
|
+ $("#lastWaterVal").shrTextField('setValue', data.water);
|
|
|
|
|
+ $("#lastEleVal").shrTextField('setValue', data.power);
|
|
|
console.log(data);
|
|
console.log(data);
|
|
|
}, error: function (response) {
|
|
}, error: function (response) {
|
|
|
shr.showError({
|
|
shr.showError({
|
|
@@ -154,5 +191,52 @@ shr.defineClass("shr.custom.WaterPowerMeterReadingEdit", shr.framework.Edit, {
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ ,getLastWaterAndEleVal(data) {
|
|
|
|
|
+ var years = $("#years").val(); //年月
|
|
|
|
|
+ var dormNumber = "";
|
|
|
|
|
+ if(data == null || data == undefined){
|
|
|
|
|
+ dormNumber = $("#dormitory").shrPromptBox('getValue').id;//宿舍编码
|
|
|
|
|
+ }else{
|
|
|
|
|
+ dormNumber = data.id;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (years == null || dormNumber == "") {
|
|
|
|
|
+ shr.showError({
|
|
|
|
|
+ message: "请先填写宿舍!"
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ _self.remoteCall({
|
|
|
|
|
+ type: "post",
|
|
|
|
|
+ method: "getLastMWaterPower",
|
|
|
|
|
+ param: {
|
|
|
|
|
+ years: years,
|
|
|
|
|
+ dormNumber: dormNumber
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ async: false, // 设置为同步请求
|
|
|
|
|
+ success: function (data) {
|
|
|
|
|
+ if(data){
|
|
|
|
|
+ $("#waterBaseRead").shrTextField('setValue', data.water);
|
|
|
|
|
+ $("#elecBaseRead").shrTextField('setValue', data.power);
|
|
|
|
|
+ $("#lastMeterDate").shrDateTimePicker('setValue', data.createDate);
|
|
|
|
|
+ $("#lastWaterVal").shrTextField('setValue', data.water);
|
|
|
|
|
+ $("#lastEleVal").shrTextField('setValue', data.power);
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(data);
|
|
|
|
|
+ }, error: function (response) {
|
|
|
|
|
+ shr.showError({
|
|
|
|
|
+ message: response
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
|
|
|