Browse Source

列表不默认选中的bug

master
王梦远 2 weeks ago
parent
commit
6a37b1f5cf
  1. 3
      src/components/formula/HomeFormulaConfig.vue
  2. 8
      src/stores/formulaStore.ts

3
src/components/formula/HomeFormulaConfig.vue

@ -18,6 +18,7 @@ const getFormData = () => {
*/ */
const registerGrandsonMethods = inject<(methods: any) => void>('registerGrandsonMethods', () => {}) const registerGrandsonMethods = inject<(methods: any) => void>('registerGrandsonMethods', () => {})
onMounted(() => { onMounted(() => {
formulaStore.initFormulaList()
registerGrandsonMethods && registerGrandsonMethods({ getFormData }) registerGrandsonMethods && registerGrandsonMethods({ getFormData })
}) })
/** /**
@ -35,7 +36,7 @@ const labelUnitMap: Record<string, any> = formulaStore.labelUnitMap
watchEffect(() => { watchEffect(() => {
formData.value formData.value
= formulaStore.selectedFormulaInfo !== null = formulaStore.selectedFormulaInfo !== null
? convertValuesToInt(formulaStore.selectedFormulaInfo)
? convertValuesToInt(formulaStore.selectedFormulaInfo as Record<string, any>)
: convertValuesToInt(formulaStore.defaultFormulaInfo as Record<string, any>) : convertValuesToInt(formulaStore.defaultFormulaInfo as Record<string, any>)
}) })
/** /**

8
src/stores/formulaStore.ts

@ -185,7 +185,7 @@ export const useFormulaStore = defineStore('formula', () => {
* @function initFormulaList * @function initFormulaList
* @desc * @desc
*/ */
const initFormulaList = async (flag: 'add' | 'edit') => {
const initFormulaList = async (flag?: 'add' | 'edit') => {
try { try {
const params = { const params = {
className: 'SettingMgrService', className: 'SettingMgrService',
@ -197,8 +197,10 @@ export const useFormulaStore = defineStore('formula', () => {
formulaList.value = res.rely formulaList.value = res.rely
if (res.rely.length > 0) { if (res.rely.length > 0) {
console.log('selectedIndex.value--', currentSelectedIndex.value) console.log('selectedIndex.value--', currentSelectedIndex.value)
flag === 'add' && (currentSelectedFormulaInfo.value = res.rely[res.rely.length - 1])
flag === 'add' && (currentSelectedIndex.value = res.rely.length - 1)
if (flag !== 'edit') {
currentSelectedFormulaInfo.value = res.rely[res.rely.length - 1]
currentSelectedIndex.value = res.rely.length - 1
}
} }
else { else {
currentSelectedIndex.value = null currentSelectedIndex.value = null

Loading…
Cancel
Save