😎优化系统流水号相关代码
This commit is contained in:
parent
695780afbf
commit
5430cea7f7
@ -60,15 +60,15 @@
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1273" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
<PackageReference Include="microsoft.semantickernel" Version="1.61.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.61.0" />
|
||||
<PackageReference Include="microsoft.semantickernel" Version="1.62.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.62.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Amazon" Version="1.56.0-alpha" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Google" Version="1.54.0-alpha" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.HuggingFace" Version="1.56.0-preview" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Ollama" Version="1.54.0-alpha" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Qdrant" Version="1.54.0-preview" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.PromptTemplates.Handlebars" Version="1.61.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Yaml" Version="1.61.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.PromptTemplates.Handlebars" Version="1.62.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Yaml" Version="1.62.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
|
||||
|
||||
@ -24,23 +24,23 @@ public class SysSerial : EntityTenantId
|
||||
/// <summary>
|
||||
/// 有效期
|
||||
/// </summary>
|
||||
[Required]
|
||||
[IgnoreUpdateSeedColumn]
|
||||
[SugarColumn(ColumnDescription = "有效期")]
|
||||
[Required]
|
||||
public virtual DateTime Expy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用分类
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnDescription = "使用分类")]
|
||||
[Required]
|
||||
public virtual SerialTypeEnum Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 重置间隔
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnDescription = "重置间隔")]
|
||||
[Required]
|
||||
public virtual ResetIntervalEnum ResetInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -71,8 +71,8 @@ public class SysSerial : EntityTenantId
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnDescription = "状态")]
|
||||
[Required]
|
||||
public virtual StatusEnum Status { get; set; } = StatusEnum.Enable;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -186,7 +186,7 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
|
||||
//new SysMenu{ Id=1310000000463, Pid=1310000000461, Title="删除", Permission="dbBackup/delete", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||
//new SysMenu{ Id=1310000000464, Pid=1310000000461, Title="增加", Permission="dbBackup/add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||
|
||||
new SysMenu{ Id=1310000000471, Pid=1310000000301, Title="流水管理", Path="/platform/serial", Name="sysSerial", Component="/system/serial/index", Icon="ele-Link", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=250 },
|
||||
new SysMenu{ Id=1310000000471, Pid=1310000000301, Title="流水序号", Path="/platform/serial", Name="sysSerial", Component="/system/serial/index", Icon="ele-Link", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=250 },
|
||||
new SysMenu{ Id=1310000000472, Pid=1310000000471, Title="查询", Permission="sysSerial/page", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||
new SysMenu{ Id=1310000000473, Pid=1310000000471, Title="编辑", Permission="sysSerial/update", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||
new SysMenu{ Id=1310000000474, Pid=1310000000471, Title="增加", Permission="sysSerial/add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||
|
||||
@ -65,7 +65,6 @@ public class SerialBaseInput
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public virtual long? TenantId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -89,7 +88,6 @@ public class PageSerialInput : BasePageInput
|
||||
/// </summary>
|
||||
[Dict(nameof(StatusEnum), AllowNullValue = true)]
|
||||
public StatusEnum? Status { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -140,7 +138,6 @@ public class AddSerialInput : SerialBaseInput
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public override string Remark { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -210,7 +207,6 @@ public class UpdateSerialInput : SerialBaseInput
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public override string Remark { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class PreviewSysSerialInput
|
||||
|
||||
@ -38,12 +38,12 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
public async Task<SqlSugarPagedList<PageSerialOutput>> Page(PageSerialInput input)
|
||||
{
|
||||
input.Keyword = input.Keyword?.Trim();
|
||||
var query = _sysSerialRep.AsQueryable().Where(u => u.TenantId == _userManager.TenantId)
|
||||
var query = _sysSerialRep.AsQueryable()
|
||||
.Where(u => u.TenantId == _userManager.TenantId)
|
||||
.WhereIF(input.Type != null, u => u.Type == input.Type)
|
||||
.WhereIF(input.Status != null, u => u.Status == input.Status)
|
||||
.Select<PageSerialOutput>();
|
||||
query = query.MergeTable();
|
||||
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
||||
return await query.MergeTable().OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -53,7 +53,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
[DisplayName("获取本地序列详情")]
|
||||
[ApiDescriptionSettings(Name = "Detail"), HttpGet]
|
||||
public async Task<SysSerial> Detail([FromQuery]BaseIdInput input)
|
||||
public async Task<SysSerial> Detail([FromQuery] BaseIdInput input)
|
||||
{
|
||||
return await _sysSerialRep.GetFirstAsync(u => u.Id == input.Id);
|
||||
}
|
||||
@ -67,8 +67,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
[ApiDescriptionSettings(Name = "Add"), HttpPost]
|
||||
public async Task<long> Add(AddSerialInput input)
|
||||
{
|
||||
var isExist = await _sysSerialRep.IsAnyAsync(u => u.Type == input.Type && u.TenantId == _userManager.TenantId);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D1006);
|
||||
if (await _sysSerialRep.IsAnyAsync(u => u.Type == input.Type && u.TenantId == _userManager.TenantId)) throw Oops.Oh(ErrorCodeEnum.D1006);
|
||||
|
||||
var entity = input.Adapt<SysSerial>();
|
||||
entity.Expy = DateTime.Now;
|
||||
@ -86,8 +85,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
public async Task Update(UpdateSerialInput input)
|
||||
{
|
||||
var seq = await _sysSerialRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
|
||||
var isExist = await _sysSerialRep.IsAnyAsync(u => u.Type == input.Type && u.TenantId == _userManager.TenantId && input.Id != seq.Id);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D1006);
|
||||
if (await _sysSerialRep.IsAnyAsync(u => u.Type == input.Type && u.TenantId == _userManager.TenantId && input.Id != seq.Id)) throw Oops.Oh(ErrorCodeEnum.D1006);
|
||||
|
||||
var entity = input.Adapt<SysSerial>();
|
||||
await _sysSerialRep.AsUpdateable(entity).IgnoreColumns(u => new { u.Expy, u.Seq }).ExecuteCommandAsync();
|
||||
@ -103,7 +101,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
public async Task Delete(BaseIdInput input)
|
||||
{
|
||||
var entity = await _sysSerialRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
|
||||
await _sysSerialRep.DeleteAsync(entity); //真删除
|
||||
await _sysSerialRep.DeleteAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -227,6 +225,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
{
|
||||
case ResetIntervalEnum.Never:
|
||||
break;
|
||||
|
||||
case ResetIntervalEnum.Day:
|
||||
if (nowDate.Date != seq.Expy.Date)
|
||||
{
|
||||
@ -234,6 +233,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
seq.Seq = seq.Min;
|
||||
}
|
||||
break;
|
||||
|
||||
case ResetIntervalEnum.Month:
|
||||
if (nowDate.Month != seq.Expy.Month || nowDate.Year != seq.Expy.Year)
|
||||
{
|
||||
@ -241,6 +241,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
seq.Seq = seq.Min;
|
||||
}
|
||||
break;
|
||||
|
||||
case ResetIntervalEnum.Year:
|
||||
if (nowDate.Year != seq.Expy.Year)
|
||||
{
|
||||
@ -248,6 +249,7 @@ public class SysSerialService : IDynamicApiController, ITransient
|
||||
seq.Seq = seq.Min;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw Oops.Oh(ErrorCodeEnum.S0006);
|
||||
}
|
||||
|
||||
@ -4,10 +4,9 @@
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using System.Text.Json;
|
||||
using Minio.DataModel;
|
||||
using NewLife.IO;
|
||||
using NewLife.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
@ -597,6 +596,7 @@ public static class SqlSugarExtension
|
||||
#endregion 简称操作
|
||||
|
||||
#region 流水号操作
|
||||
|
||||
/// <summary>
|
||||
/// 包含流水号特性的类型属性缓存表
|
||||
/// </summary>
|
||||
@ -647,5 +647,6 @@ public static class SqlSugarExtension
|
||||
.GetResult();
|
||||
entityInfo.SetValue(serial);
|
||||
}
|
||||
|
||||
#endregion 流水号操作
|
||||
}
|
||||
@ -58,7 +58,7 @@ export interface AddSerialInput {
|
||||
resetInterval: ResetIntervalEnum;
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
* 表达式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof AddSerialInput
|
||||
|
||||
@ -583,4 +583,4 @@ export * from './wechat-user-login';
|
||||
export * from './wx-open-id-login-input';
|
||||
export * from './wx-open-id-output';
|
||||
export * from './wx-phone-output';
|
||||
export * from './yes-no-enum';
|
||||
export * from './yes-no-enum';
|
||||
|
||||
@ -60,7 +60,7 @@ export interface PageSerialOutput {
|
||||
resetInterval?: ResetIntervalEnum;
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
* 表达式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof PageSerialOutput
|
||||
|
||||
@ -68,7 +68,7 @@ export interface SysSerial {
|
||||
resetInterval: ResetIntervalEnum;
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
* 格式化表达式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SysSerial
|
||||
|
||||
@ -60,7 +60,7 @@ export interface UpdateSerialInput {
|
||||
resetInterval: ResetIntervalEnum;
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
* 表达式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof UpdateSerialInput
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
<el-dialog v-model="state.showDialog" :width="800" draggable :close-on-click-modal="false">
|
||||
<template #header>
|
||||
<div style="color: #fff">
|
||||
<span>{{ state.title }}</span>
|
||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
|
||||
<span> {{ props.title }} </span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
|
||||
@ -18,23 +19,19 @@
|
||||
<g-sys-dict v-model="state.ruleForm.type" :code="'SerialTypeEnum'" render-as="select" clearable :disabled="state.disabled" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="重置间隔" prop="resetInterval">
|
||||
<g-sys-dict v-model="state.ruleForm.resetInterval" :code="'ResetIntervalEnum'" render-as="select" clearable :disabled="state.disabled" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-form-item label="表达式" prop="formater">
|
||||
<el-input v-model="state.ruleForm.formater" placeholder="表达式样例:R{yyyy}{MM}{dd}{HH}{mm}{ss}{SEQ}" clearable :disabled="state.disabled">
|
||||
<template #append>
|
||||
<el-dropdown placement="bottom" @command="(val: any) => state.ruleForm.formater += val">
|
||||
<el-button> 插槽 </el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="key in state.slotList" :key="key" :command="key">{{key}}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<el-dropdown placement="bottom" @command="(val: any) => (state.ruleForm.formater += val)">
|
||||
<el-button> 插槽 </el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="key in state.slotList" :key="key" :command="key">{{ key }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
@ -44,53 +41,62 @@
|
||||
<el-input-number v-model="state.ruleForm.min" placeholder="请输入最小值" clearable :disabled="state.disabled" class="w100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="排序" prop="orderNo">
|
||||
<el-input-number v-model="state.ruleForm.orderNo" placeholder="请输入排序" clearable :disabled="state.disabled" class="w100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="最大值" prop="max">
|
||||
<el-input-number v-model="state.ruleForm.max" placeholder="请输入最大值" clearable :disabled="state.disabled" class="w100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="state.ruleForm.remark" placeholder="请输入备注" clearable :disabled="state.disabled" />
|
||||
<el-form-item label="重置间隔" prop="resetInterval">
|
||||
<g-sys-dict v-model="state.ruleForm.resetInterval" :code="'ResetIntervalEnum'" render-as="select" clearable :disabled="state.disabled" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="排序">
|
||||
<el-input-number v-model="state.ruleForm.orderNo" placeholder="请输入排序" clearable :disabled="state.disabled" class="w100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="state.ruleForm.remark" placeholder="请输入备注" clearable :disabled="state.disabled" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="state.previewSeqNo">
|
||||
<el-form-item label="预览">
|
||||
{{ state.previewSeqNo }}
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-form-item label="预览">
|
||||
{{ state.previewSeqNo }}
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="() => (state.showDialog = false)">取 消</el-button>
|
||||
<el-button type="warning" icon="ele-View" @click="preview" v-reclick="500">预览</el-button>
|
||||
<el-button v-if="!state.disabled" @click="submit" type="primary" v-reclick="1000">确 定</el-button>
|
||||
<el-button icon="ele-CircleCloseFilled" @click="() => (state.showDialog = false)">{{ $t('message.list.cancelButtonText') }}</el-button>
|
||||
<el-button v-if="!state.disabled" type="primary" v-reclick="1000" icon="ele-CircleCheckFilled" @click="submit">{{ $t('message.list.confirmButtonText') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" name="sysSerial" setup>
|
||||
|
||||
<script lang="ts" setup name="sysSerial">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysSerialApi } from '/@/api-services/system/api';
|
||||
import { UpdateSerialInput } from '/@/api-services/system/models';
|
||||
|
||||
//父级传递来的函数,用于回调
|
||||
const props = defineProps({
|
||||
title: String,
|
||||
});
|
||||
const emit = defineEmits(['handleQuery']);
|
||||
const ruleFormRef = ref();
|
||||
const state = reactive({
|
||||
title: '',
|
||||
loading: false,
|
||||
disabled: false,
|
||||
disabled: false as any,
|
||||
showDialog: false,
|
||||
previewSeqNo: '',
|
||||
slotList: [] as any[],
|
||||
@ -101,26 +107,31 @@ const state = reactive({
|
||||
const rules = ref<FormRules>({
|
||||
type: [{ required: true, message: '请选择使用分类!', trigger: 'change' }],
|
||||
formater: [{ required: true, message: '请选择格式化!', trigger: 'blur' }],
|
||||
resetInterval: [{ required: true, message: '请选择重置方式!', trigger: 'blur' }],
|
||||
resetInterval: [{ required: true, message: '请选择重置方式!', trigger: 'blur' }],
|
||||
min: [{ required: true, message: '请输入最小值!', trigger: 'blur' }],
|
||||
orderNo: [{ required: true, message: '请输入排序!', trigger: 'blur' }],
|
||||
max: [{ required: true, message: '请输入最大值!', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态!', trigger: 'change' }],
|
||||
});
|
||||
|
||||
// 页面加载时
|
||||
onMounted(async () => {
|
||||
state.slotList = await getAPI(SysSerialApi).apiSysSerialSlotListGet().then(({data}) => data.result ?? []);
|
||||
state.slotList = await getAPI(SysSerialApi)
|
||||
.apiSysSerialSlotListGet()
|
||||
.then(({ data }) => data.result ?? []);
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (row: any, title: string) => {
|
||||
state.title = title;
|
||||
state.disabled = title?.endsWith('详情');
|
||||
const openDialog = async (row: any) => {
|
||||
state.disabled = props.title?.endsWith('详情');
|
||||
|
||||
row = JSON.parse(JSON.stringify(row));
|
||||
state.ruleForm = row.id
|
||||
? await getAPI(SysSerialApi)
|
||||
.apiSysSerialDetailGet(row.id)
|
||||
.then((res) => res.data.result ?? row)
|
||||
: row;
|
||||
state.showDialog = true;
|
||||
ruleFormRef.value?.resetFields();
|
||||
row = JSON.parse(JSON.stringify(row ?? { status: 1, orderNo: 100 }));
|
||||
state.ruleForm = row.id ? await getAPI(SysSerialApi).apiSysSerialDetailGet(row.id).then((res) => res.data.result ?? row) : row;
|
||||
|
||||
state.ruleForm.formater ??= '';
|
||||
};
|
||||
|
||||
@ -132,40 +143,35 @@ const closeDialog = () => {
|
||||
|
||||
// 预览
|
||||
const preview = () => {
|
||||
getAPI(SysSerialApi).apiSysSerialPreviewPost(state.ruleForm).then(res => {
|
||||
if (res.data.result) {
|
||||
ElMessage.success("获取成功");
|
||||
state.previewSeqNo = res.data.result;
|
||||
state.ruleForm.seq ??= 0;
|
||||
state.ruleForm.seq += 1;
|
||||
} else {
|
||||
ElMessage.error("预览失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
getAPI(SysSerialApi)
|
||||
.apiSysSerialPreviewPost(state.ruleForm)
|
||||
.then((res) => {
|
||||
if (res.data.result) {
|
||||
ElMessage.success('获取成功');
|
||||
state.previewSeqNo = res.data.result;
|
||||
state.ruleForm.seq ??= 0;
|
||||
state.ruleForm.seq += 1;
|
||||
} else {
|
||||
ElMessage.error('预览失败');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 提交
|
||||
const submit = async () => {
|
||||
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
|
||||
if (isValid) {
|
||||
let values = JSON.parse(JSON.stringify(state.ruleForm));
|
||||
// 处理多选字段值
|
||||
if (state.ruleForm.id) {
|
||||
await getAPI(SysSerialApi).apiSysSerialUpdatePost(values);
|
||||
} else {
|
||||
await getAPI(SysSerialApi).apiSysSerialAddPost(values);
|
||||
}
|
||||
closeDialog();
|
||||
ruleFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return;
|
||||
|
||||
let values = JSON.parse(JSON.stringify(state.ruleForm));
|
||||
if (state.ruleForm.id) {
|
||||
await getAPI(SysSerialApi).apiSysSerialUpdatePost(values);
|
||||
} else {
|
||||
ElMessage({
|
||||
message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
|
||||
type: 'error',
|
||||
});
|
||||
await getAPI(SysSerialApi).apiSysSerialAddPost(values);
|
||||
}
|
||||
closeDialog();
|
||||
});
|
||||
};
|
||||
|
||||
//将属性或者函数暴露给父组件
|
||||
// 将属性或者函数暴露给父组件
|
||||
defineExpose({ openDialog });
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@ -1,62 +1,64 @@
|
||||
<template>
|
||||
<div class="sysSerial-container">
|
||||
<el-card shadow="hover" :body-style="{ padding: '5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
|
||||
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" label-width="auto" style="flex: 1 1 0%">
|
||||
<el-row :gutter="10">
|
||||
<el-col class="mb5" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="使用分类" prop="type">
|
||||
<g-sys-dict v-model="state.queryParams.type" :code="'SerialTypeEnum'" render-as="select" clearable @keyup.enter.native="handleQuery(false)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col class="mb5" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<g-sys-dict v-model="state.queryParams.status" :code="'StatusEnum'" render-as="select" clearable @keyup.enter.native="handleQuery(false)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-button-group>
|
||||
<el-button type="primary" icon="ele-Search" @click="handleQuery(false)" v-auth="'sysSerial/page'"> 查询 </el-button>
|
||||
<el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
<el-card shadow="hover" :body-style="{ padding: '5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
|
||||
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" label-width="auto" style="flex: 1 1 0%">
|
||||
<el-row :gutter="10">
|
||||
<el-col class="mb5" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="使用分类" prop="type">
|
||||
<g-sys-dict v-model="state.queryParams.type" :code="'SerialTypeEnum'" render-as="select" clearable @keyup.enter.native="handleQuery(false)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col class="mb5" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<g-sys-dict v-model="state.queryParams.status" :code="'StatusEnum'" render-as="select" clearable @keyup.enter.native="handleQuery(false)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-button-group>
|
||||
<el-button type="primary" icon="ele-Search" @click="handleQuery(false)" v-auth="'sysSerial/page'"> 查询 </el-button>
|
||||
<el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<vxe-card class="full-height" style="margin-top: 5px">
|
||||
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
|
||||
<template #toolbar_buttons>
|
||||
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysSerial/add'"> 新增 </el-button>
|
||||
</template>
|
||||
<template #toolbar_tools></template>
|
||||
<template #empty><el-empty :image-size="200" /></template>
|
||||
<template #row_record="{ row }"><ModifyRecord :data="row" /></template>
|
||||
<template #row_expy="{ row, $index }">
|
||||
{{ commonFun.dateFormatYMDHMS(row, $index, row.expy) }}
|
||||
</template>
|
||||
<template #row_type="{ row, $index }">
|
||||
<g-sys-dict v-model="row.type" :code="'SerialTypeEnum'" />
|
||||
</template>
|
||||
<template #row_resetInterval="{ row, $index }">
|
||||
<g-sys-dict v-model="row.resetInterval" :code="'ResetIntervalEnum'" />
|
||||
</template>
|
||||
<template #row_status="{ row, $index }">
|
||||
<el-switch v-model="row.status" :active-value="1" :inactive-value="2" disabled />
|
||||
</template>
|
||||
<template #row_buttons="{ row }">
|
||||
<el-button icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)" v-auth="'sysSerial/delete'">删除</el-button>
|
||||
<el-button icon="ele-Edit" size="small" text type="primary" @click="handleEdit(row)" v-auth="'sysSerial/update'">编辑</el-button>
|
||||
<el-button icon="ele-Warning" size="small" text type="primary" @click="handleDetail(row)" v-auth="'sysSerial/detail'">详情</el-button>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</vxe-card>
|
||||
<EditSysSerialDialog ref="editSysSerialDialogRef" @handleQuery="handleQuery" />
|
||||
<vxe-card class="full-height" style="margin-top: 5px">
|
||||
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
|
||||
<template #toolbar_buttons>
|
||||
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysSerial/add'"> 新增 </el-button>
|
||||
</template>
|
||||
<template #toolbar_tools></template>
|
||||
<template #empty><el-empty :image-size="200" /></template>
|
||||
<template #row_record="{ row }"><ModifyRecord :data="row" /></template>
|
||||
<template #row_expy="{ row, $index }">
|
||||
{{ commonFun.dateFormatYMDHMS(row, $index, row.expy) }}
|
||||
</template>
|
||||
<template #row_type="{ row, $index }">
|
||||
<g-sys-dict v-model="row.type" :code="'SerialTypeEnum'" />
|
||||
</template>
|
||||
<template #row_resetInterval="{ row, $index }">
|
||||
<g-sys-dict v-model="row.resetInterval" :code="'ResetIntervalEnum'" />
|
||||
</template>
|
||||
<template #row_status="{ row, $index }">
|
||||
<el-switch v-model="row.status" :active-value="1" :inactive-value="2" disabled />
|
||||
</template>
|
||||
<template #row_buttons="{ row }">
|
||||
<el-button icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)" v-auth="'sysSerial/delete'">删除</el-button>
|
||||
<el-button icon="ele-Edit" size="small" text type="primary" @click="handleEdit(row)" v-auth="'sysSerial/update'">编辑</el-button>
|
||||
<el-button icon="ele-Warning" size="small" text type="primary" @click="handleDetail(row)" v-auth="'sysSerial/detail'">详情</el-button>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</vxe-card>
|
||||
|
||||
<EditSerial ref="editSerialRef" :title="state.title" @handleQuery="handleQuery" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 流水号 -->
|
||||
<script lang="ts" setup name="sysSerial">
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
@ -64,15 +66,19 @@ import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
||||
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
||||
import commonFunction from '/@/utils/commonFunction';
|
||||
import { Local } from '/@/utils/storage';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
||||
import EditSerial from './component/editSerial.vue';
|
||||
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysSerialApi } from '/@/api-services/system/api';
|
||||
import { PageSerialInput, PageSerialOutput } from '/@/api-services/system/models';
|
||||
import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
||||
import EditSysSerialDialog from './component/editSysSerialDialog.vue';
|
||||
|
||||
const i18n = useI18n();
|
||||
const commonFun = commonFunction();
|
||||
const xGrid = ref<VxeGridInstance>();
|
||||
const editSysSerialDialogRef = ref<InstanceType<typeof EditSysSerialDialog>>();
|
||||
const editSerialRef = ref<InstanceType<typeof EditSerial>>();
|
||||
const state = reactive({
|
||||
queryParams: {} as PageSerialInput,
|
||||
showAdvanceQueryUI: false,
|
||||
@ -81,6 +87,7 @@ const state = reactive({
|
||||
defaultSort: { field: 'id', order: 'asc', descStr: 'desc' },
|
||||
},
|
||||
visible: false,
|
||||
title: '',
|
||||
});
|
||||
|
||||
// 本地存储参数
|
||||
@ -150,30 +157,33 @@ const resetQuery = async () => {
|
||||
|
||||
// 打开新增页面
|
||||
const handleAdd = () => {
|
||||
editSysSerialDialogRef.value?.openDialog(undefined, '添加流水号');
|
||||
state.title = '添加流水号'; // i18n.t('message.list.addPosition');
|
||||
editSerialRef.value?.openDialog({ status: 1, orderNo: 100 });
|
||||
};
|
||||
|
||||
// 打开编辑页面
|
||||
const handleEdit = async (row: any) => {
|
||||
editSysSerialDialogRef.value?.openDialog(row, '编辑流水号');
|
||||
state.title = '编辑流水号'; //i18n.t('message.list.editPosition');
|
||||
editSerialRef.value?.openDialog(row);
|
||||
};
|
||||
|
||||
// 打开详情页面
|
||||
const handleDetail = async (row: any) => {
|
||||
editSysSerialDialogRef.value?.openDialog(row, '流水号详情');
|
||||
state.title = '流水号详情'; //i18n.t('message.list.editPosition');
|
||||
editSerialRef.value?.openDialog(row);
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = (row: any) => {
|
||||
ElMessageBox.confirm(`确定删除记录?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm(i18n.t('message.list.confirmDeletePosition', { name: row.name }), i18n.t('message.list.hint'), {
|
||||
confirmButtonText: i18n.t('message.list.confirmButtonText'),
|
||||
cancelButtonText: i18n.t('message.list.cancelButtonText'),
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
await getAPI(SysSerialApi).apiSysSerialDeletePost({ id: row.id });
|
||||
await handleQuery();
|
||||
ElMessage.success('删除成功');
|
||||
handleQuery();
|
||||
ElMessage.success(i18n.t('message.list.successDelete'));
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
@ -192,6 +202,7 @@ const gridEvents: VxeGridListeners<PageSerialOutput> = {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
:deep(.el-card) {
|
||||
overflow: visible !important;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user