212 lines
6.7 KiB
JavaScript
212 lines
6.7 KiB
JavaScript
![]() |
import {
|
|||
|
Query,
|
|||
|
QueryTask,
|
|||
|
QueryType,
|
|||
|
EditTask,
|
|||
|
EditType,
|
|||
|
Operator,
|
|||
|
CellsysType,
|
|||
|
} from './cellsysUtil.js';
|
|||
|
import { PublishTarget } from './cellsysEnum';
|
|||
|
import CellsysLayer from './cellsysLayer';
|
|||
|
import CellsysElementType from './cellsysElementType';
|
|||
|
|
|||
|
class CellsysLayerGroup extends CellsysElementType {
|
|||
|
constructor(params) {
|
|||
|
super(params);
|
|||
|
this.cellsysType = CellsysType.LayerGroup;
|
|||
|
if (!params) {
|
|||
|
params = {};
|
|||
|
}
|
|||
|
const options = params.options || { style: null };
|
|||
|
|
|||
|
this.id = params.id;
|
|||
|
this.name = params.name;
|
|||
|
this.description = params.description;
|
|||
|
this.orgId = params.org_id;
|
|||
|
this.orgName = params.org_name;
|
|||
|
this.typeCount = params.type_count;
|
|||
|
this.orgStatus = params.org_status;
|
|||
|
this.options = options;
|
|||
|
this.style = params.style;
|
|||
|
if (this.style) {
|
|||
|
//这里因为专题接口返回数据里出现style和options.style重复,在小达达的安排下和其他要素统一只取最外层style
|
|||
|
this.options['style'] = this.style;
|
|||
|
}
|
|||
|
this.layers = [];
|
|||
|
this.isPublish = params.is_publish || 0;
|
|||
|
this.createBy = params.create_by;
|
|||
|
this.publishRange = params.publish_range; //发布范围 0-群组 1-组织
|
|||
|
this.publishGroup = params.publish_group ? params.publish_group : []; //发布的群组
|
|||
|
this.isEditable = params.is_update === 1 ? true : false; //is_update表示是否允许其他人编辑 0-不允许 1-允许
|
|||
|
this.isUnlock = params.is_unlock; //是否未锁定,0-已锁定,1-未锁定
|
|||
|
this.tags = [];
|
|||
|
if (params.tag_name) {
|
|||
|
this.tags = params.tag_name.map((name) => {
|
|||
|
return { name: name };
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/* let creator = params.creator;
|
|||
|
this.creator = {
|
|||
|
memberId: null,
|
|||
|
name: null
|
|||
|
}
|
|||
|
if (creator) {
|
|||
|
this.creator = {
|
|||
|
memberId: creator.member_id,
|
|||
|
name: creator.name
|
|||
|
}
|
|||
|
}
|
|||
|
let updater = params.updater;
|
|||
|
this.updater = {
|
|||
|
memberId: null,
|
|||
|
name: null
|
|||
|
}
|
|||
|
if (updater) {
|
|||
|
this.updater = {
|
|||
|
memberId: updater.member_id,
|
|||
|
name: updater.name
|
|||
|
}
|
|||
|
}*/
|
|||
|
}
|
|||
|
|
|||
|
setId(value) {
|
|||
|
this.id = value;
|
|||
|
}
|
|||
|
|
|||
|
setName(value) {
|
|||
|
this.name = value;
|
|||
|
}
|
|||
|
|
|||
|
setDescription(value) {
|
|||
|
this.description = value;
|
|||
|
}
|
|||
|
|
|||
|
setLayers(arr) {
|
|||
|
this.layers = arr;
|
|||
|
}
|
|||
|
|
|||
|
/*旧的逻辑用法,没有将返回封装成cellsysLayer,懒得处理旧的业务逻辑故先保留*/
|
|||
|
queryLayersInfo() {
|
|||
|
let query = new Query();
|
|||
|
query.addFilter('org_id', Operator.Equals, this.orgId);
|
|||
|
query.addFilter('layer_group_id', Operator.Equals, this.id);
|
|||
|
query.setOrder({ legend_order: 'desc' });
|
|||
|
let queryTask = new QueryTask(QueryType.Layer);
|
|||
|
return queryTask.execute(query);
|
|||
|
}
|
|||
|
|
|||
|
/*新方法,和上面区别在于返回值封装了cellsysLayer*/
|
|||
|
queryLayers() {
|
|||
|
let query = new Query();
|
|||
|
query.addFilter('layer_group_id', Operator.Equals, this.id);
|
|||
|
query.setOrder({ legend_order: 'desc' });
|
|||
|
let queryTask = new QueryTask(QueryType.Layer);
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
queryTask
|
|||
|
.execute(query)
|
|||
|
.then((res) => {
|
|||
|
let resArr = res.map((item) => {
|
|||
|
let cellsysLayer = new CellsysLayer(item);
|
|||
|
cellsysLayer.type = item.layer_type;
|
|||
|
cellsysLayer.createBy = item.layer_create_by;
|
|||
|
return cellsysLayer;
|
|||
|
});
|
|||
|
resolve(resArr);
|
|||
|
})
|
|||
|
.catch((err) => {
|
|||
|
reject(err);
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
updateLayerRelations(layers) {
|
|||
|
let editTask = new EditTask(EditType.LayerRelation_Update);
|
|||
|
editTask.addParam('_layer_group_id', this.id);
|
|||
|
if (layers && layers.length > 0) {
|
|||
|
let layerRelations = layers.map((item) => {
|
|||
|
return item.id;
|
|||
|
});
|
|||
|
editTask.addParam('_layer_ids', layerRelations);
|
|||
|
} else {
|
|||
|
editTask.addParam('_layer_ids', []);
|
|||
|
}
|
|||
|
return editTask.execute();
|
|||
|
}
|
|||
|
|
|||
|
updateLayerOrder(layers) {
|
|||
|
let editTask = new EditTask(EditType.LayerOrder_Update);
|
|||
|
let legends = layers.map((o) => {
|
|||
|
return {
|
|||
|
_layer_id: o.layerId,
|
|||
|
_layer_group_id: this.id,
|
|||
|
_legend_order: o.legendOrder,
|
|||
|
};
|
|||
|
});
|
|||
|
editTask.addParam('_legends', legends);
|
|||
|
return editTask.execute();
|
|||
|
}
|
|||
|
|
|||
|
//发布功能
|
|||
|
setPublish(publishStatus, range, ids, isEditable, remark) {
|
|||
|
let editTask = new EditTask(EditType.LayerGroupPublish);
|
|||
|
editTask.addParam('_id', this.id);
|
|||
|
editTask.addParam('_layer_group_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', '=', 8);
|
|||
|
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.LayerGroupLock);
|
|||
|
editTask.addParam('_id', params.id);
|
|||
|
editTask.addParam('_is_unlock', params.isUnlock);
|
|||
|
return editTask.execute();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
export default CellsysLayerGroup;
|