feat: 🚀 远程搜索下拉框
This commit is contained in:
@@ -108,17 +108,6 @@
|
|||||||
>
|
>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template v-if="item.type === 'radio1'">
|
|
||||||
<el-radio-group v-model="_ruleForm[`${item.prop}`]">
|
|
||||||
<el-radio
|
|
||||||
:value="option.value"
|
|
||||||
:label="option.value"
|
|
||||||
v-for="(option, optionIndex) in item.options"
|
|
||||||
:key="optionIndex"
|
|
||||||
>{{ option.label }}</el-radio
|
|
||||||
>
|
|
||||||
</el-radio-group>
|
|
||||||
</template> -->
|
|
||||||
<template v-if="item.type === 'upImg'">
|
<template v-if="item.type === 'upImg'">
|
||||||
<UploadImg v-model:image-url="_ruleForm[`${item.prop}`]">
|
<UploadImg v-model:image-url="_ruleForm[`${item.prop}`]">
|
||||||
<template #tip>
|
<template #tip>
|
||||||
@@ -149,6 +138,39 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="item.type === 'selectRemote'">
|
||||||
|
<el-select
|
||||||
|
v-model="_ruleForm[`${item.prop}`]"
|
||||||
|
:placeholder="item.placeholder"
|
||||||
|
clearable
|
||||||
|
remote
|
||||||
|
filterable
|
||||||
|
multiple
|
||||||
|
:debounce="400"
|
||||||
|
@clear="handleClear(item)"
|
||||||
|
class="m-2 select"
|
||||||
|
remote-show-suffix
|
||||||
|
:remote-method="
|
||||||
|
(query:any) => {
|
||||||
|
remoteMethod(
|
||||||
|
query,
|
||||||
|
item
|
||||||
|
);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
:disabled="item.disabled"
|
||||||
|
style="width: 444px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
:label="option.name"
|
||||||
|
:value="option.value"
|
||||||
|
v-for="option in item.options"
|
||||||
|
:key="option.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<!--item.prop -->
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-if="item.type === 'selectMultiple'">
|
<template v-if="item.type === 'selectMultiple'">
|
||||||
<el-select
|
<el-select
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
@@ -174,6 +196,7 @@
|
|||||||
:data="item.options"
|
:data="item.options"
|
||||||
:placeholder="item.placeholder"
|
:placeholder="item.placeholder"
|
||||||
:render-after-expand="false"
|
:render-after-expand="false"
|
||||||
|
multiple
|
||||||
show-checkbox
|
show-checkbox
|
||||||
check-strictly
|
check-strictly
|
||||||
@change="handleSelectChange(_ruleForm[`${item.prop}`], item.prop)"
|
@change="handleSelectChange(_ruleForm[`${item.prop}`], item.prop)"
|
||||||
@@ -219,6 +242,7 @@ interface IProps {
|
|||||||
handleSelectChangeEmits?: () => void;
|
handleSelectChangeEmits?: () => void;
|
||||||
handleRadioGroupEmits?: () => void;
|
handleRadioGroupEmits?: () => void;
|
||||||
handleTreesSelectChangeEmits?: () => void;
|
handleTreesSelectChangeEmits?: () => void;
|
||||||
|
handleSelectRometeEmits?: () => void;
|
||||||
}
|
}
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
(e: "handleInputButton", result?: Record<string, any>): void;
|
(e: "handleInputButton", result?: Record<string, any>): void;
|
||||||
@@ -226,6 +250,7 @@ const emits = defineEmits<{
|
|||||||
(e: "handleSelectChangeEmits", result?: Record<string, any>): void;
|
(e: "handleSelectChangeEmits", result?: Record<string, any>): void;
|
||||||
(e: "handleRadioGroupEmits", result?: any): void;
|
(e: "handleRadioGroupEmits", result?: any): void;
|
||||||
(e: "handleTreesSelectChangeEmits", result?: any): void;
|
(e: "handleTreesSelectChangeEmits", result?: any): void;
|
||||||
|
(e: "handleSelectRometeEmits", result?: any): void;
|
||||||
}>();
|
}>();
|
||||||
const editorRef = ref<any>(null);
|
const editorRef = ref<any>(null);
|
||||||
const ruleFormRef = ref<FormInstance>();
|
const ruleFormRef = ref<FormInstance>();
|
||||||
@@ -250,6 +275,14 @@ const handleSelectChange = (params: any, prop: any) => {
|
|||||||
const handleRadioGroup = (value: any) => {
|
const handleRadioGroup = (value: any) => {
|
||||||
emits("handleRadioGroupEmits", value);
|
emits("handleRadioGroupEmits", value);
|
||||||
};
|
};
|
||||||
|
const handleClear = (item: any) => {
|
||||||
|
item.options = [];
|
||||||
|
};
|
||||||
|
//远程搜索(供应商)
|
||||||
|
const remoteMethod = async (query: any, item: any) => {
|
||||||
|
emits("handleSelectRometeEmits", { query, item });
|
||||||
|
console.log(query, item);
|
||||||
|
};
|
||||||
// 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
|
// 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
|
||||||
defineExpose({
|
defineExpose({
|
||||||
ruleForm: _ruleForm,
|
ruleForm: _ruleForm,
|
||||||
|
|||||||
@@ -80,12 +80,14 @@ export const COLUMNS = [
|
|||||||
{
|
{
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "创建时间",
|
label: "创建时间",
|
||||||
prop: "created_at"
|
prop: "created_at",
|
||||||
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "更新时间",
|
label: "更新时间",
|
||||||
prop: "updated_at"
|
prop: "updated_at",
|
||||||
|
width: 160
|
||||||
},
|
},
|
||||||
|
|
||||||
{ prop: "operation", label: "操作", fixed: "right", width: 200 }
|
{ prop: "operation", label: "操作", fixed: "right", width: 200 }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export const FORM_DATA_LV1: any[] = [
|
|||||||
{
|
{
|
||||||
prop: "compat_id",
|
prop: "compat_id",
|
||||||
placeholder: "请输入",
|
placeholder: "请输入",
|
||||||
type: "selectMultiple",
|
type: "selectRemote",
|
||||||
label: "关联标签: ",
|
label: "关联标签: ",
|
||||||
options: []
|
options: []
|
||||||
},
|
},
|
||||||
@@ -36,8 +36,9 @@ export const FORM_DATA_LV2: any[] = [
|
|||||||
{
|
{
|
||||||
prop: "compat_id",
|
prop: "compat_id",
|
||||||
placeholder: "请输入",
|
placeholder: "请输入",
|
||||||
type: "selectMultiple",
|
type: "selectRemote",
|
||||||
label: "关联标签: "
|
label: "关联标签: ",
|
||||||
|
options: []
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
:formData="dataStore.formData"
|
:formData="dataStore.formData"
|
||||||
:rules="dataStore.rules"
|
:rules="dataStore.rules"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
|
@handleSelectRometeEmits="handleSelectRometeEmits"
|
||||||
@handleRadioGroupEmits="handleRadioGroupEmits"
|
@handleRadioGroupEmits="handleRadioGroupEmits"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
@@ -159,15 +160,18 @@ const getProductCategoryList = async () => {
|
|||||||
getProductCategoryList();
|
getProductCategoryList();
|
||||||
|
|
||||||
//兼容性信息(后端大佬说直接掉列表接口)
|
//兼容性信息(后端大佬说直接掉列表接口)
|
||||||
const getProductCompatibilityList = async () => {
|
const getProductCompatibilityList = async (label_name: any) => {
|
||||||
const result = await getProductCompatibilityListApi({ is_show: 1 });
|
if (!label_name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await getProductCompatibilityListApi({ is_show: 1, page: 1, size: 50, label_name });
|
||||||
if (result?.code === 0) {
|
if (result?.code === 0) {
|
||||||
let arr: any[] = [];
|
let arr: any[] = [];
|
||||||
if (result?.data?.data?.length) {
|
if (result?.data?.data?.length) {
|
||||||
result?.data?.data?.forEach((item: any) => {
|
result?.data?.data?.forEach((item: any) => {
|
||||||
let obj = {
|
let obj = {
|
||||||
value: item.id,
|
value: item.id,
|
||||||
label: item.label_name
|
name: item.label_name
|
||||||
};
|
};
|
||||||
arr.push(obj);
|
arr.push(obj);
|
||||||
});
|
});
|
||||||
@@ -176,7 +180,6 @@ const getProductCompatibilityList = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getProductCompatibilityList();
|
|
||||||
|
|
||||||
//相关信息及行远程搜索下拉框点击
|
//相关信息及行远程搜索下拉框点击
|
||||||
const handleRemoteClick = (params: any) => {
|
const handleRemoteClick = (params: any) => {
|
||||||
@@ -216,11 +219,15 @@ const handleRadioGroupEmits = (params: any) => {
|
|||||||
dataStore.formData = cloneDeep(FORM_DATA_LV2);
|
dataStore.formData = cloneDeep(FORM_DATA_LV2);
|
||||||
dataStore.rules = cloneDeep(RULES_LV2);
|
dataStore.rules = cloneDeep(RULES_LV2);
|
||||||
} else {
|
} else {
|
||||||
dataStore.ruleForm.className = "";
|
dataStore.ruleForm.series_name = "";
|
||||||
dataStore.formData = cloneDeep(FORM_DATA_LV1);
|
dataStore.formData = cloneDeep(FORM_DATA_LV1);
|
||||||
dataStore.rules = cloneDeep(RULES_LV1);
|
dataStore.rules = cloneDeep(RULES_LV1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleSelectRometeEmits = (params: any) => {
|
||||||
|
console.log(params.query, "=============params=========");
|
||||||
|
getProductCompatibilityList(params.query);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -92,17 +92,26 @@ export const initDetailParams = (dataStore: any, data: any, editorRef: any) => {
|
|||||||
if (data.compat.length) {
|
if (data.compat.length) {
|
||||||
dataStore.ruleForm = data.compat[0];
|
dataStore.ruleForm = data.compat[0];
|
||||||
let ids: any[] = [];
|
let ids: any[] = [];
|
||||||
|
let options: any[] = [];
|
||||||
dataStore.ruleForm?.compat.forEach((item: any) => {
|
dataStore.ruleForm?.compat.forEach((item: any) => {
|
||||||
ids.push(item.compat_id);
|
ids.push(item.compat_id);
|
||||||
|
options.push({
|
||||||
|
value: item.compat_id,
|
||||||
|
name: item.label_name
|
||||||
|
});
|
||||||
});
|
});
|
||||||
dataStore.ruleForm.compat_id = ids;
|
dataStore.ruleForm.compat_id = ids;
|
||||||
|
//
|
||||||
|
console.log(options, "===options===");
|
||||||
if (dataStore.ruleForm.show_series_name === 1) {
|
if (dataStore.ruleForm.show_series_name === 1) {
|
||||||
dataStore.formData = cloneDeep(FORM_DATA_LV2);
|
dataStore.formData = cloneDeep(FORM_DATA_LV2);
|
||||||
dataStore.rules = cloneDeep(RULES_LV2);
|
dataStore.rules = cloneDeep(RULES_LV2);
|
||||||
|
dataStore.formData[0].options = options;
|
||||||
} else {
|
} else {
|
||||||
dataStore.ruleForm.className = "";
|
dataStore.ruleForm.series_name = "";
|
||||||
dataStore.formData = cloneDeep(FORM_DATA_LV1);
|
dataStore.formData = cloneDeep(FORM_DATA_LV1);
|
||||||
dataStore.rules = cloneDeep(RULES_LV1);
|
dataStore.rules = cloneDeep(RULES_LV1);
|
||||||
|
dataStore.formData[0].options = options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user