mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
【修复】代码生成
This commit is contained in:
@@ -13,10 +13,9 @@ package entity
|
||||
{{- end -}}
|
||||
{{if $hasGTime -}}import "time"{{- end }}
|
||||
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
{{range $index, $column := .Columns}}
|
||||
{{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}}
|
||||
{{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// 生成人:{{.FunctionAuthor}}
|
||||
// ==========================================================================
|
||||
|
||||
package service
|
||||
package services
|
||||
|
||||
import (
|
||||
"pandax/apps/{{.PackageName}}/entity"
|
||||
@@ -53,25 +53,62 @@ func (m *{{.BusinessName}}ModelImpl) FindListPage(page, pageSize int, data entit
|
||||
// 此处填写 where参数判断
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsQuery "1" -}}
|
||||
{{ if eq $column.QueryType "LIKE" }}
|
||||
{{- if eq $column.QueryType "LIKE" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
|
||||
}
|
||||
{{- end -}}
|
||||
{{- if eq $column.QueryType "EQ" -}}
|
||||
{{- if or (eq $column.QueryType "EQ") (eq $column.QueryType "NE") -}}
|
||||
{{- if eq $column.GoType "string" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- if eq $column.QueryType "EQ" }}
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "NE"}}
|
||||
db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- if eq $column.QueryType "EQ" }}
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "NE"}}
|
||||
db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if or (eq $column.QueryType "GT") (eq $column.QueryType "GTE") (eq $column.QueryType "LT") (eq $column.QueryType "LTE")}}
|
||||
{{- if eq $column.GoType "Time" }}
|
||||
if data.{{$column.GoField}}.Unix() > 0 {
|
||||
{{- if eq $column.QueryType "GT" }}
|
||||
db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "GTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LT"}}
|
||||
db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
{{- if eq $column.QueryType "GT" }}
|
||||
db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "GTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LT"}}
|
||||
db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if eq $column.ColumnName "delete_time" }}
|
||||
db.Where("delete_time IS NULL")
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
db.Where("delete_time IS NULL")
|
||||
err := db.Count(&total).Error
|
||||
err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
biz.ErrIsNil(err, "查询{{.TableComment}}分页列表失败")
|
||||
@@ -89,20 +126,57 @@ func (m *{{.BusinessName}}ModelImpl) FindList(data entity.{{$model}}) *[]entity.
|
||||
db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
|
||||
}
|
||||
{{- end -}}
|
||||
{{- if eq $column.QueryType "EQ" -}}
|
||||
{{- if or (eq $column.QueryType "EQ") (eq $column.QueryType "NE") -}}
|
||||
{{- if eq $column.GoType "string" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
{{- if eq $column.QueryType "EQ" }}
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "NE"}}
|
||||
db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
{{- if eq $column.QueryType "EQ" }}
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "NE"}}
|
||||
db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if or (eq $column.QueryType "GT") (eq $column.QueryType "GTE") (eq $column.QueryType "LT") (eq $column.QueryType "LTE")}}
|
||||
{{- if eq $column.GoType "Time" }}
|
||||
if data.{{$column.GoField}}.Unix() > 0 {
|
||||
{{- if eq $column.QueryType "GT" }}
|
||||
db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "GTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LT"}}
|
||||
db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
{{- if eq $column.QueryType "GT" }}
|
||||
db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "GTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LT"}}
|
||||
db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}})
|
||||
{{- else if $column.QueryType "LTE"}}
|
||||
db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}})
|
||||
{{- end }}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if eq $column.ColumnName "delete_time" }}
|
||||
db.Where("delete_time IS NULL")
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
db.Where("delete_time IS NULL")
|
||||
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询{{.TableComment}}列表失败")
|
||||
return &list
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import request from '/@/utils/request';
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 查询{{.FunctionName}}列表
|
||||
export function list{{.ClassName}}(query:any) {
|
||||
export function list{{.FunctionName}}(query:any) {
|
||||
return request({
|
||||
url: '/{{.PackageName}}/{{.BusinessName}}/list',
|
||||
method: 'get',
|
||||
@@ -10,7 +10,7 @@ export function list{{.ClassName}}(query:any) {
|
||||
}
|
||||
|
||||
// 查询{{.FunctionName}}详细
|
||||
export function get{{.ClassName}}({{.PkJsonField}}:number) {
|
||||
export function get{{.FunctionName}}({{.PkJsonField}}:number) {
|
||||
return request({
|
||||
url: '/{{.PackageName}}/{{.BusinessName}}/' + {{.PkJsonField}},
|
||||
method: 'get'
|
||||
@@ -18,7 +18,7 @@ export function get{{.ClassName}}({{.PkJsonField}}:number) {
|
||||
}
|
||||
|
||||
// 新增{{.FunctionName}}
|
||||
export function add{{.ClassName}}(data:any) {
|
||||
export function add{{.FunctionName}}(data:any) {
|
||||
return request({
|
||||
url: '/{{.PackageName}}/{{.BusinessName}}',
|
||||
method: 'post',
|
||||
@@ -27,7 +27,7 @@ export function add{{.ClassName}}(data:any) {
|
||||
}
|
||||
|
||||
// 修改{{.FunctionName}}
|
||||
export function update{{.ClassName}}(data:any) {
|
||||
export function update{{.FunctionName}}(data:any) {
|
||||
return request({
|
||||
url: '/{{.PackageName}}/{{.BusinessName}}',
|
||||
method: 'put',
|
||||
@@ -36,7 +36,7 @@ export function update{{.ClassName}}(data:any) {
|
||||
}
|
||||
|
||||
// 删除{{.FunctionName}}
|
||||
export function del{{.ClassName}}({{.PkJsonField}}: string) {
|
||||
export function del{{.FunctionName}}({{.PkJsonField}}: string) {
|
||||
return request({
|
||||
url: '/{{.PackageName}}/{{.BusinessName}}/' + {{.PkJsonField}},
|
||||
method: 'delete'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="system-menu-container">
|
||||
<el-dialog v-model="isShowDialog" width="769px">
|
||||
<div class="system-{{.BusinessName}}-container">
|
||||
<el-dialog v-model="isShowDialog" width="769px" center>
|
||||
<template #title>
|
||||
<div style="font-size: large" v-drag="['.system-menu-container .el-dialog', '.system-menu-container .el-dialog__header']">{{"{{"}}title{{"}}"}}</div>
|
||||
<div style="font-size: large" v-drag="['.system-{{.BusinessName}}-container .el-dialog', '.system-{{.BusinessName}}-container .el-dialog__header']">{{"{{"}}title{{"}}"}}</div>
|
||||
</template>
|
||||
<el-form
|
||||
:model="ruleForm"
|
||||
@@ -11,14 +11,18 @@
|
||||
label-width="80px"
|
||||
>
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if and (eq $column.IsInsert "1") (ne $column.IsPk "1") -}}
|
||||
{{- if and (eq $column.IsInsert "1") (ne $column.IsPk "1") (ne $column.JsonField "createTime") (ne $column.JsonField "updateTime") (ne $column.JsonField "deleteTime") -}}
|
||||
{{- if eq $column.HtmlType "input" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input v-model="ruleForm.{{$column.JsonField}}" placeholder="请输入{{$column.ColumnComment}}" />
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "switch" }}
|
||||
el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input v-model="ruleForm.{{$column.HtmlField}}" placeholder="请输入{{$column.ColumnComment}}" />
|
||||
<el-switch v-model="ruleForm.{{$column.HtmlField}}" />
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "select" }}
|
||||
{{if ne $column.DictType ""}}
|
||||
el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="ruleForm.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}">
|
||||
<el-option
|
||||
v-for="dict in {{$column.JsonField}}Options"
|
||||
@@ -42,11 +46,10 @@
|
||||
{{- end }}
|
||||
{{- else if eq $column.HtmlType "datetime" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-date-picker clearable size="small" style="width: 200px"
|
||||
v-model="ruleForm.{{$column.JsonField}}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择{{$column.ColumnComment}}">
|
||||
<el-date-picker clearable style="width: 200px"
|
||||
v-model="ruleForm.{{$column.JsonField}}"
|
||||
type="datetime"
|
||||
placeholder="选择{{$column.ColumnComment}}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "textarea" -}}
|
||||
@@ -69,10 +72,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel" size="small">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" size="small"
|
||||
>编 辑</el-button
|
||||
>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">编 辑</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -81,7 +82,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs, ref, unref, getCurrentInstance } from "vue";
|
||||
import { update{{.ClassName}}, add{{.ClassName}} } from "/@/api/{{.PackageName}}/{{.BusinessName}}";
|
||||
import { update{{.FunctionName}}, add{{.FunctionName}} } from "@/api/{{.PackageName}}/{{.BusinessName}}";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
export default {
|
||||
@@ -99,9 +100,19 @@ export default {
|
||||
const state = reactive({
|
||||
// 是否显示弹出层
|
||||
isShowDialog: false,
|
||||
|
||||
loading: false,
|
||||
ruleForm: {
|
||||
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if or (eq $column.IsInsert "1") (eq $column.IsPk "1") }}
|
||||
{{- if or (eq $column.GoType "int") (eq $column.GoType "int64")}}
|
||||
{{$column.JsonField}}: 0,
|
||||
{{- else if eq $column.GoType "string"}}
|
||||
{{$column.JsonField}}: "",
|
||||
{{- else }}
|
||||
{{$column.JsonField}}: undefined,
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
},
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
@@ -111,20 +122,30 @@ export default {
|
||||
{{- end }}
|
||||
// 表单校验
|
||||
ruleRules: {
|
||||
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" }}
|
||||
{{$column.JsonField}}: [
|
||||
{ required: true, message: "{{$column.ColumnComment}}不能为空", trigger: "blur" }
|
||||
],
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
},
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (row: any) => {
|
||||
if (row.{{.PkJsonField}} && row.{{.PkJsonField}} != undefined && row.{{.PkJsonField}} != 0) {
|
||||
state.ruleForm = row;
|
||||
state.ruleForm.{{.PkJsonField}}=row.{{.PkJsonField}}; // ID
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsInsert "1" }}
|
||||
state.ruleForm.{{$column.JsonField}} = row.{{$column.JsonField}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
// 更多参数
|
||||
} else {
|
||||
initForm();
|
||||
}
|
||||
state.isShowDialog = true;
|
||||
|
||||
state.loading = false;
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
proxy.getDicts("{{$column.DictType}}").then((response: any) => {
|
||||
@@ -136,7 +157,7 @@ export default {
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = (row?: object) => {
|
||||
proxy.mittBus.emit("onEdit{{.ClassName}}Module", row);
|
||||
proxy.mittBus.emit("onEdit{{.FunctionName}}Module", row);
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
// 取消
|
||||
@@ -150,16 +171,15 @@ export default {
|
||||
if (!formWrap) return;
|
||||
formWrap.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
if (
|
||||
state.ruleForm.{{.PkJsonField}} != undefined &&
|
||||
state.ruleForm.{{.PkJsonField}} != 0
|
||||
) {
|
||||
update{{.ClassName}}(state.ruleForm).then((response) => {
|
||||
state.loading = true;
|
||||
if (state.ruleForm.{{.PkJsonField}} != undefined && state.ruleForm.{{.PkJsonField}} != 0) {
|
||||
update{{.FunctionName}}(state.ruleForm).then((response) => {
|
||||
ElMessage.success("修改成功");
|
||||
state.loading = false;
|
||||
closeDialog(state.ruleForm); // 关闭弹窗
|
||||
});
|
||||
} else {
|
||||
add{{.ClassName}}(state.ruleForm).then((response) => {
|
||||
add{{.FunctionName}}(state.ruleForm).then((response) => {
|
||||
ElMessage.success("新增成功");
|
||||
closeDialog(state.ruleForm); // 关闭弹窗
|
||||
});
|
||||
@@ -170,7 +190,17 @@ export default {
|
||||
// 表单初始化,方法:`resetFields()` 无法使用
|
||||
const initForm = () => {
|
||||
state.ruleForm.{{.PkJsonField}} = 0; // ID
|
||||
// 更多参数初始化
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if or (eq $column.IsInsert "1") (eq $column.IsPk "1") }}
|
||||
{{- if or (eq $column.GoType "int") (eq $column.GoType "int64")}}
|
||||
state.ruleForm.{{$column.JsonField}} = 0;
|
||||
{{- else if eq $column.GoType "string"}}
|
||||
state.ruleForm.{{$column.JsonField}} = "";
|
||||
{{- else }}
|
||||
state.ruleForm.{{$column.JsonField}} = undefined;
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,27 +2,26 @@
|
||||
<div class="app-container">
|
||||
<el-card shadow="always">
|
||||
<!-- 查询 -->
|
||||
<el-form
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryForm"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" -}}
|
||||
{{- if and (eq $column.IsQuery "1") (ne $column.IsPk "1") (ne $column.JsonField "updateTime") (ne $column.JsonField "deleteTime") -}}
|
||||
{{- if eq $column.HtmlType "input" "textarea" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input
|
||||
v-model="queryParams.{{$column.JsonField}}"
|
||||
placeholder="请输入{{$column.ColumnComment}}"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{- else if and (eq $column.HtmlType "select" "radio" "checkbox") (ne $column.DictType "") }}
|
||||
{{- else if and (eq $column.HtmlType "switch" "select" "radio" "checkbox") (ne $column.DictType "") }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="queryParams.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}" clearable size="small">
|
||||
<el-select v-model="queryParams.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}" clearable>
|
||||
<el-option
|
||||
v-for="dict in {{$column.JsonField}}Options"
|
||||
:key="dict.dictValue"
|
||||
@@ -31,54 +30,48 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else }}
|
||||
{{- else if eq $column.HtmlType "datetime" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="queryParams.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}" clearable size="small">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
<el-date-picker clearable style="width: 200px"
|
||||
v-model="queryParams.{{$column.JsonField}}"
|
||||
type="datetime"
|
||||
placeholder="选择{{$column.ColumnComment}}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>
|
||||
<SvgIcon name="elementSearch" />
|
||||
搜索</el-button>
|
||||
<el-button size="mini" @click="resetQuery">
|
||||
<el-button type="primary" @click="handleQuery">
|
||||
<SvgIcon name="elementSearch" />搜索</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<SvgIcon name="elementRefresh" />
|
||||
重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 操作按钮 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
size="mini"
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:add'"
|
||||
@click="onOpenAddModule"
|
||||
><SvgIcon name="elementPlus" />新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
size="mini"
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:delete'"
|
||||
:disabled="multiple"
|
||||
@click="onTabelRowDel"
|
||||
><SvgIcon name="elementDelete" />删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-header-text">岗位列表</span>
|
||||
<div>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:add'"
|
||||
@click="onOpenAddModule"
|
||||
><SvgIcon name="elementPlus" />新增</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:delete'"
|
||||
:disabled="multiple"
|
||||
@click="onTabelRowDel"
|
||||
><SvgIcon name="elementDelete" />删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<!--数据表格-->
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
@@ -107,7 +100,8 @@
|
||||
{{- if ne $column.ColumnComment "" }}
|
||||
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.JsonField}}" />
|
||||
{{- end -}}
|
||||
{{- end -}}{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
@@ -115,15 +109,12 @@
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
text type="primary"
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:edit'"
|
||||
@click="onOpenEditModule(scope.row)"
|
||||
><SvgIcon name="elementEdit" />修改</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.parentId != 0"
|
||||
size="mini"
|
||||
type="text"
|
||||
text type="primary"
|
||||
v-auth="'{{.PackageName}}:{{.BusinessName}}:delete'"
|
||||
@click="onTabelRowDel(scope.row)"
|
||||
><SvgIcon name="elementDelete" />删除</el-button>
|
||||
@@ -132,16 +123,16 @@
|
||||
</el-table>
|
||||
<!-- 分页设置-->
|
||||
<div v-show="total > 0">
|
||||
<el-divider></el-divider>
|
||||
<el-pagination
|
||||
background
|
||||
:total="total"
|
||||
:current-page="queryParams.pageNum"
|
||||
:page-size="queryParams.pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
<el-divider></el-divider>
|
||||
<el-pagination
|
||||
background
|
||||
:total="total"
|
||||
:current-page="queryParams.pageNum"
|
||||
:page-size="queryParams.pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
<!-- 添加或修改岗位对话框 -->
|
||||
@@ -159,11 +150,11 @@ import {
|
||||
onUnmounted,
|
||||
} from "vue";
|
||||
import { ElMessageBox, ElMessage } from "element-plus";
|
||||
import { list{{.ClassName}}, del{{.ClassName}} } from "/@/api/{{.PackageName}}/{{.BusinessName}}";
|
||||
import { list{{.FunctionName}}, del{{.FunctionName}} } from "@/api/{{.PackageName}}/{{.BusinessName}}";
|
||||
import EditModule from "./component/editModule.vue";
|
||||
|
||||
export default {
|
||||
name: "{{.ClassName}}",
|
||||
name: "{{.FunctionName}}",
|
||||
components: { EditModule },
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
@@ -179,7 +170,7 @@ export default {
|
||||
multiple: true,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 岗位表格数据
|
||||
// 表格数据
|
||||
tableData: [],
|
||||
// 总条数
|
||||
total: 0,
|
||||
@@ -197,17 +188,17 @@ export default {
|
||||
pageSize: 10,
|
||||
// 以下为参数
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" }}
|
||||
{{- if eq $column.IsQuery "1" }}
|
||||
{{$column.JsonField}}: undefined,
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
},
|
||||
});
|
||||
|
||||
/** 查询岗位列表 */
|
||||
/** 查询列表 */
|
||||
const handleQuery = () => {
|
||||
state.loading = true;
|
||||
list{{.ClassName}}(state.queryParams).then((response) => {
|
||||
list{{.FunctionName}}(state.queryParams).then((response:any) => {
|
||||
state.tableData = response.data.data;
|
||||
state.total = response.data.total;
|
||||
state.loading = false;
|
||||
@@ -215,7 +206,11 @@ export default {
|
||||
};
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
//state.queryParams.name = undefined;
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsQuery "1" }}
|
||||
state.queryParams.{{$column.JsonField}} = undefined;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
@@ -239,26 +234,26 @@ export default {
|
||||
// 打开新增弹窗
|
||||
const onOpenAddModule = (row: object) => {
|
||||
row = [];
|
||||
state.title = "添加{{.FunctionName}}";
|
||||
state.title = "添加{{.TableComment}}";
|
||||
editModuleRef.value.openDialog(row);
|
||||
};
|
||||
// 打开编辑弹窗
|
||||
const onOpenEditModule = (row: object) => {
|
||||
state.title = "修改{{.FunctionName}}";
|
||||
state.title = "修改{{.TableComment}}";
|
||||
editModuleRef.value.openDialog(row);
|
||||
};
|
||||
/** 删除按钮操作 */
|
||||
const onTabelRowDel = (row: any) => {
|
||||
const {{.PkJsonField}}s = row.{{.PkJsonField}} || state.ids;
|
||||
ElMessageBox({
|
||||
message: '是否确认删除岗位编号为"' + {{.PkJsonField}}s + '"的数据项?',
|
||||
message: '是否确认删除编号为"' + {{.PkJsonField}}s + '"的数据项?',
|
||||
title: "警告",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(function () {
|
||||
return del{{.ClassName}}({{.PkJsonField}}s).then(() => {
|
||||
return del{{.FunctionName}}({{.PkJsonField}}s).then(() => {
|
||||
handleQuery();
|
||||
ElMessage.success("删除成功");
|
||||
});
|
||||
@@ -282,13 +277,13 @@ export default {
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
|
||||
proxy.mittBus.on("onEdit{{.ClassName}}Module", (res: any) => {
|
||||
proxy.mittBus.on("onEdit{{.FunctionName}}Module", (res: any) => {
|
||||
handleQuery();
|
||||
});
|
||||
});
|
||||
// 页面卸载时
|
||||
onUnmounted(() => {
|
||||
proxy.mittBus.off("onEdit{{.ClassName}}Module");
|
||||
proxy.mittBus.off("onEdit{{.FunctionName}}Module");
|
||||
});
|
||||
return {
|
||||
editModuleRef,
|
||||
|
||||
Reference in New Issue
Block a user