fix 优化deleted_by字段的crud生成功能

fix 优化数据`hotgo.sql`文件字段默认值和初始数据
fix 修复web端字典空数据可能引发的潜在问题
This commit is contained in:
孟帅
2024-08-27 19:19:08 +08:00
parent 33e5252516
commit 37b2b82130
14 changed files with 165 additions and 504 deletions

View File

@@ -21,11 +21,13 @@ export type FuncDictType = 'testCategoryOption';
// 可以把常用的字典类型加入进来这样会有IDE提示
export type DictType = DefaultDictType | EnumsDictType | FuncDictType | string;
export type DictListClass = 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning';
export interface Option {
label: string;
value: string | number;
key: string | number;
listClass: 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning';
listClass: DictListClass;
extra: any;
}
@@ -88,7 +90,7 @@ export const useDictStore = defineStore({
return local;
}
const opts = this.options[type] ?? [];
if (opts === undefined || opts?.length === 0) {
if (!opts || opts?.length === 0) {
return null;
}
return opts;
@@ -96,6 +98,9 @@ export const useDictStore = defineStore({
// 获取选项名称
getLabel(type: DictType, value: any) {
if (value === null || value === undefined) {
return ``;
}
const opts = this.checkOptionValue(type);
if (!opts) {
return ``;
@@ -109,10 +114,10 @@ export const useDictStore = defineStore({
},
// 获取选项标签类型
getType(
type: DictType,
value: any
): 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning' {
getType(type: DictType, value: any): DictListClass {
if (value === null || value === undefined) {
return `default`;
}
const opts = this.checkOptionValue(type);
if (!opts) {
return `default`;
@@ -127,6 +132,9 @@ export const useDictStore = defineStore({
// 获取选项额外的数据配置
getExtra(type: DictType, value: any): any {
if (value === null || value === undefined) {
return null;
}
const opts = this.checkOptionValue(type);
if (!opts) {
return null;
@@ -141,6 +149,9 @@ export const useDictStore = defineStore({
// 是否存在指定选项值
hasValue(type: DictType, value: any): boolean {
if (value === null || value === undefined) {
return false;
}
const opts = this.checkOptionValue(type);
if (!opts) {
return false;

View File

@@ -52,17 +52,17 @@
<CitySelector v-model:value="formValue.cityId" />
</n-form-item>
</n-gi>
<n-gi span="1">
<n-form-item label="排序" path="sort">
<n-input-number placeholder="请输入排序" v-model:value="formValue.sort" />
</n-form-item>
</n-gi>
<n-gi span="1">
<n-form-item label="显示开关" path="switch">
<n-switch :unchecked-value="2" :checked-value="1" v-model:value="formValue.switch"
/>
</n-form-item>
</n-gi>
<n-gi span="1">
<n-form-item label="排序" path="sort">
<n-input-number placeholder="请输入排序" v-model:value="formValue.sort" />
</n-form-item>
</n-gi>
</n-grid>
</n-form>
</n-spin>

View File

@@ -14,23 +14,24 @@ const $message = window['$message'];
export class State {
public id = 0; // ID
public categoryId = null; // 测试分类
public title = ''; // 标题
public description = ''; // 描述
public content = ''; // 内容
public image = ''; // 单图
public attachfile = ''; // 附件
public cityId = null; // 所在城市
public sort = 0; // 排序
public switch = 2; // 显示开关
public sort = 0; // 排序
public status = 1; // 状态
public createdBy = 0; // 创建者
public createdBySumma?: null | MemberSumma = null; // 创建者摘要信息
public createdAt = ''; // 创建时间
public updatedBy = 0; // 更新者
public updatedBySumma?: null | MemberSumma = null; // 更新者摘要信息
public deletedBy = 0; // 删除者
public createdAt = ''; // 创建时间
public updatedAt = ''; // 修改时间
public deletedAt = ''; // 删除时间
public categoryId = null; // 测试分类
constructor(state?: Partial<State>) {
if (state) {
@@ -187,12 +188,6 @@ export const columns = [
return renderFile(row.attachfile);
},
},
{
title: '排序',
key: 'sort',
align: 'left',
width: 100,
},
{
title: '显示开关',
key: 'switch',
@@ -214,6 +209,12 @@ export const columns = [
});
},
},
{
title: '排序',
key: 'sort',
align: 'left',
width: 100,
},
{
title: '创建者',
key: 'createdBy',
@@ -223,12 +224,6 @@ export const columns = [
return renderPopoverMemberSumma(row.createdBySumma);
},
},
{
title: '创建时间',
key: 'createdAt',
align: 'left',
width: 180,
},
{
title: '更新者',
key: 'updatedBy',
@@ -238,6 +233,12 @@ export const columns = [
return renderPopoverMemberSumma(row.updatedBySumma);
},
},
{
title: '创建时间',
key: 'createdAt',
align: 'left',
width: 180,
},
{
title: '修改时间',
key: 'updatedAt',