mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 05:46:03 +08:00
优化巡检路线代码
This commit is contained in:
parent
34c9d794af
commit
a23d505a67
@ -0,0 +1,73 @@
|
||||
<div id="chooseInspectionRoutePointModel" class="modal fade" tabindex="-1" role="dialog"
|
||||
aria-labelledby="chooseInspectionRoutePointModelLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title" id="chooseInspectionRoutePointModelLabel">选择巡检点</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class=" row">
|
||||
<div class="col-lg-12">
|
||||
<div class="ibox ">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-7 m-b-xs">
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<div class="input-group">
|
||||
<input placeholder="输入巡检点名称" type="text"
|
||||
v-model="chooseInspectionRoutePointInfo.inspectionName"
|
||||
class="form-control form-control-sm">
|
||||
<span class="input-group-append">
|
||||
<button type="button" class="btn btn-sm btn-primary"
|
||||
v-on:click="queryPoints()">查询</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive" style="margin-top:15px">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
<input type="checkbox" class="i-checks " @click="checkAll($event)" id="quan">
|
||||
</th>
|
||||
<th class="text-center">巡检点ID</th>
|
||||
<th class="text-center">巡检点名称</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="inspectionPoint in chooseInspectionRoutePointInfo.points">
|
||||
<td class="text-center">
|
||||
<input type="checkbox" class="i-checks checkItem" v-bind:value="inspectionPoint.inspectionId" v-model="chooseInspectionRoutePointInfo.selectPoints" >
|
||||
</td>
|
||||
<td class="text-center">{{inspectionPoint.inspectionId}}</td>
|
||||
<td class="text-center">{{inspectionPoint.inspectionName}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- 分页 -->
|
||||
<vc:create namespace="chooseInspectionRoutePoint" name="paginationPlus"></vc:create>
|
||||
<div class="ibox-content" v-if="chooseInspectionRoutePointInfo.points.length > 0">
|
||||
|
||||
<button class="btn btn-primary float-right" type="button" v-on:click="_chooseInspectionRoutePoint()"><i
|
||||
class="fa fa-check"></i> 提交
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
|
||||
data-dismiss="modal">取消
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,142 @@
|
||||
(function(vc){
|
||||
var DEFAULT_ROWS =10;
|
||||
vc.extends({
|
||||
propTypes: {
|
||||
emitListener:vc.propTypes.string,
|
||||
emitFunction:vc.propTypes.string
|
||||
},
|
||||
data:{
|
||||
chooseInspectionRoutePointInfo:{
|
||||
points:[],
|
||||
inspectionName:'',
|
||||
inspectionRouteId:'',
|
||||
routeName:'',
|
||||
selectPoints:[]
|
||||
}
|
||||
},
|
||||
watch: { // 监视双向绑定的数据数组
|
||||
checkData: {
|
||||
handler(){ // 数据数组有变化将触发此函数
|
||||
if($that.chooseInspectionRoutePointInfo.selectPoints.length == $that.chooseInspectionRoutePointInfo.points.length){
|
||||
document.querySelector('#quan').checked = true;
|
||||
}else {
|
||||
document.querySelector('#quan').checked = false;
|
||||
}
|
||||
},
|
||||
deep: true // 深度监视
|
||||
}
|
||||
},
|
||||
_initMethod:function(){
|
||||
},
|
||||
_initEvent:function(){
|
||||
vc.on('chooseInspectionRoutePoint','openchooseInspectionRoutePointModal',function(_param){
|
||||
$that._refreshChooseInspectionRoutePointInfo();
|
||||
$('#chooseInspectionRoutePointModel').modal('show');
|
||||
vc.copyObject(_param,$that.chooseInspectionRoutePointInfo);
|
||||
$that._loadAllPointsInfo(1,10,'');
|
||||
});
|
||||
|
||||
vc.on('chooseInspectionRoutePoint','paginationPlus', 'page_event', function (_currentPage) {
|
||||
$that._loadAllPointsInfo(_currentPage, DEFAULT_ROWS);
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
_loadAllPointsInfo:function(_page,_row,_name){
|
||||
var param = {
|
||||
params:{
|
||||
page:_page,
|
||||
row:_row,
|
||||
name:_name,
|
||||
relationship:'0',
|
||||
inspectionRouteId:$that.chooseInspectionRoutePointInfo.inspectionRouteId,
|
||||
communityId:vc.getCurrentCommunity().communityId
|
||||
}
|
||||
};
|
||||
console.log('param',param);
|
||||
|
||||
//发送get请求
|
||||
vc.http.apiGet('inspectionPoint.listInspectionPoints',
|
||||
param,
|
||||
function(json){
|
||||
var _pointInfo = JSON.parse(json);
|
||||
$that.chooseInspectionRoutePointInfo.points = _pointInfo.inspectionPoints;
|
||||
vc.emit('chooseInspectionRoutePoint','paginationPlus', 'init', {
|
||||
total: _pointInfo.records,
|
||||
currentPage: _page
|
||||
});
|
||||
},function(){
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
_chooseInspectionRoutePoint:function(_org){
|
||||
var _selectPoints = $that.chooseInspectionRoutePointInfo.selectPoints;
|
||||
var _tmpPoints = $that.chooseInspectionRoutePointInfo.points;
|
||||
if(_selectPoints.length <1){
|
||||
vc.toast("请选择巡检点");
|
||||
return ;
|
||||
}
|
||||
var _points = [];
|
||||
for(var _selectIndex = 0 ;_selectIndex <_selectPoints.length ;_selectIndex ++){
|
||||
for(var _pointIndex =0; _pointIndex < _tmpPoints.length;_pointIndex++){
|
||||
if(_selectPoints[_selectIndex] == _tmpPoints[_pointIndex].inspectionId){
|
||||
_points.push({
|
||||
inspectionId:_tmpPoints[_pointIndex].inspectionId,
|
||||
inspectionName:_tmpPoints[_pointIndex].inspectionName
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
var _objData = {
|
||||
communityId:vc.getCurrentCommunity().communityId,
|
||||
inspectionRouteId:$that.chooseInspectionRoutePointInfo.inspectionRouteId,
|
||||
points:_points
|
||||
}
|
||||
vc.http.apiPost('inspectionRoute.saveInspectionRoutePoint',
|
||||
JSON.stringify(_objData),
|
||||
{
|
||||
emulateJSON: true
|
||||
},
|
||||
function(json,res){
|
||||
$('#chooseInspectionRoutePointModel').modal('hide');
|
||||
if(res.status == 200){
|
||||
vc.emit($props.emitListener,$props.emitFunction,{
|
||||
inspectionRouteId:$that.chooseInspectionRoutePointInfo.inspectionRouteId
|
||||
});
|
||||
return ;
|
||||
}
|
||||
vc.toast(json);
|
||||
},function(){
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
$('#chooseInspectionRoutePointModel').modal('hide');
|
||||
},
|
||||
queryPoints:function(){
|
||||
$that._loadAllPointsInfo(1,10,$that.chooseInspectionRoutePointInfo.inspectionName);
|
||||
},
|
||||
_refreshChooseInspectionRoutePointInfo:function(){
|
||||
$that.chooseInspectionRoutePointInfo={
|
||||
points:[],
|
||||
inspectionName:'',
|
||||
inspectionRouteId:'',
|
||||
routeName:'',
|
||||
selectPoints:[]
|
||||
};
|
||||
},
|
||||
checkAll:function(e){
|
||||
var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
|
||||
if(e.target.checked){ // 判定全选checkbox的勾选状态
|
||||
for(var i=0;i<checkObj.length;i++){
|
||||
if(!checkObj[i].checked){ // 将未勾选的checkbox选项push到绑定数组中
|
||||
$that.chooseInspectionRoutePointInfo.selectPoints.push(checkObj[i].value);
|
||||
}
|
||||
}
|
||||
}else { // 如果是去掉全选则清空checkbox选项绑定数组
|
||||
$that.chooseInspectionRoutePointInfo.selectPoints = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
})(window.vc);
|
||||
@ -60,4 +60,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<vc:create name="chooseInspectionRoutePoint"
|
||||
emitListener="inspectionRoutePointManage"
|
||||
emitFunction="listInspectionPoint"
|
||||
></vc:create>
|
||||
</div>
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
);
|
||||
},
|
||||
_openAddInspectionRoutePointModal:function(){
|
||||
vc.emit('addInspectionRoutePointRel','openAddInspectionPointModal',{});
|
||||
vc.emit('chooseInspectionRoutePoint','openchooseInspectionRoutePointModal',$that.inspectionRoutePointManageInfo);
|
||||
},
|
||||
_openDeleteInspectionRoutePointModel:function(_inspectionPoint){
|
||||
vc.emit('deleteInspectionRoutePointRel','openDeleteInspectionPointModal',_inspectionPoint);
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
@param _msg 提示内容
|
||||
@param _notAutoHide 是否需要自动隐藏
|
||||
**/
|
||||
vc.toast = function(_msg, _notAutoHide){
|
||||
vc.message = function(_msg, _notAutoHide){
|
||||
vm.$emit('message_openMessage',{msg:_msg});
|
||||
if(!_notAutoHide){
|
||||
vm.messageTimer();
|
||||
|
||||
@ -756,7 +756,7 @@
|
||||
}
|
||||
}, function (res) {
|
||||
try {
|
||||
if (res.status == 401) {
|
||||
if (res.status == 401 && res.headers.map["location"]) {
|
||||
let _header = res.headers.map;
|
||||
//console.log('res', res);
|
||||
window.location.href = _header['location'];
|
||||
@ -839,7 +839,7 @@
|
||||
}
|
||||
}, function (res) {
|
||||
try {
|
||||
if (res.status == 401) {
|
||||
if (res.status == 401 && res.headers.map["location"]) {
|
||||
let _header = res.headers.map;
|
||||
//console.log('res', res);
|
||||
window.location.href = _header['location'];
|
||||
@ -884,7 +884,7 @@
|
||||
}
|
||||
}, function (res) {
|
||||
try {
|
||||
if (res.status == 401) {
|
||||
if (res.status == 401 && res.headers.map["location"]) {
|
||||
let _header = res.headers.map;
|
||||
//console.log('res', res);
|
||||
window.location.href = _header['location'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user