Skip to content

Commit

Permalink
完善只读模式
Browse files Browse the repository at this point in the history
  • Loading branch information
caidefeng committed May 21, 2024
1 parent 0422fb1 commit b48706c
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 81 deletions.
16 changes: 11 additions & 5 deletions src/components/Render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ export default defineComponent({
},
emits: ['update:modelValue'],
components: {
ElInput: defineAsyncComponent(() => import('element-plus/es').then(({ElInput}) => ElInput)),
ElInputNumber: defineAsyncComponent(() => import('element-plus/es').then(({ElInputNumber}) => ElInputNumber)),
ElSelect: defineAsyncComponent(() => import('element-plus/es').then(({ElSelect}) => ElSelect)),
ElRadio: defineAsyncComponent(() => import('element-plus/es').then(({ElRadio}) => ElRadio)),
ElCheckbox: defineAsyncComponent(() => import('element-plus/es').then(({ElCheckbox}) => ElCheckbox)),
ElInput: defineAsyncComponent(() => import('element-plus/es').then(({ ElInput }) => ElInput)),
ElInputNumber: defineAsyncComponent(() =>
import('element-plus/es').then(({ ElInputNumber }) => ElInputNumber)
),
ElSelect: defineAsyncComponent(() =>
import('element-plus/es').then(({ ElSelect }) => ElSelect)
),
ElRadio: defineAsyncComponent(() => import('element-plus/es').then(({ ElRadio }) => ElRadio)),
ElCheckbox: defineAsyncComponent(() =>
import('element-plus/es').then(({ ElCheckbox }) => ElCheckbox)
),
UserSelector: defineAsyncComponent(() => import('@/components/UserSelector/index.vue')),
RoleSelector: defineAsyncComponent(() => import('@/components/RoleSelector/index.vue'))
},
Expand Down
140 changes: 76 additions & 64 deletions src/typings/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,85 @@
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
const ElDivider: typeof import('element-plus/es')['ElDivider']
const ElInput: typeof import('element-plus/es')['ElInput']
const ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
const ElRadio: typeof import('element-plus/es')['ElRadio']
const ElSelect: typeof import('element-plus/es')['ElSelect']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useLink: typeof import('vue-router')['useLink']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
const EffectScope: (typeof import('vue'))['EffectScope']
const ElCheckbox: (typeof import('element-plus/es'))['ElCheckbox']
const ElDivider: (typeof import('element-plus/es'))['ElDivider']
const ElInput: (typeof import('element-plus/es'))['ElInput']
const ElInputNumber: (typeof import('element-plus/es'))['ElInputNumber']
const ElRadio: (typeof import('element-plus/es'))['ElRadio']
const ElSelect: (typeof import('element-plus/es'))['ElSelect']
const computed: (typeof import('vue'))['computed']
const createApp: (typeof import('vue'))['createApp']
const customRef: (typeof import('vue'))['customRef']
const defineAsyncComponent: (typeof import('vue'))['defineAsyncComponent']
const defineComponent: (typeof import('vue'))['defineComponent']
const effectScope: (typeof import('vue'))['effectScope']
const getCurrentInstance: (typeof import('vue'))['getCurrentInstance']
const getCurrentScope: (typeof import('vue'))['getCurrentScope']
const h: (typeof import('vue'))['h']
const inject: (typeof import('vue'))['inject']
const isProxy: (typeof import('vue'))['isProxy']
const isReactive: (typeof import('vue'))['isReactive']
const isReadonly: (typeof import('vue'))['isReadonly']
const isRef: (typeof import('vue'))['isRef']
const markRaw: (typeof import('vue'))['markRaw']
const nextTick: (typeof import('vue'))['nextTick']
const onActivated: (typeof import('vue'))['onActivated']
const onBeforeMount: (typeof import('vue'))['onBeforeMount']
const onBeforeRouteLeave: (typeof import('vue-router'))['onBeforeRouteLeave']
const onBeforeRouteUpdate: (typeof import('vue-router'))['onBeforeRouteUpdate']
const onBeforeUnmount: (typeof import('vue'))['onBeforeUnmount']
const onBeforeUpdate: (typeof import('vue'))['onBeforeUpdate']
const onDeactivated: (typeof import('vue'))['onDeactivated']
const onErrorCaptured: (typeof import('vue'))['onErrorCaptured']
const onMounted: (typeof import('vue'))['onMounted']
const onRenderTracked: (typeof import('vue'))['onRenderTracked']
const onRenderTriggered: (typeof import('vue'))['onRenderTriggered']
const onScopeDispose: (typeof import('vue'))['onScopeDispose']
const onServerPrefetch: (typeof import('vue'))['onServerPrefetch']
const onUnmounted: (typeof import('vue'))['onUnmounted']
const onUpdated: (typeof import('vue'))['onUpdated']
const provide: (typeof import('vue'))['provide']
const reactive: (typeof import('vue'))['reactive']
const readonly: (typeof import('vue'))['readonly']
const ref: (typeof import('vue'))['ref']
const resolveComponent: (typeof import('vue'))['resolveComponent']
const shallowReactive: (typeof import('vue'))['shallowReactive']
const shallowReadonly: (typeof import('vue'))['shallowReadonly']
const shallowRef: (typeof import('vue'))['shallowRef']
const toRaw: (typeof import('vue'))['toRaw']
const toRef: (typeof import('vue'))['toRef']
const toRefs: (typeof import('vue'))['toRefs']
const toValue: (typeof import('vue'))['toValue']
const triggerRef: (typeof import('vue'))['triggerRef']
const unref: (typeof import('vue'))['unref']
const useAttrs: (typeof import('vue'))['useAttrs']
const useCssModule: (typeof import('vue'))['useCssModule']
const useCssVars: (typeof import('vue'))['useCssVars']
const useLink: (typeof import('vue-router'))['useLink']
const useRoute: (typeof import('vue-router'))['useRoute']
const useRouter: (typeof import('vue-router'))['useRouter']
const useSlots: (typeof import('vue'))['useSlots']
const watch: (typeof import('vue'))['watch']
const watchEffect: (typeof import('vue'))['watchEffect']
const watchPostEffect: (typeof import('vue'))['watchPostEffect']
const watchSyncEffect: (typeof import('vue'))['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
export type {
Component,
ComponentPublicInstance,
ComputedRef,
ExtractDefaultPropTypes,
ExtractPropTypes,
ExtractPublicPropTypes,
InjectionKey,
PropType,
Ref,
VNode,
WritableComputedRef
} from 'vue'
import('vue')
}
19 changes: 13 additions & 6 deletions src/views/flowDesign/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ import type { FilterRules } from '@/components/AdvancedFilter/type'
import type { Field } from '@/components/Render/type'
import { downloadXml } from '@/api/modules/model'
const props = defineProps<{
process: FlowNode
fields: Field[]
readOnly?: boolean
}>()
const props = withDefaults(
defineProps<{
process: FlowNode
fields: Field[]
readOnly?: boolean
defaultZoom?: number
}>(),
{
readOnly: false,
defaultZoom: 100
}
)
const isDark = ref(false)
const flatFields = computed(() => {
Expand All @@ -37,7 +44,7 @@ const flatFields = computed(() => {
return all
})
const getScale = computed(() => zoom.value / 100)
const zoom = ref(100)
const zoom = ref(props.defaultZoom)
const activeData = ref<FlowNode>({
id: '',
name: '',
Expand Down
11 changes: 10 additions & 1 deletion src/views/flowDesign/nodes/Add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import type { PopoverInstance } from 'element-plus'
import type { NodeType } from './type'
const { readOnly } = inject<{
readOnly?: boolean
}>('flowDesign', { readOnly: false })
const popoverRef = ref<PopoverInstance>()
const $emits = defineEmits<{
(e: 'addNode', type: NodeType): void
Expand Down Expand Up @@ -52,7 +55,13 @@ const addTimerNode = () => {
</div>
</el-space>
<template #reference>
<el-button icon="Plus" type="primary" style="z-index: 1" circle></el-button>
<el-button
v-show="!readOnly"
icon="Plus"
type="primary"
style="z-index: 1"
circle
></el-button>
</template>
</el-popover>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/views/flowDesign/nodes/ExclusiveNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ defineProps<{

<template>
<GatewayNode v-bind="$attrs" :node="node">
<template #default="{ addNode }">
<el-button type="primary" @click="addNode('condition', node)" plain round>添加条件</el-button>
<template #default="{ addNode, readOnly }">
<el-button type="primary" :disabled="readOnly" @click="addNode('condition', node)" plain round
>添加条件</el-button
>
</template>
</GatewayNode>
</template>
Expand Down
9 changes: 6 additions & 3 deletions src/views/flowDesign/nodes/GatewayNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const $emits = defineEmits<{
const props = defineProps<{
node: BranchNode
}>()
const { readOnly } = inject<{
readOnly?: boolean
}>('flowDesign', { readOnly: false })
const addNode = (type: NodeType, node?: FlowNode) => {
$emits('addNode', type, node || props.node)
}
Expand All @@ -27,7 +30,7 @@ const moveLeft = (index: number) => {
<template>
<div class="gateway-node">
<div class="add-branch">
<slot :addNode="addNode"></slot>
<slot :addNode="addNode" :readOnly="readOnly"></slot>
</div>
<div v-for="(item, index) in node.children" :key="item.id" class="col-box">
<template v-if="index === 0">
Expand All @@ -43,14 +46,14 @@ const moveLeft = (index: number) => {
<div
class="move-left"
@click.stop="moveLeft(index)"
v-show="index !== 0 && node.children.length !== index + 1"
v-show="index !== 0 && node.children.length !== index + 1 && !readOnly"
>
<svg-icon name="el:ArrowLeft" />
</div>
<div
class="move-right"
@click.stop="moveRight(index)"
v-show="![index + 1, index + 2].includes(node.children.length)"
v-show="![index + 1, index + 2].includes(node.children.length) && !readOnly"
>
<svg-icon name="el:ArrowRight" />
</div>
Expand Down

0 comments on commit b48706c

Please sign in to comment.