/* * @Author: ag * @LastEditTime: 2021-11-16 12:56:14 * @LastEditors: ag * @Description: */ import CellsysElementType from './cellsysElementType'; import { CellsysMarkerStyle } from './cellsysStyle'; import { CellsysType, EditTask, EditType, Query, QueryTask, QueryType } from './cellsysUtil.js'; import { PublishTarget } from './cellsysEnum'; const _style = { name: '坐标', fillColor: '', fillOpacity: 1, rotate: 0, // 'data': '', 'type:': null, }; class CellsysMarkType extends CellsysElementType { constructor(params) { super(params); this.cellsysType = CellsysType.MarkerType; if (!params) { params = {}; } this.orgId = params.org_id || null; this.orgName = params.org_name || null; this.id = params.id || null; this.name = params.name || null; this.style = params.style ? params.style : CellsysMarkerStyle.getDefaultStyle(); this.description = params.description || null; this.action = params.action || 0; this.typeCount = params.type_count || 0; this.isPublish = params.is_publish || 0; } setId(value) { this.id = value; } setName(value) { this.name = value; } setDescription(value) { this.description = value; } setStyle(value) { this.style = value; } getStyle() { return this.style ? this.style : _style; } getData() { return this.style ? this.style.data : null; } getRotate() { return this.style ? this.style.rotate : 0; } getIcon() { return this.style ? this.style.icon : null; } getColor() { return this.style ? this.style.color : '#000000'; } getIconUrl() { return this.style ? this.style.path : null; } //发布功能 setPublish(publishStatus, range, ids, isEditable, remark) { let editTask = new EditTask(EditType.MarkerPublish); editTask.addParam('_id', this.id); editTask.addParam("_fence_point_type_name", this.name); editTask.addParam('_is_publish', PublishTarget[publishStatus]); editTask.addParam('_remark', remark); if (publishStatus !== "noPublish") { if (range === 1) { //发布到组织 editTask.addParam('_publish_org', ids); } else { editTask.addParam('_publish_group', ids); } editTask.addParam('_publish_range', range); } if (isEditable) { editTask.addParam('_is_update', 1); } else { editTask.addParam('_is_update', 0); } return editTask.execute(); } //查询协同数据发布记录列表 synergyDataPublishRecord(dataId, type) { let query = new Query(); query.setOrder({ create_time: 'desc' }); query.addFilter('data_type', '=', 1); query.setCurrPage(1); query.setPageSize(1); if (dataId) { query.addFilter('data_id', '=', dataId); } if (type) { query.addFilter('type', '=', type); } let queryTask = new QueryTask(QueryType.synergyDataPublishRecord, true); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { resolve(res); }) .catch((err) => { reject(err); }); }); } //锁定/解锁 setLock(params) { let editTask = new EditTask(EditType.MarkerLock); editTask.addParam('_id', params.id); editTask.addParam('_is_unlock', params.isUnlock); return editTask.execute(); } } export default CellsysMarkType;