【更新】代码生成增加对应的批量删除跟代码调优,解决了iss中提出的生成后代码不能重置等一系列问题,其次优化后端实体类导包

pull/90/head
小诺 2023-03-12 23:43:44 +08:00 committed by 俞宝山
parent 98d3c87bac
commit c7e615c7b4
3 changed files with 60 additions and 71 deletions

View File

@ -12,10 +12,7 @@
*/ */
package ${packageName}.${moduleName}.modular.${busName}.entity; package ${packageName}.${moduleName}.modular.${busName}.entity;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -147,9 +147,7 @@
} }
// 验证并提交数据 // 验证并提交数据
const onSubmit = () => { const onSubmit = () => {
formRef.value formRef.value.validate().then(() => {
.validate()
.then(() => {
submitLoading.value = true submitLoading.value = true
const formDataParam = cloneDeep(formData.value) const formDataParam = cloneDeep(formData.value)
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>

View File

@ -8,7 +8,7 @@
<% } %> <% } %>
<a-card :bordered="false"> <a-card :bordered="false">
<% if (searchCount > 0) { %> <% if (searchCount > 0) { %>
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form mb-4"> <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
<a-row :gutter="24"> <a-row :gutter="24">
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { row ++; %> <% if(!configList[i].needTableId && configList[i].needPage) { row ++; %>
@ -37,8 +37,7 @@
<% } %> <% } %>
</a-col> </a-col>
<% } else { %> <% } else { %>
<template v-if="advanced"> <a-col :span="6" v-show="advanced">
<a-col :span="6">
<% if(configList[i].effectType == 'input' || configList[i].effectType == 'textarea') { %> <% if(configList[i].effectType == 'input' || configList[i].effectType == 'textarea') { %>
<a-form-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}"> <a-form-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}">
<a-input v-model:value="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}" /> <a-input v-model:value="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}" />
@ -61,13 +60,12 @@
</a-form-item> </a-form-item>
<% } %> <% } %>
</a-col> </a-col>
</template>
<% } %> <% } %>
<% } %> <% } %>
<% } %> <% } %>
<a-col :span="6"> <a-col :span="6">
<a-button type="primary" @click="table.refresh(true)">查询</a-button> <a-button type="primary" @click="table.refresh(true)">查询</a-button>
<a-button style="margin: 0 8px" @click="() => searchFormRef.resetFields()">重置</a-button> <a-button style="margin: 0 8px" @click="reset">重置</a-button>
<% if(searchCount > 3) { %> <% if(searchCount > 3) { %>
<a @click="toggleAdvanced" style="margin-left: 8px"> <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
@ -98,7 +96,11 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatch${className}()" v-if="hasPerm('${classNameFirstLower}BatchDelete')">删除</a-button> <xn-batch-delete
v-if="hasPerm('${classNameFirstLower}BatchDelete')"
:selectedRowKeys="selectedRowKeys"
@batchDelete="deleteBatch${className}()"
/>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -131,7 +133,6 @@
</template> </template>
<script setup name="${busName}"> <script setup name="${busName}">
import { message } from 'ant-design-vue'
<% <%
var iptTool = 0; var iptTool = 0;
if (searchCount > 0) { if (searchCount > 0) {
@ -185,13 +186,14 @@
width: '150px' width: '150px'
}) })
} }
let selectedRowKeys = ref([]) const selectedRowKeys = ref([])
// 列表选择配置 // 列表选择配置
const options = { const options = {
// columns数字类型字段加入 needTotal: true 可以勾选自动算账
alert: { alert: {
show: false, show: true,
clear: () => { clear: () => {
selectedRowKeys = ref([]) selectedRowKeys.value = ref([])
} }
}, },
rowSelection: { rowSelection: {
@ -222,6 +224,11 @@
return data return data
}) })
} }
// 重置
const reset = () => {
searchFormRef.value.resetFields();
table.value.refresh(true)
}
// 删除 // 删除
const delete${className} = (record) => { const delete${className} = (record) => {
let params = [ let params = [
@ -238,20 +245,7 @@
}) })
} }
// 批量删除 // 批量删除
const deleteBatch${className} = () => { const deleteBatch${className} = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
<% for(var i = 0; i < configList.~size; i++) { %>
<% if(configList[i].needTableId) { %>
${configList[i].fieldNameCamelCase}: m
<% } %>
<% } %>
}
})
${classNameFirstLower}Api.${classNameFirstLower}Delete(params).then(() => { ${classNameFirstLower}Api.${classNameFirstLower}Delete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })