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

chore: update

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