@lcap/asl
Version:
NetEase Application Specific Language
163 lines • 5.61 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessComponentAttribute = void 0;
const decorators_1 = require("../decorators");
const __1 = require("..");
const process_1 = __importDefault(require("../../service/process"));
/**
* 流程节点属性
*/
class ProcessComponentAttribute extends __1.Vertex {
/**
* @param source 需要合并的部分参数
*/
constructor(source) {
super();
/**
* 概念类型
*/
this.level = __1.LEVEL_ENUM.processComponentAttribute;
/**
* 流程节点属性类型
*/
this.type = undefined;
/**
* 名称
*/
this.name = undefined;
/**
* 关联页面属性
*/
this.pageRef = undefined;
/**
* 关联页面路由
*/
this.url = undefined;
/**
* 流程组件 Id
*/
this.processComponentId = undefined;
/**
* 流程组件 Id
*/
this.destinationParams = [];
/**
* 流程节点
*/
this.processComponent = undefined;
source && this.assign(source);
}
/**
* 创建流程节点属性类型
*/
async create() {
const body = this.toJSON();
const result = await process_1.default.addProcessAttribute({
body,
});
this.assign(result);
this.processComponent.assign({
destination: this,
});
ProcessComponentAttribute.checkType(this.id, this.processComponent);
return this;
}
/**
* 删除流程节点属性类型
*/
async delete() {
if (this.id) {
await process_1.default.deleteProcessAttribute({ path: { id: this.id } });
this.processComponent.assign({
destination: null,
});
}
this.destroy();
}
/**
* 更新流程节点属性类型
*/
async update(none, actionOptions) {
if (this.id) {
__1.config.defaultApp?.emit('saving');
const body = this.toJSON();
const result = await process_1.default.updateProcessAttribute({
headers: {
appId: __1.config.defaultApp?.id,
operationAction: actionOptions?.actionName || 'ProcessComponentAttribute.update',
operationDesc: actionOptions?.actionDesc || `更新流程节点属性类型"${this.name}"`,
},
body,
});
this.assign(result);
ProcessComponentAttribute.checkType(this.id, this.processComponent);
await __1.config.defaultApp?.history.load();
__1.config.defaultApp?.emit('saved');
}
}
/**
* 流程节点属性类型检查
*/
static async checkType(id, processComponent) {
const result = await process_1.default.checkTypeProcessAttribute({
path: { id },
});
__1.ProcessComponent.assignTypeCheckResult(processComponent, result);
}
/**
* 从后端 JSON 生成规范的 ProcessComponentAttribute 对象
*/
static from(source, processComponent) {
const processComponentVariable = new ProcessComponentAttribute(source);
processComponentVariable.assign({
processComponent,
});
return processComponentVariable;
}
}
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "level", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "type", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "name", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "pageRef", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "url", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "processComponentId", void 0);
__decorate([
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "destinationParams", void 0);
__decorate([
decorators_1.excludedInJSON(),
decorators_1.immutable()
], ProcessComponentAttribute.prototype, "processComponent", void 0);
__decorate([
decorators_1.action('创建流程节点属性类型')
], ProcessComponentAttribute.prototype, "create", null);
__decorate([
decorators_1.action('删除流程节点属性类型')
], ProcessComponentAttribute.prototype, "delete", null);
__decorate([
decorators_1.action('更新流程节点属性类型')
], ProcessComponentAttribute.prototype, "update", null);
exports.ProcessComponentAttribute = ProcessComponentAttribute;
exports.default = ProcessComponentAttribute;
//# sourceMappingURL=ProcessComponentAttribute.js.map