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', () => {})
onMounted(() => {
formulaStore.initFormulaList()
registerGrandsonMethods && registerGrandsonMethods({ getFormData })
})
/**
@ -35,7 +36,7 @@ const labelUnitMap: Record<string, any> = formulaStore.labelUnitMap
watchEffect(() => {
formData.value
= formulaStore.selectedFormulaInfo !== null
? convertValuesToInt(formulaStore.selectedFormulaInfo)
? convertValuesToInt(formulaStore.selectedFormulaInfo 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
* @desc
*/
const initFormulaList = async (flag: 'add' | 'edit') => {
const initFormulaList = async (flag?: 'add' | 'edit') => {
try {
const params = {
className: 'SettingMgrService',
@ -197,8 +197,10 @@ export const useFormulaStore = defineStore('formula', () => {
formulaList.value = res.rely
if (res.rely.length > 0) {
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 {
currentSelectedIndex.value = null

Loading…
Cancel
Save