@@ -180,6 +180,22 @@ namespace Yi.Framework.Ddd.Application
|
|||||||
return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
|
return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取实体动态下拉框列表,子类重写该方法,通过 keywords 进行筛选
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keywords">查询关键字</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<PagedResultDto<TGetListOutputDto>> GetSelectDataListAsync(string? keywords = null)
|
||||||
|
{
|
||||||
|
List<TEntity> entities = await Repository.GetListAsync();
|
||||||
|
|
||||||
|
// 获取总数并映射结果
|
||||||
|
var totalCount = entities.Count;
|
||||||
|
var dtos = await MapToGetListOutputDtosAsync(entities);
|
||||||
|
|
||||||
|
return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量删除实体
|
/// 批量删除实体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public static class SqlSugarCoreExtensions
|
|||||||
ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
|
ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
|
||||||
where TDbContext : class, ISqlSugarDbContextDependencies
|
where TDbContext : class, ISqlSugarDbContextDependencies
|
||||||
{
|
{
|
||||||
services.TryAdd(new ServiceDescriptor(
|
services.Add(new ServiceDescriptor(
|
||||||
typeof(ISqlSugarDbContextDependencies),
|
typeof(ISqlSugarDbContextDependencies),
|
||||||
typeof(TDbContext),
|
typeof(TDbContext),
|
||||||
serviceLifetime));
|
serviceLifetime));
|
||||||
|
|||||||
@@ -59,6 +59,6 @@ export function delMenu(menuId) {
|
|||||||
return request({
|
return request({
|
||||||
url: `/menu`,
|
url: `/menu`,
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
params:{id:menuId}
|
params:{ids:menuId}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
83
Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue
Normal file
83
Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 动态数据下拉选择框 -->
|
||||||
|
<el-select v-model="value" :value-key="servicekey" filterable remote clearable :placeholder="placeholder"
|
||||||
|
:loading="loading" :style="{ width: width + '%' }" :remote-method="remoteMethod" @change="handleChange"
|
||||||
|
@clear="handleClear">
|
||||||
|
<el-option v-for="item in options" :key="item[servicekey]" :label="item[servicelabel]" :value="item" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="SelectDataTag">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import request from '@/utils/request.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: '请输入关键字',
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 100,
|
||||||
|
},
|
||||||
|
/** 动态服务名称 */
|
||||||
|
servicename: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
/** 指定响应数据的key */
|
||||||
|
servicekey: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
/** 指定响应数据的label */
|
||||||
|
servicelabel: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
/** 记录表格渲染行索引 */
|
||||||
|
index: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 0,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const emits = defineEmits(["change", "clear"]);
|
||||||
|
|
||||||
|
const list = ref([]);
|
||||||
|
const options = ref([]);
|
||||||
|
const value = ref([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
function getSelectDataList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/' + props.servicename + '/select-data-list?keywords=' + query,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function remoteMethod(query) {
|
||||||
|
options.value = [];
|
||||||
|
if (query) {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
getSelectDataList(query).then(
|
||||||
|
(response) => {
|
||||||
|
list.value = response.data.items;
|
||||||
|
options.value = list.value;
|
||||||
|
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleChange(data) {
|
||||||
|
emits("change", data || [], props.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClear() {
|
||||||
|
emits("clear");
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -43,6 +43,8 @@ import ImagePreview from "@/components/ImagePreview"
|
|||||||
import TreeSelect from '@/components/TreeSelect'
|
import TreeSelect from '@/components/TreeSelect'
|
||||||
// 字典标签组件
|
// 字典标签组件
|
||||||
import DictTag from '@/components/DictTag'
|
import DictTag from '@/components/DictTag'
|
||||||
|
// 动态数据下拉选择框组件
|
||||||
|
import SelectDataTag from '@/components/SelectDataTag'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
@@ -57,6 +59,7 @@ app.config.globalProperties.selectDictLabel = selectDictLabel
|
|||||||
app.config.globalProperties.selectDictLabels = selectDictLabels
|
app.config.globalProperties.selectDictLabels = selectDictLabels
|
||||||
|
|
||||||
// 全局组件挂载
|
// 全局组件挂载
|
||||||
|
app.component('SelectDataTag', SelectDataTag)
|
||||||
app.component('DictTag', DictTag)
|
app.component('DictTag', DictTag)
|
||||||
app.component('Pagination', Pagination)
|
app.component('Pagination', Pagination)
|
||||||
app.component('TreeSelect', TreeSelect)
|
app.component('TreeSelect', TreeSelect)
|
||||||
|
|||||||
@@ -230,6 +230,13 @@
|
|||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user