|
@ -57,7 +57,7 @@ |
|
|
{{- if .DictType}} |
|
|
{{- if .DictType}} |
|
|
<el-table-column align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<el-table-column align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<template #default="scope"> |
|
|
<template #default="scope"> |
|
|
{{"{{"}} filterDict(scope.row.{{.FieldJson}},"{{.DictType}}") {{"}}"}} |
|
|
|
|
|
|
|
|
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}} |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
|
{{- else if eq .FieldType "bool" }} |
|
|
{{- else if eq .FieldType "bool" }} |
|
@ -69,7 +69,7 @@ |
|
|
{{- end }} |
|
|
{{- end }} |
|
|
<el-table-column align="left" label="按钮组"> |
|
|
<el-table-column align="left" label="按钮组"> |
|
|
<template #default="scope"> |
|
|
<template #default="scope"> |
|
|
<el-button type="text" icon="edit" size="small" class="table-button" @click="update{{.StructName}}(scope.row)">变更</el-button> |
|
|
|
|
|
|
|
|
<el-button type="text" icon="edit" size="small" class="table-button" @click="update{{.StructName}}Func(scope.row)">变更</el-button> |
|
|
<el-button type="text" icon="delete" size="mini" @click="deleteRow(scope.row)">删除</el-button> |
|
|
<el-button type="text" icon="delete" size="mini" @click="deleteRow(scope.row)">删除</el-button> |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
@ -125,6 +125,12 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
export default { |
|
|
|
|
|
name: '{{.StructName}}' |
|
|
|
|
|
} |
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<script setup> |
|
|
import { |
|
|
import { |
|
|
create{{.StructName}}, |
|
|
create{{.StructName}}, |
|
|
delete{{.StructName}}, |
|
|
delete{{.StructName}}, |
|
@ -132,112 +138,143 @@ import { |
|
|
update{{.StructName}}, |
|
|
update{{.StructName}}, |
|
|
find{{.StructName}}, |
|
|
find{{.StructName}}, |
|
|
get{{.StructName}}List |
|
|
get{{.StructName}}List |
|
|
} from '@/api/{{.PackageName}}' // 此处请自行替换地址 |
|
|
|
|
|
import infoList from '@/mixins/infoList' |
|
|
|
|
|
export default { |
|
|
|
|
|
name: '{{.StructName}}', |
|
|
|
|
|
mixins: [infoList], |
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
listApi: get{{ .StructName }}List, |
|
|
|
|
|
dialogFormVisible: false, |
|
|
|
|
|
type: '', |
|
|
|
|
|
deleteVisible: false, |
|
|
|
|
|
multipleSelection: [], |
|
|
|
|
|
{{- range $index, $element := .DictTypes }} |
|
|
|
|
|
{{ $element }}Options: [], |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
formData: { |
|
|
|
|
|
{{- range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" }} |
|
|
|
|
|
|
|
|
} from '@/api/{{.PackageName}}' |
|
|
|
|
|
|
|
|
|
|
|
import { getDictFunc, formatDate, formatBoolean, filterDict } from '@/utils/format' |
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
|
|
import { ref } from 'vue' |
|
|
|
|
|
|
|
|
|
|
|
const dialogFormVisible = ref(false) |
|
|
|
|
|
const type = ref('') |
|
|
|
|
|
const deleteVisible = ref(false) |
|
|
|
|
|
const multipleSelection = ref([]) |
|
|
|
|
|
{{- range $index, $element := .DictTypes}} |
|
|
|
|
|
const {{ $element }}Options = ref([]) |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
const formData = ref({ |
|
|
|
|
|
{{- range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" }} |
|
|
{{.FieldJson}}: false, |
|
|
{{.FieldJson}}: false, |
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "string" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "string" }} |
|
|
{{.FieldJson}}: '', |
|
|
{{.FieldJson}}: '', |
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "int" }} |
|
|
|
|
|
{{.FieldJson}}: {{- if .DictType}} undefined{{ else }} 0{{- end }}, |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "int" }} |
|
|
|
|
|
{{.FieldJson}}: {{- if .DictType }} undefined{{ else }} 0{{- end }}, |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" }} |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "float64" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async created() { |
|
|
|
|
|
await this.getTableData() |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const page = ref(1) |
|
|
|
|
|
const total = ref(0) |
|
|
|
|
|
const pageSize = ref(10) |
|
|
|
|
|
const tableData = ref([]) |
|
|
|
|
|
const searchInfo = ref({}) |
|
|
|
|
|
|
|
|
|
|
|
const onReset = () => { |
|
|
|
|
|
searchInfo.value = {} |
|
|
|
|
|
} |
|
|
|
|
|
// 搜索 |
|
|
|
|
|
|
|
|
|
|
|
const onSubmit = () => { |
|
|
|
|
|
page.value = 1 |
|
|
|
|
|
pageSize.value = 10 |
|
|
|
|
|
{{- range .Fields}}{{- if eq .FieldType "bool" }} |
|
|
|
|
|
if (searchInfo.value.{{.FieldJson}} === ""){ |
|
|
|
|
|
searchInfo.value.{{.FieldJson}}=null |
|
|
|
|
|
}{{ end }}{{ end }} |
|
|
|
|
|
getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 分页 |
|
|
|
|
|
const handleSizeChange = (val) => { |
|
|
|
|
|
pageSize.value = val |
|
|
|
|
|
getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (val) => { |
|
|
|
|
|
page.value = val |
|
|
|
|
|
getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询 |
|
|
|
|
|
const getTableData = async() => { |
|
|
|
|
|
const table = await get{{.StructName}}List({ page: page.value, pageSize: pageSize.value, ...searchInfo.value }) |
|
|
|
|
|
if (table.code === 0) { |
|
|
|
|
|
tableData.value = table.data.list |
|
|
|
|
|
total.value = table.data.total |
|
|
|
|
|
page.value = table.data.page |
|
|
|
|
|
pageSize.value = table.data.pageSize |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getTableData() |
|
|
|
|
|
|
|
|
|
|
|
const setOptions = async () =>{ |
|
|
{{- range $index, $element := .DictTypes }} |
|
|
{{- range $index, $element := .DictTypes }} |
|
|
await this.getDict('{{$element}}') |
|
|
|
|
|
|
|
|
{{ $element }}Options.value = await getDictFunc('{{$element}}') |
|
|
{{- end }} |
|
|
{{- end }} |
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
onReset() { |
|
|
|
|
|
this.searchInfo = {} |
|
|
|
|
|
}, |
|
|
|
|
|
// 条件搜索前端看此方法 |
|
|
|
|
|
onSubmit() { |
|
|
|
|
|
this.page = 1 |
|
|
|
|
|
this.pageSize = 10 |
|
|
|
|
|
{{- range .Fields}}{{- if eq .FieldType "bool" }} |
|
|
|
|
|
if (this.searchInfo.{{.FieldJson}} === ""){ |
|
|
|
|
|
this.searchInfo.{{.FieldJson}}=null |
|
|
|
|
|
}{{ end }}{{ end }} |
|
|
|
|
|
this.getTableData() |
|
|
|
|
|
}, |
|
|
|
|
|
handleSelectionChange(val) { |
|
|
|
|
|
this.multipleSelection = val |
|
|
|
|
|
}, |
|
|
|
|
|
deleteRow(row) { |
|
|
|
|
|
this.$confirm('确定要删除吗?', '提示', { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setOptions() |
|
|
|
|
|
|
|
|
|
|
|
const handleSelectionChange = (val) => { |
|
|
|
|
|
multipleSelection.value = val |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const deleteRow = (row) => { |
|
|
|
|
|
ElMessageBox.confirm('确定要删除吗?', '提示', { |
|
|
confirmButtonText: '确定', |
|
|
confirmButtonText: '确定', |
|
|
cancelButtonText: '取消', |
|
|
cancelButtonText: '取消', |
|
|
type: 'warning' |
|
|
type: 'warning' |
|
|
}).then(() => { |
|
|
|
|
|
this.delete{{.StructName}}(row) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
async onDelete() { |
|
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
delete{{.StructName}}Func(row) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
const onDelete = async() => { |
|
|
const ids = [] |
|
|
const ids = [] |
|
|
if (this.multipleSelection.length === 0) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
|
|
|
if (multipleSelection.value.length === 0) { |
|
|
|
|
|
ElMessage({ |
|
|
type: 'warning', |
|
|
type: 'warning', |
|
|
message: '请选择要删除的数据' |
|
|
message: '请选择要删除的数据' |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.multipleSelection && |
|
|
|
|
|
this.multipleSelection.map(item => { |
|
|
|
|
|
|
|
|
multipleSelection.value && |
|
|
|
|
|
multipleSelection.value.map(item => { |
|
|
ids.push(item.ID) |
|
|
ids.push(item.ID) |
|
|
}) |
|
|
}) |
|
|
const res = await delete{{.StructName}}ByIds({ ids }) |
|
|
const res = await delete{{.StructName}}ByIds({ ids }) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '删除成功' |
|
|
message: '删除成功' |
|
|
}) |
|
|
}) |
|
|
if (this.tableData.length === ids.length && this.page > 1) { |
|
|
|
|
|
this.page-- |
|
|
|
|
|
|
|
|
if (tableData.value.length === ids.length && page.value > 1) { |
|
|
|
|
|
page.value-- |
|
|
} |
|
|
} |
|
|
this.deleteVisible = false |
|
|
|
|
|
this.getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async update{{.StructName}}(row) { |
|
|
|
|
|
const res = await find{{.StructName}}({ ID: row.ID }) |
|
|
|
|
|
this.type = 'update' |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
this.formData = res.data.re{{.Abbreviation}} |
|
|
|
|
|
this.dialogFormVisible = true |
|
|
|
|
|
|
|
|
deleteVisible.value = false |
|
|
|
|
|
getTableData() |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
closeDialog() { |
|
|
|
|
|
this.dialogFormVisible = false |
|
|
|
|
|
this.formData = { |
|
|
|
|
|
{{- range .Fields}} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const update{{.StructName}}Func = async(row) => { |
|
|
|
|
|
const res = await find{{.StructName}}({ ID: row.ID }) |
|
|
|
|
|
type.value = 'update' |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
formData.value = res.data.re{{.Abbreviation}} |
|
|
|
|
|
dialogFormVisible.value = true |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const closeDialog = () => { |
|
|
|
|
|
dialogFormVisible.value = false |
|
|
|
|
|
formData.value = { |
|
|
|
|
|
{{- range .Fields}} |
|
|
{{- if eq .FieldType "bool" }} |
|
|
{{- if eq .FieldType "bool" }} |
|
|
{{.FieldJson}}: false, |
|
|
{{.FieldJson}}: false, |
|
|
{{- end }} |
|
|
{{- end }} |
|
@ -253,49 +290,47 @@ export default { |
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{- end }} |
|
|
{{- end }} |
|
|
{{- end }} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async delete{{.StructName}}(row) { |
|
|
|
|
|
const res = await delete{{.StructName}}({ ID: row.ID }) |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
message: '删除成功' |
|
|
|
|
|
}) |
|
|
|
|
|
if (this.tableData.length === 1 && this.page > 1) { |
|
|
|
|
|
this.page-- |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
} |
|
|
} |
|
|
this.getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async enterDialog() { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const delete{{.StructName}}Func = async (row) => { |
|
|
|
|
|
const res = await delete{{.StructName}}({ ID: row.ID }) |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
message: '删除成功' |
|
|
|
|
|
}) |
|
|
|
|
|
if (tableData.value.length === 1 && page.value > 1) { |
|
|
|
|
|
page.value-- |
|
|
|
|
|
} |
|
|
|
|
|
getTableData() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const enterDialog = async () => { |
|
|
let res |
|
|
let res |
|
|
switch (this.type) { |
|
|
|
|
|
|
|
|
switch (type.value) { |
|
|
case 'create': |
|
|
case 'create': |
|
|
res = await create{{.StructName}}(this.formData) |
|
|
|
|
|
|
|
|
res = await create{{.StructName}}(formData.value) |
|
|
break |
|
|
break |
|
|
case 'update': |
|
|
case 'update': |
|
|
res = await update{{.StructName}}(this.formData) |
|
|
|
|
|
|
|
|
res = await update{{.StructName}}(formData.value) |
|
|
break |
|
|
break |
|
|
default: |
|
|
default: |
|
|
res = await create{{.StructName}}(this.formData) |
|
|
|
|
|
|
|
|
res = await create{{.StructName}}(formData.value) |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '创建/更改成功' |
|
|
message: '创建/更改成功' |
|
|
}) |
|
|
}) |
|
|
this.closeDialog() |
|
|
|
|
|
this.getTableData() |
|
|
|
|
|
|
|
|
closeDialog() |
|
|
|
|
|
getTableData() |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
openDialog() { |
|
|
|
|
|
this.type = 'create' |
|
|
|
|
|
this.dialogFormVisible = true |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const openDialog = () => { |
|
|
|
|
|
type.value = 'create' |
|
|
|
|
|
dialogFormVisible.value = true |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|