mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-04 23:40:24 +08:00
初步引入regex
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
// Regex stores user's config of splitting docx file
|
||||
@@ -73,10 +75,16 @@ func (u *UserDatabase) GetUserRegex(id int) (*Regex, error) {
|
||||
if !user.IsFileManager() {
|
||||
return nil, ErrInvalidRole
|
||||
}
|
||||
reg := newRegex()
|
||||
u.mu.RLock()
|
||||
_ = u.db.Find(UserTableRegex, ®, "WHERE ID="+strconv.Itoa(id))
|
||||
reg, _ := sql.Find[Regex](&u.db, UserTableRegex, "WHERE ID="+strconv.Itoa(id))
|
||||
u.mu.RUnlock()
|
||||
reg.ID = *user.ID
|
||||
rf := reflect.ValueOf(reg)
|
||||
defaultrf := reflect.ValueOf(newRegex())
|
||||
for i := 0; i < rf.NumField(); i++ {
|
||||
if rf.Field(i).IsZero() {
|
||||
rf.Field(i).Set(defaultrf.Field(i))
|
||||
}
|
||||
}
|
||||
return ®, nil
|
||||
}
|
||||
|
||||
87
frontend/vben/src/views/dashboard/regex/data.ts
Normal file
87
frontend/vben/src/views/dashboard/regex/data.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { FormSchema } from '/@/components/Form'
|
||||
const colProps = {
|
||||
span: 8,
|
||||
}
|
||||
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'title',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '标题',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'class',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'opencl',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'date',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'time',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'rate',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'major',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'sub',
|
||||
component: 'Input',
|
||||
colProps,
|
||||
label: '客户',
|
||||
helpMessage: '目标的服务对象',
|
||||
componentProps: {
|
||||
placeholder: '请描述你服务的客户,内部客户直接 @姓名/工号',
|
||||
},
|
||||
},
|
||||
]
|
||||
69
frontend/vben/src/views/dashboard/regex/index.vue
Normal file
69
frontend/vben/src/views/dashboard/regex/index.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<PageWrapper
|
||||
title="基础表单"
|
||||
contentBackground
|
||||
content=" 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。"
|
||||
contentClass="p-4"
|
||||
>
|
||||
<BasicForm @register="register" />
|
||||
</PageWrapper>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { BasicForm, useForm } from '/@/components/Form'
|
||||
import { defineComponent } from 'vue'
|
||||
import { schemas } from './data'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { PageWrapper } from '/@/components/Page'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FormBasicPage',
|
||||
components: { BasicForm, PageWrapper },
|
||||
setup() {
|
||||
const { createMessage } = useMessage()
|
||||
const [register, { validate, setProps }] = useForm({
|
||||
labelCol: {
|
||||
span: 8,
|
||||
},
|
||||
wrapperCol: {
|
||||
span: 15,
|
||||
},
|
||||
schemas: schemas,
|
||||
actionColOptions: {
|
||||
offset: 8,
|
||||
span: 23,
|
||||
},
|
||||
submitButtonOptions: {
|
||||
text: '提交',
|
||||
},
|
||||
submitFunc: customSubmitFunc,
|
||||
})
|
||||
|
||||
async function customSubmitFunc() {
|
||||
try {
|
||||
await validate()
|
||||
setProps({
|
||||
submitButtonOptions: {
|
||||
loading: true,
|
||||
},
|
||||
})
|
||||
setTimeout(() => {
|
||||
setProps({
|
||||
submitButtonOptions: {
|
||||
loading: false,
|
||||
},
|
||||
})
|
||||
createMessage.success('提交成功!')
|
||||
}, 2000)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
return { register }
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.form-wrap {
|
||||
padding: 24px;
|
||||
background-color: @component-background;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user