mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
模板优化
This commit is contained in:
78
admin/src/api/system_log_sms.ts
Normal file
78
admin/src/api/system_log_sms.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import request from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
|
||||
import config from '@/config'
|
||||
import queryString from 'query-string'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
export type type_system_log_sms = {
|
||||
id?: number;
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
create_time?: string;
|
||||
update_time?: string;
|
||||
}
|
||||
// 查询
|
||||
export type type_system_log_sms_query = {
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
create_timeStart?: string;
|
||||
create_timeEnd?: string;
|
||||
update_timeStart?: string;
|
||||
update_timeEnd?: string;
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_system_log_sms_edit = {
|
||||
id?: number;
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
}
|
||||
|
||||
// 系统短信日志列表
|
||||
export function system_log_sms_list(params?: type_system_log_sms_query) {
|
||||
return request.get<Pages<type_system_log_sms>>({ url: '/system_log_sms/list', params })
|
||||
}
|
||||
// 系统短信日志列表-所有
|
||||
export function system_log_sms_list_all(params?: type_system_log_sms_query) {
|
||||
return request.get<type_system_log_sms[]>({ url: '/system_log_sms/listAll', params })
|
||||
}
|
||||
|
||||
// 系统短信日志详情
|
||||
export function system_log_sms_detail(id: number | string) {
|
||||
return request.get<type_system_log_sms>({ url: '/system_log_sms/detail', params: { id } })
|
||||
}
|
||||
|
||||
// 系统短信日志新增
|
||||
export function system_log_sms_add(data: type_system_log_sms_edit) {
|
||||
return request.post<null>({ url: '/system_log_sms/add', data })
|
||||
}
|
||||
|
||||
// 系统短信日志编辑
|
||||
export function system_log_sms_edit(data: type_system_log_sms_edit) {
|
||||
return request.post<null>({ url: '/system_log_sms/edit', data })
|
||||
}
|
||||
|
||||
// 系统短信日志删除
|
||||
export function system_log_sms_delete(id: number | string) {
|
||||
return request.post<null>({ url: '/system_log_sms/del', data: { id } })
|
||||
}
|
||||
|
||||
// 系统短信日志导入
|
||||
export const system_log_sms_import_file = '/system_log_sms/ImportFile'
|
||||
|
||||
// 系统短信日志导出
|
||||
export function system_log_sms_export_file(params: any) {
|
||||
return (window.location.href =`${config.baseUrl}${config.urlPrefix}/system_log_sms/ExportFile?token=${getToken()}&` + queryString.stringify(params))
|
||||
}
|
||||
@@ -21,12 +21,12 @@ export const addUnit = (value: string | number, unit = 'px') => {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 添加单位
|
||||
* @param {unknown} value
|
||||
* @description 是否为空
|
||||
* @param {any} value
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isEmpty = (value: unknown) => {
|
||||
return value == null && typeof value == 'undefined'
|
||||
export const isEmpty = (value: any) => {
|
||||
return value === '' || value === null || value === undefined
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,3 +134,15 @@ export const getNonDuplicateID = (length = 8) => {
|
||||
export const firstToUpperCase = (str = '') => {
|
||||
return str.toLowerCase().replace(/( |^)[a-z]/g, ($1) => $1.toUpperCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 清空对象空值属性
|
||||
*/
|
||||
export const clearEmpty = (obj: Record<string, any>) => {
|
||||
for (const key of Object.keys(obj)) {
|
||||
if (isEmpty(obj[key])) {
|
||||
delete obj[key]
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
188
admin/src/views/system/log/sms/edit.vue
Normal file
188
admin/src/views/system/log/sms/edit.vue
Normal file
@@ -0,0 +1,188 @@
|
||||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:clickModalClose="true"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="场景编号" prop="scene">
|
||||
<el-input v-model="formData.scene" type="number" placeholder="请输入场景编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="mobile">
|
||||
<el-input v-model="formData.mobile" placeholder="请输入手机号码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送内容" prop="content">
|
||||
<editor v-model="formData.content" :height="500" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status">
|
||||
<el-select
|
||||
class="flex-1"
|
||||
v-model="formData.status"
|
||||
placeholder="请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.flow_apply_status"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="parseInt(item.value)"
|
||||
clearable
|
||||
:disabled="!item.status"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="短信结果" prop="results">
|
||||
<el-input
|
||||
v-model="formData.results"
|
||||
placeholder="请输入短信结果"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发送时间" prop="send_time">
|
||||
<el-input
|
||||
v-model.number="formData.send_time"
|
||||
type="number"
|
||||
placeholder="请输入发送时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
system_log_sms_edit,
|
||||
system_log_sms_add,
|
||||
system_log_sms_detail
|
||||
} from '@/api/system_log_sms'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
},
|
||||
listAllData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑系统短信日志' : '新增系统短信日志'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
scene: 0,
|
||||
mobile: '',
|
||||
content: '',
|
||||
status: '',
|
||||
results: '',
|
||||
send_time: 0
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
// scene: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入场景编号',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
// mobile: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入手机号码',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
// content: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入发送内容',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
// status: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
// results: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入短信结果',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
// send_time: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入发送时间',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
mode.value == 'edit' ? await system_log_sms_edit(data) : await system_log_sms_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
const setFormData = async (data: Record<string, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
try {
|
||||
const data = await system_log_sms_detail(row.id)
|
||||
setFormData(data)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
||||
190
admin/src/views/system/log/sms/index.vue
Normal file
190
admin/src/views/system/log/sms/index.vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div class="index-lists">
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true" label-width="70px"
|
||||
label-position="left">
|
||||
<el-form-item label="手机号码" prop="mobile" class="w-[280px]">
|
||||
<el-input v-model="queryParams.mobile" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status" class="w-[280px]">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
clearable
|
||||
>
|
||||
|
||||
<el-option label="全部" value="" />
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.flow_apply_status"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="create_time" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.create_timeStart"
|
||||
v-model:endTime="queryParams.create_timeEnd"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="更新时间" prop="update_time" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.update_timeStart"
|
||||
v-model:endTime="queryParams.update_timeEnd"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div>
|
||||
<el-button v-perms="['admin:system_log_sms:add']" type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<upload
|
||||
class="ml-3 mr-3"
|
||||
:url="system_log_sms_import_file"
|
||||
:data="{ cid: 0 }"
|
||||
type="file"
|
||||
:show-progress="true"
|
||||
@change="resetPage"
|
||||
>
|
||||
<el-button type="primary">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Upload" />
|
||||
</template>
|
||||
导入
|
||||
</el-button>
|
||||
</upload>
|
||||
<el-button type="primary" @click="exportFile">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Download" />
|
||||
</template>
|
||||
导出
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
class="mt-4"
|
||||
size="large"
|
||||
v-loading="pager.loading"
|
||||
:data="pager.lists"
|
||||
>
|
||||
<el-table-column label="场景编号" prop="scene" min-width="130" />
|
||||
<el-table-column label="手机号码" prop="mobile" min-width="130" />
|
||||
<el-table-column label="发送内容" prop="content" min-width="130" />
|
||||
<el-table-column label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.flow_apply_status" :value="row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="短信结果" prop="results" min-width="130" />
|
||||
<el-table-column label="发送时间" prop="send_time" min-width="130" />
|
||||
<el-table-column label="创建时间" prop="create_time" min-width="130" />
|
||||
<el-table-column label="更新时间" prop="update_time" min-width="130" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['admin:system_log_sms:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['admin:system_log_sms:del']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="flex justify-end mt-4">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<edit-popup
|
||||
v-if="showEdit"
|
||||
ref="editRef"
|
||||
:dict-data="dictData"
|
||||
@success="getLists"
|
||||
@close="showEdit = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { system_log_sms_delete, system_log_sms_list,system_log_sms_import_file, system_log_sms_export_file } from '@/api/system_log_sms'
|
||||
import type { type_system_log_sms,type_system_log_sms_query } from "@/api/system_log_sms";
|
||||
|
||||
|
||||
import { useDictData,useListAllData } from '@/hooks/useDictOptions'
|
||||
import type { type_dict } from '@/hooks/useDictOptions'
|
||||
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
defineOptions({
|
||||
name:"system_log_sms"
|
||||
})
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
const queryParams = reactive<type_system_log_sms_query>({
|
||||
scene: null,
|
||||
mobile: null,
|
||||
content: null,
|
||||
status: null,
|
||||
results: null,
|
||||
send_time: null,
|
||||
create_timeStart: null,
|
||||
create_timeEnd: null,
|
||||
update_timeStart: null,
|
||||
update_timeEnd: null,
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging<type_system_log_sms>({
|
||||
fetchFun: system_log_sms_list,
|
||||
params: queryParams
|
||||
})
|
||||
const { dictData } = useDictData<{
|
||||
flow_apply_status: type_dict[]
|
||||
}>(['flow_apply_status'])
|
||||
|
||||
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.getDetail(data)
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await system_log_sms_delete( id )
|
||||
feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
} catch (error) {}
|
||||
}
|
||||
const exportFile = async () => {
|
||||
try {
|
||||
await feedback.confirm('确定要导出?')
|
||||
await system_log_sms_export_file(queryParams)
|
||||
} catch (error) {}
|
||||
}
|
||||
getLists()
|
||||
</script>
|
||||
1
server/.vscode/settings.json
vendored
1
server/.vscode/settings.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"autosize",
|
||||
"daterange",
|
||||
"datetime",
|
||||
"dcloudio",
|
||||
|
||||
@@ -42,7 +42,8 @@ var SqlConstants = sqlConstants{
|
||||
|
||||
//HtmlConstants HTML相关常量
|
||||
var HtmlConstants = htmlConstants{
|
||||
HtmlInput: "input", //文本框
|
||||
HtmlInput: "input", //文本框
|
||||
HtmlInputNumber: "number",
|
||||
HtmlTextarea: "textarea", //文本域
|
||||
HtmlSelect: "select", //下拉框
|
||||
HtmlRadio: "radio", //单选框
|
||||
@@ -82,6 +83,7 @@ type sqlConstants struct {
|
||||
|
||||
type htmlConstants struct {
|
||||
HtmlInput string
|
||||
HtmlInputNumber string
|
||||
HtmlTextarea string
|
||||
HtmlSelect string
|
||||
HtmlRadio string
|
||||
|
||||
@@ -26,10 +26,10 @@ type {{{ toUpperCamelCase .ModuleName }}}Handler struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
// @Param {{{ toCamelCase .GoField }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ toCamelCase .GoField }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_end query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- else }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -54,10 +54,10 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) List(c *gin.Context) {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
// @Param {{{ toCamelCase .GoField }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ toCamelCase .GoField }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_end query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- else }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -78,7 +78,7 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) ListAll(c *gin.Context)
|
||||
// @Param Token header string true "token"
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsPk }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
// @Success 200 {object} response.Response{ data={{{ toUpperCamelCase .EntityName }}}Resp} "成功"
|
||||
@@ -103,7 +103,7 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) Detail(c *gin.Context) {
|
||||
// @Param Token header string true "token"
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsInsert }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
@@ -122,7 +122,7 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) Add(c *gin.Context) {
|
||||
// @Param Token header string true "token"
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsEdit }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
@@ -140,7 +140,7 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) Edit(c *gin.Context) {
|
||||
// @Param Token header string true "token"
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsPk }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
@@ -162,10 +162,10 @@ func (hd *{{{ toUpperCamelCase .ModuleName }}}Handler) Del(c *gin.Context) {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
// @Param {{{ toCamelCase .GoField }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ toCamelCase .GoField }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_start query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}}_end query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- else }}}
|
||||
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
// @Param {{{ .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}"
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -2,7 +2,6 @@ package model
|
||||
import (
|
||||
"x_admin/core"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"github.com/guregu/null/v5"
|
||||
)
|
||||
|
||||
//{{{ toUpperCamelCase .EntityName }}} {{{ .FunctionName }}}实体
|
||||
@@ -10,14 +9,14 @@ type {{{ toUpperCamelCase .EntityName }}} struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if not (contains $.SubTableFields .ColumnName) }}}
|
||||
{{{- if eq .GoField "is_delete" }}}
|
||||
IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
IsDelete soft_delete.DeletedAt `mapstructure:"{{{ .GoField }}}" gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
{{{- else }}}
|
||||
{{{- if eq .GoType "core.TsTime" }}}
|
||||
{{{ toUpperCamelCase .GoField }}} core.TsTime `gorm:"{{{ if eq .GoField "create_time" }}}autoCreateTime;{{{ else }}}{{{if eq .GoField "update_time"}}}autoUpdateTime;{{{ end }}}{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} core.TsTime `mapstructure:"{{{ .GoField }}}" gorm:"{{{ if eq .GoField "create_time" }}}autoCreateTime;{{{ else }}}{{{if eq .GoField "update_time"}}}autoUpdateTime;{{{ end }}}{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{- else if .IsPk }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `gorm:"primarykey;" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `mapstructure:"{{{ .GoField }}}" gorm:"primarykey;" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{- else }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{goToNullType .GoType }}} `gorm:"" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `mapstructure:"{{{ .GoField }}}" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package {{{ .ModuleName }}}
|
||||
import (
|
||||
"x_admin/core"
|
||||
|
||||
"github.com/guregu/null/v5"
|
||||
)
|
||||
|
||||
//{{{ toUpperCamelCase .EntityName }}}ListReq {{{ .FunctionName }}}列表参数
|
||||
@@ -10,10 +9,10 @@ type {{{ toUpperCamelCase .EntityName }}}ListReq struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ toUpperCamelCase .GoField }}}Start null.String `form:"{{{ toCamelCase .GoField }}}Start"` // 开始{{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}}End null.String `form:"{{{ toCamelCase .GoField }}}End"` // 结束{{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}}Start *string `mapstructure:"{{{ .GoField }}}_start" json:"{{{ .GoField }}}_start" form:"{{{ .GoField }}}_start"` // 开始{{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}}End *string `mapstructure:"{{{ .GoField }}}_end" json:"{{{ .GoField }}}_end" form:"{{{ .GoField }}}_end"` // 结束{{{ .ColumnComment }}}
|
||||
{{{- else }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{goToNullType .GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} *{{{.GoType }}} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}}" form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -25,7 +24,7 @@ type {{{ toUpperCamelCase .EntityName }}}ListReq struct {
|
||||
type {{{ toUpperCamelCase .EntityName }}}AddReq struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsInsert }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{goToNullType .GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} interface{} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}} form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
@@ -35,9 +34,9 @@ type {{{ toUpperCamelCase .EntityName }}}EditReq struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsEdit }}}
|
||||
{{{- if .IsPk }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}}" form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- else }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{goToNullType .GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} interface{} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}}" form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -47,7 +46,7 @@ type {{{ toUpperCamelCase .EntityName }}}EditReq struct {
|
||||
type {{{ toUpperCamelCase .EntityName }}}DetailReq struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsPk }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{.GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{.GoType }}} `form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
@@ -56,7 +55,7 @@ type {{{ toUpperCamelCase .EntityName }}}DetailReq struct {
|
||||
type {{{ toUpperCamelCase .EntityName }}}DelReq struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsPk }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `form:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `form:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
@@ -66,9 +65,9 @@ type {{{ toUpperCamelCase .EntityName }}}Resp struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if or .IsList .IsPk }}}
|
||||
{{{- if .IsPk }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `json:"{{{ toCamelCase .GoField }}}" structs:"{{{ toCamelCase .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}}"` // {{{ .ColumnComment }}}
|
||||
{{{- else }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{goToNullType .GoType }}} `json:"{{{ toCamelCase .GoField }}}" structs:"{{{ toCamelCase .GoField }}}" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{ toUpperCamelCase .GoField }}} {{{ .GoType }}} `mapstructure:"{{{ .GoField }}}" json:"{{{ .GoField }}}" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"x_admin/model"
|
||||
"gorm.io/gorm"
|
||||
"x_admin/util"
|
||||
"github.com/duke-git/lancet/v2/convertor"
|
||||
)
|
||||
|
||||
var {{{ toUpperCamelCase .EntityName }}}Service=New{{{ toUpperCamelCase .EntityName }}}Service()
|
||||
@@ -38,20 +39,20 @@ func (service {{{ toCamelCase .EntityName }}}Service) GetModel(listReq {{{ toUpp
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- $queryOpr := index $.ModelOprMap .QueryType }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}Start.Valid {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} >= ?", listReq.{{{ toUpperCamelCase .ColumnName }}}Start.ValueOrZero())
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}Start!= nil {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} >= ?", *listReq.{{{ toUpperCamelCase .ColumnName }}}Start)
|
||||
}
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}End.Valid {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} <= ?", listReq.{{{ toUpperCamelCase .ColumnName }}}End.ValueOrZero())
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}End!= nil {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} <= ?", *listReq.{{{ toUpperCamelCase .ColumnName }}}End)
|
||||
}
|
||||
{{{- else }}}
|
||||
{{{- if and (eq .GoType "string") (eq $queryOpr "like") }}}
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}.Valid {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} like ?", "%"+listReq.{{{ toUpperCamelCase .ColumnName }}}.ValueOrZero()+"%")
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}!= nil {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} like ?", "%"+*listReq.{{{ toUpperCamelCase .ColumnName }}}+"%")
|
||||
}
|
||||
{{{- else }}}
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}.Valid {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} = ?", listReq.{{{ toUpperCamelCase .ColumnName }}}.ValueOrZero())
|
||||
if listReq.{{{ toUpperCamelCase .ColumnName }}}!= nil {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} = ?", *listReq.{{{ toUpperCamelCase .ColumnName }}})
|
||||
}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -155,12 +156,19 @@ func (service {{{ toCamelCase .EntityName }}}Service) Edit(editReq {{{ toUpperCa
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
response.Copy(&obj, editReq)
|
||||
err = service.db.Model(&obj).Select("*").Updates(obj).Error
|
||||
// response.Copy(&obj, editReq)
|
||||
//
|
||||
editInfo, err := convertor.StructToMap(editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = service.db.Model(&obj).Updates(editInfo).Error
|
||||
if e = response.CheckErr(err, "编辑失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.SetCache(obj.{{{ toUpperCamelCase .PrimaryKey }}}, obj)
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
service.Detail(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { request } from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
export type type_{{{.ModuleName}}} = {
|
||||
{{{- range .Columns }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
}
|
||||
// 查询
|
||||
@@ -10,10 +10,10 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ toCamelCase .GoField }}}Start?: string;
|
||||
{{{ toCamelCase .GoField }}}End?: string;
|
||||
{{{ .GoField }}}_start?: string;
|
||||
{{{ .GoField }}}_end?: string;
|
||||
{{{- else }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -22,7 +22,7 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
export type type_{{{.ModuleName}}}_edit = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if or .IsEdit .IsInsert }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
<uv-form labelPosition="left" :model="form">
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsList }}}
|
||||
<uv-form-item label="{{{.ColumnComment}}}" prop="{{{(toCamelCase .GoField)}}}" borderBottom>
|
||||
<uv-form-item label="{{{.ColumnComment}}}" prop="{{{(.GoField)}}}" borderBottom>
|
||||
{{{- if and (ne .DictType "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (toCamelCase .GoField) }}}" />
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (.GoField) }}}" />
|
||||
{{{- else if and (ne .ListAllApi "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (toCamelCase .GoField) }}}" labelKey='id' valueKey='id' />
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (.GoField) }}}" labelKey='id' valueKey='id' />
|
||||
{{{- else if eq .HtmlType "imageUpload" }}}
|
||||
<uv-image :src="$filePath(form.{{{(toCamelCase .GoField)}}})" width="100%"></uv-image>
|
||||
<uv-image :src="$filePath(form.{{{(.GoField)}}})" width="100%"></uv-image>
|
||||
{{{- else }}}
|
||||
{{form.{{{(toCamelCase .GoField)}}}}}
|
||||
{{form.{{{(.GoField)}}}}}
|
||||
{{{- end }}}
|
||||
</uv-form-item>
|
||||
{{{- end }}}
|
||||
@@ -44,7 +44,7 @@
|
||||
let form = ref({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if or .IsList .IsPk }}}
|
||||
{{{ toCamelCase .GoField }}}: "",
|
||||
{{{ .GoField }}}: "",
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
});
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
<uv-form labelPosition="left" :model="form" :rules="formRules" ref="formRef">
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsEdit }}}
|
||||
<uv-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" borderBottom>
|
||||
<uv-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" borderBottom>
|
||||
{{{- if eq .HtmlType "input" }}}
|
||||
<uv-input v-model="form.{{{ (toCamelCase .GoField) }}}" border="surround"></uv-input>
|
||||
<uv-input v-model="form.{{{ (.GoField) }}}" border="surround"></uv-input>
|
||||
{{{- else if eq .HtmlType "number" }}}
|
||||
<uv-number-box v-model="form.{{{ (toCamelCase .GoField) }}}" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
<uv-number-box v-model="form.{{{ (.GoField) }}}" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
{{{- else if eq .HtmlType "textarea" }}}
|
||||
<uv-textarea v-model="form.{{{ (toCamelCase .GoField) }}}" border="surround"></uv-textarea>
|
||||
<uv-textarea v-model="form.{{{ (.GoField) }}}" border="surround"></uv-textarea>
|
||||
{{{- else if eq .HtmlType "datetime" }}}
|
||||
<x-date v-model:time="form.{{{ (toCamelCase .GoField) }}}"></x-date>
|
||||
<x-date v-model:time="form.{{{ (.GoField) }}}"></x-date>
|
||||
{{{- else if or (eq .HtmlType "checkbox") (eq .HtmlType "radio") (eq .HtmlType "select")}}}
|
||||
{{{- if ne .DictType "" }}}
|
||||
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
|
||||
<x-picker v-model="form.{{{ (.GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
|
||||
{{{- else if ne .ListAllApi "" }}}
|
||||
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="id" labelKey="id" :columns="listAllData.{{{pathToName .ListAllApi}}}"></x-picker>
|
||||
<x-picker v-model="form.{{{ (.GoField) }}}" valueKey="id" labelKey="id" :columns="listAllData.{{{pathToName .ListAllApi}}}"></x-picker>
|
||||
{{{- else }}}
|
||||
请选择字典生成代码
|
||||
{{{- end }}}
|
||||
@@ -55,15 +55,15 @@
|
||||
let formRef = ref();
|
||||
let form = ref<type_{{{ .ModuleName }}}_edit>({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq (toCamelCase .GoField) $.PrimaryKey }}}
|
||||
{{{- if eq (.GoField) $.PrimaryKey }}}
|
||||
{{{ $.PrimaryKey }}}: '',
|
||||
{{{- else if .IsEdit }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
{{{ (toCamelCase .GoField) }}}: [],
|
||||
{{{ (.GoField) }}}: [],
|
||||
{{{- else if eq .HtmlType "number" }}}
|
||||
{{{ (toCamelCase .GoField) }}}: 0,
|
||||
{{{ (.GoField) }}}: 0,
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: '',
|
||||
{{{ (.GoField) }}}: '',
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -71,7 +71,7 @@
|
||||
const formRules = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if and .IsEdit .IsRequired }}}
|
||||
{{{ (toCamelCase .GoField) }}}: [
|
||||
{{{ (.GoField) }}}: [
|
||||
{
|
||||
required: true,
|
||||
{{{- if or (eq .HtmlType "checkbox") (eq .HtmlType "datetime") (eq .HtmlType "radio") (eq .HtmlType "select") (eq .HtmlType "imageUpload") }}}
|
||||
|
||||
@@ -72,10 +72,10 @@ const queryParams = reactive<type_{{{.ModuleName}}}_query>({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ (toCamelCase .GoField) }}}Start: '',
|
||||
{{{ (toCamelCase .GoField) }}}End: '',
|
||||
{{{ (.GoField) }}}_start: '',
|
||||
{{{ (.GoField) }}}_end: '',
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: '',
|
||||
{{{ (.GoField) }}}: '',
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form">
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .IsQuery 1 }}}
|
||||
<uv-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" borderBottom>
|
||||
<uv-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" borderBottom>
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
<x-date-range v-model:startTime="form.{{{ (toCamelCase .GoField) }}}Start"
|
||||
v-model:endTime="form.{{{ (toCamelCase .GoField) }}}End"></x-date-range>
|
||||
<x-date-range v-model:startTime="form.{{{ (.GoField) }}}_start"
|
||||
v-model:endTime="form.{{{ (.GoField) }}}_end"></x-date-range>
|
||||
{{{- else if or (eq .HtmlType "checkbox") (eq .HtmlType "radio") (eq .HtmlType "select") }}}
|
||||
{{{- if ne .DictType "" }}}
|
||||
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
|
||||
<x-picker v-model="form.{{{ (.GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
|
||||
{{{- else if ne .ListAllApi "" }}}
|
||||
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="id" labelKey="id" :columns="listAllData.{{{pathToName .ListAllApi}}}"></x-picker>
|
||||
<x-picker v-model="form.{{{ (.GoField) }}}" valueKey="id" labelKey="id" :columns="listAllData.{{{pathToName .ListAllApi}}}"></x-picker>
|
||||
{{{- end }}}
|
||||
{{{- else if eq .HtmlType "input" }}}
|
||||
<uv-input v-model="form.{{{ (toCamelCase .GoField) }}}"> </uv-input>
|
||||
<uv-input v-model="form.{{{ (.GoField) }}}"> </uv-input>
|
||||
{{{- end }}}
|
||||
</uv-form-item>
|
||||
{{{- end }}}
|
||||
@@ -71,10 +71,10 @@ const { listAllData } = useListAllData<{
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ (toCamelCase .GoField) }}}Start: null,
|
||||
{{{ (toCamelCase .GoField) }}}End: null,
|
||||
{{{ (.GoField) }}}_start: null,
|
||||
{{{ (.GoField) }}}_end: null,
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: null,
|
||||
{{{ (.GoField) }}}: null,
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
|
||||
|
||||
export type type_{{{.ModuleName}}} = {
|
||||
{{{- range .Columns }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
}
|
||||
// 查询
|
||||
@@ -15,10 +15,10 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ toCamelCase .GoField }}}Start?: string;
|
||||
{{{ toCamelCase .GoField }}}End?: string;
|
||||
{{{ .GoField }}}_start?: string;
|
||||
{{{ .GoField }}}_end?: string;
|
||||
{{{- else }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -27,7 +27,7 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
export type type_{{{.ModuleName}}}_edit = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if or .IsEdit .IsInsert }}}
|
||||
{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{ .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsEdit }}}
|
||||
{{{- if ne (toCamelCase .GoField) "id" }}}
|
||||
{{{- if and (ne $.Table.TreeParent "") (eq (toCamelCase .GoField) $.Table.TreeParent) }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
{{{- if ne (.GoField) "id" }}}
|
||||
{{{- if and (ne $.Table.TreeParent "") (eq (.GoField) $.Table.TreeParent) }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-tree-select
|
||||
class="flex-1"
|
||||
v-model="formData.{{{ (toCamelCase .GoField) }}}"
|
||||
v-model="formData.{{{ (.GoField) }}}"
|
||||
:data="treeList"
|
||||
clearable
|
||||
node-key="{{{ .Table.TreePrimary }}}"
|
||||
@@ -28,25 +28,25 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "input" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-input v-model="formData.{{{ (toCamelCase .GoField) }}}" placeholder="请输入{{{ .ColumnComment }}}" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-input v-model.number="formData.{{{ (.GoField) }}}" placeholder="请输入{{{ .ColumnComment }}}" />
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "number" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-input-number v-model="formData.{{{ (toCamelCase .GoField) }}}" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-input v-model="formData.{{{ (.GoField) }}}" type="number" placeholder="请输入{{{ .ColumnComment }}}" />
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "textarea" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-input
|
||||
v-model="formData.{{{ (toCamelCase .GoField) }}}"
|
||||
v-model="formData.{{{ (.GoField) }}}"
|
||||
placeholder="请输入{{{ .ColumnComment }}}"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "checkbox" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-checkbox-group v-model="formData.{{{ (toCamelCase .GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-checkbox-group v-model="formData.{{{ (.GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
{{{- if ne .DictType "" }}}
|
||||
<el-checkbox
|
||||
v-for="(item, index) in dictData.{{{ .DictType }}}"
|
||||
@@ -68,8 +68,8 @@
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "select" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-select class="flex-1" v-model="formData.{{{ (toCamelCase .GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-select class="flex-1" v-model="formData.{{{ (.GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
{{{- if ne .DictType "" }}}
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.{{{ .DictType }}}"
|
||||
@@ -101,8 +101,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "radio" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-radio-group v-model="formData.{{{ (toCamelCase .GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-radio-group v-model="formData.{{{ (.GoField) }}}" placeholder="请选择{{{ .ColumnComment }}}">
|
||||
{{{- if ne .DictType "" }}}
|
||||
<el-radio
|
||||
v-for="(item, index) in dictData.{{{ .DictType }}}"
|
||||
@@ -134,10 +134,10 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "datetime" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<el-date-picker
|
||||
class="flex-1 !flex"
|
||||
v-model="formData.{{{ (toCamelCase .GoField) }}}"
|
||||
v-model="formData.{{{ (.GoField) }}}"
|
||||
type="datetime"
|
||||
clearable
|
||||
value-format="YYYY-MM-DD hh:mm:ss"
|
||||
@@ -145,12 +145,12 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "editor" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<editor v-model="formData.{{{ (toCamelCase .GoField) }}}" :height="500" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<editor v-model="formData.{{{ (.GoField) }}}" :height="500" />
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "imageUpload" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<material-picker v-model="formData.{{{ (toCamelCase .GoField) }}}" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<material-picker v-model="formData.{{{ (.GoField) }}}" />
|
||||
</el-form-item>
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -190,15 +190,15 @@ const popupTitle = computed(() => {
|
||||
|
||||
const formData = reactive({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq (toCamelCase .GoField) $.PrimaryKey }}}
|
||||
{{{- if eq (.GoField) $.PrimaryKey }}}
|
||||
{{{ $.PrimaryKey }}}: '',
|
||||
{{{- else if .IsEdit }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
{{{ (toCamelCase .GoField) }}}: [],
|
||||
{{{ (.GoField) }}}: [],
|
||||
{{{- else if eq .HtmlType "number" }}}
|
||||
{{{ (toCamelCase .GoField) }}}: 0,
|
||||
{{{ (.GoField) }}}: 0,
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: '',
|
||||
{{{ (.GoField) }}}: '',
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -207,7 +207,7 @@ const formData = reactive({
|
||||
const formRules = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if and .IsEdit .IsRequired }}}
|
||||
{{{ (toCamelCase .GoField) }}}: [
|
||||
{{{ (.GoField) }}}: [
|
||||
{
|
||||
required: true,
|
||||
{{{- if or (eq .HtmlType "checkbox") (eq .HtmlType "datetime") (eq .HtmlType "radio") (eq .HtmlType "select") (eq .HtmlType "imageUpload") }}}
|
||||
@@ -228,7 +228,7 @@ const handleSubmit = async () => {
|
||||
const data: any = { ...formData }
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
data.{{{ (toCamelCase .GoField) }}} = data.{{{ (toCamelCase .GoField) }}}.join(',')
|
||||
data.{{{ (.GoField) }}} = data.{{{ (.GoField) }}}.join(',')
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
mode.value == 'edit' ? await {{{ .ModuleName }}}_edit(data) : await {{{ .ModuleName }}}_add(data)
|
||||
@@ -251,7 +251,7 @@ const setFormData = async (data: Record<string, any>) => {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
//@ts-ignore
|
||||
formData.{{{ (toCamelCase .GoField) }}} = String(data.{{{ (toCamelCase .GoField) }}}).split(',')
|
||||
formData.{{{ (.GoField) }}} = String(data.{{{ (.GoField) }}}).split(',')
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .IsQuery 1 }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.{{{ (toCamelCase .GoField) }}}Start"
|
||||
v-model:endTime="queryParams.{{{ (toCamelCase .GoField) }}}End"
|
||||
v-model:startTime="queryParams.{{{ (.GoField) }}}_start"
|
||||
v-model:endTime="queryParams.{{{ (.GoField) }}}_end"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if or (eq .HtmlType "select") (eq .HtmlType "radio") }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" class="w-[280px]">
|
||||
<el-select
|
||||
v-model="queryParams.{{{ (toCamelCase .GoField) }}}"
|
||||
v-model="queryParams.{{{ (.GoField) }}}"
|
||||
|
||||
clearable
|
||||
>
|
||||
@@ -40,8 +40,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "input" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-input v-model="queryParams.{{{ (toCamelCase .GoField) }}}" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" class="w-[280px]">
|
||||
<el-input v-model="queryParams.{{{ (.GoField) }}}" />
|
||||
</el-form-item>
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -74,32 +74,32 @@
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsList }}}
|
||||
{{{- if and (ne .DictType "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (toCamelCase .GoField) }}}" />
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (.GoField) }}}" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{{- else if and (ne .ListAllApi "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (toCamelCase .GoField) }}}" labelKey='id' valueKey='id' />
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (.GoField) }}}" labelKey='id' valueKey='id' />
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{{- else if eq .HtmlType "imageUpload" }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<image-contain
|
||||
:width="40"
|
||||
:height="40"
|
||||
:src="row.{{{ (toCamelCase .GoField) }}}"
|
||||
:preview-src-list="[row.{{{ (toCamelCase .GoField) }}}]"
|
||||
:src="row.{{{ (.GoField) }}}"
|
||||
:preview-src-list="[row.{{{ (.GoField) }}}]"
|
||||
preview-teleported
|
||||
hide-on-click-modal
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{{- else }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100" />
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100" />
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -172,10 +172,10 @@ const queryParams = reactive<type_{{{.ModuleName}}}_query>({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ (toCamelCase .GoField) }}}Start: '',
|
||||
{{{ (toCamelCase .GoField) }}}End: '',
|
||||
{{{ (.GoField) }}}_start: '',
|
||||
{{{ (.GoField) }}}_end: '',
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: '',
|
||||
{{{ (.GoField) }}}: '',
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .IsQuery 1 }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.{{{ (toCamelCase .GoField) }}}Start"
|
||||
v-model:endTime="queryParams.{{{ (toCamelCase .GoField) }}}End"
|
||||
v-model:startTime="queryParams.{{{ (.GoField) }}}_start"
|
||||
v-model:endTime="queryParams.{{{ (.GoField) }}}_end"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if or (eq .HtmlType "select") (eq .HtmlType "radio") }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" class="w-[280px]">
|
||||
<el-select
|
||||
v-model="queryParams.{{{ (toCamelCase .GoField) }}}"
|
||||
v-model="queryParams.{{{ (.GoField) }}}"
|
||||
clearable
|
||||
>
|
||||
{{{- if ne .DictType "" }}}
|
||||
@@ -41,8 +41,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "input" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-input v-model="queryParams.{{{ (toCamelCase .GoField) }}}" />
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" class="w-[280px]">
|
||||
<el-input v-model="queryParams.{{{ (.GoField) }}}" />
|
||||
</el-form-item>
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -92,33 +92,33 @@
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsList }}}
|
||||
{{{- if and (ne .DictType "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (toCamelCase .GoField) }}}" />
|
||||
<dict-value :options="dictData.{{{ .DictType }}}" :value="row.{{{ (.GoField) }}}" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{{- else if and (ne .ListAllApi "") (or (eq .HtmlType "select") (eq .HtmlType "radio") (eq .HtmlType "checkbox")) }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (toCamelCase .GoField) }}}" labelKey='id' valueKey='id' />
|
||||
<dict-value :options="listAllData.{{{pathToName .ListAllApi }}}" :value="row.{{{ (.GoField) }}}" labelKey='id' valueKey='id' />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
{{{- else if eq .HtmlType "imageUpload" }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="100">
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<image-contain
|
||||
:width="40"
|
||||
:height="40"
|
||||
:src="row.{{{ (toCamelCase .GoField) }}}"
|
||||
:preview-src-list="[row.{{{ (toCamelCase .GoField) }}}]"
|
||||
:src="row.{{{ (.GoField) }}}"
|
||||
:preview-src-list="[row.{{{ (.GoField) }}}]"
|
||||
preview-teleported
|
||||
hide-on-click-modal
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{{- else }}}
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" min-width="130" />
|
||||
<el-table-column label="{{{ .ColumnComment }}}" prop="{{{ (.GoField) }}}" min-width="130" />
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -181,10 +181,10 @@ const queryParams = reactive<type_{{{.ModuleName}}}_query>({
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{ (toCamelCase .GoField) }}}Start: null,
|
||||
{{{ (toCamelCase .GoField) }}}End: null,
|
||||
{{{ (.GoField) }}}_start: null,
|
||||
{{{ (.GoField) }}}_end: null,
|
||||
{{{- else }}}
|
||||
{{{ (toCamelCase .GoField) }}}: null,
|
||||
{{{ (.GoField) }}}: null,
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (gu genUtil) InitColumn(tableId uint, column gen_model.GenTableColumn) gen_
|
||||
col.HtmlType = HtmlConstants.HtmlDatetime
|
||||
} else if util.ToolsUtil.Contains(SqlConstants.ColumnTypeNumber, columnType) {
|
||||
//数字字段
|
||||
col.HtmlType = HtmlConstants.HtmlInput
|
||||
col.HtmlType = HtmlConstants.HtmlInputNumber
|
||||
if strings.Contains(columnType, ",") {
|
||||
col.GoType = GoConstants.TypeFloat
|
||||
} else {
|
||||
@@ -244,22 +244,22 @@ func (gu genUtil) GoToTsType(s string) string {
|
||||
* @description: Go类型转可为null类型,转换后还能解决前端对int传了string类型错误问题
|
||||
*/
|
||||
func (gu genUtil) GoToNullType(s string) string {
|
||||
if s == "int64" {
|
||||
return "null.Int"
|
||||
} else if s == "int32" || s == "int" {
|
||||
return "null.Int32"
|
||||
} else if s == "int8" || s == "int16" {
|
||||
return "null.Int16"
|
||||
} else if s == "float" || s == "float32" || s == "float64" {
|
||||
return "null.Float"
|
||||
} else if s == "string" {
|
||||
return "null.String"
|
||||
} else if s == "bool" {
|
||||
return "null.Bool"
|
||||
} else if s == "time.Time" {
|
||||
return "null.Time"
|
||||
}
|
||||
return s
|
||||
// if s == "int64" {
|
||||
// return "null.Int"
|
||||
// } else if s == "int32" || s == "int" {
|
||||
// return "null.Int32"
|
||||
// } else if s == "int8" || s == "int16" {
|
||||
// return "null.Int16"
|
||||
// } else if s == "float" || s == "float32" || s == "float64" {
|
||||
// return "null.Float"
|
||||
// } else if s == "string" {
|
||||
// return "null.String"
|
||||
// } else if s == "bool" {
|
||||
// return "null.Bool"
|
||||
// } else if s == "time.Time" {
|
||||
// return "null.Time"
|
||||
// }
|
||||
return "*" + s
|
||||
}
|
||||
|
||||
// 拼接字符串
|
||||
|
||||
@@ -56,10 +56,7 @@ func (service systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptRe
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// deptResps = []SystemAuthDeptResp{}
|
||||
response.Copy(&deptResps, depts)
|
||||
// mapList = util.ArrayUtil.ListToTree(
|
||||
// util.ConvertUtil.StructsToMaps(deptResps), "id", "pid", "children")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
206
server/admin/system_log_sms/system_log_sms_ctl.go
Normal file
206
server/admin/system_log_sms/system_log_sms_ctl.go
Normal file
@@ -0,0 +1,206 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel"
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
|
||||
type SystemLogSmsHandler struct {
|
||||
requestGroup singleflight.Group
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志列表
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param scene query int false "场景编号"
|
||||
// @Param mobile query string false "手机号码"
|
||||
// @Param content query string false "发送内容"
|
||||
// @Param status query int false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param results query string false "短信结果"
|
||||
// @Param send_time query int false "发送时间"
|
||||
// @Param create_timeStart query core.TsTime false "创建时间"
|
||||
// @Param create_timeEnd query core.TsTime false "创建时间"
|
||||
// @Param update_timeStart query core.TsTime false "更新时间"
|
||||
// @Param update_timeEnd query core.TsTime false "更新时间"
|
||||
//@Success 200 {object} response.Response{ data=response.PageResp{ lists= []SystemLogSmsResp}} "成功"
|
||||
//@Router /api/admin/system_log_sms/list [get]
|
||||
func (hd *SystemLogSmsHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
|
||||
return
|
||||
}
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志列表-所有
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param scene query int false "场景编号"
|
||||
// @Param mobile query string false "手机号码"
|
||||
// @Param content query string false "发送内容"
|
||||
// @Param status query int false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param results query string false "短信结果"
|
||||
// @Param send_time query int false "发送时间"
|
||||
// @Param create_timeStart query core.TsTime false "创建时间"
|
||||
// @Param create_timeEnd query core.TsTime false "创建时间"
|
||||
// @Param update_timeStart query core.TsTime false "更新时间"
|
||||
// @Param update_timeEnd query core.TsTime false "更新时间"
|
||||
// @Success 200 {object} response.Response{ data=[]SystemLogSmsResp} "成功"
|
||||
// @Router /api/admin/system_log_sms/listAll [get]
|
||||
func (hd *SystemLogSmsHandler) ListAll(c *gin.Context) {
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.ListAll(listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志详情
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id query int false "id"
|
||||
// @Success 200 {object} response.Response{ data=SystemLogSmsResp} "成功"
|
||||
// @Router /api/admin/system_log_sms/detail [get]
|
||||
func (hd *SystemLogSmsHandler) Detail(c *gin.Context) {
|
||||
var detailReq SystemLogSmsDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err, _ := hd.requestGroup.Do("SystemLogSms:Detail:"+strconv.Itoa(detailReq.Id), func() (any, error) {
|
||||
v, err := SystemLogSmsService.Detail(detailReq.Id)
|
||||
return v, err
|
||||
})
|
||||
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
|
||||
// @Summary 系统短信日志新增
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param scene body int false "场景编号"
|
||||
// @Param mobile body string false "手机号码"
|
||||
// @Param content body string false "发送内容"
|
||||
// @Param status body int false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param results body string false "短信结果"
|
||||
// @Param send_time body int false "发送时间"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/add [post]
|
||||
func (hd *SystemLogSmsHandler) Add(c *gin.Context) {
|
||||
var addReq SystemLogSmsAddReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &addReq)) {
|
||||
return
|
||||
}
|
||||
createId, e := SystemLogSmsService.Add(addReq)
|
||||
response.CheckAndRespWithData(c,createId, e)
|
||||
}
|
||||
// @Summary 系统短信日志编辑
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "id"
|
||||
// @Param scene body int false "场景编号"
|
||||
// @Param mobile body string false "手机号码"
|
||||
// @Param content body string false "发送内容"
|
||||
// @Param status body int false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param results body string false "短信结果"
|
||||
// @Param send_time body int false "发送时间"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/edit [post]
|
||||
func (hd *SystemLogSmsHandler) Edit(c *gin.Context) {
|
||||
var editReq SystemLogSmsEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndRespWithData(c,editReq.Id, SystemLogSmsService.Edit(editReq))
|
||||
}
|
||||
// @Summary 系统短信日志删除
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "id"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/del [post]
|
||||
func (hd *SystemLogSmsHandler) Del(c *gin.Context) {
|
||||
var delReq SystemLogSmsDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, SystemLogSmsService.Del(delReq.Id))
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Summary 系统短信日志导出
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param scene query int false "场景编号"
|
||||
// @Param mobile query string false "手机号码"
|
||||
// @Param content query string false "发送内容"
|
||||
// @Param status query int false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param results query string false "短信结果"
|
||||
// @Param send_time query int false "发送时间"
|
||||
// @Param create_timeStart query core.TsTime false "创建时间"
|
||||
// @Param create_timeEnd query core.TsTime false "创建时间"
|
||||
// @Param update_timeStart query core.TsTime false "更新时间"
|
||||
// @Param update_timeEnd query core.TsTime false "更新时间"
|
||||
// @Router /api/admin/system_log_sms/ExportFile [get]
|
||||
func (hd *SystemLogSmsHandler) ExportFile(c *gin.Context) {
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.ExportFile(listReq)
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "查询信息失败")
|
||||
return
|
||||
}
|
||||
f, err := excel.NormalDynamicExport(res, "Sheet1", "系统短信日志", nil)
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "导出失败")
|
||||
return
|
||||
}
|
||||
excel.DownLoadExcel("系统短信日志" + time.Now().Format("20060102-150405"), c.Writer, f)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志导入
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Router /api/admin/system_log_sms/ImportFile [post]
|
||||
func (hd *SystemLogSmsHandler) ImportFile(c *gin.Context) {
|
||||
file, _, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "文件不存在")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
importList := []SystemLogSmsResp{}
|
||||
err = excel.GetExcelData(file, &importList)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = SystemLogSmsService.ImportFile(importList)
|
||||
response.CheckAndResp(c, err)
|
||||
}
|
||||
63
server/admin/system_log_sms/system_log_sms_schema.go
Normal file
63
server/admin/system_log_sms/system_log_sms_schema.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
)
|
||||
|
||||
// SystemLogSmsListReq 系统短信日志列表参数
|
||||
type SystemLogSmsListReq struct {
|
||||
Scene *int `form:"scene"` // 场景编号
|
||||
Mobile *string `form:"mobile"` // 手机号码
|
||||
Content *string `form:"content"` // 发送内容
|
||||
Status *int `form:"status"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results *string `form:"results"` // 短信结果
|
||||
SendTime *int `form:"send_time"` // 发送时间
|
||||
CreateTimeStart *string `form:"create_timeStart"` // 开始创建时间
|
||||
CreateTimeEnd *string `form:"create_timeEnd"` // 结束创建时间
|
||||
UpdateTimeStart *string `form:"update_timeStart"` // 开始更新时间
|
||||
UpdateTimeEnd *string `form:"update_timeEnd"` // 结束更新时间
|
||||
}
|
||||
|
||||
// SystemLogSmsAddReq 系统短信日志新增参数
|
||||
type SystemLogSmsAddReq struct {
|
||||
Scene interface{} `mapstructure:"scene" json:"scene" form:"scene"` // 场景编号
|
||||
Mobile interface{} `mapstructure:"mobile" json:"mobile" form:"mobile"` // 手机号码
|
||||
Content interface{} `mapstructure:"content" json:"content" form:"content"` // 发送内容
|
||||
Status interface{} `mapstructure:"status" json:"status" form:"status"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results interface{} `mapstructure:"results" json:"results" form:"results"` // 短信结果
|
||||
SendTime interface{} `mapstructure:"send_time" json:"send_time" form:"send_time"` // 发送时间
|
||||
}
|
||||
|
||||
// SystemLogSmsEditReq 系统短信日志编辑参数
|
||||
type SystemLogSmsEditReq struct {
|
||||
Id int `mapstructure:"id" json:"id" form:"id"` // id
|
||||
Scene interface{} `mapstructure:"scene" json:"scene" form:"scene"` // 场景编号
|
||||
Mobile interface{} `mapstructure:"mobile" json:"mobile" form:"mobile"` // 手机号码
|
||||
Content interface{} `mapstructure:"content" json:"content" form:"content"` // 发送内容
|
||||
Status interface{} `mapstructure:"status" json:"status" form:"status"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results interface{} `mapstructure:"results" json:"results" form:"results"` // 短信结果
|
||||
SendTime interface{} `mapstructure:"send_time" json:"send_time" form:"send_time"` // 发送时间
|
||||
}
|
||||
|
||||
// SystemLogSmsDetailReq 系统短信日志详情参数
|
||||
type SystemLogSmsDetailReq struct {
|
||||
Id int `form:"id"` // id
|
||||
}
|
||||
|
||||
// SystemLogSmsDelReq 系统短信日志删除参数
|
||||
type SystemLogSmsDelReq struct {
|
||||
Id int `form:"id"` // id
|
||||
}
|
||||
|
||||
// SystemLogSmsResp 系统短信日志返回信息
|
||||
type SystemLogSmsResp struct {
|
||||
Id int `mapstructure:"id" json:"id"` // id
|
||||
Scene int `mapstructure:"scene" json:"scene" excel:"name:场景编号;"` // 场景编号
|
||||
Mobile string `mapstructure:"mobile" json:"mobile" excel:"name:手机号码;"` // 手机号码
|
||||
Content string `mapstructure:"content" json:"content" excel:"name:发送内容;"` // 发送内容
|
||||
Status int `mapstructure:"status" json:"status" excel:"name:发送状态"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results string `mapstructure:"results" json:"results" excel:"name:短信结果;"` // 短信结果
|
||||
SendTime int `mapstructure:"send_time" json:"send_time" excel:"name:发送时间;"` // 发送时间
|
||||
CreateTime core.TsTime `mapstructure:"create_time" json:"create_time" excel:"name:创建时间;"` // 创建时间
|
||||
UpdateTime core.TsTime `mapstructure:"update_time" json:"update_time" excel:"name:更新时间;"` // 更新时间
|
||||
}
|
||||
229
server/admin/system_log_sms/system_log_sms_service.go
Normal file
229
server/admin/system_log_sms/system_log_sms_service.go
Normal file
@@ -0,0 +1,229 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
"x_admin/util"
|
||||
|
||||
"github.com/duke-git/lancet/v2/convertor"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var SystemLogSmsService = NewSystemLogSmsService()
|
||||
var cacheUtil = util.CacheUtil{
|
||||
Name: SystemLogSmsService.Name,
|
||||
}
|
||||
|
||||
// NewSystemLogSmsService 初始化
|
||||
func NewSystemLogSmsService() *systemLogSmsService {
|
||||
return &systemLogSmsService{
|
||||
db: core.GetDB(),
|
||||
Name: "systemLogSms",
|
||||
}
|
||||
}
|
||||
|
||||
// systemLogSmsService 系统短信日志服务实现类
|
||||
type systemLogSmsService struct {
|
||||
db *gorm.DB
|
||||
Name string
|
||||
}
|
||||
|
||||
// List 系统短信日志列表
|
||||
func (service systemLogSmsService) GetModel(listReq SystemLogSmsListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.SystemLogSms{})
|
||||
if listReq.Scene != nil {
|
||||
dbModel = dbModel.Where("scene = ?", *listReq.Scene)
|
||||
}
|
||||
if listReq.Mobile != nil {
|
||||
dbModel = dbModel.Where("mobile like ?", "%"+*listReq.Mobile+"%")
|
||||
}
|
||||
if listReq.Content != nil {
|
||||
dbModel = dbModel.Where("content = ?", *listReq.Content)
|
||||
}
|
||||
if listReq.Status != nil {
|
||||
dbModel = dbModel.Where("status = ?", *listReq.Status)
|
||||
}
|
||||
if listReq.Results != nil {
|
||||
dbModel = dbModel.Where("results = ?", *listReq.Results)
|
||||
}
|
||||
if listReq.SendTime != nil {
|
||||
dbModel = dbModel.Where("send_time = ?", *listReq.SendTime)
|
||||
}
|
||||
if listReq.CreateTimeStart != nil {
|
||||
dbModel = dbModel.Where("create_time >= ?", *listReq.CreateTimeStart)
|
||||
}
|
||||
if listReq.CreateTimeEnd != nil {
|
||||
dbModel = dbModel.Where("create_time <= ?", *listReq.CreateTimeEnd)
|
||||
}
|
||||
if listReq.UpdateTimeStart != nil {
|
||||
dbModel = dbModel.Where("update_time >= ?", *listReq.UpdateTimeStart)
|
||||
}
|
||||
if listReq.UpdateTimeEnd != nil {
|
||||
dbModel = dbModel.Where("update_time <= ?", *listReq.UpdateTimeEnd)
|
||||
}
|
||||
return dbModel
|
||||
}
|
||||
|
||||
// List 系统短信日志列表
|
||||
func (service systemLogSmsService) List(page request.PageReq, listReq SystemLogSmsListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
dbModel := service.GetModel(listReq)
|
||||
// 总数
|
||||
var count int64
|
||||
err := dbModel.Count(&count).Error
|
||||
if e = response.CheckErr(err, "失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var modelList []model.SystemLogSms
|
||||
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []SystemLogSmsResp{}
|
||||
response.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
PageSize: page.PageSize,
|
||||
Count: count,
|
||||
Lists: result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListAll 系统短信日志列表
|
||||
func (service systemLogSmsService) ListAll(listReq SystemLogSmsListReq) (res []SystemLogSmsResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.SystemLogSms
|
||||
|
||||
err := dbModel.Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询全部失败"); e != nil {
|
||||
return
|
||||
}
|
||||
response.Copy(&res, modelList)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Detail 系统短信日志详情
|
||||
func (service systemLogSmsService) Detail(Id int) (res SystemLogSmsResp, e error) {
|
||||
var obj = model.SystemLogSms{}
|
||||
err := cacheUtil.GetCache(Id, &obj)
|
||||
if err != nil {
|
||||
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "获取详情失败"); e != nil {
|
||||
return
|
||||
}
|
||||
response.Copy(&res, obj)
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Add 系统短信日志新增
|
||||
func (service systemLogSmsService) Add(addReq SystemLogSmsAddReq) (createId int, e error) {
|
||||
var obj model.SystemLogSms
|
||||
|
||||
// 无法自动转换不同类型
|
||||
// response.Copy(&obj, addReq)
|
||||
|
||||
// addInfo, err := convertor.StructToMap(addReq)
|
||||
// if err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
// // map弱类型转换到结构体
|
||||
// err = mapstructure.WeakDecode(addInfo, &obj)
|
||||
err := util.ConvertUtil.StructToStruct(&addReq, &obj)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
err = service.db.Create(&obj).Error
|
||||
e = response.CheckMysqlErr(err)
|
||||
if e != nil {
|
||||
return 0, e
|
||||
}
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
createId = obj.Id
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 系统短信日志编辑
|
||||
func (service systemLogSmsService) Edit(editReq SystemLogSmsEditReq) (e error) {
|
||||
var obj model.SystemLogSms
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
// response.Copy(&obj, editReq)
|
||||
//
|
||||
editInfo, err := convertor.StructToMap(editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = service.db.Model(&obj).Updates(editInfo).Error
|
||||
if e = response.CheckErr(err, "编辑失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
service.Detail(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Del 系统短信日志删除
|
||||
func (service systemLogSmsService) Del(Id int) (e error) {
|
||||
var obj model.SystemLogSms
|
||||
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询数据失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
err = service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// ExportFile 系统短信日志导出
|
||||
func (service systemLogSmsService) ExportFile(listReq SystemLogSmsListReq) (res []SystemLogSmsResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
// 数据
|
||||
var modelList []model.SystemLogSms
|
||||
err := dbModel.Order("id asc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []SystemLogSmsResp{}
|
||||
response.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service systemLogSmsService) ImportFile(importReq []SystemLogSmsResp) (e error) {
|
||||
var importData []model.SystemLogSms
|
||||
response.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return e
|
||||
}
|
||||
56
server/admin/system_log_sms_route.go
Normal file
56
server/admin/system_log_sms_route.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/system_log_sms"
|
||||
)
|
||||
|
||||
/**
|
||||
集成
|
||||
1. 导入
|
||||
- 请先提交git避免文件覆盖!!!
|
||||
- 下载并解压压缩包后,直接复制server、admin文件夹到项目根目录即可
|
||||
|
||||
2. 注册路由
|
||||
请在 admin/entry.go 文件引入SystemLogSmsRoute注册路由
|
||||
|
||||
3. 后台手动添加菜单和按钮
|
||||
admin:system_log_sms:add
|
||||
admin:system_log_sms:edit
|
||||
admin:system_log_sms:del
|
||||
admin:system_log_sms:list
|
||||
admin:system_log_sms:listAll
|
||||
admin:system_log_sms:detail
|
||||
admin:system_log_sms:ExportFile
|
||||
admin:system_log_sms:ImportFile
|
||||
|
||||
// 列表-先添加菜单获取菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '系统短信日志', 'system/log/sms/index', 'system_log_sms/index', 0, 1, 0, now(), now());
|
||||
按钮-替换pid参数为菜单id
|
||||
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志添加','admin:system_log_sms:add', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志编辑','admin:system_log_sms:edit', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志删除','admin:system_log_sms:del', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志列表','admin:system_log_sms:list', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志全部列表','admin:system_log_sms:listAll', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志详情','admin:system_log_sms:detail', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志导出excel','admin:system_log_sms:ExportFile', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志导入excel','admin:system_log_sms:ImportFile', 0, 1, 0, now(), now());
|
||||
*/
|
||||
|
||||
|
||||
// SystemLogSmsRoute(rg)
|
||||
func SystemLogSmsRoute(rg *gin.RouterGroup) {
|
||||
handle := system_log_sms.SystemLogSmsHandler{}
|
||||
|
||||
r := rg.Group("/", middleware.TokenAuth())
|
||||
r.GET("/system_log_sms/list", handle.List)
|
||||
r.GET("/system_log_sms/listAll", handle.ListAll)
|
||||
r.GET("/system_log_sms/detail", handle.Detail)
|
||||
r.POST("/system_log_sms/add",middleware.RecordLog("系统短信日志新增"), handle.Add)
|
||||
r.POST("/system_log_sms/edit",middleware.RecordLog("系统短信日志编辑"), handle.Edit)
|
||||
r.POST("/system_log_sms/del", middleware.RecordLog("系统短信日志删除"), handle.Del)
|
||||
r.GET("/system_log_sms/ExportFile", middleware.RecordLog("系统短信日志导出"), handle.ExportFile)
|
||||
r.POST("/system_log_sms/ImportFile",middleware.RecordLog("系统短信日志导入"), handle.ImportFile)
|
||||
}
|
||||
@@ -47,6 +47,7 @@ require (
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/duke-git/lancet/v2 v2.3.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
|
||||
@@ -25,6 +25,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/duke-git/lancet/v2 v2.3.2 h1:Cv+uNkx5yGqDSvGc5Vu9eiiZobsPIf0Ng7NGy5hEdow=
|
||||
github.com/duke-git/lancet/v2 v2.3.2/go.mod h1:zGa2R4xswg6EG9I6WnyubDbFO/+A/RROxIbXcwryTsc=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
|
||||
18
server/model/system_log_sms.go
Normal file
18
server/model/system_log_sms.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
)
|
||||
|
||||
// SystemLogSms 系统短信日志实体
|
||||
type SystemLogSms struct {
|
||||
Id int `json:"id" gorm:"primarykey;" excel:"name:id;"` // id
|
||||
Scene int `json:"scene" excel:"name:场景编号;"` // 场景编号
|
||||
Mobile string `json:"mobile" excel:"name:手机号码;"` // 手机号码
|
||||
Content string `json:"content" excel:"name:发送内容;"` // 发送内容
|
||||
Status int `json:"status" excel:"name:发送状态:[0=发送中, 1=发送成功, 2=发送失败];"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results string `json:"results" excel:"name:短信结果;"` // 短信结果
|
||||
SendTime int `mapstructure:"send_time" excel:"name:发送时间;"` // 发送时间
|
||||
CreateTime core.TsTime `json:"CreateTime" gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间
|
||||
UpdateTime core.TsTime `json:"UpdateTime" gorm:"autoUpdateTime;comment:'更新时间'" excel:"name:更新时间;"` // 更新时间
|
||||
}
|
||||
@@ -3,8 +3,9 @@ package util
|
||||
import (
|
||||
"x_admin/core"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/duke-git/lancet/v2/convertor"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
var ConvertUtil = convertUtil{}
|
||||
@@ -13,7 +14,7 @@ var ConvertUtil = convertUtil{}
|
||||
type convertUtil struct{}
|
||||
|
||||
// StructsToMaps 将结构体转换成Map列表
|
||||
func (cu convertUtil) StructsToMaps(obj interface{}) (data []map[string]interface{}) {
|
||||
func (c convertUtil) StructsToMaps(obj interface{}) (data []map[string]interface{}) {
|
||||
var objList []interface{}
|
||||
err := copier.Copy(&objList, obj)
|
||||
if err != nil {
|
||||
@@ -21,7 +22,35 @@ func (cu convertUtil) StructsToMaps(obj interface{}) (data []map[string]interfac
|
||||
return nil
|
||||
}
|
||||
for _, v := range objList {
|
||||
data = append(data, structs.Map(v))
|
||||
data = append(data, c.StructToMap(v))
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// StructToMap 结构体转换成map
|
||||
func (c convertUtil) StructToMap(from interface{}) map[string]interface{} {
|
||||
// var y = map[string]interface{}{}
|
||||
// mapstructure.Decode(from, &y) //mapstructure
|
||||
|
||||
// copier.Copy(&m, from)
|
||||
m, _ := convertor.StructToMap(from) // 需要tag:json
|
||||
|
||||
// if e != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
return m
|
||||
}
|
||||
|
||||
// MapToStruct 将map弱类型转换成结构体
|
||||
func (c convertUtil) MapToStruct(from map[string]interface{}, to interface{}) (err error) {
|
||||
err = mapstructure.WeakDecode(from, to) // 需要tag:mapstructure
|
||||
return err
|
||||
}
|
||||
|
||||
// StructToStruct 将结构体from弱类型转换成结构体to,需要tag:json,mapstructure
|
||||
func (c convertUtil) StructToStruct(from interface{}, to interface{}) (err error) {
|
||||
m := c.StructToMap(from)
|
||||
err = c.MapToStruct(m, to)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ func (su stringUtil) ToCamelCase(s string) string {
|
||||
for i := 1; i < len(words); i++ {
|
||||
words[i] = c.String(words[i])
|
||||
}
|
||||
// return s
|
||||
return strings.Join(words, "")
|
||||
}
|
||||
|
||||
|
||||
92
x_admin_app/api/system_log_sms.ts
Normal file
92
x_admin_app/api/system_log_sms.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { request } from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
export type type_system_log_sms = {
|
||||
id?: number;
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
create_time?: string;
|
||||
update_time?: string;
|
||||
}
|
||||
// 查询
|
||||
export type type_system_log_sms_query = {
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
create_timeStart?: string;
|
||||
create_timeEnd?: string;
|
||||
update_timeStart?: string;
|
||||
update_timeEnd?: string;
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_system_log_sms_edit = {
|
||||
id?: number;
|
||||
scene?: number;
|
||||
mobile?: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
results?: string;
|
||||
send_time?: number;
|
||||
}
|
||||
|
||||
|
||||
// 系统短信日志列表
|
||||
export function system_log_sms_list(params?: type_system_log_sms_query) {
|
||||
return request<Pages<type_system_log_sms>>({
|
||||
url: '/system_log_sms/list',
|
||||
method: 'GET',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
// 系统短信日志列表-所有
|
||||
export function system_log_sms_list_all(params?: type_system_log_sms_query) {
|
||||
return request<type_system_log_sms[]>({
|
||||
url: '/system_log_sms/listAll',
|
||||
method: 'GET',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
// 系统短信日志详情
|
||||
export function system_log_sms_detail(id: number | string) {
|
||||
return request<type_system_log_sms>({
|
||||
url: '/system_log_sms/detail',
|
||||
method: 'GET',
|
||||
data: { id }
|
||||
})
|
||||
}
|
||||
|
||||
// 系统短信日志新增
|
||||
export function system_log_sms_add(data: type_system_log_sms_edit) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/add',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 系统短信日志编辑
|
||||
export function system_log_sms_edit(data: type_system_log_sms_edit) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/edit',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 系统短信日志删除
|
||||
export function system_log_sms_delete(id: number | string) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/del',
|
||||
method: "POST",
|
||||
data:{
|
||||
id
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"navigationBarTitleText": "项目监控",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -73,6 +73,34 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索监控-客户端信息"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/system/log/sms/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志详情",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑系统短信日志"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索系统短信日志"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,39 +34,43 @@
|
||||
|
||||
|
||||
let baseList = [{
|
||||
icon: "/static/index/equipment.png",
|
||||
path: "/pages/monitor_project/index",
|
||||
title: "项目监控",
|
||||
},
|
||||
{
|
||||
icon: "/static/index/equipment.png",
|
||||
path: "/pages/monitor_client/index",
|
||||
title: "项目用户",
|
||||
},
|
||||
icon: "/static/index/equipment.png",
|
||||
path: "/pages/monitor_project/index",
|
||||
title: "项目监控",
|
||||
},
|
||||
{
|
||||
icon: "/static/index/equipment.png",
|
||||
path: "/pages/monitor_client/index",
|
||||
title: "项目用户",
|
||||
}, {
|
||||
icon: "/static/index/equipment.png",
|
||||
path: "/pages/system/log/sms/index",
|
||||
title: "Log",
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
icon: "scan",
|
||||
// path: "/pages/equipment/equipment",
|
||||
title: "扫码维护",
|
||||
fn: function() {
|
||||
// console.log('this', this);
|
||||
scanCode().then((path) => {
|
||||
// toPath(path);
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
var query = queryToObj(path);
|
||||
if (!query.state) {
|
||||
toast("请扫描设备二维码");
|
||||
return;
|
||||
}
|
||||
toPath("/pages/equipment/details", {
|
||||
number: query.state,
|
||||
});
|
||||
{
|
||||
icon: "scan",
|
||||
// path: "/pages/equipment/equipment",
|
||||
title: "扫码维护",
|
||||
fn: function () {
|
||||
// console.log('this', this);
|
||||
scanCode().then((path) => {
|
||||
// toPath(path);
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
var query = queryToObj(path);
|
||||
if (!query.state) {
|
||||
toast("请扫描设备二维码");
|
||||
return;
|
||||
}
|
||||
toPath("/pages/equipment/details", {
|
||||
number: query.state,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
];
|
||||
|
||||
107
x_admin_app/pages/system/log/sms/details.vue
Normal file
107
x_admin_app/pages/system/log/sms/details.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" :model="form">
|
||||
<uv-form-item label="场景编号" prop="scene" borderBottom>
|
||||
{{form.scene}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="mobile" borderBottom>
|
||||
{{form.mobile}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="content" borderBottom>
|
||||
{{form.content}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status" borderBottom>
|
||||
<dict-value :options="dictData.flow_apply_status" :value="row.status" />
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="results" borderBottom>
|
||||
{{form.results}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="send_time" borderBottom>
|
||||
{{form.send_time}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="create_time" borderBottom>
|
||||
{{form.create_time}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="更新时间" prop="update_time" borderBottom>
|
||||
{{form.update_time}}
|
||||
</uv-form-item>
|
||||
</uv-form>
|
||||
<uv-button
|
||||
v-if="$perms('admin:system_log_sms:edit')"
|
||||
type="primary"
|
||||
text="编辑"
|
||||
customStyle="margin: 40rpx 0"
|
||||
@click="edit"
|
||||
></uv-button>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {ref} from "vue";
|
||||
import { onLoad,onShow } from "@dcloudio/uni-app";
|
||||
import { useDictData,useListAllData } from "@/hooks/useDictOptions";
|
||||
import { system_log_sms_detail } from "@/api/system_log_sms";
|
||||
|
||||
|
||||
import {
|
||||
toast,
|
||||
alert,
|
||||
toPath
|
||||
} from "@/utils/utils";
|
||||
|
||||
let form = ref({
|
||||
id: "",
|
||||
scene: "",
|
||||
mobile: "",
|
||||
content: "",
|
||||
status: "",
|
||||
results: "",
|
||||
send_time: "",
|
||||
create_time: "",
|
||||
update_time: "",
|
||||
});
|
||||
const { dictData } = useDictData<
|
||||
{
|
||||
flow_apply_status: any[]
|
||||
}>(['flow_apply_status'])
|
||||
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
getDetails(e.id);
|
||||
});
|
||||
onShow((e) => {
|
||||
if (form.value?.id) {
|
||||
getDetails(form.value.id);
|
||||
}
|
||||
});
|
||||
onPullDownRefresh(() => {
|
||||
getDetails(form.value.id);
|
||||
});
|
||||
function getDetails(id: number | string) {
|
||||
system_log_sms_detail(id).then((res) => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.code == 200) {
|
||||
if (res?.data) {
|
||||
form.value = res?.data
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.stopPullDownRefresh();
|
||||
toast(err.message||"网络错误");
|
||||
});
|
||||
}
|
||||
|
||||
function edit() {
|
||||
toPath("/pages/system/log/sms/edit", { id: form.value.id });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
169
x_admin_app/pages/system/log/sms/edit.vue
Normal file
169
x_admin_app/pages/system/log/sms/edit.vue
Normal file
@@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" :model="form" :rules="formRules" ref="formRef">
|
||||
<uv-form-item label="id" prop="id" borderBottom>
|
||||
<uv-number-box v-model="form.id" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="场景编号" prop="scene" borderBottom>
|
||||
<uv-number-box v-model="form.scene" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="mobile" borderBottom>
|
||||
<uv-input v-model="form.mobile" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status" borderBottom>
|
||||
<x-picker v-model="form.status" valueKey="value" labelKey="name" :columns="dictData.flow_apply_status"></x-picker>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="results" borderBottom>
|
||||
<uv-textarea v-model="form.results" border="surround"></uv-textarea>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="send_time" borderBottom>
|
||||
<uv-number-box v-model="form.send_time" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
</uv-form-item>
|
||||
|
||||
<uv-button type="primary" text="提交" customStyle="margin: 40rpx 0"
|
||||
@click="submit"></uv-button>
|
||||
</uv-form>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
system_log_sms_detail,
|
||||
system_log_sms_edit,
|
||||
system_log_sms_add
|
||||
} from "@/api/system_log_sms";
|
||||
import type { type_system_log_sms_edit } from "@/api/system_log_sms";
|
||||
|
||||
import {
|
||||
toast,
|
||||
alert
|
||||
} from "@/utils/utils";
|
||||
import {
|
||||
useDictData,useListAllData
|
||||
} from "@/hooks/useDictOptions";
|
||||
import type { type_dict } from '@/hooks/useDictOptions'
|
||||
|
||||
let formRef = ref();
|
||||
let form = ref<type_system_log_sms_edit>({
|
||||
id: '',
|
||||
scene: 0,
|
||||
mobile: '',
|
||||
content: '',
|
||||
status: '',
|
||||
results: '',
|
||||
send_time: 0,
|
||||
});
|
||||
const formRules = {
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
scene: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入场景编号',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号码',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入发送内容',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
results: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入短信结果',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
send_time: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入发送时间',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
}
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
if (e.id) {
|
||||
getDetails(e.id);
|
||||
}
|
||||
});
|
||||
const { dictData } = useDictData<{
|
||||
flow_apply_status: type_dict[]
|
||||
}>(['flow_apply_status'])
|
||||
|
||||
function getDetails(id) {
|
||||
system_log_sms_detail(id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res?.data) {
|
||||
form.value = res?.data
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toast(err.message||"网络错误");
|
||||
});
|
||||
}
|
||||
|
||||
function submit() {
|
||||
console.log("submit", form.value);
|
||||
formRef.value.validate().then(() => {
|
||||
if (form.value.id) {
|
||||
system_log_sms_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
getDetails(form.value?.id);
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
system_log_sms_add(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("添加成功");
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
132
x_admin_app/pages/system/log/sms/index.vue
Normal file
132
x_admin_app/pages/system/log/sms/index.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<view>
|
||||
<!--
|
||||
<uv-sticky :customNavHeight="0" bgColor="#fff">
|
||||
<uv-status-bar></uv-status-bar>
|
||||
<uv-navbar
|
||||
leftText=""
|
||||
:safeAreaInsetTop="false"
|
||||
:fixed="false"
|
||||
title="系统短信日志"
|
||||
autoBack
|
||||
>
|
||||
<template v-slot:right>
|
||||
<uv-icon v-if="!fromSearch" name="search" size="24" @click="moreSearch"></uv-icon>
|
||||
</template>
|
||||
</uv-navbar>
|
||||
|
||||
</uv-sticky>
|
||||
-->
|
||||
<uv-list>
|
||||
<uv-list-item
|
||||
v-for="item of pager.lists"
|
||||
:key="item.id"
|
||||
clickable
|
||||
show-arrow
|
||||
:title="item.id"
|
||||
:right-text="item.id"
|
||||
@click="toDetails(item)"
|
||||
></uv-list-item>
|
||||
</uv-list>
|
||||
<wd-fab v-model:active="activeFab" :draggable="true">
|
||||
<wd-button v-if="!fromSearch" custom-class="fab-button" type="primary" round @click="moreSearch" >
|
||||
<wd-icon name="search" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
<wd-button v-if="$perms('admin:system_log_sms:add')" custom-class="fab-button" type="primary" round @click="add">
|
||||
<wd-icon name="add" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
</wd-fab>
|
||||
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
|
||||
|
||||
<uv-empty v-if="pager.loading =='nomore'&&pager.lists.length == 0" marginTop="150" mode="data"></uv-empty>
|
||||
<uv-loading-page
|
||||
:loading="pager.pageNo == 1 && pager.loading == 'loading'"
|
||||
loading-text="加载中..."
|
||||
font-size="24rpx"
|
||||
></uv-loading-page>
|
||||
<uv-load-more
|
||||
v-if="pager.lists.length > 0"
|
||||
:status="pager.loading"
|
||||
:loading-text="pager.loadingText"
|
||||
:loadmore-text="pager.loadmoreText"
|
||||
:nomore-text="pager.nomoreText"
|
||||
@loadmore="NextPage"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from "vue";
|
||||
import {
|
||||
onLoad,
|
||||
onPullDownRefresh,
|
||||
onReachBottom,
|
||||
onPageScroll,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { system_log_sms_list } from "@/api/system_log_sms";
|
||||
import type { type_system_log_sms,type_system_log_sms_query } from "@/api/system_log_sms";
|
||||
|
||||
import { usePaging } from "@/hooks/usePaging";
|
||||
import { toPath } from "@/utils/utils";
|
||||
const queryParams = reactive<type_system_log_sms_query>({
|
||||
scene: '',
|
||||
mobile: '',
|
||||
content: '',
|
||||
status: '',
|
||||
results: '',
|
||||
send_time: '',
|
||||
create_timeStart: '',
|
||||
create_timeEnd: '',
|
||||
update_timeStart: '',
|
||||
update_timeEnd: '',
|
||||
});
|
||||
let activeFab = ref(false);
|
||||
let fromSearch=ref(false);
|
||||
onLoad((e) => {
|
||||
console.log("system_log_sms onLoad", e);
|
||||
if (e) {
|
||||
for (const key in e) {
|
||||
if (Object.hasOwnProperty.call(e, key)) {
|
||||
fromSearch.value = true;
|
||||
queryParams[key] = e[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
getLists();
|
||||
});
|
||||
const { pager, getLists, NextPage, resetPage, resetParams } = usePaging<type_system_log_sms>({
|
||||
fetchFun: system_log_sms_list,
|
||||
params: queryParams,
|
||||
});
|
||||
let scrollTop = ref(0);
|
||||
onPageScroll((e) => {
|
||||
scrollTop.value = e.scrollTop;
|
||||
});
|
||||
onPullDownRefresh(() => {
|
||||
resetPage();
|
||||
});
|
||||
onReachBottom(() => {
|
||||
NextPage();
|
||||
});
|
||||
|
||||
function toDetails(item) {
|
||||
toPath("/pages/system/log/sms/details", { id: item.id });
|
||||
}
|
||||
function moreSearch() {
|
||||
toPath("/pages/system/log/sms/search");
|
||||
}
|
||||
function add() {
|
||||
toPath("/pages/system/log/sms/edit");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.fab-button) {
|
||||
min-width: auto !important;
|
||||
box-sizing: border-box;
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
border-radius: 40px !important;
|
||||
margin: 8rpx;
|
||||
}
|
||||
</style>
|
||||
32
x_admin_app/pages/system/log/sms/pages.json
Normal file
32
x_admin_app/pages/system/log/sms/pages.json
Normal file
@@ -0,0 +1,32 @@
|
||||
// 请将pages里的数据手动合并到根目录下pages.json中
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/system/log/sms/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志详情",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑系统短信日志"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索系统短信日志"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
86
x_admin_app/pages/system/log/sms/search.vue
Normal file
86
x_admin_app/pages/system/log/sms/search.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form">
|
||||
<uv-form-item label="场景编号" prop="scene" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="mobile" borderBottom>
|
||||
<uv-input v-model="form.mobile"> </uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="status" borderBottom>
|
||||
<x-picker v-model="form.status" valueKey="value" labelKey="name" :columns="dictData.flow_apply_status"></x-picker>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="results" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="send_time" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="create_time" borderBottom>
|
||||
<x-date-range v-model:startTime="form.create_timeStart"
|
||||
v-model:endTime="form.create_timeEnd"></x-date-range>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="更新时间" prop="update_time" borderBottom>
|
||||
<x-date-range v-model:startTime="form.update_timeStart"
|
||||
v-model:endTime="form.update_timeEnd"></x-date-range>
|
||||
</uv-form-item>
|
||||
|
||||
<uv-button type="primary" text="搜索" customStyle="margin-top: 20rpx" @click="submit"></uv-button>
|
||||
</uv-form>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
computed
|
||||
} from "vue";
|
||||
import {
|
||||
toPath,
|
||||
toast,
|
||||
clearObjEmpty
|
||||
} from "@/utils/utils";
|
||||
import {
|
||||
useDictData,useListAllData
|
||||
} from "@/hooks/useDictOptions";
|
||||
import xDateRange from "@/components/x-date-range/x-date-range.vue";
|
||||
import type {type_system_log_sms_query} from "@/api/monitor_project";
|
||||
const { dictData } = useDictData<{
|
||||
flow_apply_status: any[]
|
||||
}>(['flow_apply_status'])
|
||||
|
||||
let form = ref<type_system_log_sms_query>({
|
||||
scene: null,
|
||||
mobile: null,
|
||||
content: null,
|
||||
status: null,
|
||||
results: null,
|
||||
send_time: null,
|
||||
create_timeStart: null,
|
||||
create_timeEnd: null,
|
||||
update_timeStart: null,
|
||||
update_timeEnd: null,
|
||||
});
|
||||
|
||||
function submit() {
|
||||
console.log("submit", form.value);
|
||||
|
||||
const search = clearObjEmpty(form.value);
|
||||
|
||||
if (Object.keys(search).length === 0) {
|
||||
return toast("请输入查询条件");
|
||||
}
|
||||
|
||||
toPath("/pages/system/log/sms/index", search);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user