Explorar el Código

代码模板,查询备份参数

CzRger hace 8 meses
padre
commit
0ce9d7da94

+ 14 - 9
snowy-plugin/snowy-plugin-gen/src/main/resources/frontend/index.vue.btl

@@ -64,7 +64,7 @@
 				<% } %>
 				<% } %>
 				<a-col :span="6">
-					<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
+					<a-button type="primary" @click="onSearch()">查询</a-button>
 					<a-button style="margin: 0 8px" @click="reset">重置</a-button>
 					<% if(searchCount > 3) { %>
 					<a @click="toggleAdvanced" style="margin-left: 8px">
@@ -137,7 +137,7 @@
 			</template>
 		</s-table>
 	</a-card>
-	<Form ref="formRef" @successful="tableRef.refresh()" />
+	<Form ref="formRef" @successful="onSearch()" />
 </template>
 
 <script setup name="${busName}">
@@ -161,6 +161,7 @@
 	import ${classNameFirstLower}Api from '@/api/${moduleName}/${classNameFirstLower}Api'
 	<% if (searchCount > 0) { %>
 	const searchFormState = ref({})
+	const searchFormStateReal = ref({}) // 点击搜索后备份的查询参数
 	const searchFormRef = ref()
 	<% } %>
 	const tableRef = ref()
@@ -213,30 +214,34 @@
 	}
 	const loadData = (parameter) => {
 		<% if (searchCount > 0) { %>
-		const searchFormParam = cloneDeep(searchFormState.value)
 		<% for(var i = 0; i < configList.~size; i++) { %>
 		<% if(!configList[i].needTableId && configList[i].needPage) { %>
 		<% if (configList[i].effectType == 'datepicker') {%>
 		// ${configList[i].fieldNameCamelCase}范围查询条件重载
-		if (searchFormParam.${configList[i].fieldNameCamelCase}) {
-			searchFormParam.start${configList[i].fieldNameCamelCaseFirstUpper} = searchFormParam.${configList[i].fieldNameCamelCase}[0]
-			searchFormParam.end${configList[i].fieldNameCamelCaseFirstUpper} = searchFormParam.${configList[i].fieldNameCamelCase}[1]
-			delete searchFormParam.${configList[i].fieldNameCamelCase}
+		if (searchFormStateReal.value.${configList[i].fieldNameCamelCase}) {
+			searchFormStateReal.value.start${configList[i].fieldNameCamelCaseFirstUpper} = searchFormStateReal.value.${configList[i].fieldNameCamelCase}[0]
+			searchFormStateReal.value.end${configList[i].fieldNameCamelCaseFirstUpper} = searchFormStateReal.value.${configList[i].fieldNameCamelCase}[1]
+			delete searchFormStateReal.value.${configList[i].fieldNameCamelCase}
 		}
 		<% } %>
 		<% } %>
 		<% } %>
-		return ${classNameFirstLower}Api.${classNameFirstLower}Page(Object.assign(parameter, searchFormParam)).then((data) => {
+		return ${classNameFirstLower}Api.${classNameFirstLower}Page(Object.assign(parameter, searchFormStateReal.value)).then((data) => {
 		<% } else { %>
 		return ${classNameFirstLower}Api.${classNameFirstLower}Page(parameter).then((data) => {
 		<% } %>
 			return data
 		})
 	}
+	// 搜索同时备份参数
+    const onSearch = (parameter) => {
+        searchFormStateReal.value = cloneDeep(searchFormState.value)
+        tableRef.value.refresh(parameter)
+    }
 	// 重置
 	const reset = () => {
 		searchFormRef.value.resetFields()
-		tableRef.value.refresh(true)
+		onSearch(true)
 	}
 	// 删除
 	const delete${className} = (record) => {

+ 33 - 28
snowy-plugin/snowy-plugin-gen/src/main/resources/frontend/index_inside.vue.btl

@@ -64,7 +64,7 @@
 				<% } %>
 				<% } %>
 				<a-col :span="6">
-					<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
+					<a-button type="primary" @click="onSearch()">查询</a-button>
 					<a-button style="margin: 0 8px" @click="reset">重置</a-button>
 					<% if(searchCount > 3) { %>
 					<a @click="toggleAdvanced" style="margin-left: 8px">
@@ -137,7 +137,7 @@
 			</template>
 		</s-table>
 	</a-card>
-	<Detail v-else ref="detailRef" @onClose="indexShow = true" @successful="tableRef.refresh()" />
+	<Detail v-else ref="detailRef" @onClose="indexShow = true" @successful="onSearch()" />
 </template>
 
 <script setup name="${busName}">
@@ -161,6 +161,7 @@
 	import ${classNameFirstLower}Api from '@/api/${moduleName}/${classNameFirstLower}Api'
 	<% if (searchCount > 0) { %>
 	const searchFormState = ref({})
+	const searchFormStateReal = ref({}) // 点击搜索后备份的查询参数
 	const searchFormRef = ref()
 	<% } %>
 	const tableRef = ref()
@@ -213,32 +214,36 @@
 		}
 	}
 	const loadData = (parameter) => {
-		<% if (searchCount > 0) { %>
-		const searchFormParam = cloneDeep(searchFormState.value)
-		<% for(var i = 0; i < configList.~size; i++) { %>
-		<% if(!configList[i].needTableId && configList[i].needPage) { %>
-		<% if (configList[i].effectType == 'datepicker') {%>
-		// ${configList[i].fieldNameCamelCase}范围查询条件重载
-		if (searchFormParam.${configList[i].fieldNameCamelCase}) {
-			searchFormParam.start${configList[i].fieldNameCamelCaseFirstUpper} = searchFormParam.${configList[i].fieldNameCamelCase}[0]
-			searchFormParam.end${configList[i].fieldNameCamelCaseFirstUpper} = searchFormParam.${configList[i].fieldNameCamelCase}[1]
-			delete searchFormParam.${configList[i].fieldNameCamelCase}
-		}
-		<% } %>
-		<% } %>
-		<% } %>
-		return ${classNameFirstLower}Api.${classNameFirstLower}Page(Object.assign(parameter, searchFormParam)).then((data) => {
-		<% } else { %>
-		return ${classNameFirstLower}Api.${classNameFirstLower}Page(parameter).then((data) => {
-		<% } %>
-			return data
-		})
-	}
-	// 重置
-	const reset = () => {
-		searchFormRef.value.resetFields()
-		tableRef.value.refresh(true)
-	}
+        <% if (searchCount > 0) { %>
+        <% for(var i = 0; i < configList.~size; i++) { %>
+        <% if(!configList[i].needTableId && configList[i].needPage) { %>
+        <% if (configList[i].effectType == 'datepicker') {%>
+        // ${configList[i].fieldNameCamelCase}范围查询条件重载
+        if (searchFormStateReal.value.${configList[i].fieldNameCamelCase}) {
+            searchFormStateReal.value.start${configList[i].fieldNameCamelCaseFirstUpper} = searchFormStateReal.value.${configList[i].fieldNameCamelCase}[0]
+            searchFormStateReal.value.end${configList[i].fieldNameCamelCaseFirstUpper} = searchFormStateReal.value.${configList[i].fieldNameCamelCase}[1]
+            delete searchFormStateReal.value.${configList[i].fieldNameCamelCase}
+        }
+        <% } %>
+        <% } %>
+        <% } %>
+        return ${classNameFirstLower}Api.${classNameFirstLower}Page(Object.assign(parameter, searchFormStateReal.value)).then((data) => {
+        <% } else { %>
+        return ${classNameFirstLower}Api.${classNameFirstLower}Page(parameter).then((data) => {
+        <% } %>
+            return data
+        })
+    }
+    // 搜索同时备份参数
+    const onSearch = (parameter) => {
+        searchFormStateReal.value = cloneDeep(searchFormState.value)
+        tableRef.value.refresh(parameter)
+    }
+    // 重置
+    const reset = () => {
+        searchFormRef.value.resetFields()
+        onSearch(true)
+    }
 	// 删除
 	const delete${className} = (record) => {
 		let params = [