Files
PropertyDeployment/resources/Web/MicroCommunityWeb/html/pages/property/equipmentAccount/equipmentAccount.js
2025-12-09 20:22:03 +08:00

215 lines
10 KiB
JavaScript

/**
入驻园区
**/
(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROW = 10;
vc.extends({
data: {
equipmentAccountInfo: {
currentPage: '1',
equipmentAccounts: [],
total: 0,
records: 1,
moreCondition: false,
showFlag: false,
machineId: '',
machineIds: [],
conditions: {
machineName: '',
machineCode: '',
locationObjId: '',
releaseUserName: '',
state: '',
importanceLevel: '',
chargeOrgId: '',
firstEnableTime: '',
typeId: ''
},
useStatus: [],
importanceLevels: []
}
},
_initMethod: function () {
//与字典表关联
vc.getDict('equipment_account', "state", function (_data) {
$that.equipmentAccountInfo.useStatus = _data;
});
//与字典表关联
vc.getDict('equipment_account', "importance_level", function (_data) {
$that.equipmentAccountInfo.importanceLevels = _data;
});
//根据 参数查询相应数据
//$that._loadDataByParam();
// vc.emit('roomNewTree', 'openRoomTree', {
// callName: 'equipmentAccount'
// });
},
_initEvent: function () {
$that._listEquipmentAccounts(DEFAULT_PAGE, DEFAULT_ROW);
vc.on('equipmentAccount', 'switchType', function (_param) {
$that.equipmentAccountInfo.conditions.typeId = _param.typeId;
$that.equipmentAccountInfo.conditions.typeName = _param.typeName;
$that.equipmentAccountInfo.conditions.flag = 1;
$that.equipmentAccountInfo.conditions.locationObjId = '';
$that._listEquipmentAccounts(DEFAULT_PAGE, DEFAULT_ROW);
$that.equipmentAccountInfo.machineIds = [];
});
vc.on('equipmentAccount', 'changeRoom', function (_param) {
console.log("就是我呀", _param)
});
vc.on('equipmentAccount', 'listEquipmentAccounts', function (_param) {
$that.equipmentAccountInfo.machineIds = [];
$that.equipmentAccountInfo.conditions.locationObjId = '';
$that._listEquipmentAccounts($that.equipmentAccountInfo.currentPage, DEFAULT_ROW);
});
vc.on('equipmentAccount', 'loadData', function (_param) {
$that.equipmentAccountInfo.machineIds = [];
$that.equipmentAccountInfo.conditions.locationObjId = '';
$that._listEquipmentAccounts($that.equipmentAccountInfo.currentPage, DEFAULT_ROW);
});
vc.on('pagination', 'page_event', function (_currentPage) {
$that.equipmentAccountInfo.currentPage = _currentPage;
$that._listEquipmentAccounts(_currentPage, DEFAULT_ROW);
$that.equipmentAccountInfo.machineIds = [];
});
vc.on('equipmentAccount', 'selectAction', function (_id) {
$that.equipmentAccountInfo.machineIds = [];
$that.equipmentAccountInfo.conditions.typeId = '';
$that.equipmentAccountInfo.conditions.locationObjId = _id;
$that._listEquipmentAccounts($that.equipmentAccountInfo.currentPage, DEFAULT_ROW);
})
},
methods: {
_listEquipmentAccounts: function (_page, _row) {
$that.equipmentAccountInfo.conditions.page = _page;
$that.equipmentAccountInfo.conditions.row = _row;
$that.equipmentAccountInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
let param = {
params: JSON.parse(JSON.stringify($that.equipmentAccountInfo.conditions))
};
//发送get请求
vc.http.apiGet('/equipmentAccount.listEquipmentAccount',
param,
function (json, res) {
var _json = JSON.parse(json);
$that.equipmentAccountInfo.total = _json.total;
$that.equipmentAccountInfo.records = _json.records;
$that.equipmentAccountInfo.equipmentAccounts = _json.data;
vc.emit('pagination', 'init', {
total: $that.equipmentAccountInfo.records,
dataCount: $that.equipmentAccountInfo.total,
currentPage: _page
});
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_openAddEquipmentAccountModal: function () {
if (!$that.equipmentAccountInfo.conditions.typeId) {
vc.toast('请先选择设备分类');
return;
}
vc.jumpToPage('/#/pages/property/addEquipmentAccount?typeId=' + $that.equipmentAccountInfo.conditions.typeId)
},
_openEditEquipmentAccountModel: function (_equipmentAccount) {
vc.jumpToPage('/#/pages/property/editEquipmentAccount?machineId=' + _equipmentAccount.machineId);
},
_openChangeStateEquipmentModel: function (_equipmentAccount) {
vc.emit('changeStateEquipment', 'openChangeStateEquipmentModal', _equipmentAccount);
},
_openMoveEquipmentModel: function (_equipmentAccount) {
vc.emit('moveEquipment', 'openMoveEquipmentModal', _equipmentAccount);
},
_openEquipmentAccountDetail: function (_equipmentAccount) {
vc.jumpToPage('/#/pages/property/equipmentAccountDetail?machineId=' + _equipmentAccount.machineId)
},
_openDeleteEquipmentAccountModel: function (_equipmentAccount) {
vc.emit('deleteEquipmentAccount', 'openDeleteEquipmentAccountModal', _equipmentAccount);
},
_printEquipmentAccountInfoLabel: function (_equipmentAccount) {
vc.emit('printEquipmentAccount', 'openPrintEquipmentAccountModal', _equipmentAccount);
},
/**
* 新增打印功能,跳转打印页面
*/
_printEquipmentAccount: function (_equipmentAccount) {
window.open("/print.html#/pages/property/printEquipmentAccountLabel?machineId=" + _equipmentAccount.machineId)
},
// _openEquipmentAccountInfoModel: function (_equipmentAccount) {
// vc.emit('viewEquipmentAccount', 'openViewEquipmentAccountModal', _equipmentAccount);
// },
//查询
_queryEquipmentAccountMethod: function () {
$that._listEquipmentAccounts(DEFAULT_PAGE, DEFAULT_ROW);
},
//重置
_resetEquipmentAccountMethod: function () {
$that.equipmentAccountInfo.conditions.machineName = "";
$that.equipmentAccountInfo.conditions.machineCode = "";
$that.equipmentAccountInfo.conditions.state = "";
$that.equipmentAccountInfo.conditions.importanceLevel = "";
$that._listEquipmentAccounts(DEFAULT_PAGE, DEFAULT_ROW);
},
_exportEquipmentAccount: function () {
vc.jumpToPage('/callComponent/importExportEquipment/exportData?communityId=' + vc.getCurrentCommunity().communityId + "&pagePath=equipmentAccount" + "&typeId=" +
$that.equipmentAccountInfo.conditions.typeId + "&machineIds=" + $that.equipmentAccountInfo.machineIds);
},
_openImportEquipment: function () {
vc.emit('importEquipment', 'openImportEquipmentModal', {typeId: $that.equipmentAccountInfo.conditions.typeId})
},
_queryRoomMethod: function () {
$that._listEquipmentAccounts(DEFAULT_PAGE, DEFAULT_ROW);
},
_showFlag: function () {
if ($that.equipmentAccountInfo.showFlag) {
$that.equipmentAccountInfo.showFlag = false;
} else {
$that.equipmentAccountInfo.showFlag = true;
}
},
_moreCondition: function () {
if ($that.equipmentAccountInfo.moreCondition) {
$that.equipmentAccountInfo.moreCondition = false;
} else {
$that.equipmentAccountInfo.moreCondition = true;
}
},
checkAllEqu: 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.equipmentAccountInfo.machineIds.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
$that.equipmentAccountInfo.machineIds = [];
}
},
isCheckAll: function (e) {
let checkObj = document.querySelectorAll('.checkItem');
var count = 0;
for (var i = 0; i < checkObj.length; i++) {
if (checkObj[i].checked) {
count++;
}
}
if (checkObj.length == count) {
document.getElementById("check1").checked = true;
} else {
document.getElementById("check1").checked = false;
}
},
_printEquipmentAccounts: function () {
if ($that.equipmentAccountInfo.machineIds.length == 0) {
vc.toast('请先勾选设备');
return;
}
window.open("/print.html#/pages/property/printEquipmentAccountLabels?machineIds=" + $that.equipmentAccountInfo.machineIds)
},
}
});
})(window.vc);