|
@@ -1,5 +1,5 @@
|
|
|
import _ from 'lodash'
|
|
|
-import {Lib, lookupScope} from './lib'
|
|
|
+import {Lib, lookupScope, LibParam} from './lib'
|
|
|
import {ajax} from "./config";
|
|
|
import {msg as msgSimple, showErrorDialog as showErrorDialogSimple} from "../message";
|
|
|
|
|
@@ -431,6 +431,13 @@ export function invokeServer(url: string, ...args: any[]) {
|
|
|
}
|
|
|
|
|
|
export function clearViewModelValues(viewModel, propertyName) {
|
|
|
+ if (!propertyName) {
|
|
|
+ const dd = viewModel.getData()
|
|
|
+ _.forOwn(dd, (value, key) => {
|
|
|
+ viewModel.set(key, '')
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
const dd = _.get(viewModel.getData(), propertyName)
|
|
|
_.forOwn(dd, (value, key) => {
|
|
|
viewModel.set(propertyName + '.' + key, '')
|
|
@@ -514,8 +521,14 @@ export function confirm(msg, sender?): Promise<void> {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export class SystemEventFu {
|
|
|
+/**
|
|
|
+ * 任何符号字符串都替换成下换线
|
|
|
+ */
|
|
|
+export function normId(value: string) {
|
|
|
+ return _.replace(value, /[^\w]/g, '_')
|
|
|
+}
|
|
|
|
|
|
+export class SystemEventFu {
|
|
|
@Lib({
|
|
|
title: '弹出确认对话框,回答 YES 之后调用某方法',
|
|
|
author: '罗一帆',
|
|
@@ -523,21 +536,9 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-06',
|
|
|
type: 'system',
|
|
|
category: '对话框',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'string',
|
|
|
- title: '对话框的确认文字',
|
|
|
- name: 'text',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'event',
|
|
|
- title: '确认之后调用的方法',
|
|
|
- name: 'fn',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- confirm(text, fn) {
|
|
|
+ confirm(@LibParam('对话框的确认文字', 'string')text,
|
|
|
+ @LibParam('确认之后的调用的方法', 'event') fn) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
const msg = calcExpress(scope.viewModel.data, text)
|
|
@@ -548,22 +549,14 @@ export class SystemEventFu {
|
|
|
}
|
|
|
|
|
|
@Lib({
|
|
|
- title: '删除表格当前的选中行',
|
|
|
+ title: '删除表格当前的选中行(前端删除)',
|
|
|
author: '罗一帆',
|
|
|
createAt: '2021-07-08',
|
|
|
updateAt: '2021-07-08',
|
|
|
type: 'system',
|
|
|
category: '表格',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'refs',
|
|
|
- title: 'gridRef 表格引用名',
|
|
|
- allowEmpty: true,
|
|
|
- name: 'gridRefName',
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- gridRemoveCurrentRow(gridRefName) {
|
|
|
+ gridRemoveCurrentRow(@LibParam('表格引用名', 'refs') gridRefName) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
const grid = scope.refs[gridRefName]
|
|
@@ -581,27 +574,11 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-06',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'string',
|
|
|
- title: 'groovy 服务路径',
|
|
|
- name: 'invokeUrl',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: 'invoke 参数的 lookup 表达式, 如果不填 默认提交所有的 viewModel.data',
|
|
|
- name: 'invokeParam',
|
|
|
- allowEmpty: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'string',
|
|
|
- title: '服务读取后,数据的回写位置,可以是 scope.XX / system.XX / string / lookup表达式',
|
|
|
- name: 'writeTarget',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- loadForm(invokeUrl: string, invokeParam: any, writeTarget: any) {
|
|
|
+ loadForm(@LibParam('后端服务路径', 'string')invokeUrl: string,
|
|
|
+ @LibParam('后端需要的数据,默认情况提交所有', 'lookup', true) invokeParam: any,
|
|
|
+ //可以是 scope.XX / system.XX / string / lookup表达式
|
|
|
+ @LibParam('提交成功后的回调', 'viewModel', true) writeTarget: any) {
|
|
|
return function (sender) {
|
|
|
if (!invokeUrl) {
|
|
|
return
|
|
@@ -655,27 +632,10 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'string',
|
|
|
- title: 'groovy 服务路径',
|
|
|
- name: 'groovyUrl',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: '参数的 lookup 表达式, 如果不填 默认提交所有的 viewModel.data',
|
|
|
- name: 'arg0',
|
|
|
- allowEmpty: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'event',
|
|
|
- title: '成功后的回调',
|
|
|
- name: 'successCallback',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- commit(groovyUrl: string, arg0: any, successCallback) {
|
|
|
+ commit(@LibParam('后端服务路径', 'string')groovyUrl: string,
|
|
|
+ @LibParam('后端需要的数据,默认情况提交所有', 'lookup', true) arg0: any,
|
|
|
+ @LibParam('提交成功后的回调', 'event', true) successCallback) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
|
|
@@ -716,21 +676,9 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'string',
|
|
|
- title: 'groovy 服务路径',
|
|
|
- name: 'groovyUrl',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: '参数的 lookup 表达式, 如果不填 默认提交所有的 viewModel.data',
|
|
|
- name: 'arg0',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- formCommit(groovyUrl: string, arg0: any) {
|
|
|
+ formCommit(@LibParam('后端服务路径', 'string')groovyUrl: string,
|
|
|
+ @LibParam('后端需要的参数,默认情况提交所有', 'lookup', true)arg0: any) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
|
|
@@ -777,16 +725,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '对话框',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: '傳回成功數據的 lookup 表達式',
|
|
|
- name: 'lookupObject',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- dialogSuccess(lookupObject) {
|
|
|
+ dialogSuccess(@LibParam('传回给父窗口的成功参数对象', 'lookup', true)lookupObject) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
if (lookupObject) {
|
|
@@ -806,15 +746,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'viewModel',
|
|
|
- title: 'propertyName 属性路径',
|
|
|
- name: 'propertyName',
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- clearViewModelValues(propertyName: string) {
|
|
|
+ clearViewModelValues(@LibParam('属性路径', 'viewModel', true)propertyName: string) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
clearViewModelValues(scope.viewModel, propertyName)
|
|
@@ -828,21 +761,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'viewModel',
|
|
|
- title: 'propertyName 属性路径',
|
|
|
- name: 'propertyName',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'refs',
|
|
|
- title: 'gridRef 表格引用名',
|
|
|
- allowEmpty: true,
|
|
|
- name: 'gridRefName',
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- getGrid(url) {
|
|
|
+ getGrid(@LibParam('定义文件', 'module')url) {
|
|
|
return function (sender, config) {
|
|
|
// @ts-ignore
|
|
|
require([url], (grid) => {
|
|
@@ -859,21 +779,9 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'viewModel',
|
|
|
- title: 'propertyName 属性路径',
|
|
|
- name: 'propertyName',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'refs',
|
|
|
- title: 'gridRef 表格引用名',
|
|
|
- allowEmpty: true,
|
|
|
- name: 'gridRefName',
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- clearViewModelReloadGrid(propertyName: string, gridRefName?: string) {
|
|
|
+ clearViewModelReloadGrid(@LibParam('属性路径', 'viewModel')propertyName: string,
|
|
|
+ @LibParam('要刷新的表格', 'refs', true)gridRefName?: string) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
clearViewModelValues(scope.viewModel, propertyName)
|
|
@@ -893,16 +801,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'refs',
|
|
|
- title: 'gridRef 表格引用名, 不填写的情况下刷新所有',
|
|
|
- allowEmpty: true,
|
|
|
- name: 'gridRefName',
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- reloadGrid(gridRefName: string) {
|
|
|
+ reloadGrid(@LibParam('表格引用对象', 'refs', true) gridRefName: string) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
if (!gridRefName) {
|
|
@@ -921,27 +821,10 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '对话框',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'module',
|
|
|
- title: '业务模块名',
|
|
|
- name: 'url',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: '参数数据 lookup 表达式',
|
|
|
- name: 'lookupForData',
|
|
|
- allowEmpty: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'event',
|
|
|
- title: '成功回调',
|
|
|
- name: 'successCallback',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- showDialog(url: string, lookupForData: any, successCallback) {
|
|
|
+ showDialog(@LibParam('业务模块名', 'module') url: string,
|
|
|
+ @LibParam('参数数据 lookup 表达式', 'lookup', true) lookupForData: any,
|
|
|
+ @LibParam('成功回调', 'event', true) successCallback) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
const data = scope.viewModel.data
|
|
@@ -964,21 +847,9 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-02',
|
|
|
type: 'system',
|
|
|
category: '对话框',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'module',
|
|
|
- title: '模块名 (WidgetDialog)',
|
|
|
- name: 'widgetUrl',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'object',
|
|
|
- title: 'lookup 映射关系',
|
|
|
- name: 'lookupSetting',
|
|
|
- allowEmpty: true,
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- showWidget(widgetUrl, lookup) {
|
|
|
+ showWidget(@LibParam('模块名 (WidgetDialog)', 'module')widgetUrl,
|
|
|
+ @LibParam('lookup 映射关系', 'lookup', true)lookup) {
|
|
|
return function (sender, queryValue) {
|
|
|
showWidget(widgetUrl, lookup, sender, queryValue)
|
|
|
}
|
|
@@ -991,15 +862,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-05',
|
|
|
type: 'system',
|
|
|
category: '表单',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'viewModel',
|
|
|
- title: 'lookup 设值',
|
|
|
- name: 'lookup',
|
|
|
- },
|
|
|
- ]
|
|
|
})
|
|
|
- clearViewModelByLookup(lookup) {
|
|
|
+ clearViewModelByLookup(@LibParam('设值表达式', 'lookup') lookup) {
|
|
|
return function (sender) {
|
|
|
clearViewModelByLookup(sender, lookup)
|
|
|
}
|
|
@@ -1012,15 +876,8 @@ export class SystemEventFu {
|
|
|
updateAt: '2021-07-05',
|
|
|
type: 'system',
|
|
|
category: '对话框',
|
|
|
- args: [
|
|
|
- {
|
|
|
- type: 'event',
|
|
|
- title: '对话框的返回值回调',
|
|
|
- name: 'callBack',
|
|
|
- },
|
|
|
- ]
|
|
|
})
|
|
|
- closeMe(callBack) {
|
|
|
+ closeMe(@LibParam('对话框的返回值回调', 'event', true) callBack) {
|
|
|
return function (sender) {
|
|
|
const scope = lookupScope(sender)
|
|
|
scope.close()
|