😎代码生成及校验规则优化
This commit is contained in:
parent
119d2e5668
commit
c5a032f42a
@ -24,12 +24,6 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="App\**" />
|
||||
<EmbeddedResource Remove="App\**" />
|
||||
<None Remove="App\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
|
||||
<ProjectReference Include="..\Plugins\Admin.NET.Plugin.GoView\Admin.NET.Plugin.GoView.csproj" />
|
||||
|
||||
@ -219,5 +219,6 @@ public class CodeGenConfig
|
||||
/// 验证触发器
|
||||
/// </summary>
|
||||
public string Trigger { get; set; }
|
||||
#endregion
|
||||
|
||||
#endregion 不在数据库中的字段
|
||||
}
|
||||
@ -9,26 +9,32 @@ public class VerifyRuleItem
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public long Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证类型
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证错误消息
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public string Min { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public string Max { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 正则表达式
|
||||
/// </summary>
|
||||
public string Pattern { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型(搭配正则)
|
||||
/// </summary>
|
||||
|
||||
@ -120,7 +120,9 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
|
||||
|
||||
// 生成代码时,主键并不是必要输入项,故一定要排除主键字段
|
||||
//codeGenConfig.WhetherRequired = (tableColumn.IsNullable || tableColumn.IsPrimarykey) ? YesNoEnum.N.ToString() : YesNoEnum.Y.ToString();
|
||||
|
||||
#region 添加校验规则
|
||||
|
||||
//添加校验规则
|
||||
codeGenConfig.Id = YitIdHelper.NextId();
|
||||
//验证规则
|
||||
@ -136,7 +138,8 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
|
||||
}
|
||||
codeGenConfig.WhetherRequired = ruleItems.Any(t => t.Type == "required") ? YesNoEnum.Y.ToString() : YesNoEnum.N.ToString();
|
||||
codeGenConfig.Rules = ruleItems.ToJson();
|
||||
#endregion
|
||||
|
||||
#endregion 添加校验规则
|
||||
|
||||
codeGenConfig.QueryWhether = YesOrNo;
|
||||
codeGenConfig.WhetherAddUpdate = YesOrNo;
|
||||
|
||||
@ -345,7 +345,9 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Directory.Delete(outputPath, true);
|
||||
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig() { CodeGenId = input.Id }); // 字段集合
|
||||
|
||||
#region 构造前端需要验证的数据
|
||||
|
||||
foreach (var item in tableFieldList)
|
||||
{
|
||||
List<VerifyRuleItem> list = new List<VerifyRuleItem>();
|
||||
@ -365,7 +367,9 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
item.AnyRule = list.Count > 0;
|
||||
item.RemoteVerify = list.Any(t => t.Type == "remote");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion 构造前端需要验证的数据
|
||||
|
||||
var queryWhetherList = tableFieldList.Where(u => u.QueryWhether == YesNoEnum.Y.ToString()).ToList(); // 前端查询集合
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType == "Upload" || u.EffectType == "fk" || u.EffectType == "ApiTreeSelect").ToList(); // 需要连表查询的字段
|
||||
(string joinTableNames, string lowerJoinTableNames) = GetJoinTableStr(joinTableList); // 获取连表的实体名和别名
|
||||
@ -455,7 +459,9 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
public async Task<Dictionary<string, string>> Preview(SysCodeGen input)
|
||||
{
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig() { CodeGenId = input.Id }); // 字段集合
|
||||
|
||||
#region 构造前端需要验证的数据
|
||||
|
||||
foreach (var item in tableFieldList)
|
||||
{
|
||||
List<VerifyRuleItem> list = new List<VerifyRuleItem>();
|
||||
@ -475,7 +481,9 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
item.AnyRule = list.Count > 0;
|
||||
item.RemoteVerify = list.Any(t => t.Type == "remote");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion 构造前端需要验证的数据
|
||||
|
||||
var queryWhetherList = tableFieldList.Where(u => u.QueryWhether == YesNoEnum.Y.ToString()).ToList(); // 前端查询集合
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType == "Upload" || u.EffectType == "fk" || u.EffectType == "ApiTreeSelect").ToList(); // 需要连表查询的字段
|
||||
(string joinTableNames, string lowerJoinTableNames) = GetJoinTableStr(joinTableList); // 获取连表的实体名和别名
|
||||
|
||||
@ -20,6 +20,7 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
|
||||
import { AdminResultListCodeGenConfig } from '../models';
|
||||
import { AdminResultSysCodeGenConfig } from '../models';
|
||||
import { CodeGenConfig } from '../models';
|
||||
import { VerifyRuleItem } from '../models';
|
||||
/**
|
||||
* SysCodeGenConfigApi - axios parameter creator
|
||||
* @export
|
||||
@ -62,10 +63,15 @@ export const SysCodeGenConfigApiAxiosParamCreator = function (configuration?: Co
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
apiSysCodeGenConfigDetailGet: async (id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
apiSysCodeGenConfigDetailGet: async (id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/api/sysCodeGenConfig/detail`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||
@ -218,6 +224,26 @@ export const SysCodeGenConfigApiAxiosParamCreator = function (configuration?: Co
|
||||
localVarQueryParameter['OrderNo'] = orderNo;
|
||||
}
|
||||
|
||||
if (rules !== undefined) {
|
||||
localVarQueryParameter['Rules'] = rules;
|
||||
}
|
||||
|
||||
if (ruleItems) {
|
||||
localVarQueryParameter['RuleItems'] = ruleItems;
|
||||
}
|
||||
|
||||
if (remoteVerify !== undefined) {
|
||||
localVarQueryParameter['RemoteVerify'] = remoteVerify;
|
||||
}
|
||||
|
||||
if (anyRule !== undefined) {
|
||||
localVarQueryParameter['AnyRule'] = anyRule;
|
||||
}
|
||||
|
||||
if (trigger !== undefined) {
|
||||
localVarQueryParameter['Trigger'] = trigger;
|
||||
}
|
||||
|
||||
const query = new URLSearchParams(localVarUrlObj.search);
|
||||
for (const key in localVarQueryParameter) {
|
||||
query.set(key, localVarQueryParameter[key]);
|
||||
@ -270,10 +296,15 @@ export const SysCodeGenConfigApiAxiosParamCreator = function (configuration?: Co
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
apiSysCodeGenConfigListGet: async (id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
apiSysCodeGenConfigListGet: async (id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/api/sysCodeGenConfig/list`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||
@ -426,6 +457,26 @@ export const SysCodeGenConfigApiAxiosParamCreator = function (configuration?: Co
|
||||
localVarQueryParameter['OrderNo'] = orderNo;
|
||||
}
|
||||
|
||||
if (rules !== undefined) {
|
||||
localVarQueryParameter['Rules'] = rules;
|
||||
}
|
||||
|
||||
if (ruleItems) {
|
||||
localVarQueryParameter['RuleItems'] = ruleItems;
|
||||
}
|
||||
|
||||
if (remoteVerify !== undefined) {
|
||||
localVarQueryParameter['RemoteVerify'] = remoteVerify;
|
||||
}
|
||||
|
||||
if (anyRule !== undefined) {
|
||||
localVarQueryParameter['AnyRule'] = anyRule;
|
||||
}
|
||||
|
||||
if (trigger !== undefined) {
|
||||
localVarQueryParameter['Trigger'] = trigger;
|
||||
}
|
||||
|
||||
const query = new URLSearchParams(localVarUrlObj.search);
|
||||
for (const key in localVarQueryParameter) {
|
||||
query.set(key, localVarQueryParameter[key]);
|
||||
@ -535,11 +586,16 @@ export const SysCodeGenConfigApiFp = function(configuration?: Configuration) {
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultSysCodeGenConfig>>> {
|
||||
const localVarAxiosArgs = await SysCodeGenConfigApiAxiosParamCreator(configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options);
|
||||
async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultSysCodeGenConfig>>> {
|
||||
const localVarAxiosArgs = await SysCodeGenConfigApiAxiosParamCreator(configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options);
|
||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||
return axios.request(axiosRequestArgs);
|
||||
@ -581,11 +637,16 @@ export const SysCodeGenConfigApiFp = function(configuration?: Configuration) {
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultListCodeGenConfig>>> {
|
||||
const localVarAxiosArgs = await SysCodeGenConfigApiAxiosParamCreator(configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options);
|
||||
async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultListCodeGenConfig>>> {
|
||||
const localVarAxiosArgs = await SysCodeGenConfigApiAxiosParamCreator(configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options);
|
||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||
return axios.request(axiosRequestArgs);
|
||||
@ -650,11 +711,16 @@ export const SysCodeGenConfigApiFactory = function (configuration?: Configuratio
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultSysCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options).then((request) => request(axios, basePath));
|
||||
async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultSysCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
@ -692,11 +758,16 @@ export const SysCodeGenConfigApiFactory = function (configuration?: Configuratio
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options).then((request) => request(axios, basePath));
|
||||
async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
@ -754,12 +825,17 @@ export class SysCodeGenConfigApi extends BaseAPI {
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof SysCodeGenConfigApi
|
||||
*/
|
||||
public async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultSysCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(this.configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options).then((request) => request(this.axios, this.basePath));
|
||||
public async apiSysCodeGenConfigDetailGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultSysCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(this.configuration).apiSysCodeGenConfigDetailGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -797,12 +873,17 @@ export class SysCodeGenConfigApi extends BaseAPI {
|
||||
* @param {string} [valueColumn] 选中值字段
|
||||
* @param {string} [pidColumn] 父级字段
|
||||
* @param {number} [orderNo] 排序
|
||||
* @param {string} [rules] 字段验证规则
|
||||
* @param {Array<VerifyRuleItem>} [ruleItems] 字段验证集合
|
||||
* @param {boolean} [remoteVerify] 是否远程验证
|
||||
* @param {boolean} [anyRule] 是否存在验证规则
|
||||
* @param {string} [trigger] 验证触发器
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof SysCodeGenConfigApi
|
||||
*/
|
||||
public async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(this.configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, options).then((request) => request(this.axios, this.basePath));
|
||||
public async apiSysCodeGenConfigListGet(id?: number, codeGenId?: number, columnName?: string, propertyName?: string, columnLength?: number, lowerPropertyName?: string, columnComment?: string, netType?: string, effectType?: string, fkConfigId?: string, fkEntityName?: string, fkTableName?: string, lowerFkEntityName?: string, fkColumnName?: string, fkLinkColumnName?: string, lowerFkColumnName?: string, fkColumnNetType?: string, dictTypeCode?: string, whetherRetract?: string, whetherRequired?: string, whetherSortable?: string, queryWhether?: string, queryType?: string, whetherTable?: string, whetherAddUpdate?: string, columnKey?: string, dataType?: string, whetherCommon?: string, tableNickName?: string, displayColumn?: string, valueColumn?: string, pidColumn?: string, orderNo?: number, rules?: string, ruleItems?: Array<VerifyRuleItem>, remoteVerify?: boolean, anyRule?: boolean, trigger?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListCodeGenConfig>> {
|
||||
return SysCodeGenConfigApiFp(this.configuration).apiSysCodeGenConfigListGet(id, codeGenId, columnName, propertyName, columnLength, lowerPropertyName, columnComment, netType, effectType, fkConfigId, fkEntityName, fkTableName, lowerFkEntityName, fkColumnName, fkLinkColumnName, lowerFkColumnName, fkColumnNetType, dictTypeCode, whetherRetract, whetherRequired, whetherSortable, queryWhether, queryType, whetherTable, whetherAddUpdate, columnKey, dataType, whetherCommon, tableNickName, displayColumn, valueColumn, pidColumn, orderNo, rules, ruleItems, remoteVerify, anyRule, trigger, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { VerifyRuleItem } from './verify-rule-item';
|
||||
/**
|
||||
* 代码生成详细配置参数
|
||||
*
|
||||
@ -283,4 +284,44 @@ export interface CodeGenConfig {
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
orderNo?: number;
|
||||
|
||||
/**
|
||||
* 字段验证规则
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
rules?: string | null;
|
||||
|
||||
/**
|
||||
* 字段验证集合
|
||||
*
|
||||
* @type {Array<VerifyRuleItem>}
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
ruleItems?: Array<VerifyRuleItem> | null;
|
||||
|
||||
/**
|
||||
* 是否远程验证
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
remoteVerify?: boolean;
|
||||
|
||||
/**
|
||||
* 是否存在验证规则
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
anyRule?: boolean;
|
||||
|
||||
/**
|
||||
* 验证触发器
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenConfig
|
||||
*/
|
||||
trigger?: string | null;
|
||||
}
|
||||
|
||||
@ -404,6 +404,7 @@ export * from './user-input';
|
||||
export * from './user-menu-input';
|
||||
export * from './user-output';
|
||||
export * from './user-role-input';
|
||||
export * from './verify-rule-item';
|
||||
export * from './visual-column';
|
||||
export * from './visual-db-table';
|
||||
export * from './visual-table';
|
||||
|
||||
@ -307,4 +307,12 @@ export interface SysCodeGenConfig {
|
||||
* @memberof SysCodeGenConfig
|
||||
*/
|
||||
orderNo?: number;
|
||||
|
||||
/**
|
||||
* 字段验证规则
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SysCodeGenConfig
|
||||
*/
|
||||
rules?: string | null;
|
||||
}
|
||||
|
||||
78
Web/src/api-services/models/verify-rule-item.ts
Normal file
78
Web/src/api-services/models/verify-rule-item.ts
Normal file
@ -0,0 +1,78 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Admin.NET 通用权限开发平台
|
||||
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 验证规则选项
|
||||
*
|
||||
* @export
|
||||
* @interface VerifyRuleItem
|
||||
*/
|
||||
export interface VerifyRuleItem {
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
key?: number;
|
||||
|
||||
/**
|
||||
* 验证类型
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
type?: string | null;
|
||||
|
||||
/**
|
||||
* 验证错误消息
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
message?: string | null;
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
min?: string | null;
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
max?: string | null;
|
||||
|
||||
/**
|
||||
* 正则表达式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
pattern?: string | null;
|
||||
|
||||
/**
|
||||
* 数据类型(搭配正则)
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VerifyRuleItem
|
||||
*/
|
||||
dataType?: string | null;
|
||||
}
|
||||
@ -19,7 +19,15 @@
|
||||
<el-table-column prop="effectType" label="作用类型" width="140" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<div class="effect-type-container">
|
||||
<el-select v-model="scope.row.effectType" class="m-2" style="width: 90%" placeholder="Select" :disabled="judgeColumns(scope.row)" @change="effectTypeChange(scope.row, scope.$index)" filterable>
|
||||
<el-select
|
||||
v-model="scope.row.effectType"
|
||||
class="m-2"
|
||||
style="width: 90%"
|
||||
placeholder="Select"
|
||||
:disabled="judgeColumns(scope.row)"
|
||||
@change="effectTypeChange(scope.row, scope.$index)"
|
||||
filterable
|
||||
>
|
||||
<el-option v-for="item in state.effectTypeList" :key="item.code" :label="item.value" :value="item.code" />
|
||||
</el-select>
|
||||
<el-button
|
||||
@ -80,10 +88,9 @@
|
||||
<el-input v-model="scope.row.orderNo" autocomplete="off" type="number" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="orderNo" label="校验" width="120" align="center" show-overflow-tooltip>
|
||||
<el-table-column prop="orderNo" label="校验规则" width="120" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-button type="primary" v-if="(scope.row.columnKey=== 'False') && (!scope.row.whetherCommon)"
|
||||
@click="openVerifyDialog(scope.row)">规则{{ scope.row.ruleCount }}</el-button>
|
||||
<el-button type="primary" plain v-if="scope.row.columnKey === 'False' && !scope.row.whetherCommon" @click="openVerifyDialog(scope.row)">校验规则{{ scope.row.ruleCount }}</el-button>
|
||||
<span v-else></span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -113,7 +120,7 @@ import verifyDialog from '/@/views/system/codeGen/component/verifyDialog.vue';
|
||||
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysCodeGenConfigApi, SysConstApi, SysDictDataApi, SysDictTypeApi, SysEnumApi } from '/@/api-services/api';
|
||||
import { CodeGenConfig } from '/@/api-services/models/code-gen-config';
|
||||
// import { CodeGenConfig } from '/@/api-services/models/code-gen-config';
|
||||
|
||||
const emits = defineEmits(['handleQuery']);
|
||||
const fkDialogRef = ref();
|
||||
@ -122,7 +129,7 @@ const verifyDialogRef = ref();
|
||||
const state = reactive({
|
||||
isShowDialog: false,
|
||||
loading: false,
|
||||
tableData: [] as CodeGenConfig[],
|
||||
tableData: [] as any, // CodeGenConfig[],
|
||||
dbData: [] as any,
|
||||
effectTypeList: [] as any,
|
||||
dictTypeCodeList: [] as any,
|
||||
@ -198,7 +205,7 @@ const handleQuery = async (row: any) => {
|
||||
if (item[key] === 'N' || (lstWhetherColumn.includes(key) && item[key] === null)) {
|
||||
item[key] = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
// 验证规则相关
|
||||
let rules = new Array();
|
||||
if (item.rules != '' && item.rules !== null) {
|
||||
@ -255,13 +262,13 @@ const submitVerifyOk = (data: any) => {
|
||||
let rules = new Array();
|
||||
if (data.rules != '' && data.rules !== null) {
|
||||
rules = JSON.parse(data.rules);
|
||||
let requiredRule = rules.find(t => t.type === 'required');
|
||||
let requiredRule = rules.find((t) => t.type === 'required');
|
||||
if (requiredRule) {
|
||||
state.tableData[i].whetherRequired = true;
|
||||
} else {
|
||||
state.tableData[i].whetherRequired = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -284,7 +291,7 @@ const submit = async () => {
|
||||
var lst = state.tableData;
|
||||
console.log(lst);
|
||||
let ignoreFields = ['remoteVerify', 'anyRule', 'columnKey'];
|
||||
lst.forEach((item: CodeGenConfig) => {
|
||||
lst.forEach((item: any) => {
|
||||
// 必填那一项转换
|
||||
for (var key in item) {
|
||||
if (item[key] === true && !ignoreFields.includes(key)) {
|
||||
@ -300,51 +307,6 @@ const submit = async () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const convertDbType = (dbType: number) => {
|
||||
let result = '';
|
||||
switch (dbType) {
|
||||
case 0:
|
||||
result = 'MySql';
|
||||
break;
|
||||
case 1:
|
||||
result = 'SqlServer';
|
||||
break;
|
||||
case 2:
|
||||
result = 'Sqlite';
|
||||
break;
|
||||
case 3:
|
||||
result = 'Oracle';
|
||||
break;
|
||||
case 4:
|
||||
result = 'PostgreSql';
|
||||
break;
|
||||
case 5:
|
||||
result = 'Dm';
|
||||
break;
|
||||
case 6:
|
||||
result = 'Kdbndp';
|
||||
break;
|
||||
case 7:
|
||||
result = 'Oscar';
|
||||
break;
|
||||
case 8:
|
||||
result = 'MySqlConnector';
|
||||
break;
|
||||
case 9:
|
||||
result = 'Access';
|
||||
break;
|
||||
default:
|
||||
result = 'Custom';
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const isOrNotSelect = () => [
|
||||
{ label: '是', value: 1 },
|
||||
{ label: '否', value: 0 },
|
||||
];
|
||||
|
||||
// 导出对象
|
||||
defineExpose({ openDialog });
|
||||
</script>
|
||||
|
||||
@ -7,8 +7,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<div class="pattern-box">
|
||||
<div class="pattern-item" v-for="(item, index) in patternData" :key="index"
|
||||
:class="{ active: state.index == index }" @click="handlePatternClick(item, index)">
|
||||
<div class="pattern-item" v-for="(item, index) in patternData" :key="index" :class="{ active: state.index == index }" @click="handlePatternClick(item, index)">
|
||||
<div class="title">{{ item.title }}</div>
|
||||
<div class="info">{{ item.info }}</div>
|
||||
<div class="pattern">{{ item.pattern }}</div>
|
||||
@ -25,8 +24,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUnmounted, reactive, ref, toRaw } from 'vue';
|
||||
import { ElMessage } from "element-plus";
|
||||
import { reactive, ref } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
const patternData = ref([
|
||||
{
|
||||
@ -257,7 +256,7 @@ const state = reactive({
|
||||
index: -1,
|
||||
});
|
||||
|
||||
const emit = defineEmits(["submitPattern"]);
|
||||
const emit = defineEmits(['submitPattern']);
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
@ -279,9 +278,9 @@ const handlePatternClick = (item: any, index: number) => {
|
||||
state.index = index;
|
||||
ElMessage({
|
||||
message: `点击确定完成操作!`,
|
||||
type: "success",
|
||||
type: 'success',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const submit = async () => {
|
||||
@ -304,7 +303,7 @@ defineExpose({ openDialog });
|
||||
|
||||
.pattern-item {
|
||||
width: 48%;
|
||||
border: 1px solid #D9D9D9;
|
||||
border: 1px solid #d9d9d9;
|
||||
box-sizing: border-box;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
@ -324,9 +323,9 @@ defineExpose({ openDialog });
|
||||
.pattern {
|
||||
font-size: 10px;
|
||||
margin-top: 5px;
|
||||
background: #1D1F21;
|
||||
background: #1d1f21;
|
||||
padding: 3px 5px;
|
||||
color: #D9D9D9;
|
||||
color: #d9d9d9;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
<el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="800px">
|
||||
<template #header>
|
||||
<div style="color: #fff">
|
||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit />
|
||||
</el-icon>
|
||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
|
||||
<span> 编辑规则 </span>
|
||||
</div>
|
||||
</template>
|
||||
@ -16,38 +15,26 @@
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-form-item label="验证类型" prop="type">
|
||||
<el-select v-model="state.ruleForm.type" placeholder="请选择类型" @change="handleTypeChange">
|
||||
<el-option v-for="(item, index) in validTypeData" :key="index" :label="item.name"
|
||||
:value="item.code" />
|
||||
<el-option v-for="(item, index) in validTypeData" :key="index" :label="item.name" :value="item.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"
|
||||
v-if="state.ruleForm.type == 'pattern'">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="state.ruleForm.type == 'pattern'">
|
||||
<el-form-item label="提示信息" prop="message">
|
||||
<el-input v-model="state.ruleForm.message" placeholder="请输入提示信息" maxlength="128" show-word-limit
|
||||
clearable />
|
||||
|
||||
<el-input v-model="state.ruleForm.message" placeholder="请输入提示信息" maxlength="128" show-word-limit clearable />
|
||||
</el-form-item>
|
||||
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"
|
||||
v-if="state.ruleForm.type == 'length'">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="state.ruleForm.type == 'length'">
|
||||
<el-form-item label="最小值" prop="min">
|
||||
<el-input-number v-model="state.ruleForm.min" :min="0" :max="100000" />
|
||||
</el-form-item>
|
||||
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"
|
||||
v-if="state.ruleForm.type == 'length'">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="state.ruleForm.type == 'length'">
|
||||
<el-form-item label="最大值" prop="max">
|
||||
<el-input-number v-model="state.ruleForm.max" :min="0" :max="100000" />
|
||||
|
||||
</el-form-item>
|
||||
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"
|
||||
v-if="state.ruleForm.type == 'pattern'">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="state.ruleForm.type == 'pattern'">
|
||||
<el-form-item label="正则式" prop="pattern">
|
||||
<el-input v-model="state.ruleForm.pattern" placeholder="请输入正则表达式">
|
||||
<template #append>
|
||||
@ -64,7 +51,6 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col> -->
|
||||
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -90,12 +76,12 @@
|
||||
</style>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUnmounted, reactive, ref, toRaw, isReactive } from 'vue';
|
||||
import { reactive, ref, toRaw } from 'vue';
|
||||
import patternDialog from '/@/views/system/codeGen/component/patternDialog.vue';
|
||||
import { ElMessage, dialogEmits } from "element-plus";
|
||||
import type { FormRules } from "element-plus";
|
||||
import { ElMessage } from 'element-plus';
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
const emit = defineEmits(["submitRule"]);
|
||||
const emit = defineEmits(['submitRule']);
|
||||
// 自行添加其他规则
|
||||
const rules = ref<FormRules>({
|
||||
type: [
|
||||
@ -111,8 +97,8 @@ const rules = ref<FormRules>({
|
||||
required: true,
|
||||
pattern: /[^\d]/g,
|
||||
message: '请输入正确的数字',
|
||||
trigger: 'blur'
|
||||
}
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
max: [
|
||||
{
|
||||
@ -120,8 +106,8 @@ const rules = ref<FormRules>({
|
||||
required: true,
|
||||
pattern: /[^\d]/g,
|
||||
message: '请输入正确的数字',
|
||||
trigger: 'blur'
|
||||
}
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
message: [
|
||||
{
|
||||
@ -130,9 +116,7 @@ const rules = ref<FormRules>({
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
pattern: [
|
||||
{ required: true, message: '请输入正则表达式', trigger: 'blur' },
|
||||
],
|
||||
pattern: [{ required: true, message: '请输入正则表达式', trigger: 'blur' }],
|
||||
// dataType: [
|
||||
// {
|
||||
// required: true,
|
||||
@ -179,9 +163,8 @@ const closeDialog = () => {
|
||||
|
||||
// 打开正则选择框
|
||||
const openPatternDialog = () => {
|
||||
|
||||
patternDialogRef.value.openDialog();
|
||||
}
|
||||
};
|
||||
|
||||
// 取消
|
||||
const cancel = () => {
|
||||
@ -192,7 +175,7 @@ const cancel = () => {
|
||||
const submitPatternOK = (data: any) => {
|
||||
// console.log('submitPatternOK', data);
|
||||
state.ruleForm.pattern = data.pattern;
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const submit = async () => {
|
||||
@ -200,12 +183,12 @@ const submit = async () => {
|
||||
if (isValid) {
|
||||
let values = toRaw(state.ruleForm);
|
||||
values.key = toRaw(state.id);
|
||||
emit("submitRule", Object.assign({}, values));
|
||||
emit('submitRule', Object.assign({}, values));
|
||||
closeDialog();
|
||||
} else {
|
||||
ElMessage({
|
||||
message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
|
||||
type: "error",
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -217,12 +200,12 @@ const handleTypeChange=()=>{
|
||||
};
|
||||
// 重置表单值
|
||||
const resetFields = () => {
|
||||
state.ruleForm.message="";
|
||||
state.ruleForm.message = '';
|
||||
state.ruleForm.min = 0;
|
||||
state.ruleForm.max = 10;
|
||||
state.ruleForm.pattern="";
|
||||
state.ruleForm.pattern = '';
|
||||
// state.ruleForm.dataType=null;
|
||||
}
|
||||
};
|
||||
|
||||
// 导出对象
|
||||
defineExpose({ openDialog });
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
<el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="800px">
|
||||
<template #header>
|
||||
<div style="color: #fff">
|
||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit />
|
||||
</el-icon>
|
||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
|
||||
<span> {{ state.title }} </span>
|
||||
</div>
|
||||
</template>
|
||||
@ -56,13 +55,10 @@ const state = reactive({
|
||||
isShowDialog: false,
|
||||
loading: false,
|
||||
tableData: [] as any,
|
||||
title: ''
|
||||
title: '',
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
|
||||
});
|
||||
onMounted(async () => {});
|
||||
|
||||
// 添加返回
|
||||
const submitRuleOK = (data: any) => {
|
||||
@ -80,7 +76,6 @@ onUnmounted(() => {
|
||||
//mittBus.off('submitRefreshFk', () => { });
|
||||
});
|
||||
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (row: any) => {
|
||||
// handleQuery(addRow);
|
||||
@ -91,7 +86,6 @@ const openDialog = (row: any) => {
|
||||
state.tableData = JSON.parse(row.rules);
|
||||
}
|
||||
|
||||
|
||||
// state.tableData = row.rules;
|
||||
state.id = row.id;
|
||||
state.isShowDialog = true;
|
||||
@ -124,7 +118,7 @@ const submit = async () => {
|
||||
// 删除验证规则
|
||||
const handleDeleteRule = (scope: any) => {
|
||||
state.tableData.splice(scope.$index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
// 导出对象
|
||||
defineExpose({ openDialog });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user