liangzongpeng 2024-07-02 11:23:42 +08:00
commit 4623d4780e
8 changed files with 324 additions and 32 deletions

View File

@ -143,3 +143,16 @@ public class QueryByIdSysUnitGroupInput : DeleteSysUnitGroupInput
{
}
/// <summary>
/// 单位组检查输入参数
/// </summary>
public class CheckSysUnitGroupInput : SysUnitGroupBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}

View File

@ -11,9 +11,14 @@ namespace Admin.NET.Application;
public class SysUnitGroupService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysUnitGroup> _rep;
public SysUnitGroupService(SqlSugarRepository<SysUnitGroup> rep)
private readonly SysUnitService _sysUnitService;
public SysUnitGroupService(SqlSugarRepository<SysUnitGroup> rep,
SysUnitService sysUnitService )
{
_rep = rep;
_sysUnitService = sysUnitService;
}
/// <summary>
@ -101,9 +106,17 @@ public class SysUnitGroupService : IDynamicApiController, ITransient
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<SysUnitGroupOutput>().ToListAsync();
}
/// <summary>
/// 检查单位是否存在数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "CheckUnitList")]
public async Task<bool> CheckUnitList(CheckSysUnitGroupInput input)
{
var sysUnits = await _sysUnitService.ListByGroupId(input.Id);
return sysUnits.Any();
}
}

View File

@ -2,6 +2,7 @@
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace Admin.NET.Application;
/// <summary>
/// 单位服务
@ -171,5 +172,21 @@ public class SysUnitService : IDynamicApiController, ITransient
return result;
}
/// <summary>
/// 校验基本单位是否唯一
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "checkBaseUnit")]
public async Task<SysUnit> CheckBaseUnit(AddSysUnitInput input)
{
var result = await _rep.AsQueryable()
.Where(a => !a.IsDelete && a.IsBaseUnit==true)
.WhereIF(input.GroupUnitId > 0, u => u.GroupUnitId == input.GroupUnitId)
.FirstAsync();
return result;
}
}

View File

@ -13,7 +13,6 @@
<ItemGroup>
<None Remove="Admin.NET.Core.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.24" />
<PackageReference Include="AngleSharp" Version="1.1.2" />

View File

@ -362,6 +362,54 @@ export const SysUnitApiAxiosParamCreator = function (configuration?: Configurati
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {UpdateSysUnitInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysUnitCheckPost: async (body?: UpdateSysUnitInput, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysUnit/checkBaseUnit`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
@ -473,6 +521,19 @@ export const SysUnitApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary
* @param body
* @param options
*/
async apiSysUnitCheckPost(body?: UpdateSysUnitInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysUnitApiAxiosParamCreator(configuration).apiSysUnitCheckPost(body, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};
@ -551,6 +612,15 @@ export const SysUnitApiFactory = function (configuration?: Configuration, basePa
async apiSysUnitUpdatePost(body?: UpdateSysUnitInput, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysUnitApiFp(configuration).apiSysUnitUpdatePost(body, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param body
* @param options
*/
async apiSysUnitCheckPost(body?: UpdateSysUnitInput, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysUnitApiFp(configuration).apiSysUnitCheckPost(body, options).then((request) => request(axios, basePath));
},
};
};
@ -637,4 +707,14 @@ export class SysUnitApi extends BaseAPI {
public async apiSysUnitUpdatePost(body?: UpdateSysUnitInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysUnitApiFp(this.configuration).apiSysUnitUpdatePost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param body
* @param options
*/
async apiSysUnitCheckPost(body?: UpdateSysUnitInput, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysUnitApiFp(this.configuration).apiSysUnitCheckPost(body, options).then((request) => request(this.axios, this.basePath));
}
}

View File

@ -25,6 +25,7 @@ import { AdminResultSysUnitGroup } from '../models';
import { DeleteSysUnitGroupInput } from '../models';
import { SysUnitGroupInput } from '../models';
import { UpdateSysUnitGroupInput } from '../models';
import {CheckSysUnitGroupInput} from "/@/api-services/models/check-sys-unit-group-input";
/**
* SysUnitGroupApi - axios parameter creator
* @export
@ -313,6 +314,54 @@ export const SysUnitGroupApiAxiosParamCreator = function (configuration?: Config
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {CheckSysUnitGroupInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysUnitGroupCheckPost: async (body?: CheckSysUnitGroupInput, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysUnitGroup/CheckUnitList`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
@ -410,6 +459,20 @@ export const SysUnitGroupApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary
* @param {CheckSysUnitGroupInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysUnitGroupCheckPost(body?: CheckSysUnitGroupInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysUnitGroupApiAxiosParamCreator(configuration).apiSysUnitGroupCheckPost(body, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};
@ -553,4 +616,15 @@ export class SysUnitGroupApi extends BaseAPI {
public async apiSysUnitGroupUpdatePost(body?: UpdateSysUnitGroupInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysUnitGroupApiFp(this.configuration).apiSysUnitGroupUpdatePost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {UpdateSysUnitGroupInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysUnitGroupApi
*/
public async apiSysUnitGroupCheckPost(body?: CheckSysUnitGroupInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysUnitGroupApiFp(this.configuration).apiSysUnitGroupCheckPost(body, options).then((request) => request(this.axios, this.basePath));
}
}

View File

@ -0,0 +1,29 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* .NET (.NET6/Vue3)沿
*
* 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 CheckSysUnitGroupInput
*/
export interface CheckSysUnitGroupInput {
/**
* Id
*
* @type {number}
* @memberof UpdateSysUnitGroupInput
*/
id: number;
}

View File

@ -62,6 +62,46 @@
</div>
<div class="tab">
<div>
<!-- <el-table-->
<!-- :data="data.unit"-->
<!-- style="width: 40%"-->
<!-- v-loading="loading"-->
<!-- tooltip-effect="light"-->
<!-- row-key="id"-->
<!-- @sort-change="sortChange"-->
<!-- border="">-->
<!-- <el-table-column type="index" label="序号" width="55" align="center"/>-->
<!-- <el-table-column prop="name" label="名称" width="140" show-overflow-tooltip="" />-->
<!-- <el-table-column prop="codeNum" label="编码" width="140" show-overflow-tooltip="" />-->
<!-- <el-table-column prop="aliasName" label="别名" width="140" show-overflow-tooltip="" />-->
<!-- <el-table-column prop="simpleNumber" label="助记码" width="140" show-overflow-tooltip="" />-->
<!-- <el-table-column prop="specifications" label="规格型号" width="140" show-overflow-tooltip="" />-->
<!-- <el-table-column prop="isEnable" label="可用状态" width="120" show-overflow-tooltip="">-->
<!-- <template #default="scope">-->
<!-- <el-tag v-if="scope.row.isEnable"> </el-tag>-->
<!-- <el-tag type="danger" v-else> </el-tag>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column prop="remarks" label="备注" width="200" show-overflow-tooltip="" />-->
<!-- <el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" v-if="auth('materials:update') || auth('materials:delete')">-->
<!-- <template #default="scope">-->
<!-- <el-button icon="ele-Edit" size="small" text="" type="primary" @click="editUnit(scope.row)"> </el-button>-->
<!-- <el-button icon="ele-Delete" size="small" text="" type="primary" @click="deleteUnit(scope.row)" > 删除 </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<!-- <el-pagination-->
<!-- v-model:currentPage="tableParams.page"-->
<!-- v-model:page-size="tableParams.pageSize"-->
<!-- :total="tableParams.total"-->
<!-- :page-sizes="[10, 20, 50, 100, 200, 500]"-->
<!-- small=""-->
<!-- background=""-->
<!-- @size-change="handleSizeChange"-->
<!-- @current-change="handleCurrentChange"-->
<!-- layout="total, sizes, prev, pager, next, jumper"-->
<!-- />-->
<vxe-table show-overflow height="100%" :data="data.unit" :border=true
:tree-config="{ transform: true }" :scroll-y="{ gt: 20 }">
<vxe-column type="checkbox" width="60" fixed="left"></vxe-column>
@ -216,10 +256,12 @@ import { SysUnitApi, SysUnitGroupApi } from '/@/api-services/api';
import { AddSysUnitInput, SqlSugarPagedListSysUnitOutput, SysUnitGroupOutput, SysUnitInput} from '/@/api-services/models';
import type { FormRules } from "element-plus";
import { ElMessageBox, ElMessage } from 'element-plus';
import {auth} from "/@/utils/authFunction";
let data = reactive({
unit: [] as SqlSugarPagedListSysUnitOutput[],//
unitGroup: [] as SysUnitGroupOutput[],//
selectUnitGroupId:0,
});
const ruleFormRef = ref();
@ -268,6 +310,7 @@ const unitGroup = async () => {
//
const radioChangeEvent = ({ row }) => {
data.selectUnitGroupId = row.id;
unitPage({groupUnitId:row.id})
}
const formInline = reactive({} as SysUnitInput)
@ -289,20 +332,35 @@ const addUnit= ()=>{
//
const unitSubmit = async () => {
//
let checkRes = await getAPI(SysUnitApi).apiSysUnitCheckPost(unitFrom.value);
if(checkRes.data.code === 200){
const item = checkRes.data.result;
if(mTitle.value=='新增'){
if(unitFrom.value.isBaseUnit && item!=null){
ElMessage({ message: '基本单位必须唯一', type: 'error', });
unitFrom.value.isBaseUnit = false;
return;
}
let res = await getAPI(SysUnitApi).apiSysUnitAddPost(unitFrom.value);
if (res.data.code===200) {
dialogTableVisible.value = false;
unitPage();
unitPage({groupUnitId:data.selectUnitGroupId});
}
}else{
if(unitFrom.value.isBaseUnit && item!=null && item.id!=unitFrom.value.id)
{
ElMessage({ message: '基本单位必须唯一', type: 'error', });
unitFrom.value.isBaseUnit = false;
return;
}
let res = await getAPI(SysUnitApi).apiSysUnitUpdatePost(unitFrom.value);
if (res.data.code===200) {
dialogTableVisible.value = false;
unitPage();
unitPage({groupUnitId:data.selectUnitGroupId});
}
}
}
}
const editUnit=async(row:any)=>{
@ -321,7 +379,7 @@ const deleteUnit=async(row:any)=>{
let res = await getAPI(SysUnitApi).apiSysUnitDeletePost(row);
if (res.data.code == 200) {
ElMessage({ message: '成功', type: 'success', })
unitPage()
unitPage();
//state.tableData.handleList();
} else
ElMessage.error(res.data.message!)
@ -342,6 +400,12 @@ const editUnitGroup=async(row:any)=>{
}
const deleteUnitGroup=async(row:any)=>{
let checkRes = await getAPI(SysUnitGroupApi).apiSysUnitGroupCheckPost({Id:row.id});
if(checkRes.data.code == 200){
const result = checkRes.data.result;
if(result){
return ElMessage.error("存在单位数据,不允许删除")
}
ElMessageBox.confirm(`确定删除?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -352,6 +416,7 @@ const deleteUnitGroup=async(row:any)=>{
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupDeletePost(row);
if (res.data.code == 200) {
ElMessage({ message: '成功', type: 'success', })
unitGroup()
unitPage()
//state.tableData.handleList();
} else
@ -360,6 +425,8 @@ const deleteUnitGroup=async(row:any)=>{
.catch(() => {});
}
}
const pageVO1 = reactive({
currentPage: 1,
pageSize: 10,