feat: 物料脱离store依赖 (#312)

This commit is contained in:
dayou 2024-06-28 17:09:00 +08:00 committed by GitHub
parent d6dc68429a
commit 39b6b1a53f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 24 deletions

View File

@ -109,13 +109,13 @@ export default defineComponent({
<EditOptions <EditOptions
moduleConfig={props.moduleConfig} moduleConfig={props.moduleConfig}
editConfigure={questionMeta?.editConfigure} editConfigure={questionMeta?.editConfigure}
onChange={this.onChange}
> >
<dynamicComponent <dynamicComponent
readonly readonly
{...props} {...props}
onBlur={this.onBlur} onBlur={this.onBlur}
onFocus={this.onFocus} onFocus={this.onFocus}
change={this.onChange}
/> />
</EditOptions> </EditOptions>
) : ( ) : (
@ -124,7 +124,6 @@ export default defineComponent({
{...props} {...props}
onBlur={this.onBlur} onBlur={this.onBlur}
onFocus={this.onFocus} onFocus={this.onFocus}
change={this.onChange}
/> />
)} )}
</div> </div>

View File

@ -43,7 +43,6 @@
</template> </template>
<script> <script>
import { get as _get } from 'lodash-es' import { get as _get } from 'lodash-es'
import { mapGetters } from 'vuex'
export default { export default {
props: { props: {
min: { min: {
@ -80,9 +79,6 @@ export default {
this.initRange() this.initRange()
}, },
computed: { computed: {
...mapGetters({
currentEditKey: 'edit/currentEditKey'
}),
innerVisible: { innerVisible: {
get() { get() {
return this.visible return this.visible
@ -119,9 +115,8 @@ export default {
explain: item.explain explain: item.explain
} }
} }
const paramsKey = `rangeConfig`
const payload = { const payload = {
key: `${this.currentEditKey}.${paramsKey}`, key: `rangeConfig`,
value: res value: res
} }
this.$emit('confirm', payload) this.$emit('confirm', payload)

View File

@ -39,17 +39,11 @@
<script> <script>
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
import { mapGetters } from 'vuex'
import { cloneDeep as _cloneDeep } from 'lodash-es' import { cloneDeep as _cloneDeep } from 'lodash-es'
import RichEditor from '@/common/Editor/RichEditor.vue' import RichEditor from '@/common/Editor/RichEditor.vue'
export default { export default {
name: 'OptionEdit', name: 'OptionEdit',
computed: {
...mapGetters({
currentEditKey: 'edit/currentEditKey'
})
},
props: { props: {
optionList: { optionList: {
type: Array, type: Array,
@ -93,7 +87,7 @@ export default {
handleChange(index, value) { handleChange(index, value) {
// //
const optionKey = `options[${index}].text` const optionKey = `options[${index}].text`
const key = `${this.currentEditKey}.${optionKey}` const key = `${optionKey}`
this.$emit('change', { key, value }) this.$emit('change', { key, value })
}, },
onAddOption(index) { onAddOption(index) {

View File

@ -1,7 +1,5 @@
import { defineComponent, ref, computed, onMounted } from 'vue' import { defineComponent, ref, computed, onMounted } from 'vue'
import store from '@/management/store'
import OptionEdit from './Options/OptionEdit.vue' import OptionEdit from './Options/OptionEdit.vue'
import OptionEditBar from './Options/OptionEditBar.vue' import OptionEditBar from './Options/OptionEditBar.vue'
import UseOptionBase from './Options/UseOptionBase' import UseOptionBase from './Options/UseOptionBase'
@ -10,7 +8,6 @@ export default defineComponent({
name: 'EditOptions', name: 'EditOptions',
provide() { provide() {
return { return {
currentEditKey: store.getters['edit/currentEditKey'],
moduleConfig: computed(() => this.moduleConfig) moduleConfig: computed(() => this.moduleConfig)
} }
}, },
@ -24,10 +21,7 @@ export default defineComponent({
required: true required: true
} }
}, },
setup(props, { slots }) { setup(props, { slots, emit }) {
const currentEditKey = computed(() => {
return store.getters['edit/currentEditKey']
})
const getOptions = computed(() => { const getOptions = computed(() => {
return props.moduleConfig.options return props.moduleConfig.options
}) })
@ -44,12 +38,12 @@ export default defineComponent({
const handleOptionChange = (value) => { const handleOptionChange = (value) => {
const optionKey = `options` const optionKey = `options`
const key = `${currentEditKey.value}.${optionKey}` const key = `${optionKey}`
handleChange({ key, value }) handleChange({ key, value })
} }
const handleChange = ({ key, value }) => { const handleChange = ({ key, value }) => {
store.dispatch('edit/changeSchema', { key, value }) emit('change', { key, value })
} }
const hasAdvancedConfig = ref(false) const hasAdvancedConfig = ref(false)