import { Query, QueryTask, QueryType, EditTask, EditType, Operator, CellsysType, QueryMG, ThirdpartyObjectType } from './cellsysUtil.js'; import { CellsysExtensionRecord } from './cellsysExtension.js'; import CellsysElementType from './cellsysElementType'; import { CellsysLineStyle } from './cellsysStyle'; import { PublishTarget } from './cellsysEnum'; class CellsysLineType extends CellsysElementType { constructor(params) { super(params); this.cellsysType = CellsysType.LineType; if (!params) { params = {}; } this.orgId = params.org_id; this.id = params.id; this.name = params.name; this.style = params.style ? params.style : CellsysLineStyle.getDefaultStyle(); this.description = params.description; this.orgName = params.org_name; 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; } getIcon() { return this.style ? this.style.icon : null; } getColor() { return this.style ? this.style.color : '#000000'; } getFillColor() { return this.style ? this.style.strokeColor : null; } getFillOpacity() { return this.style ? this.style.fillOpacity : null; } getCssStyle() { // return formatterLineStyle(this.style); if (this.style) { return { 'border-color': this.style.strokeColor || null, opacity: this.style.strokeOpacity || null, 'border-top-width': (this.style.weight || 0) + 'px', 'border-top-style': this.style.dashArray == '10,10' ? 'dashed' : 'solid', cursor: 'text', }; } return null; } //发布功能 setPublish(publishStatus, range, ids, isEditable, remark) { let editTask = new EditTask(EditType.LinePublish); editTask.addParam('_id', this.id); editTask.addParam("_fence_line_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', '=', 3); 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.LineLock); editTask.addParam('_id', params.id); editTask.addParam('_is_unlock', params.isUnlock); return editTask.execute(); } } export default CellsysLineType;