Pre Merge pull request !485 from panjiabao/dev

pull/485/MERGE
panjiabao 2025-09-10 00:37:13 +00:00 committed by Gitee
commit 230062cd06
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 725 additions and 0 deletions

View File

@ -0,0 +1,45 @@
import request from '@/config/axios'
export interface CodingRulesDetailsVO {
id: string
ruleId: string
orderNum: number
type: string
value: string
len: number
initial: number
stepSize: number
fillKey: string
remark: string
deletedTime: Date
}
// 查询编码规则明细列表
export const getCodingRulesDetailsPage = async (params) => {
return await request.get({ url: '/system/coding-rules/getDetails', params })
}
// 查询编码规则明细详情
export const getCodingRulesDetails = async (id: number) => {
return await request.get({ url: '/system/coding-rules/getDetailInfo?id=' + id })
}
// 新增编码规则明细
export const createCodingRulesDetails = async (data: CodingRulesDetailsVO) => {
return await request.post({ url: '/system/coding-rules/insertDetails', data })
}
// 修改编码规则明细
export const updateCodingRulesDetails = async (data: CodingRulesDetailsVO) => {
return await request.put({ url: '/system/coding-rules/updateDetails', data })
}
// 删除编码规则明细
export const deleteCodingRulesDetails = async (id: number) => {
return await request.delete({ url: '/system/coding-rules/deleteDetails?id=' + id })
}
// 导出编码规则明细 Excel
export const exportCodingRulesDetailsApi = async (params) => {
return await request.download({ url: '/system/coding-rules-details/export-excel', params })
}

View File

@ -0,0 +1,44 @@
import request from '@/config/axios'
export interface CodingRulesVO {
id: string
code: string
name: string
remark: string
deletedTime: Date
}
// 查询编号规则表头列表
export const getCodingRulesPage = async (params) => {
return await request.get({ url: '/system/coding-rules/page', params })
}
// 查询编号规则表头详情
export const getCodingRules = async (id: number) => {
return await request.get({ url: '/system/coding-rules/get?id=' + id })
}
// 新增编号规则表头
export const createCodingRules = async (data: CodingRulesVO) => {
return await request.post({ url: '/system/coding-rules/create', data })
}
// 修改编号规则表头
export const updateCodingRules = async (data: CodingRulesVO) => {
return await request.put({ url: '/system/coding-rules/update', data })
}
// 删除编号规则表头
export const deleteCodingRules = async (id: number) => {
return await request.delete({ url: '/system/coding-rules/delete?id=' + id })
}
// 导出编号规则表头 Excel
export const exportCodingRulesApi = async (params) => {
return await request.download({ url: '/system/coding-rules/export-excel', params })
}
// 预览编号规则
export const previewCodingRulesApi = async (params) => {
return await request.get({ url: '/system/coding-rules/genCodingRules', params })
}

View File

@ -0,0 +1,65 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules" v-loading="formLoading" />
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as CodingRulesApi from '@/api/system/codingrules'
import { rules, allSchemas } from './codingRules.data'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
//
if (id) {
formLoading.value = true
try {
const data = await CodingRulesApi.getCodingRules(id)
formRef.value.setValues(data)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.getElFormRef().validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formRef.value.formModel as CodingRulesApi.CodingRulesVO
if (formType.value === 'create') {
await CodingRulesApi.createCodingRules(data)
message.success(t('common.createSuccess'))
} else {
await CodingRulesApi.updateCodingRules(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

View File

@ -0,0 +1,55 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const rules = reactive({
code: [required],
name: [required],
})
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
isForm: false,
isTable: false
},
{
label: '规则编码',
field: 'code',
isSearch: true,
},
{
label: '名称',
field: 'name',
isSearch: true,
},
{
label: '描述',
field: 'remark',
isSearch: true,
},
{
label: '创建时间',
field: 'createTime',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
width: 220
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)

View File

@ -0,0 +1,130 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules" v-loading="formLoading">
<template #orderNum="form">
<el-input
v-model="form.orderNum"
type="number"
placeholder="请设置序号"
clearable
/>
</template>
<template #value="form">
<el-input v-if="form.type !== '2'" :disabled="['3','4','5'].includes(form.type)" v-model="form.value" placeholder="请输入设置值" />
<el-select
v-else
v-model="form.value"
placeholder="请选择日期格式"
>
<el-option
v-for="dict in getDictOptions(DICT_TYPE.CODING_RULES_DATE_FORMAT)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</template>
<template #len="form">
<el-input
v-model="form.len"
type="number"
placeholder="请设置长度"
:disabled="form.type === '1' || form.type === '2'"
clearable
/>
</template>
<template #initial="form">
<el-input
v-model="form.initial"
type="number"
placeholder="请设置起始值"
:disabled="form.type === '1' || form.type === '2'"
clearable
/>
</template>
<template #stepSize="form">
<el-input
v-model="form.stepSize"
type="number"
placeholder="请设置步长"
:disabled="form.type === '1' || form.type === '2'"
clearable
/>
</template>
<template #fillKey="form">
<el-input
v-model="form.fillKey"
type="number"
placeholder="请设置补位符"
:disabled="form.type === '1' || form.type === '2'"
clearable
/>
</template>
</Form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as CodingRulesDetailsApi from '@/api/system/codingrules/details'
import { rules, allSchemas } from './codingRulesDetails.data'
import { DICT_TYPE, getDictOptions, getIntDictOptions } from '@/utils/dict'
const { t } = useI18n() //
const message = useMessage() //
const route = useRoute()
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
//
if (id) {
formLoading.value = true
try {
const data = await CodingRulesDetailsApi.getCodingRulesDetails(id)
formRef.value.setValues(data)
console.log(formRef.value);
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.getElFormRef().validate()
if (!valid) return
//
formLoading.value = true
try {
formRef.value.formModel.ruleId = route.query.id
const data = formRef.value.formModel as CodingRulesDetailsApi.CodingRulesDetailsVO
if (formType.value === 'create') {
await CodingRulesDetailsApi.createCodingRulesDetails(data)
message.success(t('common.createSuccess'))
} else {
await CodingRulesDetailsApi.updateCodingRulesDetails(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

View File

@ -0,0 +1,136 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const rules = reactive({
ruleId: [required],
orderNum: [required],
type: [required],
})
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
isForm: false,
isTable: false,
},
{
label: '编码规则头id',
field: 'ruleId',
isSearch: false,
isTable: false,
isForm: false
},
{
label: '序号',
field: 'orderNum',
isSearch: false,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '类型',
field: 'type',
isSearch: false,
dictType: DICT_TYPE.CODING_RULES_TYPE
},
{
label: '设置值',
field: 'value',
isSearch: false,
},
{
label: '长度',
field: 'len',
isSearch: false,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '起始值',
field: 'initial',
isSearch: false,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '步长',
field: 'stepSize',
isSearch: false,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '补位符',
field: 'fillKey',
isSearch: false,
},
{
label: '备注',
field: 'remark',
isSearch: false,
form: {
component: 'Input',
componentProps: {
type: 'textarea',
rows: 3
},
colProps: {
span: 24
}
}
},
{
label: '创建时间',
field: 'createTime',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
},
{
label: '删除时间',
field: 'deletedTime',
formatter: dateFormatter,
isSearch: false,
isForm: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
},
},
{
label: '操作',
field: 'action',
isForm: false
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)

View File

@ -0,0 +1,121 @@
<template>
<!-- 搜索工作栏 -->
<ContentWrap>
<!-- <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
新增等操作按钮
<template #actionMore>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:coding-rules-details:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</template>
</Search> -->
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:coding-rules-details:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="primary"
plain
@click="handlePreview()"
>
<Icon icon="ep:view" class="mr-5px" />预览编码规则
</el-button>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="allSchemas.tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
>
<template #action="{ row }">
<el-button
link
type="primary"
@click="openForm('update', row.id)"
v-hasPermi="['system:coding-rules-details:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
v-hasPermi="['system:coding-rules-details:delete']"
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<CodingRulesDetailsForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts" name="CodingRulesDetails">
import { allSchemas } from './codingRulesDetails.data'
import * as CodingRulesDetailsApi from '@/api/system/codingrules/details'
import CodingRulesDetailsForm from './CodingRulesDetailsForm.vue'
import * as CodingRulesApi from '@/api/system/codingrules'
import { ElMessage, ElMessageBox } from 'element-plus'
const route = useRoute()
// tableObject
// tableMethods
// https://doc.iocoder.cn/vue3/crud-schema/
const { tableObject, tableMethods } = useTable({
getListApi: async () => {
tableObject.params.id = route.query.id
const data = await CodingRulesDetailsApi.getCodingRulesDetailsPage(tableObject.params)
return { list: data }
},
delListApi: CodingRulesDetailsApi.deleteCodingRulesDetails //
})
//
const { getList, setSearchParams } = tableMethods
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = (id: number) => {
tableMethods.delList(id, false)
}
/** 预览编码规则 */
const handlePreview = async () => {
const params = {
code: route.query.code,
preview: true
}
const previewData = await CodingRulesApi.previewCodingRulesApi(params)
ElMessageBox.alert(
`<strong>${previewData}</strong>`,
'编码规则预览',
{
dangerouslyUseHTMLString: true,
}
)
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -0,0 +1,129 @@
<template>
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
<!-- 新增等操作按钮 -->
<template #actionMore>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:coding-rules:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</template>
</Search>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="allSchemas.tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
>
<template #action="{ row }">
<el-button
link
type="primary"
@click="handlePreview(row.code)"
v-hasPermi="['system:coding-rules:update']"
>
预览
</el-button>
<el-button
link
type="primary"
@click="handleSetting(row.id, row.code)"
v-hasPermi="['system:coding-rules:update']"
>
规则设置
</el-button>
<el-button
link
type="primary"
@click="openForm('update', row.id)"
v-hasPermi="['system:coding-rules:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
v-hasPermi="['system:coding-rules:delete']"
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<CodingRulesForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts" name="CodingRules">
import { allSchemas } from './codingRules.data'
import * as CodingRulesApi from '@/api/system/codingrules'
import CodingRulesForm from './CodingRulesForm.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { Action } from 'element-plus'
const router = useRouter()
// tableObject
// tableMethods
// https://doc.iocoder.cn/vue3/crud-schema/
const { tableObject, tableMethods } = useTable({
getListApi: CodingRulesApi.getCodingRulesPage, //
delListApi: CodingRulesApi.deleteCodingRules //
})
//
const { getList, setSearchParams } = tableMethods
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = (id: number) => {
tableMethods.delList(id, false)
}
//
const handlePreview = async (code: string) => {
const params = {
code,
preview: true
}
const previewData = await CodingRulesApi.previewCodingRulesApi(params)
ElMessageBox.alert(
`<strong>${previewData}</strong>`,
'编码规则预览',
{
dangerouslyUseHTMLString: true,
}
)
}
//
const handleSetting = (id?: number, code?: string) => {
router.push({
name: 'CodingRulesDetails',
query: { id, code }
})
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>