提交 34ac7d2d authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 9ff2f106
<script setup lang="ts">
import { useUserAttr, useMetaEvent } from '@/composables/useAllData'
import { searchMetaMemberAttrs } from '@/api/base'
defineProps<{ label: string }>()
const form = defineModel<any>()
......@@ -24,7 +25,7 @@ const defaultScore = [
]
onMounted(() => {
form.value = Object.assign({ basis: '1', rule: '101', event_id: '0', attr_id: '', attr_type: '', config: [...defaultScore] }, form.value)
form.value = Object.assign({ basis: '1', rule: '101', event_id: '-1', attr_id: '', attr_type: '', config: [...defaultScore] }, form.value)
})
const { userAttrList } = useUserAttr()
......@@ -36,9 +37,6 @@ const currentRuleList = computed(() => {
const currentAttrList = computed(() => {
let list = userAttrList.value
if (form.value.basis === '2') {
list = metaEventList.value.find(item => item.id === form.value.event_id)?.event_attrs || []
}
return list.filter(item => {
if (form.value.rule === '101') {
return ['2', '3', '4', '5'].includes(item.type)
......@@ -48,6 +46,9 @@ const currentAttrList = computed(() => {
return true
})
})
const currentMetaEventList = computed(() => {
return [{ id: '-1', name: '全部事件' }, ...metaEventList.value]
})
function handleBasisChange(value: any) {
if (value === '1') {
......@@ -65,11 +66,34 @@ function handleRuleChange(value: any) {
} else {
form.value.config = [...defaultScore]
}
form.value.attr_id = ''
}
function handleAttrChange(value: any) {
form.value.attr_type = currentAttrList.value.find(item => item.id === value)?.type
}
const options = ref<{ label: string; value: string }[]>([])
const loading = ref(false)
async function remoteMethod(search: string = '') {
options.value = []
if (form.value.attr_id) {
loading.value = true
await searchMetaMemberAttrs({ search, member_meta_id: form.value.attr_id, per_page: 100 }).then(res => {
options.value = res.data.list.map((item: any) => {
return { label: item.attr_value, value: item.attr_value }
})
})
loading.value = false
}
}
watch(
() => form.value.attr_id,
() => {
form.value.rule === '102' && remoteMethod()
},
{ immediate: true }
)
</script>
<template>
......@@ -89,9 +113,9 @@ function handleAttrChange(value: any) {
<el-option v-for="item in currentRuleList" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
<el-select v-model="form.event_id" placeholder="选择事件" style="width: 160px" v-if="form.basis === '2'">
<el-option v-for="item in metaEventList" :key="item.id" :label="item.name" :value="item.id"></el-option>
<el-option v-for="item in currentMetaEventList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<el-select v-model="form.attr_id" placeholder="选择属性" style="width: 160px" @change="handleAttrChange">
<el-select v-model="form.attr_id" placeholder="选择属性" style="width: 160px" @change="handleAttrChange" v-else>
<el-option v-for="item in currentAttrList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
......@@ -102,7 +126,9 @@ function handleAttrChange(value: any) {
<b>{{ item.level }}</b>
</div>
<div class="rfm-box-body">
<el-input placeholder="选择属性值" v-model="item.value"></el-input>
<el-select placeholder="选择属性值" v-model="item.value" filterable allow-create :loading="loading">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
</div>
</template>
......
......@@ -37,53 +37,67 @@ export interface ConnectionType {
// 所有用户属性
const userAttrList = ref<AttrType[]>([])
const userAttrLoading = ref(false)
export function useUserAttr() {
function fetchUserAttrList() {
getMetaUserAttrList({ check_role: true }).then((res: any) => {
async function fetchUserAttrList() {
if (userAttrLoading.value) return
userAttrLoading.value = true
await getMetaUserAttrList({ check_role: true }).then((res: any) => {
userAttrList.value = res.data.items
})
userAttrLoading.value = false
}
onMounted(() => {
if (!userAttrList.value?.length) fetchUserAttrList()
})
return { fetchUserAttrList, userAttrList }
return { fetchUserAttrList, userAttrList, userAttrLoading }
}
// 所有事件
const metaEventList = ref<MetaEventType[]>([])
const metaEventLoading = ref(false)
export function useMetaEvent() {
function fetchMetaEventList() {
getMetaEventList({ check_role: true }).then((res: any) => {
async function fetchMetaEventList() {
if (metaEventLoading.value) return
metaEventLoading.value = true
await getMetaEventList({ check_role: true }).then((res: any) => {
metaEventList.value = res.data.items
})
metaEventLoading.value = false
}
onMounted(() => {
if (!metaEventList.value?.length) fetchMetaEventList()
})
return { fetchMetaEventList, metaEventList }
return { fetchMetaEventList, metaEventList, metaEventLoading }
}
// 所有标签
const tagList = ref<TagType[]>([])
const tagLoading = ref(false)
export function useTag() {
function fetchTagList() {
getTagList({ check_role: 1 }).then((res: any) => {
async function fetchTagList() {
if (tagLoading.value) return
tagLoading.value = true
await getTagList({ check_role: 1 }).then((res: any) => {
tagList.value = res.data.items
})
tagLoading.value = false
}
onMounted(() => {
if (!tagList.value?.length) fetchTagList()
})
return { fetchTagList, tagList }
return { fetchTagList, tagList, tagLoading }
}
// 所有连接
const connectionList = ref<ConnectionType[]>([])
const connectionLoading = ref(false)
export function useConnection() {
async function fetchConnectionList() {
if (connectionLoading.value) return
connectionLoading.value = true
const connectionType = useMapStore().getMapValuesByKey('experiment_connection_type')
getConnectionList().then((res: any) => {
await getConnectionList().then((res: any) => {
connectionList.value = res.data.items.map((item: any) => {
const connection = connectionType.find(type => type.value == item.type)
const attrs = typeof item.config_attributes === 'string' ? JSON.parse(item.config_attributes) : item.config_attributes
......@@ -91,11 +105,12 @@ export function useConnection() {
return { ...item, config_attributes: attrs, name, type_name: connection?.label || item.type }
})
})
connectionLoading.value = false
}
onMounted(() => {
if (!connectionList.value?.length) fetchConnectionList()
})
return { fetchConnectionList, connectionList }
return { fetchConnectionList, connectionList, connectionLoading }
}
// 所有成员
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论