(function (vc, vm) { vc.extends({ data: { editInspectionPointInfo: { inspectionId: '', pointObjId: '', pointObjType: '', pointObjTypes: [], pointObjName: '', inspectionName: '', communityId: '', remark: '', items: [], itemId: '', nfcCode: '', lng:'', lat:'' } }, _initMethod: function () { }, _initEvent: function () { vc.on('editInspectionPoint', 'openEditInspectionPointModal', function (_params) { $that.refreshEditInspectionPointInfo(); //与字典表关联 vc.getDict('inspection_point', "point_obj_type", function (_data) { $that.editInspectionPointInfo.pointObjTypes = _data; }); $('#editInspectionPointModel').modal('show'); vc.copyObject(_params, $that.editInspectionPointInfo); //传输数据到machineSelect2组件 if ($that.editInspectionPointInfo.pointObjType == '1001') { //设备时设置 vc.emit('editInspectionPoint', 'machineSelect2', 'setMachine', { machineId: $that.editInspectionPointInfo.pointObjId, machineName: $that.editInspectionPointInfo.pointObjName, }); } $that.editInspectionPointInfo.communityId = vc.getCurrentCommunity().communityId; $that._listEditInspectionItems(); setTimeout(function(){ $that.editInspectionPointInfo.element = 'editInspectionPointMap'; vc.emit('selectMapPos', 'init',$that.editInspectionPointInfo); },1000) }); vc.on("editInspectionPointInfo", "notify", function (_param) { if (_param.hasOwnProperty("machineId") && $that.editInspectionPointInfo.pointObjType == '1001') { $that.editInspectionPointInfo.pointObjId = _param.machineId; $that.editInspectionPointInfo.pointObjName = _param.machineName; } }); }, methods: { editInspectionPointValidate: function () { return vc.validate.validate({ editInspectionPointInfo: $that.editInspectionPointInfo }, { 'editInspectionPointInfo.inspectionName': [{ limit: "required", param: "", errInfo: "巡检点名称不能为空" }, { limit: "maxLength", param: "100", errInfo: "巡检点名称不能超过100位" }], 'editInspectionPointInfo.pointObjId': [{ limit: "required", param: "", errInfo: "位置信息不能为空" }], 'editInspectionPointInfo.pointObjType': [{ limit: "required", param: "", errInfo: "巡检类型不能为空" }], 'editInspectionPointInfo.pointObjName': [{ limit: "required", param: "", errInfo: "巡检位置不能为空" }], 'editInspectionPointInfo.itemId': [{ limit: "required", param: "", errInfo: "巡检项目不能为空" }], 'editInspectionPointInfo.remark': [{ limit: "maxLength", param: "200", errInfo: "备注信息不能超过200位" }], 'editInspectionPointInfo.inspectionId': [{ limit: "required", param: "", errInfo: "巡检点ID不能为空" }] }); }, _pointObjTypeChange: function () { let type = $that.editInspectionPointInfo.pointObjType; $that.editInspectionPointInfo.pointObjId = ''; $that.editInspectionPointInfo.pointObjName = ''; if (type == '1001') { vc.emit('editInspectionPoint', 'machineSelect2', 'setMachine', { machineId: $that.editInspectionPointInfo.pointObjId, machineName: '必填,请选择设备', }); } }, editInspectionPoint: function () { if ($that.editInspectionPointInfo.pointObjType == '2002') { $that.editInspectionPointInfo.pointObjId = '-1'; } if (!$that.editInspectionPointValidate()) { vc.toast(vc.validate.errInfo); return; } vc.http.apiPost( '/inspectionPoint.updateInspectionPoint', JSON.stringify($that.editInspectionPointInfo), { emulateJSON: true }, function (json, res) { let _json = JSON.parse(json); if (_json.code == 0) { //关闭model $('#editInspectionPointModel').modal('hide'); vc.emit('inspectionPoint', 'listInspectionPoint', {}); vc.toast("修改成功"); return; } else { vc.toast(_json.msg); } }, function (errInfo, error) { console.log('请求失败处理'); vc.toast(errInfo); }); }, _listEditInspectionItems: function (_page, _rows) { let param = { params: { page: 1, row: 100, communityId: vc.getCurrentCommunity().communityId } }; //发送get请求 vc.http.apiGet('/inspectionItem.listInspectionItem', param, function (json, res) { let _inspectionItemManageInfo = JSON.parse(json); $that.editInspectionPointInfo.items = _inspectionItemManageInfo.data; }, function (errInfo, error) { console.log('请求失败处理'); } ); }, refreshEditInspectionPointInfo: function () { $that.editInspectionPointInfo = { inspectionId: '', pointObjId: '', pointObjType: '', pointObjTypes: [], pointObjName: '', inspectionName: '', communityId: '', remark: '', items: [], itemId: '', nfcCode: '', lng:'', lat:'' } }, } }); })(window.vc, window.$that);