提交 1b4f4220 编写于 作者: tony001's avatar tony001

update:更新

上级 5592e3ca
import { ControlPropsBase, ControlStateBase, UIBase } from '@core';
import { RouteLocationNormalizedLoaded, Router, useRoute, useRouter } from 'vue-router';
import { ControlPropsBase, ControlStateBase, IParam, UIBase } from '@core';
/**
* @description 部件基类
......@@ -9,67 +8,66 @@ import { RouteLocationNormalizedLoaded, Router, useRoute, useRouter } from 'vue-
export class ControlBase {
/**
* @description 部件状态
* 部件状态数据
*
* @type {ControlStateBase}
* @memberof ControlBase
*/
public controlState: ControlStateBase;
public declare state: ControlStateBase;
/**
* @description 路由器
* @type {Router}
* 输入参数
*
* @type {IParam}
* @memberof ControlBase
*/
public router: Router = useRouter();
public declare props: IParam;
/**
* @description 路由
* @type {RouteLocationNormalizedLoaded}
* 输出事件
*
* @type {Function}
* @memberof ControlBase
*/
public route: RouteLocationNormalizedLoaded = useRoute();
public declare emit: Function;
/**
* @description 事件
* @type {*}
* Creates an instance of ControlBase.
* @param {*} options 配置参数
* @memberof ControlBase
*/
public emit: any;
/**
* Creates an instance of ControlBase.
* @param {*} options 配置参数
* @param {ControlPropsBase} props 输入参数
* @param {Function} emit 输出事件
* @memberof ControlBase
*/
constructor(options: any) {
this.controlState = reactive(options);
constructor(options: any, props: ControlPropsBase, emit: Function) {
this.state = reactive(options);
this.props = props;
this.emit = emit;
}
/**
* @description 根据props调整设置部分部件基类
* @param {ControlPropsBase} props 传入props
* @memberof ControlBase
*/
public setState(props: ControlPropsBase) {
// toDo 项目级配置入口,优先级大于平台,提供全局的一次性配置
// 只读属性处理:把props的属性的Ref赋给state,以维持响应性。
this.controlState.viewSubject = toRef(props, 'viewSubject') as any;
public setState() {
this.state.viewSubject = toRef(this.props, 'viewSubject') as any;
}
/**
* @description 使用部件上下文参数逻辑块
* @param {ControlPropsBase} props
* @return {*}
* @memberof ControlBase
*/
public useControlContextParams(props: ControlPropsBase) {
const context = UIBase.toOneWayRef(props, 'context');
const viewParams = UIBase.toOneWayRef(props, 'viewParams');
public useControlContextParams() {
const context = UIBase.toOneWayRef(this.props, 'context');
const viewParams = UIBase.toOneWayRef(this.props, 'viewParams');
// 把Ref赋值到State上进行解包
this.controlState.context = context;
this.controlState.viewParams = viewParams;
this.state.context = context;
this.state.viewParams = viewParams;
return { context, viewParams };
}
......@@ -81,12 +79,11 @@ export class ControlBase {
* @return {*}
* @memberof ControlBase
*/
public moduleInstall(props: ControlPropsBase, emit?: Function) {
this.emit = emit?.bind(this);
this.setState(props);
this.useControlContextParams(props);
public moduleInstall() {
this.setState();
this.useControlContextParams();
return {
state: this.controlState,
state: this.state
};
}
}
......@@ -14,7 +14,7 @@ export class ExpBarControl extends MainControl {
* @type {ExpBarControlState}
* @memberof ExpBarControl
*/
public declare controlState: ExpBarControlState;
public declare state: ExpBarControlState;
/**
* @description 处理部件事件
......@@ -23,7 +23,7 @@ export class ExpBarControl extends MainControl {
*/
public handleCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
const { selection } = this.controlState;
const { selection } = this.state;
switch (action) {
case 'selectionchange':
this.onSelectionChange(data);
......@@ -66,16 +66,13 @@ export class ExpBarControl extends MainControl {
/**
* @description 安装部件所有功能模块的方法
* @param {ExpBarControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof ExpBarControl [emit] 事件
*/
public moduleInstall(props: ExpBarControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
public moduleInstall() {
const superParams = super.moduleInstall();
return {
...superParams,
state: this.controlState,
handleCtrlEvent: this.handleCtrlEvent.bind(this)
};
}
......
......@@ -13,7 +13,7 @@ export class FormControl extends MainControl {
* @type {FormControlState}
* @memberof FormControl
*/
public declare controlState: FormControlState;
public declare state: FormControlState;
/**
* @description 检验表单动态逻辑
......@@ -26,12 +26,12 @@ export class FormControl extends MainControl {
if (logic.logicType == 'GROUP' && logic.logics?.length > 0) {
let result: boolean = true;
if (logic.groupOP == 'AND') {
const falseItem = logic.logics.find((childLogic: IParam)=> {
const falseItem = logic.logics.find((childLogic: IParam) => {
return !this.verifyGroupLogic(data, childLogic);
})
result = falseItem ? false : true;
} else if (logic.groupOP == 'OR') {
const trueItem = logic.logics.find((childLogic: IParam)=> {
const trueItem = logic.logics.find((childLogic: IParam) => {
return this.verifyGroupLogic(data, childLogic);
})
result = trueItem ? true : false;
......@@ -55,8 +55,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public formDataChange(name: string, value: any) {
const { enableAutoSave } = this.controlState;
const { data } = toRefs(this.controlState);
const { enableAutoSave } = this.state;
const { data } = toRefs(this.state);
data.value[name] = value;
this.resetFormData(name);
this.formItemUpdate(name);
......@@ -72,7 +72,7 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public resetFormData(name: string) {
const { detailsModel } = this.controlState;
const { detailsModel } = this.state;
Object.values(detailsModel).forEach((item: IParam) => {
if (item.resetItemName && Object.is(name, item.resetItemName)) {
this.formDataChange(item.name, null);
......@@ -89,8 +89,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public async formItemUpdate(name: string) {
const { detailsModel, context, viewParams, controlService } = this.controlState;
const { data } = toRefs(this.controlState);
const { detailsModel, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state);
if (detailsModel[name] && detailsModel[name].formItemUpdate) {
const formItemUpdate = detailsModel[name].formItemUpdate;
if (formItemUpdate.customCode) {
......@@ -123,8 +123,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public formDynamicLogic(name: string) {
const { data } = this.controlState;
const { detailsModel } = toRefs(this.controlState);
const { data } = this.state;
const { detailsModel } = toRefs(this.state);
Object.values(detailsModel.value).forEach((item: IParam) => {
if (item.groupLogics?.length > 0) {
item.groupLogics.forEach((logic: IParam) => {
......@@ -162,8 +162,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public afterFormAction(action: string) {
const { appDeCodeName, data } = this.controlState;
const { context } = toRefs(this.controlState);
const { appDeCodeName, data } = this.state;
const { context } = toRefs(this.state);
if (appDeCodeName) {
if (Object.is(action, 'save') || Object.is(action, 'autoSave') || Object.is(action, 'submit')) {
if (data[appDeCodeName]) {
......@@ -182,8 +182,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public setFormEnableCond() {
const { data } = this.controlState;
const { detailsModel } = toRefs(this.controlState);
const { data } = this.state;
const { detailsModel } = toRefs(this.state);
Object.values(detailsModel.value).forEach((item: IParam) => {
if (Object.is(item.detailType, 'FORMITEM')) {
switch (item.enableCond) {
......@@ -215,8 +215,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public calcActionAuthState() {
const { data, UIService, actionModel } = this.controlState;
const { detailsModel } = toRefs(this.controlState);
const { data, UIService, actionModel } = this.state;
const { detailsModel } = toRefs(this.state);
const tempModel = deepCopy(actionModel);
UIUtil.calcActionItemAuthState(data, tempModel, UIService);
Object.values(detailsModel.value).forEach((item: IParam) => {
......@@ -256,8 +256,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public setCreateDefault() {
const { detailsModel, context, viewParams, controlService } = this.controlState;
const { data } = toRefs(this.controlState);
const { detailsModel, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state);
Object.values(detailsModel).forEach((detail: IParam) => {
if (Object.is(detail.detailType, 'FORMITEM')) {
if ((detail.createDV || detail.createDVT) && data.value.hasOwnProperty(detail.codeName)) {
......@@ -297,8 +297,8 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public setUpdateDefault() {
const { detailsModel, context, viewParams, controlService } = this.controlState;
const { data } = toRefs(this.controlState);
const { detailsModel, context, viewParams, controlService } = this.state;
const { data } = toRefs(this.state);
Object.values(detailsModel).forEach((detail: IParam) => {
if (Object.is(detail.detailType, 'FORMITEM')) {
if ((detail.updateDV || detail.updateDVT) && data.value.hasOwnProperty(detail.codeName)) {
......@@ -339,8 +339,8 @@ export class FormControl extends MainControl {
* @return {*}
* @memberof FormControl
*/
public useLoadDraft(props: FormControlProps) {
const { viewSubject, controlName } = this.controlState;
public useLoadDraft() {
const { viewSubject, controlName } = this.state;
/**
* 加载行为
......@@ -350,8 +350,8 @@ export class FormControl extends MainControl {
*/
const loadDraft = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeKeyFieldName } = this.controlState;
const { data } = toRefs(this.controlState);
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeKeyFieldName } = this.state;
const { data } = toRefs(this.state);
if (!controlAction.loadDraftAction) {
return;
}
......@@ -399,12 +399,11 @@ export class FormControl extends MainControl {
/**
* @description 使用加载功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public useLoad(props: FormControlProps) {
const { viewSubject, controlName } = this.controlState;
public useLoad() {
const { viewSubject, controlName } = this.state;
/**
* 加载行为
......@@ -414,8 +413,8 @@ export class FormControl extends MainControl {
*/
const load = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.controlState;
const { data } = toRefs(this.controlState);
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.state;
const { data } = toRefs(this.state);
if (!controlAction.loadAction) {
return;
}
......@@ -460,12 +459,11 @@ export class FormControl extends MainControl {
/**
* @description 使用加载功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public useSave(props?: FormControlProps) {
const { viewSubject, controlName } = this.controlState;
public useSave() {
const { viewSubject, controlName } = this.state;
/**
* 保存行为
......@@ -476,12 +474,12 @@ export class FormControl extends MainControl {
const save = async (opt: any = {}) => {
try {
// 获取需要的状态变量
const { controlService, context, viewParams, showBusyIndicator, data } = this.controlState;
const { controlService, context, viewParams, showBusyIndicator, data } = this.state;
// TODO 值规则校验处理
// 判断实体行为
const { updateAction, createAction } = this.controlState.controlAction;
const { updateAction, createAction } = this.state.controlAction;
const saveAction: any = data.srfuf == '1' ? updateAction : createAction;
const saveFunName = data.srfuf == '1' ? 'update' : 'create';
if (!saveAction) {
......@@ -514,7 +512,7 @@ export class FormControl extends MainControl {
}
// 请求后处理
this.controlState.data = response.data;
this.state.data = response.data;
// TODO 表单onFormLoad
} catch (error) {
......@@ -548,7 +546,7 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public useRemove(props: FormControlProps) {
const { viewSubject, controlName } = this.controlState;
const { viewSubject, controlName } = this.state;
/**
* 删除行为
......@@ -559,10 +557,10 @@ export class FormControl extends MainControl {
const remove = async (opt: any = {}) => {
try {
// 获取需要的状态变量
const { controlService, context, viewParams, showBusyIndicator } = this.controlState;
const { controlService, context, viewParams, showBusyIndicator } = this.state;
// 判断实体行为
const removeAction = this.controlState.controlAction.removeAction;
const removeAction = this.state.controlAction.removeAction;
if (!removeAction) {
return;
}
......@@ -579,7 +577,7 @@ export class FormControl extends MainControl {
arg,
{
action: removeAction,
isLoading:showBusyIndicator
isLoading: showBusyIndicator
},
);
if (!response.status || response.status !== 200) {
......@@ -587,7 +585,7 @@ export class FormControl extends MainControl {
}
// 请求后处理
this.controlState.data = response.data;
this.state.data = response.data;
} catch (error) {
// TODO 错误异常处理
console.log(error);
......@@ -657,20 +655,17 @@ export class FormControl extends MainControl {
/**
* @description 安装部件所有功能模块的方法
* @param {FormControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof FormControl [emit] 事件
*/
public moduleInstall(props: FormControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
public moduleInstall() {
const superParams = super.moduleInstall();
// 表单行为能力启用
const { load } = this.useLoad(props);
const { save } = this.useSave(props);
const { load } = this.useLoad();
const { save } = this.useSave();
return {
...superParams,
state: this.controlState,
load,
save,
handleEditorEvent: this.handleEditorEvent.bind(this),
......
......@@ -14,20 +14,20 @@ export class GridControl extends MainControl {
* @type {GridControlState}
* @memberof GridControl
*/
public declare controlState: GridControlState;
public declare state: GridControlState;
/**
* @description
* @param {GridControlProps} props
* @memberof GridControl
*/
public setState(props: GridControlProps) {
super.setState(props);
this.controlState.multiple = toRef(props, "multiple") as any;
this.controlState.rowEditState = toRef(props, "rowEditState") as any;
this.controlState.rowActiveMode = toRef(props, "rowActiveMode") as any;
this.controlState.selectedData = toRef(props, "selectedData") as any;
this.controlState.selectFirstDefault = toRef(props, "selectFirstDefault") as any;
public setState() {
super.setState();
this.state.multiple = toRef(this.props, "multiple") as any;
this.state.rowEditState = toRef(this.props, "rowEditState") as any;
this.state.rowActiveMode = toRef(this.props, "rowActiveMode") as any;
this.state.selectedData = toRef(this.props, "selectedData") as any;
this.state.selectFirstDefault = toRef(this.props, "selectFirstDefault") as any;
}
/**
......@@ -37,8 +37,8 @@ export class GridControl extends MainControl {
* @param {*} value 表格列属性值
* @memberof GridControl
*/
public gridDataChange(rowIndex: number, name: string, value: any){
const { data } = toRefs(this.controlState);
public gridDataChange(rowIndex: number, name: string, value: any) {
const { data } = toRefs(this.state);
if (data.value[rowIndex][name] !== value) {
data.value[rowIndex][name] = value;
data.value[rowIndex]["rowDataState"] = "update";
......@@ -52,7 +52,7 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public getActionAuthState(rowData: IParam) {
const { UIService, uAColumnModel } = this.controlState;
const { UIService, uAColumnModel } = this.state;
let tempModel: any = deepCopy(uAColumnModel);
UIUtil.calcActionItemAuthState(rowData, tempModel, UIService);
return tempModel;
......@@ -81,8 +81,8 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public autoGroup() {
const { gridGroup } = this.controlState;
const { data, columnsModel } = toRefs(this.controlState);
const { gridGroup } = this.state;
const { data, columnsModel } = toRefs(this.state);
const { groupField } = gridGroup;
let autoGroup: string[] = [];
data.value.forEach((item: IParam) => {
......@@ -116,8 +116,8 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public async codeListGroup() {
const { gridGroup } = this.controlState;
const { data, columnsModel } = toRefs(this.controlState);
const { gridGroup } = this.state;
const { data, columnsModel } = toRefs(this.state);
const { groupField } = gridGroup;
// TODO 代码表数据
let codeListGroup: IParam[] = [];
......@@ -160,7 +160,7 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public calcGridAuthState() {
const { data, columnsModel } = toRefs(this.controlState);
const { data, columnsModel } = toRefs(this.state);
let columnModel = this.getGridColumn(columnsModel.value, "UAGRIDCOLUMN");
if (columnModel) {
data.value.forEach((item: IParam) => {
......@@ -176,26 +176,26 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public setGridColSpan() {
const { columnsModel } = toRefs(this.controlState);
const { columnsModel } = toRefs(this.state);
columnsModel.value.forEach((columnModel: IParam) => {
const customRender = ({text, record, index, column}: IParam) => {
const customRender = ({ text, record, index, column }: IParam) => {
const option = {
props: {} as IParam,
};
if (record.children) {
if (Object.is(column.columnType, "GROUP")) {
Object.assign(option.props,{
Object.assign(option.props, {
colSpan: columnsModel.value.length,
});
} else {
Object.assign(option.props,{
Object.assign(option.props, {
colSpan: 0
});
}
}
return option;
}
Object.assign(columnModel,{
Object.assign(columnModel, {
customRender: customRender,
})
});
......@@ -206,7 +206,7 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public handleGridGroup() {
const { gridGroup } = this.controlState;
const { gridGroup } = this.state;
const { enableGroup, groupField, groupMode } = gridGroup;
if (enableGroup && groupField && !Object.is(groupMode, "NONE")) {
if (Object.is(groupMode, "AUTO")) {
......@@ -223,7 +223,7 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public async remoteAgg(): Promise<IParam[]> {
const { gridAgg } = this.controlState;
const { gridAgg } = this.state;
const aggData: IParam[] = [];
// TODO 调用服务获取聚合数据
return aggData;
......@@ -279,15 +279,15 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public async handleDataAgg() {
const { gridPaging, gridGroup, columnsModel } = this.controlState;
const { gridAgg } = toRefs(this.controlState);
const { gridPaging, gridGroup, columnsModel } = this.state;
const { gridAgg } = toRefs(this.state);
let { aggMode, aggData } = gridAgg.value;
const { enableGroup } = gridGroup;
if (!Object.is(aggMode, "NONE")) {
const { enablePagingBar, current, pageSize } = gridPaging;
let dataAgg: IParam[] = [];
if (Object.is(aggMode, "PAGE")) {
const dataRef = toRef(this.controlState, "data");
const dataRef = toRef(this.state, "data");
dataAgg = [...dataRef.value];
} else if (Object.is(aggMode, "ALL")) {
dataAgg = await this.remoteAgg();
......@@ -323,8 +323,8 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public handleDefaultSelect() {
const { selectedData, selectFirstDefault, controlName, data } = this.controlState;
const { selectedRowKeys } = toRefs(this.controlState);
const { selectedData, selectFirstDefault, controlName, data } = this.state;
const { selectedRowKeys } = toRefs(this.state);
if (selectedData?.length > 0) {
const _selectedRowKeys: string[] = [];
selectedData.forEach((selected: IParam) => {
......@@ -346,18 +346,17 @@ export class GridControl extends MainControl {
/**
* @description 使用加载功能模块
* @param {GridControlProps} props 传入的props
* @return {*}
* @memberof GridControl
*/
public useLoad(props: GridControlProps) {
const { viewSubject, controlName } = this.controlState;
public useLoad() {
const { viewSubject, controlName } = this.state;
const load = async (opt: any = {}) => {
try {
const {
controlService, context, viewParams, showBusyIndicator, controlAction, gridSort
} = this.controlState;
const { gridPaging, data } = toRefs(this.controlState);
} = this.state;
const { gridPaging, data } = toRefs(this.state);
if (!controlAction.fetchAction) {
return;
}
......@@ -412,15 +411,14 @@ export class GridControl extends MainControl {
/**
* @description 使用保存功能模块
* @param {GridControlProps} props 传入的props
* @return {*}
* @memberof GridControl
*/
public useSave(props: GridControlProps) {
const { viewSubject, controlName } = this.controlState;
public useSave() {
const { viewSubject, controlName } = this.state;
const save = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, data, controlAction } = this.controlState;
const { controlService, context, viewParams, showBusyIndicator, data, controlAction } = this.state;
// TODO 值规则校验处理
for (const item of data) {
......@@ -474,11 +472,11 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public useRemove(props: GridControlProps) {
const { viewSubject, controlName } = this.controlState;
const { viewSubject, controlName } = this.state;
const remove = async (opt: IParam[] = []) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName } = this.controlState;
const { data } = toRefs(this.controlState);
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName } = this.state;
const { data } = toRefs(this.state);
if (!controlAction.removeAction) {
return;
}
......@@ -502,7 +500,7 @@ export class GridControl extends MainControl {
});
const _removeAction = keys.length > 1 ? "removeBatch" : controlAction.removeAction;
let _context = deepCopy(context);
Object.assign(_context, {[appDeCodeName]: keys});
Object.assign(_context, { [appDeCodeName]: keys });
let _viewParams = deepCopy(viewParams);
const arg: IParam = {
[appDeCodeName]: keys,
......@@ -548,17 +546,17 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public useNewRow(props: GridControlProps) {
const { viewSubject, controlName } = this.controlState;
const { viewSubject, controlName } = this.state;
const newRow = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.controlState;
const { data } = toRefs(this.controlState);
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.state;
const { data } = toRefs(this.state);
if (!controlAction.loadDraftAction) {
return;
}
let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams);
const arg: any = {...opt};
const arg: any = { ...opt };
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.loadDraft(
_context,
......@@ -566,7 +564,7 @@ export class GridControl extends MainControl {
{ action: controlAction.loadDraftAction, isLoading: showBusyIndicator },
);
if (response.status || response.status == 200) {
data.value = [...data.value,[response.data]];
data.value = [...data.value, [response.data]];
}
} catch (error) {
// TODO 错误异常处理
......@@ -594,12 +592,11 @@ export class GridControl extends MainControl {
/**
* @description 使用自定义模块(蚂蚁金服UI自定义)
* @param {GridControlProps} props
* @memberof GridControl
*/
public useCustom(props: GridControlProps) {
const { controlName, selectFirstDefault, rowEditState, rowActiveMode } = this.controlState;
const { selectedRowKeys, gridPaging } = toRefs(this.controlState);
public useCustom() {
const { controlName, selectFirstDefault, rowEditState, rowActiveMode } = this.state;
const { selectedRowKeys, gridPaging } = toRefs(this.state);
let { current, pageSize } = gridPaging.value;
// 滚动条配置
const scrollOption = computed(() => {
......@@ -624,16 +621,16 @@ export class GridControl extends MainControl {
if (!rowEditState) {
selectedRowKeys.value = [record.srfkey];
if (!record.children) {
this.emit("ctrlEvent",{ tag: controlName, action: "selectionChange", data: [deepCopy(record)] })
this.emit("ctrlEvent", { tag: controlName, action: "selectionChange", data: [deepCopy(record)] })
if (Object.is(rowActiveMode, 1)) {
this.emit("ctrlEvent",{ tag: controlName, action: "rowClick", data: [deepCopy(record)] })
this.emit("ctrlEvent", { tag: controlName, action: "rowClick", data: [deepCopy(record)] })
}
}
}
},
onDblclick: () => {
if (!record.children && Object.is(rowActiveMode, 2)) {
this.emit("ctrlEvent",{ tag: controlName, action: "rowDbClick", data: [deepCopy(record)] })
this.emit("ctrlEvent", { tag: controlName, action: "rowDbClick", data: [deepCopy(record)] })
}
}
};
......@@ -646,7 +643,7 @@ export class GridControl extends MainControl {
return {
columnWidth: 90,
selectedRowKeys: selectedRowKeys.value,
checkStrictly: props.multiple ? false : true,
checkStrictly: this.props.multiple ? false : true,
onChange: (_selectedRowKeys: string[], selectedRows: IParam[]) => {
selectedRowKeys.value = _selectedRowKeys;
const selection: IParam[] = [];
......@@ -655,7 +652,7 @@ export class GridControl extends MainControl {
selection.push(select);
}
})
this.emit("ctrlEvent",{ tag: controlName, action: "selectionChange", data: selection })
this.emit("ctrlEvent", { tag: controlName, action: "selectionChange", data: selection })
},
};
});
......@@ -668,7 +665,7 @@ export class GridControl extends MainControl {
if (pagination) {
current = pagination.current;
pageSize = pagination.pageSize;
this.useLoad(props).load();
this.useLoad().load();
}
}
return {
......@@ -713,18 +710,15 @@ export class GridControl extends MainControl {
/**
* @description 安装部件所有功能模块的方法
* @param {GridControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof GridControl [emit] 事件
*/
public moduleInstall(props: GridControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props);
const { custom } = this.useCustom(props);
public moduleInstall() {
const superParams = super.moduleInstall();
const { load } = this.useLoad();
const { custom } = this.useCustom();
return {
...superParams,
state: this.controlState,
load,
custom,
handleEditorEvent: this.handleEditorEvent.bind(this),
......
......@@ -13,32 +13,26 @@ export class MainControl extends ControlBase {
* @type {MainControlState}
* @memberof MainControl
*/
public declare controlState: MainControlState;
public declare state: MainControlState;
/**
* @description 根据props调整设置部件state
* @param {MainControlProps} props 传入的Props
* @memberof MainControl
*/
public setState(props: MainControlProps) {
super.setState(props);
// 只读属性处理:把props的属性的Ref赋给state,以维持响应性。
this.controlState.showBusyIndicator = toRef(props, 'showBusyIndicator') as any;
this.controlState.controlAction = toRef(props, 'controlAction') as any;
public setState() {
super.setState();
this.state.showBusyIndicator = toRef(this.props, 'showBusyIndicator') as any;
this.state.controlAction = toRef(this.props, 'controlAction') as any;
}
/**
* @description 安装部件所有功能模块的方法
* @param {MainControlProps} props 传入的Props
* @param {Function} [emit] [emit] 事件
* @return {*}
* @memberof MainControl
*/
public moduleInstall(props: MainControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
public moduleInstall() {
const superParams = super.moduleInstall();
return {
...superParams,
state: this.controlState,
...superParams
};
}
}
import { Ref } from 'vue';
import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam, AppFuncService, deepCopy } from '@core';
import { MenuControlState, IActionParam, ControlBase, IParam, deepCopy } from '@core';
import { useRoute } from 'vue-router';
/**
* @description 菜单部件
......@@ -14,17 +15,16 @@ export class MenuControl extends ControlBase {
* @type {MenuControlState}
* @memberof MenuControl
*/
public declare controlState: MenuControlState;
public declare state: MenuControlState;
/**
* @description 根据props调整设置部分部件基类
* @param {MenuControlProps} props 菜单输入属性
* @memberof MenuControl
*/
public setState(props: MenuControlProps) {
super.setState(props);
this.controlState.defaultView = toRef(props, 'defaultView') as any;
this.controlState.menuAlign = toRef(props, 'menuAlign') as any;
public setState() {
super.setState();
this.state.defaultView = toRef(this.props, 'defaultView') as any;
this.state.menuAlign = toRef(this.props, 'menuAlign') as any;
}
/**
......@@ -34,7 +34,7 @@ export class MenuControl extends ControlBase {
*/
public computedEffectiveMenus(items: IParam[]) {
items.forEach((item: IParam) => {
const { authService } = this.controlState;
const { authService } = this.state;
// TODO 获取菜单权限
// if (!authService?.getMenusPermission?.(item)) {
// item.hidden = true;
......@@ -53,7 +53,7 @@ export class MenuControl extends ControlBase {
public handleDefaultOpens(items: IParam[], defaultOpens: Ref<string[]>) {
items.forEach((item: any) => {
if (item.expanded) {
defaultOpens.value = [... defaultOpens.value, item.name];
defaultOpens.value = [...defaultOpens.value, item.name];
}
if (item.items?.length > 0) {
this.handleDefaultOpens(item.items, defaultOpens);
......@@ -66,11 +66,12 @@ export class MenuControl extends ControlBase {
* @memberof MenuControl
*/
public handleDefaultSelect() {
const { funcs, defaultView, menuAlign } = this.controlState;
const defaultSelectRef = toRef(this.controlState, 'defaultSelect');
const dataRef = toRef(this.controlState, 'menus');
if (this.route.matched?.length == 2) {
const [{ }, matched] = this.route.matched;
const route = useRoute();
const { funcs, defaultView, menuAlign } = this.state;
const defaultSelectRef = toRef(this.state, 'defaultSelect');
const dataRef = toRef(this.state, 'menus');
if (route.matched?.length == 2) {
const [{ }, matched] = route.matched;
const appFunc: any = funcs.find((func: any) => Object.is(func.routePath, matched.path) && Object.is(func.funcType, 'APPVIEW'));
if (appFunc) {
this.computeMenuSelect(dataRef.value, appFunc.funcTag);
......@@ -102,9 +103,9 @@ export class MenuControl extends ControlBase {
* @memberof MenuControl
*/
public computeMenuSelect(menus: IParam[], funcTag: string): boolean {
const { funcs } = this.controlState;
const defaultSelectRef = toRef(this.controlState, 'defaultSelect');
const defaultOpensRef = toRef(this.controlState, 'defaultOpens');
const { funcs } = this.state;
const defaultSelectRef = toRef(this.state, 'defaultSelect');
const defaultOpensRef = toRef(this.state, 'defaultOpens');
return menus.some((item: any) => {
if (Object.is(funcTag, '') && item.funcTag && item.openDefault && !item.hidden) {
const appFunc = funcs?.find((func: any) => Object.is(func.funcTag, item.funcTag));
......@@ -163,34 +164,33 @@ export class MenuControl extends ControlBase {
* @memberof MenuControl
*/
public menuClick(item: IParam) {
const { context, viewParams } = this.controlState;
const { context, viewParams } = this.state;
App.getAppFuncService().executeAppFunc(item, deepCopy(context), deepCopy(viewParams));
}
/**
* @description 使用加载功能模块
* @param {MenuControlProps} props 传入的props
* @return {*}
* @memberof MenuControl
*/
public useLoad(props: MenuControlProps){
const { viewSubject, controlName } = this.controlState;
const load = async (opt: any = {})=>{
const dataRef = toRef(this.controlState, 'menus');
const defaultOpensRef = toRef(this.controlState, 'defaultOpens');
public useLoad() {
const { viewSubject, controlName } = this.state;
const load = async (opt: any = {}) => {
const dataRef = toRef(this.state, 'menus');
const defaultOpensRef = toRef(this.state, 'defaultOpens');
this.computedEffectiveMenus(dataRef.value);
this.handleDefaultOpens(dataRef.value, defaultOpensRef);
this.handleDefaultSelect();
}
// 订阅viewSubject,监听load行为
if(viewSubject){
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam)=>{
if(Object.is(controlName, tag) && Object.is("load", action) ){
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
load(data);
}
})
// 部件卸载时退订viewSubject
onUnmounted(()=>{
onUnmounted(() => {
subscription.unsubscribe();
})
}
......@@ -206,7 +206,7 @@ export class MenuControl extends ControlBase {
*/
public menuSelect($event: IParam) {
const { key } = $event;
const dataRef = toRef(this.controlState, 'menus');
const dataRef = toRef(this.state, 'menus');
let item = this.compute(dataRef.value, key);
if (Object.keys(item).length > 0) {
this.menuClick(item);
......@@ -215,23 +215,20 @@ export class MenuControl extends ControlBase {
/**
* @description 安装部件所有功能模块的方法
* @param {MenuControlProps} props 传入的Props
* @param {Function} [emit] [emit] 事件
* @return {*}
* @memberof MenuControl
*/
public moduleInstall(props: MenuControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props)
public moduleInstall() {
const superParams = super.moduleInstall();
const { load } = this.useLoad();
const menuSelect = this.menuSelect.bind(this);
this.menuSelect =($event: IParam) => {
this.menuSelect = ($event: IParam) => {
menuSelect($event);
}
return {
...superParams,
state: this.controlState,
load,
menuSelect: this.menuSelect,
};
......
import { Ref, ref } from 'vue';
import { IActionParam, MainControl } from '@core';
import { PickupViewPanelControlProps } from './pickupviewpanel-control-prop';
import { PickupViewPanelControlState } from './pickupviewpanel-control-state';
......@@ -14,19 +13,9 @@ export class PickupViewPanelControl extends MainControl {
/**
* @description 部件状态
* @type {FormControlState}
* @memberof FormControl
*/
public declare controlState: PickupViewPanelControlState;
/**
* @description 根据props设置部件state
* @param {PickupViewPanelControlProps} props
* @memberof PickupViewPanelControl
*/
public setState(props: PickupViewPanelControlProps) {
super.setState(props);
}
public declare state: PickupViewPanelControlState;
/**
* @description
......@@ -34,7 +23,7 @@ export class PickupViewPanelControl extends MainControl {
* @memberof PickupViewPanelControl
*/
public useLoad(props: PickupViewPanelControlProps) {
const { viewSubject, controlName, context, viewParams } = this.controlState;
const { viewSubject, controlName, context, viewParams } = this.state;
// 订阅viewSubject,监听load行为
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
......@@ -58,7 +47,7 @@ export class PickupViewPanelControl extends MainControl {
*/
public handleViewEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
const { controlName } = this.controlState;
const { controlName } = this.state;
if (Object.is("selectionChange", action)) {
this.emit('ctrlEvent', { tag: controlName, action: action, data: data });
}
......@@ -66,17 +55,14 @@ export class PickupViewPanelControl extends MainControl {
/**
* @description 安装部件所有功能模块的方法
* @param {PickupViewPanelControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof FormControl [emit] 事件
* @memberof PickupViewPanelControl
*/
public moduleInstall(props: PickupViewPanelControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
public moduleInstall() {
const superParams = super.moduleInstall();
return {
...superParams,
handleViewEvent: this.handleViewEvent.bind(this),
state: this.controlState
handleViewEvent: this.handleViewEvent.bind(this)
};
}
}
\ No newline at end of file
import { deepCopy, FormControl, FormControlProps, FormControlState } from '@core';
import { FormControl, FormControlState } from '@core';
/**
* @description 表单部件
* @description 搜索表单部件
* @export
* @class FormControl
* @extends {MainControl}
* @todo 部件加载loading,能否不写在行为方法里。
*/
export class SearchFormControl extends FormControl {
/**
......@@ -13,18 +12,18 @@ export class SearchFormControl extends FormControl {
* @type {FormControlState}
* @memberof FormControl
*/
public declare controlState: FormControlState;
public declare state: FormControlState;
/**
* @description 查询
* @memberof SearchFormControl
*/
public onSearch() {
const { controlName } = this.controlState;
const { controlName } = this.state;
this.emit("ctrlEvent", {
tag: controlName,
action: "selectionChange",
data: this.controlState.data,
data: this.state.data,
});
}
......@@ -47,18 +46,15 @@ export class SearchFormControl extends FormControl {
/**
* @description 安装部件所有功能模块的方法
* @param {FormControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof FormControl [emit] 事件
* @memberof SearchFormControl
*/
public moduleInstall(props: FormControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
public moduleInstall() {
const superParams = super.moduleInstall();
// 表单行为能力启用
const { loadDraft } = this.useLoadDraft(props);
const { loadDraft } = this.useLoadDraft();
return {
...superParams,
state: this.controlState,
loadDraft,
onSearch: this.onSearch.bind(this),
onCancel: this.onCancel.bind(this),
......
......@@ -15,16 +15,15 @@ export class TreeControl extends MainControl {
* @type {TreeControlState}
* @memberof TreeControl
*/
public declare controlState: TreeControlState;
public declare state: TreeControlState;
/**
* @description 根据props调整设置部件state
* @param {TreeControlProps} props 传入的props
* @memberof TreeControl
*/
public setState(props: TreeControlProps): void {
super.setState(props);
this.controlState.isBranchAvailable = toRef(props, 'isBranchAvailable') as any;
public setState(): void {
super.setState();
this.state.isBranchAvailable = toRef(this.props, 'isBranchAvailable') as any;
}
/**
......@@ -38,7 +37,7 @@ export class TreeControl extends MainControl {
e.node.isCurrent = false;
return;
}
const { isBranchAvailable, currentselectedNode, multiple, selectedNodes, controlName } = this.controlState;
const { isBranchAvailable, currentselectedNode, multiple, selectedNodes, controlName } = this.state;
if (isBranchAvailable && e.node.leaf) {
if (currentselectedNode && Object.keys(currentselectedNode).length > 0) {
currentselectedNode.value.srfchecked = 0;
......@@ -47,7 +46,7 @@ export class TreeControl extends MainControl {
currentselectedNode.value = e.node;
if (!multiple) {
selectedNodes.push(currentselectedNode.value);
this.emit("ctrlEvent",{ tag: controlName, action: 'selectionchange', data: deepCopy(selectedNodes) });
this.emit("ctrlEvent", { tag: controlName, action: 'selectionchange', data: deepCopy(selectedNodes) });
}
}
}
......@@ -60,7 +59,7 @@ export class TreeControl extends MainControl {
* @memberof TreeControl
*/
private computecurNodeContext(curNode: any) {
const { context } = this.controlState;
const { context } = this.state;
let tempContext: any = {};
if (curNode && curNode.data && curNode.data.srfappctx) {
tempContext = deepCopy(curNode.data.srfappctx);
......@@ -72,19 +71,18 @@ export class TreeControl extends MainControl {
/**
* @description 使用加载功能模块
* @param {TreeControlProps} props 传入的props
* @return {*}
* @memberof TreeControl
*/
public useLoad(props: TreeControlProps) {
const { viewSubject, controlName } = this.controlState;
public useLoad() {
const { viewSubject, controlName } = this.state;
const load = async (node: any, isFirst: boolean = false) => {
if (node?.dataRef?.children) {
return null;
}
const {
controlService, data, viewParams, srfnodefilter
} = this.controlState;
} = this.state;
let tempViewParams: any = deepCopy(viewParams);
let curNode: any = {};
curNode = deepObjectMerge(curNode, node);
......@@ -128,7 +126,7 @@ export class TreeControl extends MainControl {
const isSelectedAll = node.checked;
// TODO 默认选中
// this.setDefaultSelection(items, isRoot, isSelectedAll);
this.emit("ctrlEvent",{ tag: controlName, action: "load", data: items });
this.emit("ctrlEvent", { tag: controlName, action: "load", data: items });
} catch (error) {
console.error(error);
}
......@@ -152,17 +150,14 @@ export class TreeControl extends MainControl {
/**
* @description 安装部件所有功能模块的方法
* @param {TreeControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof TreeControl [emit] 事件
* @memberof TreeControl
*/
public moduleInstall(props: TreeControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props);
public moduleInstall() {
const superParams = super.moduleInstall();
const { load } = this.useLoad();
return {
...superParams,
state: this.controlState,
treeNodeSelect: this.treeNodeSelect.bind(this),
load
};
......
import { deepCopy, ExpBarControl, IActionParam, IParam, UIUtil } from "@core";
import { TreeExpBarControlProps } from "./tree-exp-bar-control-prop";
import { TreeExpBarControlState } from "./tree-exp-bar-control-state";
/**
......@@ -14,7 +13,7 @@ export class TreeExpBarControl extends ExpBarControl {
* @type {ExpBarControlState}
* @memberof TreeExpBarControl
*/
public declare controlState: TreeExpBarControlState;
public declare state: TreeExpBarControlState;
protected onSelectionChange(args: any[]) {
if (args.length == 0) {
......@@ -31,7 +30,7 @@ export class TreeExpBarControl extends ExpBarControl {
const refView = this.getExpItemView({ nodeType: nodeType });
// TODO 选择视图面板支持
if (refView) {
const { selection } = this.controlState;
const { selection } = this.state;
const { tempContext, tempViewParams } = this.computeNavParams(arg);
// 置空
Object.assign(selection, {});
......@@ -48,7 +47,7 @@ export class TreeExpBarControl extends ExpBarControl {
protected getExpItemView(arg: any = {}): IParam | null {
const expMode: string = `EXPITEM:${arg.nodeType}`;
const { viewRefs } = this.controlState;
const { viewRefs } = this.state;
if (viewRefs && viewRefs.length > 0) {
const viewRef = viewRefs.find((_viewRef: any) => _viewRef.name == expMode);
return viewRef ? deepCopy(viewRef) : null;
......@@ -60,7 +59,7 @@ export class TreeExpBarControl extends ExpBarControl {
protected computeNavParams(arg: any): { tempContext: any, tempViewParams: any } {
const tempContext: any = {};
const tempViewParams: any = {};
let { counter, context } = this.controlState;
let { counter, context } = this.state;
if (arg && arg.navfilter) {
Object.defineProperty(tempViewParams, arg.navfilter, {
value: arg.srfkey,
......@@ -104,11 +103,10 @@ export class TreeExpBarControl extends ExpBarControl {
/**
* @description 使用加载功能模块
* @param {TreeExpBarControlProps} props 传入的props
* @memberof TreeExpBarControl
*/
public useLoad(props: TreeExpBarControlProps) {
const { viewSubject, controlName, xDataControlName } = this.controlState;
public useLoad() {
const { viewSubject, controlName, xDataControlName } = this.state;
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag)) {
......@@ -124,16 +122,14 @@ export class TreeExpBarControl extends ExpBarControl {
/**
* @description 安装部件所有功能模块的方法
* @param {TreeExpBarControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof TreeExpBarControl [emit] 事件
* @memberof TreeExpBarControl
*/
public moduleInstall(props: TreeExpBarControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
this.useLoad(props);
public moduleInstall() {
const superParams = super.moduleInstall();
this.useLoad();
return {
...superParams,
...superParams
};
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ interface CtrlEmit {
}
const emit = defineEmits < CtrlEmit > ();
const { state, menuSelect } = new MenuControl(CtrlConfig).moduleInstall(props, emit);
const { state, menuSelect } = new MenuControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
......@@ -25,7 +25,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, handleEditorEvent, handleComponentEvent } = new FormControl(CtrlConfig).moduleInstall(props, emit);
const { state, handleEditorEvent, handleComponentEvent } = new FormControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
......@@ -33,7 +33,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力
const { state, load, handleEditorEvent, handleToolbarEvent, custom } = new GridControl(CtrlConfig).moduleInstall(props, emit);
const { state, load, handleEditorEvent, handleToolbarEvent, custom } = new GridControl(CtrlConfig, props, emit).moduleInstall();
const { scrollOption, rowKey, rowClassName, customRow, rowSelectionOption, resizeColumn, handleGridChange } = custom;
// 暴露内部状态及能力
......
......@@ -31,7 +31,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, handleViewEvent } = new PickupViewPanelControl(CtrlConfig).moduleInstall(props, emit);
const { state, handleViewEvent } = new PickupViewPanelControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
......@@ -31,7 +31,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, inited, viewdata, viewparam } = new PickupViewPanelControl(CtrlConfig).moduleInstall(props, emit);
const { state, inited, viewdata, viewparam } = new PickupViewPanelControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
......@@ -26,7 +26,7 @@ interface CtrlEmit {
const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法
const { state, handleEditorEvent, handleComponentEvent, onSearch, loadDraft, onOk, onCancel } = new SearchFormControl(CtrlConfig).moduleInstall(props, emit);
const { state, handleEditorEvent, handleComponentEvent, onSearch, loadDraft, onOk, onCancel } = new SearchFormControl(CtrlConfig, props, emit).moduleInstall();
</script>
<template>
......
......@@ -35,7 +35,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, handleCtrlEvent } = new TreeExpBarControl(CtrlConfig).moduleInstall(props, emit);
const { state, handleCtrlEvent } = new TreeExpBarControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
......@@ -29,7 +29,7 @@ interface CtrlEmit {
const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法
const { state, load, treeNodeSelect } = new TreeControl(CtrlConfig).moduleInstall(props, emit);
const { state, load, treeNodeSelect } = new TreeControl(CtrlConfig, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册