Quellcode durchsuchen

几处代码优化

Ir0nMax vor 1 Jahr
Ursprung
Commit
445e9069f1

+ 2 - 3
Admin.NET/Admin.NET.Web.Entry/wwwroot/template/Service.cs.vm

@@ -166,9 +166,8 @@ public class @(Model.ClassName)Service : IDynamicApiController, ITransient
     [ApiDescriptionSettings(Name = "BatchDelete"), HttpPost]
     public async Task<int> BatchDelete([Required(ErrorMessage = "主键列表不能为空")]List<Delete@(Model.ClassName)Input> input)
     {
-        var exp = Expressionable.Create<@(Model.ClassName)>();
-        foreach (var row in input) exp = exp.Or(it => @Model.PrimaryKeysFormat(" && ", "it.{0} == row.{0}"));
-        var list = await _@(Model.LowerClassName)Rep.AsQueryable().Where(exp.ToExpression()).ToListAsync();
+        var ids = input.Select(row => row.Id).ToList();
+        var list = await _@(Model.LowerClassName)Rep.AsQueryable().Where(it => ids.Contains(it.Id)).ToListAsync();
         return await _@(Model.LowerClassName)Rep.FakeDeleteAsync(list);   //假删除
         //return await _@(Model.LowerClassName)Rep.DeleteAsync(list);   //真删除
     }

+ 61 - 58
Web/src/components/sysDict/sysDict.vue

@@ -1,75 +1,78 @@
 <script setup lang="ts">
-import {reactive, watch} from "vue";
-import { DictItem } from "/@/types/global";
-import { useUserInfo } from "/@/stores/userInfo";
+import { reactive, watch } from 'vue';
+import { DictItem } from '/@/types/global';
+import { useUserInfo } from '/@/stores/userInfo';
 
 const emit = defineEmits(['update:modelValue']);
 const dictList = useUserInfo().dictList;
 const props = defineProps({
-  modelValue: {
-    type: [String, Number, Boolean, null],
-    required: true
-  },
-  code: {
-    type: String,
-    required: true
-  },
-  propLabel: {
-    type: String,
-    default: 'label'
-  },
-  propValue: {
-    type: String,
-    default: 'value'
-  },
-  onItemFilter: {
-    type: Function,
-    default: (dict: any): boolean => dict
-  },
-  renderAs: {
-    type: String,
-    default: 'tag',
-    validator(value: string) {
-      return ['tag', 'select', 'radio'].includes(value);
-    }
-  }
+	modelValue: {
+		type: [String, Number, Boolean, null],
+		required: true,
+	},
+	code: {
+		type: String,
+		required: true,
+	},
+	propLabel: {
+		type: String,
+		default: 'label',
+	},
+	propValue: {
+		type: String,
+		default: 'value',
+	},
+	onItemFilter: {
+		type: Function,
+		default: (dict: any): boolean => dict,
+	},
+	renderAs: {
+		type: String,
+		default: 'tag',
+		validator(value: string) {
+			return ['tag', 'select', 'radio'].includes(value);
+		},
+	},
 });
 
 const state = reactive({
-  dict: {} as DictItem | undefined,
-  dictData: [] as DictItem[],
-  value: null as any,
+	dict: {} as DictItem | undefined,
+	dictData: [] as DictItem[],
+	value: null as any,
 });
 
 const setDictValue = (value: any) => {
-  state.value = value;
-  state.dictData = dictList[props.code]?.filter(props.onItemFilter) ?? [];
-  state.dict = state.dictData.find((x: any) => x[props.propValue] == state.value);
-  if (state.dict && !["success", "warning", "info", "primary", "danger"].includes(state.dict.tagType ?? '')) state.dict.tagType = "primary";
-}
+	state.value = value;
+	state.dictData = dictList[props.code]?.filter(props.onItemFilter) ?? [];
+	state.dict = state.dictData.find((x: any) => x[props.propValue] == state.value);
+	if (state.dict && !['success', 'warning', 'info', 'primary', 'danger'].includes(state.dict.tagType ?? '')) state.dict.tagType = 'primary';
+};
 
-watch(() => props.modelValue, (newValue) => setDictValue(newValue), { immediate: true });
+watch(
+	() => props.modelValue,
+	(newValue) => setDictValue(newValue),
+	{ immediate: true }
+);
 </script>
 
 <template>
-  <!-- 渲染标签 -->
-  <template v-if="props.renderAs === 'tag'">
-    <el-tag v-if="state.dict" v-bind="$attrs" :type="state.dict.tagType" :style="state.dict.styleSetting" :class="state.dict.classSetting">{{ state.dict[props.propLabel] }}</el-tag>
-    <span v-else>{{ state.value }}</span>
-  </template>
-  <!-- 渲染选择器 -->
-  <template v-if="props.renderAs === 'select'">
-    <el-select v-model="state.value" v-bind="$attrs" @change="(newValue: any) => emit('update:modelValue', newValue)">
-      <el-option :label="item[props.propLabel]" :value="item[props.propValue]" v-for="(item, index) in state.dictData" :key="index" />
-    </el-select>
-  </template>
-  <!-- 渲染单选框 -->
-  <template v-if="props.renderAs === 'radio'">
-    <el-radio-group v-model="state.value" v-bind="$attrs" @change="(newValue: any) => emit('update:modelValue', newValue)">
-      <el-radio :value="item[props.propValue]" v-for="(item, index) in state.dictData" :key="index">{{item[props.propLabel]}}</el-radio>
-    </el-radio-group>
-  </template>
+	<!-- 渲染标签 -->
+	<template v-if="props.renderAs === 'tag'">
+		<el-tag v-if="state.dict" v-bind="$attrs" :type="state.dict.tagType" :style="state.dict.styleSetting" :class="state.dict.classSetting">{{ state.dict[props.propLabel] }}</el-tag>
+		<span v-else>{{ state.value }}</span>
+	</template>
+	<!-- 渲染选择器 -->
+	<template v-if="props.renderAs === 'select'">
+		<el-select v-model="state.value" v-bind="$attrs" @change="(newValue: any) => emit('update:modelValue', newValue)">
+			<el-option :label="`[${item[props.propValue]}]${item[props.propLabel]}`" :value="item[props.propValue]" v-for="(item, index) in state.dictData" :key="index" />
+		</el-select>
+	</template>
+	<!-- 渲染单选框 -->
+	<template v-if="props.renderAs === 'radio'">
+		<el-radio-group v-model="state.value" v-bind="$attrs" @change="(newValue: any) => emit('update:modelValue', newValue)">
+			<el-radio :value="item[props.propValue]" v-for="(item, index) in state.dictData" :key="index">{{ item[props.propLabel] }}</el-radio>
+		</el-radio-group>
+	</template>
 </template>
 
-<style scoped lang="scss">
-</style>
+<style scoped lang="scss"></style>

+ 1 - 1
Web/src/views/system/job/index.vue

@@ -142,7 +142,7 @@
 				</el-table-column>
 				<el-table-column prop="jobDetail.createType" label="作业创建类型" width="110" align="center" show-overflow-tooltip>
 					<template #default="scope">
-            <g-sys-dict v-model="scope.row.jobDetail?.createType" code="JobCreateTypeEnum" />
+						<g-sys-dict v-model="scope.row.jobDetail.createType" code="JobCreateTypeEnum" />
 					</template>
 				</el-table-column>
 				<!-- <el-table-column prop="jobDetail.includeAnnotations" label="扫描特性触发器" align="center" show-overflow-tooltip>