张同海 7 months ago
commit 02c42d433f

@ -1,3 +1,8 @@
<!--
* @Description:
* @Author: lijj
* @Date: 2024-04-15 17:08:07
-->
<template>
<span :class="getClass">
<slot></slot>
@ -45,9 +50,9 @@
.@{prefix-cls} {
position: relative;
display: flex;
padding-left: 7px;
font-size: 16px;
font-weight: 500;
font-family: 'PingFang SC';
font-weight: 600;
line-height: 24px;
color: @text-color-base;
cursor: pointer;

@ -4,9 +4,10 @@
ref="formElRef"
:class="getFormClass"
:model="formModel"
layout="vertical"
@keypress.enter="handleEnterPress"
>
<Row v-bind="getRow">
<Row v-bind="getRow" :gutter="15">
<slot name="formHeader"></slot>
<template v-for="schema in getSchema" :key="schema.field">
<FormItem
@ -318,13 +319,20 @@
&-label label::after {
margin: 0 6px 0 2px;
}
&-label {
padding-bottom: 1px;
}
&-no-colon {
font-size: 12px;
color: #262626;
font-weight: 600;
}
&-with-help {
margin-bottom: 0;
}
&:not(.ant-form-item-with-help) {
margin-bottom: 20px;
margin-bottom: 15px;
}
&.suffix-item {

@ -212,22 +212,21 @@ export function useFormEvents({
return
}
const schema: FormSchema[] = []
unref(getSchema).forEach((val) => {
updateData.forEach((item) => {
let _val
updateData.forEach((item) => {
if (val.field === item.field) {
_val = item
unref(getSchema).forEach((val) => {
if (item.field === val.field) {
_val = val
}
})
if (_val !== undefined && val.field === _val.field) {
const newSchema = deepMerge(val, _val)
if (_val !== undefined && item.field === _val.field) {
const newSchema = deepMerge(_val, item)
schema.push(newSchema as FormSchema)
} else {
schema.push(val)
schema.push(_val)
}
})
_setDefaultValue(schema)
schemaRef.value = uniqBy(schema, 'field')
}

@ -15,7 +15,6 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
wrapperCol: globWrapperCol,
layout,
} = unref(propsRef)
// If labelWidth is set globally, all items setting
if ((!globalLabelWidth && !labelWidth && !globalLabelCol) || disabledLabelWidth) {
labelCol.style = {
@ -34,7 +33,8 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
return {
labelCol: { style: { width }, ...col },
wrapperCol: {
style: { width: layout === 'vertical' ? '100%' : `calc(100% - ${width})` },
// style: { width: layout === 'vertical' ? '100%' : `calc(100% - ${width})` },
style: { width: '100%' },
...wrapCol,
},
}

@ -41,6 +41,7 @@ export interface FormActionType {
) => Promise<void>
validateFields: (nameList?: NamePath[]) => Promise<any>
validate: (nameList?: NamePath[]) => Promise<any>
getFieldList: (nameList?: NamePath[]) => Promise<any>
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>
}
@ -133,6 +134,7 @@ export interface FormSchema {
valueField?: string
// Label name
label?: string | VNode
enLabel?: string | VNode
// Auxiliary text
subLabel?: string
// Help text on the right side of the text

@ -1,14 +1,19 @@
<!--
* @Description:
* @Author: lijj
* @Date: 2024-04-15 17:08:07
-->
<template>
<Modal v-bind="getBindValue" @cancel="handleCancel">
<template v-if="!$slots.closeIcon" #closeIcon>
<ModalClose
:can-fullscreen="getProps.canFullscreen"
:full-screen="fullScreenRef"
:form-schema="getProps.formSchema"
@cancel="handleCancel"
@fullscreen="handleFullScreen"
/>
</template>
<template v-if="!$slots.title" #title>
<ModalHeader
:help-message="getProps.helpMessage"
@ -85,7 +90,6 @@
const propsRef = ref<Partial<ModalProps> | null>(null)
const modalWrapperRef = ref<any>(null)
const { prefixCls } = useDesign('basic-modal')
// modal Bottom and top height
const extHeightRef = ref(0)
const modalMethods: ModalMethods = {

@ -1,3 +1,8 @@
/*
* @Description:
* @Author: lijj
* @Date: 2024-04-15 17:08:07
*/
import { Modal } from 'ant-design-vue'
import { defineComponent, toRefs, unref } from 'vue'
import { basicProps } from '../props'

@ -1,5 +1,12 @@
<template>
<div :class="getClass">
<Tooltip
v-if="formSchema && formSchema.length"
:title="t('component.modal.edit')"
placement="bottom"
>
<DiffOutlined @click="addFormToSet" />
</Tooltip>
<template v-if="canFullscreen">
<Tooltip v-if="fullScreen" :title="t('component.modal.restore')" placement="bottom">
<FullscreenExitOutlined role="full" @click="handleFullScreen" />
@ -14,18 +21,42 @@
</div>
</template>
<script lang="ts">
import { FormSchema } from '/@/components/Table'
import { editCodeGoodsType } from '/@/views/baseinfo/formset/api'
import { defineComponent, computed } from 'vue'
import { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined } from '@ant-design/icons-vue'
import {
FullscreenExitOutlined,
FullscreenOutlined,
CloseOutlined,
DiffOutlined
} from '@ant-design/icons-vue'
import { useDesign } from '/@/hooks/web/useDesign'
import { Tooltip } from 'ant-design-vue'
import { useI18n } from '/@/hooks/web/useI18n'
// idname
import { permissionsInfo } from '/@/hooks/web/usePermission'
//
import { useMessage } from '/@/hooks/web/useMessage'
const { createMessage } = useMessage()
export default defineComponent({
name: 'ModalClose',
components: { Tooltip, FullscreenExitOutlined, FullscreenOutlined, CloseOutlined },
components: {
Tooltip,
FullscreenExitOutlined,
FullscreenOutlined,
CloseOutlined,
DiffOutlined
},
props: {
canFullscreen: { type: Boolean, default: true },
fullScreen: { type: Boolean },
formSchema: {
type: Array,
default: () => {
return []
}
}
},
emits: ['cancel', 'fullscreen'],
setup(props, { emit }) {
@ -45,18 +76,53 @@
function handleCancel(e: Event) {
emit('cancel', e)
}
function handleFullScreen(e: Event) {
e?.stopPropagation()
e?.preventDefault()
emit('fullscreen')
}
//
const addFormToSet = () => {
const columns = props.formSchema.map((item: FormSchema) => {
const res = {
defaultValue: item.defaultValue || '',
field: item.field || '',
label: item.label || '',
required: item.required || false,
colProps: item.colProps || { span: 24 },
component: item.component
}
//
if (item.show !== false) {
res['show'] = true
}
// raidooption
if (/^Select|RadioButtonGroup$/.test(item.component)) {
res['options'] = item?.componentProps?.options
}
return res
})
const Apidata = {
id: 0,
permissionId: permissionsInfo().permissionId,
templateName: permissionsInfo().permissionName,
permissionName: permissionsInfo().permissionName,
content: JSON.stringify({
columns: columns
})
}
editCodeGoodsType(Apidata).then(res => {
if (res.succeeded) {
createMessage.success('添加成功!')
}
})
}
return {
t,
getClass,
prefixCls,
handleCancel,
addFormToSet,
handleFullScreen,
}
},
@ -68,7 +134,7 @@
display: flex;
height: 95%;
align-items: center;
justify-content: center;
> span {
margin-left: 48px;
font-size: 16px;
@ -89,9 +155,6 @@
}
& span:nth-child(1) {
display: inline-block;
padding: 10px;
&:hover {
color: @primary-color;
}

@ -80,4 +80,5 @@ export const basicProps = Object.assign({}, modalProps, {
wrapClassName: { type: String },
zIndex: { type: Number },
formSchema: { type: Array },
})

@ -375,7 +375,7 @@
}
editColumnSet(Object.assign(Apidata, getPermissionInfo())).then(res => {
if (res.succeeded) {
createMessage.success('成功添加报表到列表设置')
createMessage.success('添加成功')
}
})
}

@ -0,0 +1,38 @@
/*
* @Description: hook
* @Author: lijj
* @Date: 2024-04-24 10:50:17
*/
// 获取表单更改过的字段接口
import { getFormSetInfoByModule } from '/@/views/baseinfo/formset/api'
// 接口
import { getColumnSetInfoByModule } from '/@/views/baseinfo/columnset/api'
// 引入表格权限信息包含id和name
import { permissionsInfo } from '/@/hooks/web/usePermission'
/**
* @description:
* @param {*} updateSchema (vben)
*/
export function updateFormField(updateSchema) {
getFormSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => {
if (res?.data?.content) {
const content = JSON.parse(res.data.content)
updateSchema(content.columns)
}
})
}
/**
* @description:
* @param {*} setColumns
*/
export function updateTableField(setColumns) {
getColumnSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => {
const { data } = res
if (data?.content) {
const txt = JSON.parse(data?.content)
setColumns(txt.columns)
}
})
}

@ -1,3 +1,4 @@
import { ref } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import { useAppStore } from '/@/store/modules/app'
@ -17,6 +18,35 @@ import { intersection } from 'lodash-es'
import { isArray } from '/@/utils/is'
import { useMultipleTabStore } from '/@/store/modules/multipleTab'
/**
* @description: pathid
*/
export function permissionsInfo() {
let permissionId: string = ''
let permissionName: string = ''
const fullPath = ref(router.currentRoute.value.path)
const routerList = treeOptionData(usePermissionStore().getWrouteList)
routerList.forEach(item => {
if (item.path === fullPath.value) {
console.log(fullPath.value)
permissionId = item.id
permissionName = item.name
}
})
return { permissionId, permissionName }
}
// 递归查找路由中path与当前path完全相同的路由
function treeOptionData(array, result = []) {
array.forEach(item => {
result.push({ name: item.name, id: item.id, path: item.path })
if (item.children && item.children.length) {
treeOptionData(item.children, result)
}
})
return JSON.parse(JSON.stringify(result))
}
// User permissions related operations
export function usePermission() {
const userStore = useUserStore()

@ -52,6 +52,7 @@ export default {
close: 'Close',
maximize: 'Maximize',
restore: 'Restore',
edit: 'Add form to form settings'
},
table: {
settingDens: 'Density',

@ -54,6 +54,7 @@ export default {
close: '关闭',
maximize: '最大化',
restore: '还原',
edit: '将该表单添加到表单设置'
},
table: {
settingDens: '密度',

@ -5,9 +5,10 @@
*/
import { request } from '/@/utils/request'
import { DataResult, PageRequest } from '/@/api/model/baseModel'
enum Api {
list = '/mainApi/ColumnSet/GetColumnSetList',
edit = '/mainApi/ColumnSet/EditColumnSet',
const Api = {
list: '/mainApi/ColumnSet/GetColumnSetList',
edit: '/mainApi/ColumnSet/EditColumnSet',
newColunm: '/mainApi/ColumnSet/GetColumnSetInfoByModule',
}
// 列表数据
export function getColumnSetList(data: PageRequest) {
@ -26,3 +27,12 @@ export function editColumnSet(data: PageRequest) {
data,
})
}
// 获取表单已编辑的列
export function getColumnSetInfoByModule(query) {
return request<DataResult>({
url: Api.newColunm,
method: 'get',
params: query,
})
}

@ -11,10 +11,10 @@
v-for="item in colData"
:key="item.value"
:type="btnType(item.value)"
draggable="true"
:draggable="true"
@click="chooseCol(item)"
@dragstart="handleDragStart($event, item)"
@dragover.prevent="handleDragOver($event, item)"
@dragover.prevent="handleDragOver($event)"
@dragenter="handleDragEnter($event, item)"
@dragend="handleDragEnd($event, item)"
>

@ -59,7 +59,7 @@
</a-select>
</a-form-item>
<a-form-item label="是否显示">
<a-radio-group :disabled="formDisable" v-model:value="formData.visible">
<a-radio-group v-model:value="formData.visible" :disabled="formDisable">
<a-radio :value="true"></a-radio>
<a-radio :value="false"></a-radio>
</a-radio-group>
@ -69,7 +69,7 @@
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted, nextTick } from 'vue'
import { reactive, ref, onMounted, defineExpose } from 'vue'
import emitter from '/@/utils/Bus'
const formDisable = ref(true)
const form = ref()

@ -29,7 +29,6 @@
const TableColSetRef = ref()
const submit = async () => {
const flag = await TableColSetRef.value.onSubmit()
console.log(flag)
return flag
}
const getColList = () => {

@ -68,6 +68,8 @@
import { getColumnSetList, editColumnSet } from './api'
//
import { columns, searchFormSchema } from './columns'
import { message } from 'ant-design-vue'
import { updateTableField } from '/@/hooks/component/costomForm'
//
const TableSetRef = ref()
// boolean
@ -89,7 +91,7 @@
loading.value = true
editColumnSet(colData.value).then(res => {
if (res.succeeded) {
message.success('更新成功!')
}
loading.value = false
visible.value = flag
@ -101,9 +103,11 @@
}
const colData = ref({})
provide('colData', colData)
const [registerTable, { getForm, getPaginationRef }] = useTable({
const [registerTable, { getForm, getPaginationRef, setColumns }] = useTable({
title: '可设置列表',
api: async (p) => {
//
updateTableField(setColumns)
const res: API.DataResult = await getColumnSetList(p)
return new Promise((resolve) => {
resolve({ data: [...res.data], total: res.count })

@ -3,6 +3,7 @@
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
:form-schema="formSchema"
width="50%"
@register="registerModal"
@ok="handleSave"

@ -1,110 +0,0 @@
<template>
<BasicModal
v-bind="$attrs"
:use-wrapper="true"
title="表单设置"
width="50%"
@register="registerModal"
@ok="handleSave"
>
<BasicForm @register="registerForm" />
<!--右下角按钮-->
<template #footer>
<a-button
pre-icon="ant-design:close-outlined"
type="warning"
:loading="loading"
ghost
style="margin-right: 0.8rem"
@click="closeModal"
>取消</a-button
>
<a-button
type="success"
:loading="loading"
pre-icon="ant-design:check-outlined"
style="margin-right: 0.8rem"
@click="handleSave(true)"
>
确定
</a-button>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref, h } from 'vue'
import { BasicModal, useModalInner } from '/@/components/Modal'
import { BasicForm, useForm } from '/@/components/Form/index'
// import { formSchema } from './columns'
import { editCodeGoodsType, getCodeGoodsTypeInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
import { Icon } from '/@/components/Icon'
import { useModal } from '/@/components/Modal'
import { getColumns } from '/@/api/system/role'
const props = defineProps({
schemaArr: { type: Array },
})
let formSchema = props.schemaArr
const [register, { openModal }] = useModal()
// Emits
const emit = defineEmits(['contentOk', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields()
setModalProps({ confirmLoading: false, loading: true })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
let obj = {}
JSON.parse(data.record.content).forEach((e) => {
obj[`${e.field}-defaultValue`] = e.defaultValue
obj[`${e.field}-required`] = e.required
obj[`${e.field}-show`] = e.show
})
setFieldsValue(obj)
setModalProps({ confirmLoading: false })
} else {
setFieldsValue({ permissionIdentity: unref(2) })
}
setModalProps({ loading: false })
})
async function handleSave(exit) {
try {
const values = await validate()
setModalProps({ confirmLoading: true, loading: true })
// TODO custom api
console.log(values)
let Arr = []
Object.keys(values).forEach((e) => {
let type = true
Arr.forEach((item) => {
if (item.field == e.split('-')[0]) {
item[e.split('-')[1]] = values[e]
type = false
}
})
if (type) {
let obj = {
field: e.split('-')[0],
}
obj[e.split('-')[1]] = values[e]
Arr.push(obj)
}
// console.log()
})
emit('contentOk', JSON.stringify(Arr))
exit && closeModal()
} finally {
// loading.value = false;
setModalProps({ confirmLoading: false, loading: false })
}
}
</script>

@ -1,230 +0,0 @@
<template>
<BasicModal
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
width="35%"
@register="registerModal"
@ok="handleSave"
>
<BasicForm @register="registerForm" />
<!--右下角按钮-->
<template #footer>
<a-button
pre-icon="ant-design:close-outlined"
type="warning"
:loading="loading"
ghost
style="margin-right: 0.8rem"
@click="closeModal"
>取消</a-button
>
<a-button
type="success"
:loading="loading"
pre-icon="ant-design:check-outlined"
style="margin-right: 0.8rem"
@click="handleSave(false)"
>仅保存</a-button
>
<a-button
pre-icon="ant-design:check-circle-outlined"
type="primary"
:loading="loading"
@click="handleSave(true)"
>保存并关闭</a-button
>
</template>
</BasicModal>
<Modal v-if="ModalType" :schema-arr="schemaArr" @register="register" @contentOk="contentOk" />
</template>
<script lang="ts" setup>
import { ref, computed, unref, h } from 'vue'
import { BasicModal, useModalInner } from '/@/components/Modal'
import { BasicForm, useForm } from '/@/components/Form/index'
import { formSchema } from './columns'
import { editCodeGoodsType, getCodeGoodsTypeInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
import { Icon } from '/@/components/Icon'
import { useModal } from '/@/components/Modal'
import Modal from './Modal.vue'
import { getColumnsByClient } from '/@/views/baseinfo/formcopy/api'
const [register, { openModal }] = useModal()
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
const rowId = ref('')
const schemaArr = ref([])
const ModalType = ref(false)
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields()
setModalProps({ confirmLoading: false, loading: true })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
// setModalProps({ confirmLoading: true });
rowId.value = data.record.id
const res: API.DataResult = await getCodeGoodsTypeInfo({ id: unref(rowId) })
if (res.succeeded) {
console.log(res, 2222)
setFieldsValue({
...res.data,
})
// console.log('Form', getFieldsValue());
// setFieldsValue({ trainId: unref(res.data.trainId) });
}
// setModalProps({ confirmLoading: false });
} else {
setFieldsValue({ permissionIdentity: unref(2) })
}
updateSchema({
field: 'setting',
label: '',
component: 'Input',
colProps: { span: 2 },
// Input
render: ({ model, field }) => {
return h(Icon, {
icon: 'ant-design:setting-filled',
style: { marginLeft: '10px', cursor: 'pointer' },
// value: model[field],
// onChange: (e: ChangeEvent) => {
// model[field] = e.target.value
// },
onClick: async (e) => {
if (model.columnView) {
schemaArr.value = []
let schemaA = []
const res: API.DataResult = await getColumnsByClient({
tableViewName: model.columnView,
})
// const res: API.DataResult = await getCodeGoodsTypeInfo({ id: unref(rowId) })
if (res.succeeded) {
res.data.forEach((e) => {
schemaA.push(
...[
{
field: `divider-${e.dbColumnName}`,
component: 'Divider',
label: e.columnDescription,
colProps: {
span: 24,
},
},
{
field: `${e.dbColumnName}-defaultValue`,
label: '默认值',
component: 'Input',
colProps: { span: 8 },
defaultValue: '',
},
{
field: `${e.dbColumnName}-required`,
label: '是否必填',
component: 'RadioButtonGroup',
defaultValue: false,
colProps: { span: 8 },
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
},
},
{
field: `${e.dbColumnName}-show`,
label: '是否显示',
component: 'RadioButtonGroup',
defaultValue: false,
colProps: { span: 8 },
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
},
},
],
)
// schemaA.push({
// field: e.dbColumnName,
// label: e.columnDescription,
// defaultValue: '',
// show: true,
// required: false,
// })
})
schemaArr.value = schemaA
}
ModalType.value = true
setTimeout(() => {
openModal(true, {
record: model,
isUpdate: model.content ? true : false,
})
}, 300)
} else {
createMessage.warning('请先选择中文视图名')
}
},
})
},
})
setModalProps({ loading: false })
})
function contentOk(data) {
console.log(data)
setFieldsValue({
content: data,
})
}
const getTitle = computed(() => (!unref(isUpdate) ? '新增表单设置' : '编辑表单设置'))
async function handleSave(exit) {
try {
const values = await validate()
console.log(values,111)
setModalProps({ confirmLoading: true, loading: true })
// TODO custom api
console.log(values)
// loading.value = true;
const res: API.DataResult = await editCodeGoodsType(values)
console.log(res)
if (res.succeeded) {
createMessage.success(res.message)
emit('success')
//
if (!exit) {
if (unref(isUpdate)) {
await refresh()
} else {
rowId.value = res.data
isUpdate.value = true
await refresh()
}
}
} else {
createMessage.error(res.message)
}
ModalType.value = false
exit && closeModal()
} finally {
// loading.value = false;
setModalProps({ confirmLoading: false, loading: false })
}
}
async function refresh() {
const res: API.DataResult = await getCodeGoodsTypeInfo({ id: unref(rowId) })
if (res.succeeded) {
await setFieldsValue({
...res.data,
})
}
}
</script>

@ -1,10 +1,16 @@
/*
* @Description:
* @Author: lijj
* @Date: 2024-04-16 16:14:31
*/
// @ts-ignore
import { request } from '/@/utils/request'
import { DataResult, PageRequest } from '/@/api/model/baseModel'
enum Api {
list = '/mainApi/FormSet/GetFormSetList',
EditCodeGoodsType = '/mainApi/FormSet/EditFormSet',
GetCodeGoodsTypeInfo = '/mainApi/FormSet/GetFormSetInfo',
const Api = {
list: '/mainApi/FormSet/GetFormSetList',
EditCodeGoodsType: '/mainApi/FormSet/EditFormSet',
GetCodeGoodsTypeInfo: '/mainApi/FormSet/GetFormSetInfo',
GetFormSetInfoByModule: '/mainApi/FormSet//GetFormSetInfoByModule',
}
// 列表 (Auth)
export function getCodeGoodsTypeList(data: PageRequest) {
@ -30,3 +36,12 @@ export function getCodeGoodsTypeInfo(query) {
params: query,
})
}
// 查询表单是否发生编辑
export function getFormSetInfoByModule(query) {
return request<DataResult>({
url: Api.GetFormSetInfoByModule,
method: 'get',
params: query,
})
}

@ -2,8 +2,6 @@ import { BasicColumn, FormSchema } from '/@/components/Table'
import { Tag } from 'ant-design-vue'
import { getClientPermissionList } from '/@/api/system/role'
import { getTablesByClient } from '/@/views/baseinfo/formcopy/api'
import { Icon } from '/@/components/Icon'
import { h } from 'vue'
const columnViewData = []
const res: API.DataResult = await getTablesByClient()
if (res.succeeded) {
@ -102,122 +100,5 @@ export const formSchema: FormSchema[] = [
component: 'Input',
defaultValue: '',
show: false,
},
{
field: 'templateName',
label: '模板名称',
component: 'Input',
colProps: { span: 20 },
required: true,
},
{
field: 'permissionId',
label: '权限模块名称',
component: 'Select',
colProps: { span: 20 },
required: true,
componentProps: ({ formModel }) => {
return {
options: ClientPermissionData,
// xxxx props
onChange: (e) => {
console.log(e)
ClientPermissionList.forEach((item) => {
if (item.id == e) {
console.log(item)
formModel.permissionName = item.permissionName
}
})
},
}
},
},
{
field: 'columnView',
label: '中文视图名',
component: 'Select',
required: true,
colProps: { span: 12 },
componentProps: ({ formModel }) => {
return {
options: columnViewData,
onChange: (e: ChangeEvent) => {
if (e != formModel.columnView) {
formModel.content = ''
}
},
}
},
},
{
field: 'isPublic',
label: '是否公共标识',
component: 'RadioButtonGroup',
defaultValue: true,
colProps: { span: 12 },
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
},
},
{
field: 'content',
label: '表单设置',
component: 'InputTextArea',
colProps: { span: 20 },
defaultValue: '',
componentProps: {
rows: 4,
},
dynamicDisabled: true,
},
// <Icon icon="ion:chevron-forward" :style="$attrs.iconStyle" />
{
field: 'setting',
label: '',
component: 'Input',
colProps: { span: 2 },
// 通过函数渲染一个 Input
render: ({ model, field }) => {
return h(Icon, {
icon: 'ant-design:setting-filled',
style: { marginLeft: '10px', cursor: 'pointer' },
// value: model[field],
// onChange: (e: ChangeEvent) => {
// model[field] = e.target.value
// },
})
},
},
{
field: 'status',
label: '是否可用',
component: 'RadioButtonGroup',
defaultValue: 0,
colProps: { span: 20 },
componentProps: {
options: [
{ label: '禁用', value: 1 },
{ label: '启用', value: 0 },
],
},
},
{
field: 'orderNo',
label: '排序',
component: 'InputNumber',
colProps: { span: 20 },
defaultValue: 1,
},
{
field: 'note',
label: '备注',
component: 'InputTextArea',
colProps: { span: 20 },
componentProps: {
rows: 2,
},
},
}
]

@ -0,0 +1,102 @@
<!--
* @Description:
* @Author: lijj
* @Date: 2024-04-22 09:04:38
-->
<template>
<BasicModal
:use-wrapper="true"
:title="getTitle"
width="90%"
@register="registerModal"
@ok="handleSave"
>
<ds-form v-if="getVisible" ref="FormDragRef" :content="content" />
<!--右下角按钮-->
<template #footer>
<a-button
pre-icon="ant-design:close-outlined"
type="warning"
ghost
style="margin-right: 0.8rem"
@click="closeModal"
>
取消
</a-button>
<a-button
type="success"
pre-icon="ant-design:check-outlined"
style="margin-right: 0.8rem"
@click="handleSave(false)"
>
仅保存
</a-button>
<a-button
pre-icon="ant-design:check-circle-outlined"
type="primary"
@click="handleSave(true)"
>
保存并关闭
</a-button>
</template>
</BasicModal>
<!-- <Modal v-if="ModalType" :schema-arr="schemaArr" @register="register" @contentOk="contentOk" /> -->
</template>
<script lang="ts" setup>
import { ref, computed, unref, defineEmits } from 'vue'
import { BasicModal, useModalInner } from '/@/components/Modal'
import { editCodeGoodsType, getCodeGoodsTypeInfo } from './../api'
import { useMessage } from '/@/hooks/web/useMessage'
//
import DsForm from './form.vue'
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const rowId = ref('')
const content = ref({})
var postData = {}
const FormDragRef = ref()
const { createMessage } = useMessage()
const [registerModal, { setModalProps, closeModal, getVisible }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false, loading: true })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
setModalProps({ confirmLoading: true });
rowId.value = data.record.id
const res: API.DataResult = await getCodeGoodsTypeInfo({ id: unref(rowId) })
if (res.succeeded) {
postData = res.data
content.value = JSON.parse(res.data.content)
}
}
setModalProps({ loading: false })
})
const getTitle = computed(() => (!unref(isUpdate) ? '新增表单设置' : '编辑表单设置'))
async function handleSave(exit) {
const contents = await FormDragRef.value.validate()
if (contents) {
setModalProps({ confirmLoading: true, loading: true })
postData.content = JSON.stringify({ columns: contents })
editCodeGoodsType(postData).then(res => {
if (exit) {
closeModal()
}
createMessage.success(res.message)
setModalProps({ confirmLoading: false, loading: false })
})
.catch((err) => {
createMessage.error(err.message)
setModalProps({ confirmLoading: false, loading: false })
})
}
}
async function refresh() {
const res: API.DataResult = await getCodeGoodsTypeInfo({ id: unref(rowId) })
if (res.succeeded) {
await setFieldsValue({
...res.data,
})
}
}
</script>

@ -0,0 +1,257 @@
<!--
* @Description: 基础配置 -> 表单设置 -> 表单设置弹窗内容组件
* @Author: lijj
* @Date: 2024-04-16 10:33:31
-->
<template>
<div class="form-set-drag-box">
<div class="table-box">
<!-- 表单区域组件 -->
<a-form>
<a-row :gutter="16">
<a-col
v-for="(item, index) in formItems.list"
:class="{active: activeClass == item.field}"
:key="index"
:span="item?.colProps?.span"
:draggable="true"
@dragstart="handleDragStart($event, item)"
@dragover.prevent="handleDragOver($event)"
@dragenter="handleDragEnter($event, item)"
@dragend="handleDragEnd"
>
<a-form-item v-if="item.field != 'id'" :label="item.label" :name="item.label" @click="chooseItem(item)">
<div class="model-input">占位使用</div>
</a-form-item>
</a-col>
</a-row>
</a-form>
</div>
<div class="opt-box">
<h3>字段属性设置</h3>
<!-- 表格操作列组件 -->
<a-form
ref="form"
:model="formItems.formData"
:rules="rules"
>
<a-form-item label="字段名称(中文)" name="label">
<a-input v-model:value="formItems.formData.label" :disabled="formDisable" placeholder="请输入" />
</a-form-item>
<a-form-item label="字段名称(英文)" name="enLabel">
<a-input v-model:value="formItems.formData.enLabel" :disabled="formDisable" placeholder="请输入" />
</a-form-item>
<a-form-item v-if="/^InputTextArea|RadioButtonGroup|Select|Input$/.test(formItems.formData.component)" label="默认值" name="defaultValue">
<a-select
v-if="formItems.formData.component == 'Select' || formItems.formData.component == 'RadioButtonGroup'"
v-model="formItems.formData.defaultValue"
placeholder="请选择"
:disabled="formDisable"
>
<a-select-option
v-for="item in formItems.formData.options"
:value="item.value"
>
{{ item.label }}
</a-select-option>
</a-select>
<a-input v-else v-model:value="formItems.formData.defaultValue" :disabled="formDisable" placeholder="请输入" />
</a-form-item>
<a-form-item label="是否必填" name="required">
<a-radio-group v-model:value="formItems.formData.required" :disabled="formDisable">
<a-radio :value="true"></a-radio>
<a-radio :value="false"></a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否显示" name="show">
<a-radio-group v-model:value="formItems.formData.show" :disabled="formDisable">
<a-radio :value="true"></a-radio>
<a-radio :value="false"></a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="所占列宽(支持输入1~24)" name="colProps">
<a-input-number
v-model:value="formItems.formData.colProps.span"
:min="1"
:max="24"
palceholder="请输入1~24的整数"
:disabled="formDisable"
/>
</a-form-item>
</a-form>
</div>
</div>
</template>
<script setup lang="ts">
import { FormSchema } from '/@/components/Table'
import { ref, reactive, defineProps, computed, watch, unref } from 'vue'
const props = defineProps({
//
content: {
type: Object,
default: {}
}
})
//
let formItems = reactive({
list: [],
formData: <FormSchema> {
colProps: {
span: ''
}
}
})
//
const formDisable = ref(true)
//
const form = ref()
const getProps = computed(() => {
return { ...props }
})
//
const rules = {
label: [
{
required: true,
message: '请输入中文字段名称',
trigger: 'blur'
}
],
enLabel: [
{
required: true,
message: '请输入英文字段名称',
trigger: 'blur'
}
]
}
//
let dragging = {}
//
let ending = {}
const activeClass = ref()
//
const handleDragStart = (e, item) => {
dragging = item
}
//
const chooseItem = (item) => {
if (formItems.formData.field) {
form.value.validate()
.then(() => {
formToggle(item)
})
} else {
formToggle(item)
}
}
const formToggle = (item) => {
form.value.clearValidate()
activeClass.value = item.field
formItems.formData = item
formDisable.value = false
}
//
const handleDragOver = (e) => {
e.dataTransfer.dropEffect = 'move'
}
//
const handleDragEnter = (e, item) => {
e.dataTransfer.effectAllowed = 'move'
ending = item
}
//
const handleDragEnd = () => {
if (ending.field === dragging.field) {
return
}
//
let newItems = [...formItems.list]
//
const src = newItems.indexOf(dragging)
//
const dst = newItems.indexOf(ending)
newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]))
formItems.list = newItems
}
//
const validate = async () => {
const list = JSON.parse(JSON.stringify(formItems.list))
if (list && list.length) {
list.forEach(item => {
if (item?.options) {
delete item.options
}
})
}
if (!formDisable.value) {
const flag = await new Promise((resolve) => {
form.value.validate()
.then(() => {
return resolve(list)
})
.catch(() => {
return resolve(false)
})
})
return flag
} else {
return list
}
}
watch(
() => unref(getProps).content,
(content) => {
//
formItems.list = content.columns
},
)
defineExpose({
validate
})
</script>
<style lang="scss">
.form-set-drag-box {
display: flex;
.opt-box {
width: 200px;
border-left: 1px solid #d9d9d9;
.ant-form-item {
display: table-caption;
margin: 0 0 10px 15px;
width: 170px;
}
.ant-form-item-label > label {
color: #262626;
height: 27px;
font-size: 12px;
font-weight: 500;
}
}
.table-box {
padding: 0 15px;
flex: 1;
.ant-input-disabled {
cursor: pointer;
}
.ant-form-item {
margin: 12px 0;
cursor: pointer;
}
.active {
background-color: #f3f3f3;
}
.model-input {
border: 1px solid #d9d9d9;
width: 100%;
height: 32px;
line-height: 30px;
padding-left: 15px;
color:rgba(0, 0, 0, 0.45);
border-radius: 4px;
}
}
}
</style>

@ -23,15 +23,16 @@
</template>
</template>
</BasicTable>
<TenantAuditStepModal @register="registerModal" @success="handleSuccess" />
<!-- 表单编辑组件 -->
<FormModel @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup>
import { defineComponent, onMounted, ref } from 'vue'
import { ref } from 'vue'
import { BasicTable, useTable, TableAction, SorterResult } from '/@/components/Table'
import { getCodeGoodsTypeList, importCodeGoodsType } from './api'
import { getCodeGoodsTypeList } from './api'
import { useModal } from '/@/components/Modal'
import TenantAuditStepModal from './TenantAuditStepModal.vue'
import FormModel from './component/FormModel.vue'
import { columns, searchFormSchema } from './columns'
import { useMessage } from '/@/hooks/web/useMessage'
const { notification } = useMessage()

@ -3,6 +3,7 @@
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
:form-schema="formSchema"
width="30%"
@register="registerModal"
@ok="handleSave"
@ -43,6 +44,10 @@
import { BasicForm, useForm } from '/@/components/Form/index'
import { formSchema } from './columns'
import { ApiEdit, ApiInfo } from './api'
// idname
import { permissionsInfo } from '/@/hooks/web/usePermission'
//
import { getFormSetInfoByModule } from '/@/views/baseinfo/formset/api'
import { useMessage } from '/@/hooks/web/useMessage'
// Emits
const emit = defineEmits(['success', 'register'])
@ -50,7 +55,7 @@
const loading = ref(false)
const rowId = ref('')
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
@ -63,13 +68,17 @@
if (unref(isUpdate)) {
// setModalProps({ confirmLoading: true });
rowId.value = data.record.id
getFormSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => {
if (res?.data?.content) {
const content = JSON.parse(res.data.content)
updateSchema(content.columns)
}
})
const res: API.DataResult = await ApiInfo({ id: unref(rowId) })
if (res.succeeded) {
setFieldsValue({
...res.data,
})
// console.log('Form', getFieldsValue());
// setFieldsValue({ trainId: unref(res.data.trainId) });
}
// setModalProps({ confirmLoading: false });
} else {

@ -5,7 +5,6 @@ enum Api {
list = '/mainApi/CodeIssueType/GetCodeIssueTypeList',
edit = '/mainApi/CodeIssueType/EditCodeIssueType',
info = '/mainApi/CodeIssueType/GetCodeIssueTypeInfo',
BasicsList = '/mainApi/CodeIssueType/GetBasicsCodeIssueTypeList',
ExistList = '/mainApi/CodeIssueType/GetExistCodeIssueTypeList',
Import = '/mainApi/CodeIssueType/ImportCodeIssueType',
@ -58,3 +57,4 @@ export function ApiImport(data: PageRequest) {
data,
})
}

@ -3,6 +3,7 @@
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
:form-schema="formSchema"
width="50%"
@register="registerModal"
@ok="handleSave"
@ -50,12 +51,11 @@
const loading = ref(false)
const rowId = ref('')
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
const [registerForm, { resetFields, setFieldsValue, validate, getFieldList }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields()
setModalProps({ confirmLoading: false, loading: true })
@ -64,6 +64,7 @@
// setModalProps({ confirmLoading: true });
rowId.value = data.record.id
const res: API.DataResult = await ApiInfo({ id: unref(rowId) })
getFieldList()
if (res.succeeded) {
setFieldsValue({
...res.data,
@ -85,10 +86,8 @@
const values = await validate()
setModalProps({ confirmLoading: true, loading: true })
// TODO custom api
console.log(values)
// loading.value = true;
const res: API.DataResult = await ApiEdit(values)
console.log(res)
if (res.succeeded) {
createMessage.success(res.message)
emit('success')

@ -3,6 +3,7 @@
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
:form-schema="formSchema"
width="30%"
@register="registerModal"
@ok="handleSave"
@ -44,13 +45,14 @@
import { formSchema } from './columns'
import { ApiEdit, ApiInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
import { updateFormField } from '/@/hooks/component/costomForm'
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
const rowId = ref('')
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
@ -62,6 +64,7 @@
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
// setModalProps({ confirmLoading: true });
updateFormField(updateSchema)
rowId.value = data.record.id
const res: API.DataResult = await ApiInfo({ id: unref(rowId) })
if (res.succeeded) {

@ -30,7 +30,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv
console.log(process.env.NODE_ENV)
const isBuild = command === 'build'
hmr: false
return {
base: VITE_PUBLIC_PATH,
root,

Loading…
Cancel
Save