闫腾 2 лет назад
Родитель
Сommit
053195da12

+ 20 - 1
Admin.NET/Admin.NET.Application/Demo/Dm_ApplyDemoService.cs

@@ -4,6 +4,7 @@ using Admin.NET.Application.Entity;
 using Microsoft.AspNetCore.Http;
 using Magicodes.ExporterAndImporter.Core.Models;
 using Furion.Logging;
+using Yitter.IdGenerator;
 namespace Admin.NET.Application;
 /// <summary>
 /// 申请示例服务
@@ -37,7 +38,7 @@ public class Dm_ApplyDemoService : IDynamicApiController, ITransient
     /// <returns></returns>
     private ISugarQueryable<Dm_ApplyDemo> Query(Dm_ApplyDemoInput input)
     {
-        var query = _rep.AsQueryable()
+        var query = _rep.AsQueryable().Where(m=>!m.IsDelete)
             .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
                 u.ApplyNO.Contains(input.SearchKey.Trim())
                 || u.Remark.Contains(input.SearchKey.Trim())
@@ -84,6 +85,24 @@ public class Dm_ApplyDemoService : IDynamicApiController, ITransient
         await _rep.InsertAsync(entity);
         return entity.Id;
     }
+    /// <summary>
+    /// 批量增加申请示例
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    [HttpPost]
+    [ApiDescriptionSettings(Name = "PatchAdd")]
+    public async Task<List<PathAddApplyDemoItem>> PatchAdd(List<PathAddApplyDemoItem> input)
+    {
+        foreach (var item in input)
+        {
+            var entity = item.Adapt<Dm_ApplyDemo>();
+            entity.Id = YitIdHelper.NextId();
+            await _rep.InsertAsync(entity);
+            item.Id= entity.Id;
+        }
+        return input;
+    }
 
     /// <summary>
     /// 删除申请示例

+ 117 - 69
Admin.NET/Admin.NET.Application/Demo/Dto/Dm_ApplyDemoInput.cs

@@ -75,6 +75,54 @@ public class Dm_ApplyDemoBaseInput
 
 }
 
+/// <summary>
+/// 批量添加
+/// </summary>
+public class PathAddApplyDemoInput
+{
+    public List<PathAddApplyDemoItem> Items { get; set; }
+}
+public class PathAddApplyDemoItem
+{
+    /// <summary>
+    /// Id
+    /// </summary> 
+    public long Id { get; set; }
+
+    /// <summary>
+    /// 机构类型 详见字典类型 org_type
+    /// </summary>
+    public virtual long? OrgType { get; set; }
+
+    /// <summary>
+    /// ApplyNO
+    /// </summary>
+    [Required(ErrorMessage = "ApplyNO不能为空")]
+    public string ApplyNO { get; set; }
+
+    /// <summary>
+    /// ApplicatDate
+    /// </summary>
+    [Required(ErrorMessage = "ApplicatDate不能为空")]
+    public DateTime ApplicatDate { get; set; }
+
+    /// <summary>
+    /// Amount
+    /// </summary>
+    [Required(ErrorMessage = "Amount不能为空")]
+    public decimal Amount { get; set; }
+
+    /// <summary>
+    /// IsNotice
+    /// </summary>
+    [Required(ErrorMessage = "IsNotice不能为空")]
+    public bool IsNotice { get; set; }
+
+    /// <summary>
+    /// Remark
+    /// </summary>
+    public string Remark { get; set; }
+}
 /// <summary>
 /// 申请示例分页查询输入参数
 /// </summary>
@@ -121,73 +169,73 @@ public class Dm_ApplyDemoInput : BasePageInput
     public List<DateTime?> ApplicatDateRange { get; set; }
 }
 
+/// <summary>
+/// 申请示例增加输入参数
+/// </summary>
+public class AddDm_ApplyDemoInput : Dm_ApplyDemoBaseInput
+{
     /// <summary>
-    /// 申请示例增加输入参数
-    /// </summary>
-    public class AddDm_ApplyDemoInput : Dm_ApplyDemoBaseInput
-    {
-        /// <summary>
-        /// ApplyNO
-        /// </summary>
-        [Required(ErrorMessage = "ApplyNO不能为空")]
-        public override string ApplyNO { get; set; }
-        
-        /// <summary>
-        /// ApplicatDate
-        /// </summary>
-        [Required(ErrorMessage = "ApplicatDate不能为空")]
-        public override DateTime ApplicatDate { get; set; }
-        
-        /// <summary>
-        /// Amount
-        /// </summary>
-        [Required(ErrorMessage = "Amount不能为空")]
-        public override decimal Amount { get; set; }
-        
-        /// <summary>
-        /// IsNotice
-        /// </summary>
-        [Required(ErrorMessage = "IsNotice不能为空")]
-        public override bool IsNotice { get; set; }
-        
-        /// <summary>
-        /// Remark
-        /// </summary>
-        [Required(ErrorMessage = "Remark不能为空")]
-        public override string Remark { get; set; }
-        
-        /// <summary>
-        /// IsDelete
-        /// </summary>
-        [Required(ErrorMessage = "IsDelete不能为空")]
-        public override bool IsDelete { get; set; }
-        
-    }
-
-    /// <summary>
-    /// 申请示例删除输入参数
-    /// </summary>
-    public class DeleteDm_ApplyDemoInput : BaseIdInput
-    {
-    }
-
-    /// <summary>
-    /// 申请示例更新输入参数
-    /// </summary>
-    public class UpdateDm_ApplyDemoInput : Dm_ApplyDemoBaseInput
-    {
-        /// <summary>
-        /// Id
-        /// </summary>
-        [Required(ErrorMessage = "Id不能为空")]
-        public long Id { get; set; }
-        
-    }
-
-    /// <summary>
-    /// 申请示例主键查询输入参数
-    /// </summary>
-    public class QueryByIdDm_ApplyDemoInput : DeleteDm_ApplyDemoInput
-    {
-
-    }
+    /// ApplyNO
+    /// </summary>
+    [Required(ErrorMessage = "ApplyNO不能为空")]
+    public override string ApplyNO { get; set; }
+
+    /// <summary>
+    /// ApplicatDate
+    /// </summary>
+    [Required(ErrorMessage = "ApplicatDate不能为空")]
+    public override DateTime ApplicatDate { get; set; }
+
+    /// <summary>
+    /// Amount
+    /// </summary>
+    [Required(ErrorMessage = "Amount不能为空")]
+    public override decimal Amount { get; set; }
+
+    /// <summary>
+    /// IsNotice
+    /// </summary>
+    [Required(ErrorMessage = "IsNotice不能为空")]
+    public override bool IsNotice { get; set; }
+
+    /// <summary>
+    /// Remark
+    /// </summary>
+    [Required(ErrorMessage = "Remark不能为空")]
+    public override string Remark { get; set; }
+
+    /// <summary>
+    /// IsDelete
+    /// </summary>
+    [Required(ErrorMessage = "IsDelete不能为空")]
+    public override bool IsDelete { get; set; }
+
+}
+
+/// <summary>
+/// 申请示例删除输入参数
+/// </summary>
+public class DeleteDm_ApplyDemoInput : BaseIdInput
+{
+}
+
+/// <summary>
+/// 申请示例更新输入参数
+/// </summary>
+public class UpdateDm_ApplyDemoInput : Dm_ApplyDemoBaseInput
+{
+    /// <summary>
+    /// Id
+    /// </summary>
+    [Required(ErrorMessage = "Id不能为空")]
+    public long Id { get; set; }
+
+}
+
+/// <summary>
+/// 申请示例主键查询输入参数
+/// </summary>
+public class QueryByIdDm_ApplyDemoInput : DeleteDm_ApplyDemoInput
+{
+
+}

+ 9 - 1
Web/src/api/main/dm_ApplyDemo.ts

@@ -1,4 +1,4 @@
-import request from '/@/utils/request';
+import request,{request2} from '/@/utils/request';
 import { downloadByData } from '/@/utils/download';
 enum Api {
 	AddDm_ApplyDemo = '/api/dm_ApplyDemo/add',
@@ -8,6 +8,14 @@ enum Api {
 	DetailDm_ApplyDemo = '/api/dm_ApplyDemo/detail',
 }
 
+// 批量增加申请示例
+export const patchAddDm_ApplyDemo = (params?: any) =>
+	request2({
+		url: '/api/dm_ApplyDemo/PatchAdd',
+		method: 'post',
+		data: params,
+	});
+
 // 增加申请示例
 export const addDm_ApplyDemo = (params?: any) =>
 	request({

+ 9 - 6
Web/src/stores/userInfo.ts

@@ -132,12 +132,14 @@ export const useUserInfo = defineStore('userInfo', {
 
 		//根据字典类型和值取字典项
 		getDictItemByVal(typePCode: string, val: string) {
-			const _val = val.toString();
-			const ds = this.getDictDatasByCode(typePCode);
-			for (let index = 0; index < ds.length; index++) {
-				const element = ds[index];
-				if (element.code == _val) {
-					return element;
+			if(val){
+				const _val = val.toString();
+				const ds = this.getDictDatasByCode(typePCode);
+				for (let index = 0; index < ds.length; index++) {
+					const element = ds[index];
+					if (element.code == _val) {
+						return element;
+					}
 				}
 			}
 			return {};
@@ -149,6 +151,7 @@ export const useUserInfo = defineStore('userInfo', {
 		},
 		//根据字典类型和描述取值
 		getDictValByLabel(typePCode: string, label: string) {
+			if(!label) return ''
 			const ds = this.getDictDatasByCode(typePCode);
 			for (let index = 0; index < ds.length; index++) {
 				const element = ds[index];

+ 96 - 124
Web/src/views/main/dm_ApplyDemo/component/patchEditDialog.vue

@@ -1,13 +1,13 @@
 <template>
 	<div class="dm_ApplyDemo-container">
-		<el-dialog v-model="isShowDialog"  width="80%" draggable="">
+		<el-dialog v-model="isShowDialog" width="80%" draggable="">
 			<template #header>
 				<div style="color: #fff">
 					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
 					<span>{{ props.title }}</span>
 				</div>
 			</template>
-			<TableEditor :columns="editFormSchema" :v-model:value="vm.value" :rules="rules"></TableEditor>
+			<TableEditor :columns="editFormSchema" v-model:value="vm.value" :rules="rules"></TableEditor>
 			<template #footer>
 				<span class="dialog-footer">
 					<el-button @click="cancel">取 消</el-button>
@@ -24,133 +24,105 @@
 }
 </style>
 <script lang="ts" setup>
-	import { ref,onMounted, reactive } from "vue";
-	import { getDictDataItem as di, getDictDataListInt as dl } from '/@/utils/dict-utils';
-	import { ElMessage } from "element-plus";
-	import type { FormRules } from "element-plus";
-	import { addDm_ApplyDemo, updateDm_ApplyDemo, detailDm_ApplyDemo } from "/@/api/main/dm_ApplyDemo";
-	import TableEditor from "/@/components/table/TableEditor.vue";
-
-	//父级传递来的参数
-	var props = defineProps({
-		title: {
+import { ref, onMounted, reactive } from 'vue';
+import { getDictDataItem as di, getDictDataListInt as dl } from '/@/utils/dict-utils';
+import { ElMessage } from 'element-plus';
+import type { FormRules } from 'element-plus';
+import { patchAddDm_ApplyDemo} from '/@/api/main/dm_ApplyDemo';
+import TableEditor from '/@/components/table/TableEditor.vue';
+
+//父级传递来的参数
+var props = defineProps({
+	title: {
 		type: String,
-		default: "",
+		default: '',
+	},
+});
+//父级传递来的函数,用于回调
+const emit = defineEmits(['reloadTable']);
+
+const isShowDialog = ref(false);
+//自行添加其他规则
+const rules = ref<FormRules>({
+	orgType: [{ required: true, message: '请输入机构类型!', trigger: 'blur' }],
+	applyNO: [{ required: true, message: '请输入申请号!', trigger: 'blur' }],
+	applicatDate: [{ required: true, message: '请选择申请时间!', trigger: 'change' }],
+	amount: [{ required: true, message: '请输入申请金额!', trigger: 'blur' }],
+	//      remark: [{ required: true, message: '请输入备注!', trigger: 'blur',},],
+});
+const editFormSchema = [
+	{
+		label: 'id',
+		field: 'id',
+		component: 'el-input',
+		ifShow: false,
+	},
+	{
+		label: '机构类型',
+		field: 'orgType',
+		component: 'el-select',
+		componentProps: {
+			options: dl('org_type'),
+		},
+	},
+	{
+		label: '申请号',
+		field: 'applyNO',
+		component: 'el-input',
+	},
+	{
+		label: '申请时间',
+		field: 'applicatDate',
+		component: 'el-date-picker',
+	},
+	{
+		label: '申请金额',
+		field: 'amount',
+		component: 'el-input-number',
+	},
+	{
+		label: '是否通知',
+		field: 'isNotice',
+		component: 'el-switch',
+	},
+	{
+		label: '备注',
+		field: 'remark',
+		component: 'el-input',
 	},
-	});
-	//父级传递来的函数,用于回调
-	const emit = defineEmits(["reloadTable"]);
-	const ruleFormRef = ref();
-	const isShowDialog = ref(false);
-	const ruleForm = ref<any>({});
-	//自行添加其他规则
-	const rules = ref<FormRules>({
-        orgType: [{ required: true, message: '请输入机构类型!', trigger: 'blur',},],
-        applyNO: [{ required: true, message: '请输入申请号!', trigger: 'blur',},],
-        applicatDate: [{ required: true, message: '请选择申请时间!', trigger: 'change',},],
-        amount: [{ required: true, message: '请输入申请金额!', trigger: 'blur',},],
-  //      remark: [{ required: true, message: '请输入备注!', trigger: 'blur',},],
-	});
- const editFormSchema = [
-  {
-    label: 'id',
-    field: 'id',
-    component: 'el-input',
-    ifShow: false,
-  }, 
-  {
-    label: '机构类型',
-    field: 'orgType',
-    component: 'el-select',
-    componentProps: {
-      options: dl('org_type'),
-    },
-  },
-  {
-    label: '申请号',
-    field: 'applyNO',
-    component: 'el-input',
-  },
-  {
-    label: '申请时间',
-    field: 'applicatDate',
-    component: 'el-date-picker',
-  },
-  {
-    label: '申请金额',
-    field: 'amount',
-    component: 'el-input-number',
-  },
-  {
-    label: '是否通知',
-    field: 'isNotice',
-    component: 'el-switch',
-  },
-  {
-    label: '备注',
-    field: 'remark',
-    component: 'el-input',
-  },
 ];
 
-var vm = reactive({  value: [] as any[] });
-	// 打开弹窗
-	const openDialog = async (row: any) => {
-		// ruleForm.value = JSON.parse(JSON.stringify(row));
-		// 改用detail获取最新数据来编辑
-		let rowData = JSON.parse(JSON.stringify(row));
-		if (rowData.id)
-			ruleForm.value = (await detailDm_ApplyDemo(rowData.id)).data.result;
-		else
-			ruleForm.value = rowData;
-		isShowDialog.value = true;
-	};
-
-	// 关闭弹窗
-	const closeDialog = () => {
-		emit("reloadTable");
-		isShowDialog.value = false;
-	};
-
-	// 取消
-	const cancel = () => {
-		isShowDialog.value = false;
-	};
-
-	// 提交
-	const submit = async () => {
-		ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
-			if (isValid) {
-				let values = ruleForm.value;
-				if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
-					await addDm_ApplyDemo(values);
-				} else {
-					await updateDm_ApplyDemo(values);
-				}
-				closeDialog();
-			} else {
-				ElMessage({
-					message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
-					type: "error",
-				});
-			}
+var vm = reactive({ value: [] as any[] });
+// 打开弹窗
+const openDialog = async (row: any) => {
+	isShowDialog.value = true;
+};
+
+// 关闭弹窗
+const closeDialog = () => {
+	emit('reloadTable');
+	isShowDialog.value = false;
+};
+
+// 取消
+const cancel = () => {
+	isShowDialog.value = false;
+};
+
+// 提交
+const submit = async () => {
+	if(vm.value && vm.value.length>0){
+		await patchAddDm_ApplyDemo(vm.value).then((res:any)=>{
+			//vm.value=res;
+			console.log(res)
 		});
-	};
+		closeDialog();
+	}
+};
 
+// 页面加载时
+onMounted(async () => {});
 
-
-
-
-
-
-	// 页面加载时
-	onMounted(async () => {
-	});
-
-	//将属性或者函数暴露给父组件
-	defineExpose({ openDialog });
+//将属性或者函数暴露给父组件
+defineExpose({ openDialog });
 </script>
-
-
-
-