2024-08-20 08:28:51 +00:00
|
|
|
|
<!-- 链接组件 -->
|
2024-08-12 02:18:11 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="flex-row align-c gap-10 br-d radius-sm plr-11 url-value-input" @click="dialogVisible = true">
|
|
|
|
|
|
<div class="flex-1 flex-width size-12 text-line-1">
|
2024-08-20 07:46:49 +00:00
|
|
|
|
<text v-if="!is_obj_empty(modelValue)">{{ modelValue.name || modelValue.title }}</text>
|
2024-08-12 02:18:11 +00:00
|
|
|
|
<text v-else class="cr-9">{{ placeholder }}</text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="value-input-icon">
|
|
|
|
|
|
<template v-if="is_obj_empty(modelValue)">
|
|
|
|
|
|
<icon name="arrow-right" size="12" color="9"></icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<div @click.stop="clear_model_value">
|
|
|
|
|
|
<icon name="close-o" size="12" color="c"></icon>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2024-09-28 05:50:55 +00:00
|
|
|
|
<url-value-dialog v-model:model-value="new_model_value" v-model:dialog-visible="dialogVisible" :select-is-url="true" :type="type" @update:model-value="model_value_call_back"></url-value-dialog>
|
2024-08-12 02:18:11 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import { is_obj_empty } from '@/utils';
|
|
|
|
|
|
const app = getCurrentInstance();
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description: 页面链接
|
|
|
|
|
|
* @param modelValue{Object} 默认值
|
|
|
|
|
|
* @param dialogVisible {Boolean} 弹窗显示
|
|
|
|
|
|
* @param type{String} 链接类型为空数组则表示无限制,全部可用,传过来则表示传的值可用
|
|
|
|
|
|
* @param placeholder{String} 提示文字
|
|
|
|
|
|
* @return {*} update:modelValue
|
|
|
|
|
|
*/
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
type: {
|
|
|
|
|
|
type: Array as PropType<string[]>,
|
|
|
|
|
|
default: () => [],
|
|
|
|
|
|
},
|
|
|
|
|
|
placeholder: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: '请选择链接',
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const modelValue = defineModel({ type: Object, default: {} });
|
2024-08-20 10:25:22 +00:00
|
|
|
|
const new_model_value = ref<any[]>([]);
|
2024-08-20 08:28:51 +00:00
|
|
|
|
const dialogVisible = defineModel('dialogVisible', { type: Boolean, default: false });
|
2024-08-12 02:18:11 +00:00
|
|
|
|
//#endregion 链接清空-------------------------------------------------start
|
|
|
|
|
|
const clear_model_value = () => {
|
|
|
|
|
|
modelValue.value = {};
|
|
|
|
|
|
};
|
|
|
|
|
|
//#endregion 链接清空-------------------------------------------------end
|
2024-08-20 10:25:22 +00:00
|
|
|
|
const model_value_call_back = (value: any[]) => {
|
|
|
|
|
|
if (value.length > 0) {
|
|
|
|
|
|
modelValue.value = JSON.parse(JSON.stringify(value[0]));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2024-08-12 02:18:11 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
@import 'index.scss';
|
|
|
|
|
|
</style>
|