### Vue Component Setup and API Imports
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Sets up a Vue 3 component with necessary API imports for data operations (tree list, list, add, delete, update, get). Includes conditional imports for buttons and custom input features.
```javascript
import { treelist${genTable.BusinessName}, list${genTable.BusinessName},
$if(replaceDto.ShowBtnAdd) add${genTable.BusinessName}, $end
$if(replaceDto.ShowBtnDelete || replaceDto.ShowBtnMultiDel)del${genTable.BusinessName},
$end
$if(replaceDto.ShowBtnEdit) update${genTable.BusinessName},
$end
get${genTable.BusinessName},
$if(showCustomInput) changeSort $end } from '@/api/${tool.FirstLowerCase(genTable.ModuleName)}/${genTable.BusinessName.ToLower()}.js'
```
```javascript
$if(replaceDto.ShowEditor == 1)
import Editor from '@/components/Editor'
$end
```
--------------------------------
### Vue Script Setup Imports
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Imports necessary functions and components for a Vue 3 script setup block. Includes API functions for data manipulation and conditional imports for features like rich text editors or data import.
```JavaScript
import { list${genTable.BusinessName},
$if(replaceDto.ShowBtnAdd) add${genTable.BusinessName}, $end
$if(replaceDto.ShowBtnDelete || replaceDto.ShowBtnMultiDel)del${genTable.BusinessName},$end
$if(replaceDto.ShowBtnEdit) update${genTable.BusinessName},$end
get${genTable.BusinessName},
$if(replaceDto.ShowBtnTruncate) clear${genTable.BusinessName}, $end
$if(showCustomInput) changeSort $end }
from '@/api/${tool.FirstLowerCase(genTable.ModuleName)}/${genTable.BusinessName.ToLower()}.js'
```
```JavaScript
$if(replaceDto.ShowEditor == 1)
import Editor from '@/components/Editor'
$end
$if(replaceDto.ShowBtnImport)
import importData from '@/components/ImportData'
$end
```
--------------------------------
### Dictionary Parameter Setup in Vue3
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue3.txt
Prepares an array of dictionary types to be fetched. This is used to populate dropdowns or select options dynamically.
```javascript
$set(index = 0)
var dictParams = [
$foreach(item in dicts)
$if(item.DictType != "")
'${item.DictType}',
$set(index = index + 1)
$end
$end
]
$if(index > 0)
proxy.getDicts(dictParams).then((response) => {
response.data.forEach((element) => {
state.options[element.dictType] = element.list
})
})
$end
```
--------------------------------
### Form Validation Rules Setup
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt
Sets up form validation rules after the component is ready. It uses a setTimeout to ensure the form instance is available.
```javascript
onReady() {
// 需要在onReady中设置规则
setTimeout(() => {
this.${refs}refs.uForm.setRules(this.rules)
}, 300)
}
```
--------------------------------
### Vue2 Component Imports and API Setup
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue2.txt
Sets up necessary imports for utility functions and API calls. Ensure the paths are correct for your project structure.
```javascript
import {
checkPermi
} from '@/utils/permission.js'
import {
list${genTable.BusinessName},
$if(replaceDto.ShowBtnDelete)
del${genTable.BusinessName},
$end
} from '@/api/${tool.FirstLowerCase(genTable.ModuleName)}/${genTable.BusinessName.ToLower()}.js'
```
--------------------------------
### List Data with Query Parameters
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Fetches a list of data using GET request. Supports custom parameter serialization for complex queries.
```javascript
import request from '@/utils/request'
import QS from 'qs'
/**
* ${genTable.functionName}分页查询
* @param {查询条件} query
*/
export function list${genTable.BusinessName}(query) {
return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/list',
method: 'get',
params: query,
paramsSerializer: function (params) {
return QS.stringify(params, { indices: false })
}
})
}
```
--------------------------------
### List Data
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Fetches a list of data using a GET request with query parameters.
```javascript
import request from '@/utils/request'
/**
* ${genTable.functionName}分页查询
* @param {查询条件} query
*/
export function list${genTable.BusinessName}(query) {
return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/list',
method: 'get',
params: query
})
}
```
--------------------------------
### Get Resource Details
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
Retrieves the details of a specific resource by its ID.
```APIDOC
## GET /${genTable.ModuleName}/${genTable.BusinessName}/{id}
### Description
Retrieves the details of a specific resource.
### Method
GET
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The ID of the resource to retrieve.
```
--------------------------------
### Get Data Details
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Retrieves the details of a specific data entry by its ID using a GET request.
```javascript
import request from '@/utils/request'
/**
* 获取${genTable.functionName}详情
* @param {Id} id
*/
export function get${genTable.BusinessName}(id) {
return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/' + id,
method: 'get'
})
}
```
--------------------------------
### Create Role ID Sequence
Source: https://github.com/izhaorui/zr.admin.net/blob/main/document/oracle/seq.txt
Creates a sequence for role IDs, starting from 10 and incrementing by 1. This sequence is intended for the role table.
```SQL
create sequence SEQ_SYS_ROLE_ROLEID
minvalue 10
maxvalue 99999999
start with 10
increment by 1
nocache
order;
```
--------------------------------
### Create Menu ID Sequence
Source: https://github.com/izhaorui/zr.admin.net/blob/main/document/oracle/seq.txt
Generates a sequence for menu IDs, with a starting value of 2000 and increments of 1. This sequence is specific to the menu table.
```SQL
create sequence SEQ_SYS_MENU_MENUID
minvalue 2000
maxvalue 99999999
start with 2000
increment by 1
nocache
order;
```
--------------------------------
### Vue 2 Data Binding Example
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue2.txt
Illustrates data binding within a Vue 2 component, specifically updating a query parameter based on user input. Ensure the corresponding data property exists in your component's state.
```vue
this.queryParams.${column.CsharpFieldFl} = e.value
```
--------------------------------
### Create Department ID Sequence
Source: https://github.com/izhaorui/zr.admin.net/blob/main/document/oracle/seq.txt
Defines a sequence for department IDs, starting at 200 and incrementing by 1. This sequence is intended for the department table.
```SQL
create sequence SEQ_SYS_DEPT_DEPTID
minvalue 200
maxvalue 99999999
start with 200
increment by 1
nocache
order;
```
--------------------------------
### Get List Data
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Fetches the main list data for the component. It handles date range queries, loading states, and updates the dataList and total count.
```javascript
function getList(){
$foreach(item in genTable.Columns)
$if(item.HtmlType == "datetime" && item.IsQuery == true)
proxy.addDateRange(queryParams, dateRange${item.CsharpField}.value, '${item.CsharpField}');
$end
$end
loading.value = true
treelist${genTable.BusinessName}(queryParams).then(res => {
const { code, data } = res
if (code == 200) {
//dataList.value = res.data.result
//total.value = res.data.totalNum
dataList.value = res.data
loading.value = false
}
})
.catch(() => {
loading.value = false
})
}
```
--------------------------------
### Import
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplIService.txt
Imports a list of items into the system.
```APIDOC
## Import
### Description
Imports a list of items into the system.
### Method
POST (Assumed based on typical RESTful conventions for importing data)
### Endpoint
/api/items/import (Example endpoint, actual endpoint may vary)
### Request Body
- **list** (array) - Required - A list of items to import.
```
--------------------------------
### get${genTable.BusinessName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Retrieves the details of a specific ${genTable.functionName} by its ID.
```APIDOC
## get${genTable.BusinessName}
### Description
Retrieves the details of a specific ${genTable.functionName} by its ID.
### Method
GET
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The ID of the ${genTable.functionName} to retrieve.
```
--------------------------------
### Get ${genTable.FunctionName} Details
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Retrieves the detailed information for a specific ${genTable.FunctionName} entry by its ID.
```APIDOC
## GET /{${replaceDto.PKName}}
### Description
Retrieves the details of a specific ${genTable.FunctionName} entry.
### Method
GET
### Endpoint
/{${replaceDto.PKName}}
### Parameters
#### Path Parameters
- **${replaceDto.PKName}** (${replaceDto.PKType}) - Required - The unique identifier of the ${genTable.FunctionName} entry.
### Response
#### Success Response (200)
- **info** (${replaceDto.ModelTypeName}Dto) - The detailed information of the ${genTable.FunctionName} entry.
```
--------------------------------
### Tree List Data
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Fetches data in a tree structure using a GET request.
```javascript
import request from '@/utils/request'
/**
* ${genTable.functionName}tree查询
* @param {查询条件} query
*/
export function treelist${genTable.BusinessName}(query) {
return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/treelist',
method: 'get',
params: query
})
}
```
--------------------------------
### Form Initialization and Refs
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form3.txt
Initializes form state, rules, and options using Vue's `toRefs` and `ref`. Sets up form validation rules after a short delay.
```Vue.js
const {
form,
rules,
options
} = toRefs(state)
const opertype = ref(0)
// 表单引用
const uFormRef = ref(null)
setTimeout(() => {
proxy.${refs}refs.uFormRef.setRules(state.rules)
}, 300)
```
--------------------------------
### Add
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplIService.txt
Adds a new item to the system.
```APIDOC
## Add
### Description
Adds a new item to the system.
### Method
POST (Assumed based on typical RESTful conventions for creating resources)
### Endpoint
/api/items (Example endpoint, actual endpoint may vary)
### Request Body
- **parm** (object) - Required - The item data to add.
```
--------------------------------
### Get Data Details by ID
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
Retrieve the details of a specific data record using its unique identifier.
```javascript
export function get${genTable.BusinessName}(id) {
return request({
url: '/${genTable.ModuleName}/${genTable.BusinessName}/' + id,
method: 'get'
})
}
```
--------------------------------
### Change Sort Order
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Changes the sort order of data entries. Uses a GET request with data parameters.
```javascript
import request from '@/utils/request'
export function changeSort(data) {
return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/ChangeSort',
method: 'get',
params: data
})
}
```
--------------------------------
### Download Import Template
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Provides a downloadable Excel template for data import. It generates an empty template based on the specified DTO. Requires export permission.
```csharp
///
/// ${genTable.FunctionName}导入模板下载
///
///
[HttpGet("importTemplate")]
[Log(Title = "${genTable.FunctionName}模板", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
var result = DownloadImportTemplate(new List<${replaceDto.ModelTypeName}Dto>() { }, "${replaceDto.ModelTypeName}");
return ExportExcel(result.Item2, result.Item1);
}
```
--------------------------------
### Add Resource
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
Creates a new resource with the provided data.
```APIDOC
## POST /${genTable.ModuleName}/${genTable.BusinessName}
### Description
Creates a new resource.
### Method
POST
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}
### Parameters
#### Request Body
- **data** (object) - Required - The data for the new resource.
```
--------------------------------
### C# Service Implementation for Data Operations
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplService.txt
This snippet shows the basic structure of a service class for managing a specific entity. It includes methods for retrieving lists, details, adding, and updating entities, with support for related data and conditional logic based on configuration.
```csharp
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ${options.DtosNamespace}.${options.SubNamespace}.Dto;
using ${options.ModelsNamespace}.${options.SubNamespace};
using ${options.RepositoriesNamespace};
using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service;
$if(genTable.TplCategory == "tree")
using System.Collections.Generic;
$end
namespace ${options.ServicesNamespace}.${options.SubNamespace}
{
///
/// ${genTable.FunctionName}Service业务层处理
///
[AppService(ServiceType = typeof(I${replaceDto.ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service
{
///
/// 查询${genTable.FunctionName}列表
///
///
///
public PagedInfo<${replaceDto.ModelTypeName}Dto> GetList(${replaceDto.ModelTypeName}QueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
$if(null != genTable.SubTableName && "" != genTable.SubTableName)
//.Includes(x => x.${genTable.SubTable.ClassName}Nav) //填充子对象
$end
$if(genTable.Options.SortField != "" && genTable.Options.SortField != null)
//.OrderBy("${genTable.Options.SortField} ${genTable.Options.SortType}")
$end
.Where(predicate.ToExpression())
.ToPage<${replaceDto.ModelTypeName}, ${replaceDto.ModelTypeName}Dto>(parm);
return response;
}
$if(genTable.TplCategory == "tree")
///
/// 查询${genTable.FunctionName}树列表
///
///
///
public List<${replaceDto.ModelTypeName}> GetTreeList(${replaceDto.ModelTypeName}QueryDto parm)
{
var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>();
$foreach(column in genTable.Columns)
$if(column.IsQuery)
$if(column.CsharpType == "string")
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.${column.CsharpField}), ${tool.QueryExp(column.CsharpField, column.QueryType)};
$elseif(column.CsharpType == "int" || column.CsharpType == "long")
predicate = predicate.AndIF(parm.${column.CsharpField} != null, ${tool.QueryExp(column.CsharpField, column.QueryType)};
$end
$end
$end
var response = Queryable()
.Where(predicate.ToExpression())
.ToTree(it => it.Children, it => it.${genTable.Options.TreeParentCode}, 0);
return response;
}
$end
///
/// 获取详情
///
///
///
public ${replaceDto.ModelTypeName} GetInfo(${replaceDto.PKType} ${replaceDto.PKName})
{
var response = Queryable()
$if(null != genTable.SubTableName && "" != genTable.SubTableName)
.Includes(x => x.${genTable.SubTable.ClassName}Nav) //填充子对象
$end
.Where(x => x.${replaceDto.PKName} == ${replaceDto.PKName})
.First();
return response;
}
///
/// 添加${genTable.FunctionName}
///
///
///
public ${replaceDto.ModelTypeName} Add${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} model)
{
$if(null != genTable.SubTableName && "" != genTable.SubTableName)
return Context.InsertNav(model).Include(s1 => s1.${genTable.SubTable.ClassName}Nav).ExecuteReturnEntity();
$else
$if(replaceDto.useSnowflakeId)
Insertable(model).ExecuteReturnSnowflakeId();
return model;
$else
return Insertable(model).ExecuteReturnEntity();
$end
$end
}
$if(replaceDto.ShowBtnEdit)
///
/// 修改${genTable.FunctionName}
///
///
///
public int Update${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} model)
{
$if(null != genTable.SubTableName && "" != genTable.SubTableName)
return Context.UpdateNav(model).Include(z1 => z1.${genTable.SubTable.ClassName}Nav).ExecuteCommand() ? 1 : 0;
$else
return Update(model, true$if(replaceDto.enableLog), "修改${genTable.FunctionName}"$end);
$end
}
$end
$if(replaceDto.ShowBtnTruncate)
///
/// 清空${genTable.FunctionName}
///
///
public bool Truncate${replaceDto.ModelTypeName}()
{
var newTableName = $"${genTable.TableName}_${DateTime.Now:yyyyMMdd}";
if (Queryable().Any() && !Context.DbMaintenance.IsAnyTable(newTableName))
{
```
--------------------------------
### Insert Main Menu Item
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/PgSql.txt
Use this script to insert a new main menu item into the sys_menu table. It requires dynamic values for function name, parent ID, and business name.
```sql
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time)
VALUES ('${genTable.functionName}', ${parentId}, 999, '${genTable.BusinessName}', '${tool.FirstLowerCase(genTable.ModuleName)}/${genTable.BusinessName}', 0, 0, 'C', '0', '0', '${replaceDto.PermissionPrefix}:list', 'icon1', 'system', null);
```
--------------------------------
### Form Initialization and Data Loading
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt
Handles form initialization and loading data for editing. It sets up the form object based on the provided data, with special handling for checkbox group fields.
```javascript
onLoad(e) {
this.opertype = e.opertype
if (e.id) {
get${genTable.BusinessName}(e.id).then(res => {
const {
code,
data
} = res
if (code == 200) {
this.form = {
...data,
$foreach(item in genTable.Columns)
$if(item.HtmlType == "checkbox")
${item.CsharpFieldFl}Checked: data.${item.CsharpFieldFl} ? data.${item.CsharpFieldFl}.split(',') : [],
$end
$end
}
}
})
} else {
this.reset()
}
}
```
--------------------------------
### Vue Dictionary Parameters Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Prepares an array of dictionary types to be fetched. This is used to load necessary dictionary data for select components or other dictionary-based UI elements.
```JavaScript
var dictParams = [
$foreach(item in dicts)
$if(item.DictType != "")
"${item.DictType}",
$set(index = index + 1)
$end
$end
]
```
--------------------------------
### Insert Main Menu Entry
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/SqlTemplate.txt
Use this SQL statement to insert a new main menu item into the sys_menu table. It requires dynamic values for the menu name, parent ID, path, component, and permissions.
```sql
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time)
VALUES ('${genTable.functionName}', ${parentId}, 999, '${genTable.BusinessName}', '${tool.FirstLowerCase(genTable.ModuleName)}/${genTable.BusinessName}', 0, 0, 'C', '0', '0', '${replaceDto.PermissionPrefix}:list', 'icon1', 'system', GETDATE());
```
--------------------------------
### Create General ID Sequence
Source: https://github.com/izhaorui/zr.admin.net/blob/main/document/oracle/seq.txt
Defines a general-purpose sequence for ID generation. It starts at 1 and increments by 1, with a maximum value of 99999999.
```SQL
create sequence SEQ_ID
minvalue 1
maxvalue 99999999
start with 1
increment by 1
nocache
order;
```
--------------------------------
### Import Data from Excel
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Imports data from an Excel file. The file is read into a stream and then parsed into a list of DTOs. Requires `multipart/form-data` consumption and import permission.
```csharp
///
/// 导入
///
///
///
[HttpPost("importData")]
[Consumes("multipart/form-data")]
[Log(Title = "${genTable.FunctionName}导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false)]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:import")]
public IActionResult ImportData(IFormFile file)
{
List<${replaceDto.ModelTypeName}Dto> list = new();
using (var stream = file.OpenReadStream())
{
list = stream.Query<${replaceDto.ModelTypeName}Dto>(startCell: "A1").ToList();
}
return SUCCESS(_${replaceDto.ModelTypeName}Service.Import${replaceDto.ModelTypeName}(list.Adapt>()));
}
```
--------------------------------
### Download Import Template
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Downloads an Excel template for data import. This template can be used to format data before uploading it to the system.
```APIDOC
## GET /importTemplate
### Description
Downloads an Excel template for data import. This template can be used to format data before uploading it to the system.
### Method
GET
### Endpoint
/importTemplate
### Response
#### Success Response (200)
Returns an Excel file containing the import template.
#### Response Example
(Excel file content)
```
--------------------------------
### Fetching Data List in Vue3
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue3.txt
Fetches a list of data using the provided query parameters. It handles loading states, appends new data to the existing list, and updates the total count. Includes uni-app loading indicators.
```javascript
function getList() {
uni.showLoading({
title: 'loading...'
})
state.loading = true
$foreach(item in genTable.Columns)
$if((item.HtmlType == "datetime" || item.HtmlType == "datePicker") && item.IsQuery == true)
proxy.addDateRange(queryParams, dateRange${item.CsharpField}.value, '${item.CsharpField}');
$end
$end
list${genTable.BusinessName}(queryParams).then(res => {
if (res.code == 200) {
dataList.value = [...dataList.value, ...res.data.result]
total.value = res.data.totalNum;
state.loaing = false
}
}).finally(() => {
uni.hideLoading()
})
}
```
--------------------------------
### GetInfo
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplIService.txt
Retrieves detailed information for a specific item using its primary key.
```APIDOC
## GetInfo
### Description
Retrieves detailed information for a specific item using its primary key.
### Method
GET (Assumed based on typical RESTful conventions for item retrieval)
### Endpoint
/api/items/{id} (Example endpoint, actual endpoint may vary)
### Parameters
#### Path Parameters
- **id** (PKType) - Required - The primary key of the item to retrieve.
```
--------------------------------
### Vue Date Range Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Initializes date range variables for date picker components used in queries. Allows users to select a start and end date for filtering.
```JavaScript
$foreach(item in genTable.Columns)
$if((item.HtmlType == "datetime" || item.HtmlType == "datePicker") && item.IsQuery == true)
// ${item.ColumnComment}时间范围
const dateRange${item.CsharpField} = ref([])
$end
$end
```
--------------------------------
### C# Controller for Entity Management
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
This template defines a base controller for managing a specific entity. It includes methods for querying lists, retrieving details, adding, updating, and deleting entities. Ensure the necessary DTOs, services, and models are correctly referenced.
```csharp
using Microsoft.AspNetCore.Mvc;
using ${options.DtosNamespace}.${options.SubNamespace}.Dto;
using ${options.ModelsNamespace}.${options.SubNamespace};
using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service;
$if(replaceDto.ShowBtnImport)
using MiniExcelLibs;
$end
//创建时间:${replaceDto.AddTime}
namespace ${options.ApiControllerNamespace}.Controllers.${options.SubNamespace}
{
///
/// ${genTable.functionName}
///
[Route("${genTable.ModuleName}/${genTable.BusinessName}")]
public class ${replaceDto.ModelTypeName}Controller : BaseController
{
///
/// ${genTable.FunctionName}接口
///
private readonly I${replaceDto.ModelTypeName}Service _${replaceDto.ModelTypeName}Service;
public ${replaceDto.ModelTypeName}Controller(I${replaceDto.ModelTypeName}Service ${replaceDto.ModelTypeName}Service)
{
_${replaceDto.ModelTypeName}Service = ${replaceDto.ModelTypeName}Service;
}
///
/// 查询${genTable.FunctionName}列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:list")]
public IActionResult Query${replaceDto.ModelTypeName}([FromQuery] ${replaceDto.ModelTypeName}QueryDto parm)
{
var response = _${replaceDto.ModelTypeName}Service.GetList(parm);
return SUCCESS(response);
}
$if(genTable.TplCategory == "tree")
///
/// 查询${genTable.FunctionName}列表树
///
///
///
[HttpGet("treeList")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:list")]
public IActionResult QueryTree${replaceDto.ModelTypeName}([FromQuery] ${replaceDto.ModelTypeName}QueryDto parm)
{
var response = _${replaceDto.ModelTypeName}Service.GetTreeList(parm);
return SUCCESS(response);
}
$end
///
/// 查询${genTable.FunctionName}详情
///
///
///
[HttpGet("{${replaceDto.PKName}}")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:query")]
public IActionResult Get${replaceDto.ModelTypeName}(${replaceDto.PKType} ${replaceDto.PKName})
{
var response = _${replaceDto.ModelTypeName}Service.GetInfo(${replaceDto.PKName});
var info = response.Adapt<${replaceDto.ModelTypeName}Dto>();
return SUCCESS(info);
}
$if(replaceDto.ShowBtnAdd)
///
/// 添加${genTable.FunctionName}
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:add")]
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.INSERT)]
public IActionResult Add${replaceDto.ModelTypeName}([FromBody] ${replaceDto.ModelTypeName}Dto parm)
{
var modal = parm.Adapt<${replaceDto.ModelTypeName}>().ToCreate(HttpContext);
var response = _${replaceDto.ModelTypeName}Service.Add${replaceDto.ModelTypeName}(modal);
return SUCCESS(response);
}
$end
$if(replaceDto.ShowBtnEdit)
///
/// 更新${genTable.FunctionName}
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:edit")]
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.UPDATE)]
public IActionResult Update${replaceDto.ModelTypeName}([FromBody] ${replaceDto.ModelTypeName}Dto parm)
{
var modal = parm.Adapt<${replaceDto.ModelTypeName}>().ToUpdate(HttpContext);
var response = _${replaceDto.ModelTypeName}Service.Update${replaceDto.ModelTypeName}(modal);
return ToResponse(response);
}
$end
$if(replaceDto.ShowBtnDelete || replaceDto.ShowBtnMultiDel)
///
/// 删除${genTable.FunctionName}
///
///
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:delete")]
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.DELETE)]
public IActionResult Delete${replaceDto.ModelTypeName}([FromRoute]string ids)
{
var idArr = Tools.SplitAndConvert<${replaceDto.PKType}>(ids);
return ToResponse(_${replaceDto.ModelTypeName}Service.Delete(idArr$if(replaceDto.enableLog), "删除${genTable.FunctionName}"$end));
}
$end
$if(replaceDto.ShowBtnExport)
///
/// 导出${genTable.FunctionName}
```
--------------------------------
### List Resources
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
Retrieves a paginated list of resources based on the provided query parameters.
```APIDOC
## GET /${genTable.ModuleName}/${genTable.BusinessName}/list
### Description
Retrieves a paginated list of resources.
### Method
GET
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}/list
### Parameters
#### Query Parameters
- **query** (object) - Required - Query parameters for filtering and pagination.
```
--------------------------------
### export${genTable.BusinessName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Exports ${genTable.functionName} data based on the provided query parameters.
```APIDOC
## export${genTable.BusinessName}
### Description
Exports ${genTable.functionName} data based on the provided query parameters.
### Method
GET
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}/export
### Parameters
#### Query Parameters
- **query** (object) - Required - Query parameters for filtering the export.
```
--------------------------------
### GetList
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplIService.txt
Retrieves a paginated list of items based on the provided query parameters.
```APIDOC
## GetList
### Description
Retrieves a paginated list of items based on the provided query parameters.
### Method
GET (Assumed based on typical RESTful conventions for list retrieval)
### Endpoint
/api/items (Example endpoint, actual endpoint may vary)
### Parameters
#### Query Parameters
- **parm** (object) - Required - Query parameters for filtering and pagination.
```
--------------------------------
### Vue2 Method for Navigating to Add Page
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue2.txt
Navigates to the add/edit page with an operation type of '1' (add). Use this when a user initiates adding a new record.
```javascript
handleAdd() {
this.${tab}tab.navigateTo('./edit?opertype=1')
}
```
--------------------------------
### Initializing Query Parameters in Vue3
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue3.txt
Defines reactive query parameters for data fetching, including pagination, sorting, and specific field filters. Undefined values are used for optional query fields.
```javascript
const queryParams = reactive({
pageNum: 1,
pageSize: 20,
sort: '${genTable.Options.SortField}',
sortType: '${genTable.Options.SortType}',
$foreach(item in genTable.Columns)
$if(item.IsQuery == true)
${item.CsharpFieldFl}: undefined,
$end
$end
})
```
--------------------------------
### Insert Action Buttons for Menu
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/PgSql.txt
This script inserts action buttons (Query, Add, Delete, Modify, Export) as sub-menu items under a specified parent menu ID. It dynamically retrieves the current time.
```sql
DO $$
DECLARE @menuId integer;
DECLARE @nowTime datetime;
BEGIN
SELECT @@identity INTO @menuId;
SELECT now()::timestamp(0)without time zone INTO @nowTime
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('查询', @menuId, 1, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:query', '', 'system', @nowTime);
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('新增', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:add', '', 'system', @nowTime);
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('删除', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:delete', '', 'system', @nowTime);
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('修改', @menuId, 4, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:edit', '', 'system', @nowTime);
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('导出', @menuId, 5, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:export', '', 'system', @nowTime);
END $$;
```
--------------------------------
### Import Data with Validation
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplService.txt
Imports a list of data, performing validation checks for required fields and handling potential errors. It splits data into insertable, error, and ignored lists, providing a summary of the operation.
```csharp
public (string, object, object) Import${replaceDto.ModelTypeName}(List<${replaceDto.ModelTypeName}> list)
{
var x = Context.Storageable(list)
.SplitInsert(it => !it.Any())
.SplitError(x => x.Item.${column.CsharpField}.IsEmpty(), "${column.ColumnComment}不能为空")
.ToStorage();
var result = x.AsInsertable.ExecuteCommand();
string msg = $"插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误数据{x.ErrorList.Count} 不计算数据{x.IgnoreList.Count} 删除数据{x.DeleteList.Count} 总共{x.TotalList.Count}";
Console.WriteLine(msg);
foreach (var item in x.ErrorList)
{
Console.WriteLine("错误" + item.StorageMessage);
}
foreach (var item in x.IgnoreList)
{
Console.WriteLine("忽略" + item.StorageMessage);
}
return (msg, x.ErrorList, x.IgnoreList);
}
```
--------------------------------
### Create User ID Sequence
Source: https://github.com/izhaorui/zr.admin.net/blob/main/document/oracle/seq.txt
Establishes a sequence for user IDs, beginning at 1 and incrementing by 100. This sequence is designed for the user table.
```SQL
create sequence SEQ_SYS_USER_USERID
minvalue 100
maxvalue 99999999
start with 1
increment by 100
nocache
order;
```
--------------------------------
### Export ${genTable.FunctionName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Exports ${genTable.FunctionName} data, likely in a file format.
```APIDOC
## GET /export
### Description
Exports ${genTable.FunctionName} data.
### Method
GET
### Endpoint
/export
### Response
#### Success Response (200)
- **response** (file) - The exported file containing ${genTable.FunctionName} data.
```
--------------------------------
### Vue Query Parameters Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Initializes reactive query parameters for data fetching in a Vue component. Includes pagination, sorting, and dynamically added query fields based on table columns.
```JavaScript
const { proxy } = getCurrentInstance()
const ids = ref([])
const loading = ref(false)
const showSearch = ref(true)
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
sort: '${genTable.Options.SortField}',
sortType: '${genTable.Options.SortType}',
$foreach(item in genTable.Columns)
$if(item.IsQuery == true)
${item.CsharpFieldFl}: undefined,
$end
$end
})
```
--------------------------------
### Add Operation
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Initializes the form for adding a new record, setting the title and operation type.
```javascript
// 添加按钮操作
function handleAdd() {
reset();
open.value = true
title.value = '添加'
opertype.value = 1
}
```
--------------------------------
### Export Data
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Initiates the data export process, prompting the user for confirmation.
```javascript
$if(replaceDto.ShowBtnExport)
// 导出按钮操作
function handleExport() {
proxy
.${confirm}confirm("是否确认导出${genTable.functionName}数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
})
$end
```
--------------------------------
### Update Operation
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Fetches existing data for a given ID, opens the dialog, and populates the form for editing.
```javascript
// 修改按钮操作
function handleUpdate(row) {
reset()
const id = row.${replaceDto.FistLowerPk} || ids.value
get${genTable.BusinessName}(id).then((res) => {
const { code, data } = res
if (code == 200) {
open.value = true
title.value = "修改数据"
opertype.value = 2
form.value = {
...data,
$foreach(item in genTable.Columns)
$if(item.HtmlType == "checkbox")
${item.CsharpFieldFl}Checked: data.${item.CsharpFieldFl} ? data.${item.CsharpFieldFl}.split(',') : [],
$end
$end
}
}
})
}
```
--------------------------------
### Select Menu Item by ID
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/PgSql.txt
Retrieves a specific menu item based on its unique menu ID.
```sql
SELECT * FROM sys_menu WHERE menuId = @menuId;
```
--------------------------------
### Handle Query
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Resets the page number to 1 and triggers a data list refresh.
```javascript
// 查询
function handleQuery() {
queryParams.pageNum = 1
getList()
}
```
--------------------------------
### Fetch Dictionaries
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Fetches dictionary data and populates state options based on dictionary type. Assumes a proxy object with a getDicts method and a state object with an options property.
```javascript
proxy.getDicts(dictParams).then((response) => {
response.data.forEach((element) => {
state.options[element.dictType] = element.list
})
})
```
--------------------------------
### Select Menu Items
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/MySqlTemplate.txt
Retrieves menu items from the sys_menu table, either all children of a specific parent or a single menu item by its ID.
```sql
SELECT * FROM sys_menu WHERE parentId = @menuId;
SELECT * FROM sys_menu WHERE menuId = @menuId;
```
--------------------------------
### Vue Sub-Table Management Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Initializes state variables and refs for managing a sub-table, including lists for data, selected items, and control flags for full-screen and drawer views.
```javascript
$if(sub)
/*********************${genTable.SubTable.FunctionName}子表信息*************************/
const ${tool.FirstLowerCase(genTable.SubTable.ClassName)}List = ref([])
const checked${genTable.SubTable.ClassName} = ref([])
const fullScreen = ref(false)
const drawer = ref(false)
$end
```
--------------------------------
### Date Range Query Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Initializes date range variables for query parameters, specifically for columns of type 'datetime' that are marked for querying.
```javascript
$foreach(item in genTable.Columns)
$if(item.HtmlType == "datetime" && item.IsQuery == true)
// ${item.ColumnComment}时间范围
const dateRange${item.CsharpField} = ref([])
$end
$end
```
--------------------------------
### Export Data to Excel
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Handles exporting data to an Excel file. It checks for data availability before proceeding with the export process. Requires the service to have an `ExportList` method.
```csharp
///
///
///
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
[HttpGet("export")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:export")]
public IActionResult Export([FromQuery] ${replaceDto.ModelTypeName}QueryDto parm)
{
var list = _${replaceDto.ModelTypeName}Service.ExportList(parm).Result;
if (list == null || list.Count <= 0)
{
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
}
var result = ExportExcelMini(list, "${genTable.FunctionName}", "${genTable.FunctionName}");
return ExportExcel(result.Item2, result.Item1);
}
```
--------------------------------
### list${genTable.BusinessName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Retrieves a paginated list of ${genTable.functionName} with specified query parameters.
```APIDOC
## list${genTable.BusinessName}
### Description
Retrieves a paginated list of ${genTable.functionName} with specified query parameters.
### Method
GET
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}/list
### Parameters
#### Query Parameters
- **query** (object) - Required - Query parameters for filtering and pagination.
```
--------------------------------
### Add ${genTable.FunctionName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Adds a new ${genTable.FunctionName} entry to the system.
```APIDOC
## POST
### Description
Adds a new ${genTable.FunctionName} entry.
### Method
POST
### Endpoint
/
### Parameters
#### Request Body
- **parm** (${replaceDto.ModelTypeName}Dto) - Required - The data for the new ${genTable.FunctionName} entry.
### Response
#### Success Response (200)
- **response** (object) - The result of the add operation.
```
--------------------------------
### Import Data
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt
Imports data from an uploaded Excel file. The file should be in a format compatible with the system's import template.
```APIDOC
## POST /importData
### Description
Imports data from an uploaded Excel file. The file should be in a format compatible with the system's import template.
### Method
POST
### Endpoint
/importData
### Parameters
#### Request Body
- **file** (IFormFile) - Required - The Excel file containing the data to import.
### Response
#### Success Response (200)
Indicates that the data has been successfully imported.
#### Response Example
{
"code": 200,
"message": "Operation successful"
}
```
--------------------------------
### Form State and Rules Initialization
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Initializes reactive state for form data, validation rules, and options, including dynamic rule generation based on column properties like required fields and data types. It also sets up initial states for single and multiple selections.
```javascript
const state = reactive({
single: true,
multiple: true,
submitLoading: false,
form: {},
rules: {
${column.CsharpFieldFl}: [{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.HtmlType == "select")"change"$else"blur"$end }],
${column.CsharpFieldFl}$if(column.HtmlType == "selectMulti")Checked$end: [{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.HtmlType == "select")"change"$else"blur"$end
$if(column.CsharpType == "int" || column.CsharpType == "long"), type: "number" $end }],
},
options: {
$if(column.DictType != "")${column.DictType}$else${column.CsharpFieldFl}Options$end: [],
}
})
const { form, rules, options, single, multiple } = toRefs(state)
```
--------------------------------
### Add Button
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
Conditional button for adding new items. Requires 'add' permission prefix.
```Vue
{{ ${t}t('btn.add') }}
```
--------------------------------
### add${genTable.BusinessName}
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
Adds a new ${genTable.functionName} with the provided data.
```APIDOC
## add${genTable.BusinessName}
### Description
Adds a new ${genTable.functionName} with the provided data.
### Method
POST
### Endpoint
/${genTable.ModuleName}/${genTable.BusinessName}
### Parameters
#### Request Body
- **data** (object) - Required - The data for the new ${genTable.functionName}.
```
--------------------------------
### Handling Search and Refresh in Vue3
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/vue3.txt
Initiates a data search by resetting the page number and clearing the data list, then calls `getList`. If `refresh` is true, it triggers a pull-down-to-refresh action.
```javascript
function handleQuery(refresh) {
queryParams.pageNum = 1;
dataList.value = []
state.show = false
if (refresh) {
uni.startPullDownRefresh();
}
getList()
}
```
--------------------------------
### List Data with Query
Source: https://github.com/izhaorui/zr.admin.net/blob/main/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
Use this function to perform a paginated query for data. It accepts a query object for filtering and sorting.
```javascript
export function list${genTable.BusinessName}(query) {
return request({
url: '/${genTable.ModuleName}/${genTable.BusinessName}/list',
method: 'get',
data: query,
})
}
```