Skip to content

Commit

Permalink
feat: 设置器加载统一,代码优化 didi#269
Browse files Browse the repository at this point in the history
  • Loading branch information
webaddkevin committed Aug 5, 2024
1 parent 136cdfb commit 107729f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 41 deletions.
4 changes: 2 additions & 2 deletions web/src/management/pages/edit/components/SetterField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</template>
<script setup lang="ts">
import { watch, ref, shallowRef } from 'vue'
import { get as _get, pick as _pick, isFunction as _isFunction } from 'lodash-es'
import { get as _get, pick as _pick, isFunction as _isFunction, values as _values } from 'lodash-es'
import FormItem from '@/materials/setters/widgets/FormItem.vue'
import setterLoader from '@/materials/setters/setterLoader'
Expand Down Expand Up @@ -70,7 +70,7 @@ const formatValue = ({ item, moduleConfig }: any) => {
result = _get(moduleConfig, key, item.value)
}
if (keys) {
result = _pick(moduleConfig, keys)
result = _values(_pick(moduleConfig, keys))
}
return result
Expand Down
26 changes: 8 additions & 18 deletions web/src/management/pages/edit/modules/resultModule/SetterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@
<div class="setter-title">
{{ currentEditText }}
</div>
<el-form class="question-config-form" label-position="top" @submit.prevent>
<template v-for="(item, index) in formFields" :key="index">
<FormItem
v-if="item.type && !item.hidden && Boolean(registerTypes[item.type])"
:form-config="item"
:style="item.style"
>
<Component
v-if="Boolean(registerTypes[item.type])"
:is="components[item.type]"
:module-config="moduleConfig"
:form-config="item"
@form-change="handleFormChange"
/>
</FormItem>
</template>
</el-form>
<SetterField
class="question-config-form"
label-position="top"
:form-config-list="formFields"
:module-config="moduleConfig"
@form-change="handleFormChange"
/>
</div>
</template>
<script setup lang="ts">
Expand All @@ -28,9 +18,9 @@ import { storeToRefs } from 'pinia'
import { useEditStore } from '@/management/stores/edit'
import { get as _get } from 'lodash-es'
import FormItem from '@/materials/setters/widgets/FormItem.vue'
import setterLoader from '@/materials/setters/setterLoader'
import statusConfig from '@/management/pages/edit/setterConfig/statusConfig'
import SetterField from '@/management/pages/edit/components/SetterField.vue'
const textMap = {
Success: '提交成功页面配置',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,15 @@
{{ form.title }}
</span>
</div>
<el-form
<SetterField
:key="form.key"
class="question-config-form"
label-position="left"
label-width="200px"
@submit.prevent
>
<template v-for="(item, index) in form.formList">
<FormItem
v-if="item.type && !item.hidden && Boolean(registerTypes[item.type])"
:key="index"
:form-config="item"
:style="item.style"
>
<Component
v-if="Boolean(registerTypes[item.type])"
:is="components[item.type]"
:module-config="form.dataConfig"
:form-config="item"
@form-change="handleFormChange"
/>
</FormItem>
</template>
</el-form>
:form-config-list="form.formList"
:module-config="form.dataConfig"
@form-change="handleFormChange"
/>
</div>
</div>
</div>
Expand All @@ -48,8 +34,8 @@ import { useEditStore } from '@/management/stores/edit'
import baseConfig from '@/management/pages/edit/setterConfig/baseConfig'
import baseFormConfig from '@/management/pages/edit/setterConfig/baseFormConfig'
import FormItem from '@/materials/setters/widgets/FormItem.vue'
import setterLoader from '@/materials/setters/setterLoader'
import SetterField from '@/management/pages/edit/components/SetterField.vue'
import WhiteList from './components/WhiteList.vue'
import TeamMemberList from './components/TeamMemberList.vue'
Expand Down

0 comments on commit 107729f

Please sign in to comment.