bugfix: 编辑时无法回显用户邮箱
This commit is contained in:
@@ -245,7 +245,7 @@
|
|||||||
Admin Account:
|
Admin Account:
|
||||||
<span>*</span>
|
<span>*</span>
|
||||||
</span>
|
</span>
|
||||||
<SelectUser v-model="formState.adminAccId" labelKey="email" />
|
<SelectUser ref="userRef" v-model="formState.adminAccId" labelKey="email" />
|
||||||
</div>
|
</div>
|
||||||
<div class="admin_state_item">
|
<div class="admin_state_item">
|
||||||
<span>
|
<span>
|
||||||
@@ -403,8 +403,6 @@ import type { FormInstance, Rule } from 'ant-design-vue/es/form'
|
|||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import dayjs, { Dayjs } from 'dayjs'
|
import dayjs, { Dayjs } from 'dayjs'
|
||||||
|
|
||||||
const testuser = ref('')
|
|
||||||
|
|
||||||
type PlanStatus = 'PENDING' | 'ACTIVE' | 'EXPIRED'
|
type PlanStatus = 'PENDING' | 'ACTIVE' | 'EXPIRED'
|
||||||
interface SubscriptionPlan {
|
interface SubscriptionPlan {
|
||||||
id: number
|
id: number
|
||||||
@@ -425,6 +423,7 @@ const disabledDate = (current: Dayjs) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const countryList = ref([])
|
const countryList = ref([])
|
||||||
|
const userRef = ref(null)
|
||||||
|
|
||||||
const searchForm = reactive({
|
const searchForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
@@ -667,7 +666,6 @@ const openEdit = (record: SubscriptionPlan) => {
|
|||||||
String(org.id) === String(record.organizationId)
|
String(org.id) === String(record.organizationId)
|
||||||
)
|
)
|
||||||
if (!orgExists) {
|
if (!orgExists) {
|
||||||
// 从表格数据中获取组织名称,如果存在则添加临时项
|
|
||||||
const orgName = (record as any).organizationName
|
const orgName = (record as any).organizationName
|
||||||
if (orgName) {
|
if (orgName) {
|
||||||
organizationOptions.value = [
|
organizationOptions.value = [
|
||||||
@@ -680,6 +678,16 @@ const openEdit = (record: SubscriptionPlan) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (record.adminAccId) {
|
||||||
|
console.log(userRef.value)
|
||||||
|
nextTick(() => {
|
||||||
|
userRef.value.patchList({
|
||||||
|
label: record.name,
|
||||||
|
value: record.adminAccId,
|
||||||
|
email: record.adminAccEmail
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
modalVisible.value = true
|
modalVisible.value = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, reactive } from 'vue'
|
import { computed, ref, reactive ,defineExpose} from 'vue'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import { Https } from '@/tool/https'
|
import { Https } from '@/tool/https'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
@@ -94,6 +94,21 @@ const doFetch = async (reset = false) => {
|
|||||||
})
|
})
|
||||||
const data = res?.data
|
const data = res?.data
|
||||||
pager.hasMore = res?.hasMore
|
pager.hasMore = res?.hasMore
|
||||||
|
if (tempItem.value.value) {
|
||||||
|
const exists = data.find(
|
||||||
|
it =>
|
||||||
|
(props.valueKey ? it[props.valueKey] : it.value) ===
|
||||||
|
(props.valueKey ? tempItem.value[props.valueKey] : tempItem.value.value)
|
||||||
|
)
|
||||||
|
if (!!exists) {
|
||||||
|
// 如果存在,用data中的新数据覆盖internalList中的旧数据
|
||||||
|
const index = internalList.value.indexOf(tempItem.value)
|
||||||
|
const existsIndex = data.indexOf(exists)
|
||||||
|
internalList.value[index] = { ...exists }
|
||||||
|
data.splice(existsIndex, 1)
|
||||||
|
tempItem.value = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (pager.page === 1) internalList.value = data
|
if (pager.page === 1) internalList.value = data
|
||||||
else internalList.value = internalList.value.concat(data)
|
else internalList.value = internalList.value.concat(data)
|
||||||
pager.page += 1
|
pager.page += 1
|
||||||
@@ -129,6 +144,24 @@ const handleFocus = () => {
|
|||||||
const onChange = (val: any) => {
|
const onChange = (val: any) => {
|
||||||
emit('change', val)
|
emit('change', val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解决回显时没有加载对应选项的问题
|
||||||
|
const tempItem = ref({})
|
||||||
|
const patchList = item => {
|
||||||
|
const exists = internalList.value.find(
|
||||||
|
it =>
|
||||||
|
(props.valueKey ? it[props.valueKey] : it.value) ===
|
||||||
|
(props.valueKey ? item[props.valueKey] : item.value)
|
||||||
|
)
|
||||||
|
if (!exists) {
|
||||||
|
internalList.value.unshift({ ...item, temp: true })
|
||||||
|
tempItem.value = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
patchList
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user