|
@@ -1810,6 +1810,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
type: String,
|
|
type: String,
|
|
|
default: "1",
|
|
default: "1",
|
|
|
},
|
|
},
|
|
|
|
|
+ inp: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false,
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
//级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
|
|
//级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
|
|
|
param: {
|
|
param: {
|
|
@@ -1825,6 +1829,13 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
emits: ["update:modelValue", "change"],
|
|
emits: ["update:modelValue", "change"],
|
|
|
|
|
|
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
|
|
+ const canInput = props.inp === true;
|
|
|
|
|
+ const inputText = Vue.ref("");
|
|
|
|
|
+ const filteredOptions = Vue.ref(props.opt);
|
|
|
|
|
+ const visibleOptions = Vue.computed(() =>
|
|
|
|
|
+ canInput ? filteredOptions.value : props.opt
|
|
|
|
|
+ );
|
|
|
|
|
+ let inputRequestId = 0;
|
|
|
// alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
|
|
// alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
|
|
|
const selectItem = Vue.ref({ label: props.placeholder, value: "" });
|
|
const selectItem = Vue.ref({ label: props.placeholder, value: "" });
|
|
|
const popupWinVisible = Vue.ref(false);
|
|
const popupWinVisible = Vue.ref(false);
|
|
@@ -1866,6 +1877,8 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
selectItem.value = ""; //清除本下拉菜单当前选中的值
|
|
selectItem.value = ""; //清除本下拉菜单当前选中的值
|
|
|
|
|
+ inputText.value = "";
|
|
|
|
|
+ filteredOptions.value = props.opt;
|
|
|
emit("update:modelValue", ""); //通知父级
|
|
emit("update:modelValue", ""); //通知父级
|
|
|
|
|
|
|
|
//清空下拉菜单,并设置第一项的值为placeholder
|
|
//清空下拉菜单,并设置第一项的值为placeholder
|
|
@@ -1992,9 +2005,21 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
return { valid: true };
|
|
return { valid: true };
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const updateSelectItem = () => {
|
|
|
|
|
+ const item = props.opt.find((it) => it.value === props.modelValue);
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ selectItem.value = item;
|
|
|
|
|
+ inputText.value = item.label;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ selectItem.value = { label: "", value: "" };
|
|
|
|
|
+ inputText.value = "";
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// 处理选择事件
|
|
// 处理选择事件
|
|
|
const doSelectItem = (item) => {
|
|
const doSelectItem = (item) => {
|
|
|
selectItem.value = item;
|
|
selectItem.value = item;
|
|
|
|
|
+ inputText.value = item.label;
|
|
|
emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
|
|
emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
|
|
|
|
|
|
|
|
// alert('item.value:'+item.value);
|
|
// alert('item.value:'+item.value);
|
|
@@ -2251,6 +2276,8 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
upperValue.value = "";
|
|
upperValue.value = "";
|
|
|
|
|
|
|
|
selectItem.value = ""; //清除本下拉菜单当前选中的值
|
|
selectItem.value = ""; //清除本下拉菜单当前选中的值
|
|
|
|
|
+ inputText.value = "";
|
|
|
|
|
+ filteredOptions.value = props.opt;
|
|
|
emit("update:modelValue", ""); //通知父级
|
|
emit("update:modelValue", ""); //通知父级
|
|
|
|
|
|
|
|
//清空所有下拉菜单项
|
|
//清空所有下拉菜单项
|
|
@@ -2394,11 +2421,107 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
const matchedOption = props.opt.find((opt) => opt.value === value);
|
|
const matchedOption = props.opt.find((opt) => opt.value === value);
|
|
|
if (matchedOption) {
|
|
if (matchedOption) {
|
|
|
selectItem.value = matchedOption;
|
|
selectItem.value = matchedOption;
|
|
|
|
|
+ inputText.value = matchedOption.label;
|
|
|
emit("update:modelValue", value);
|
|
emit("update:modelValue", value);
|
|
|
emit("change", value);
|
|
emit("change", value);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ async function updateOptionBYInputText(inputValue) {
|
|
|
|
|
+ const pickerParam = Array.isArray(props.param)
|
|
|
|
|
+ ? props.param[props.param.length - 1]
|
|
|
|
|
+ : props.param;
|
|
|
|
|
+ if (!props.url || !pickerParam || !pickerParam.codebook) return;
|
|
|
|
|
+
|
|
|
|
|
+ const requestId = ++inputRequestId;
|
|
|
|
|
+ const searchText = inputValue || "";
|
|
|
|
|
+ const searchAll = searchText.trim().length === 0;
|
|
|
|
|
+ let url = props.url;
|
|
|
|
|
+ const filterObj = {
|
|
|
|
|
+ ...(pickerParam.filter && typeof pickerParam.filter === "object"
|
|
|
|
|
+ ? pickerParam.filter
|
|
|
|
|
+ : {}),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ Object.keys(filterObj).forEach((key) => {
|
|
|
|
|
+ url += "&" + key + "=" + encodeURIComponent(filterObj[key]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (pickerParam.filterfield) {
|
|
|
|
|
+ const filterFields = String(pickerParam.filterfield).split(",");
|
|
|
|
|
+ filterFields.forEach((fieldName) => {
|
|
|
|
|
+ const fields = document.getElementsByName(fieldName);
|
|
|
|
|
+ if (!fields || fields.length < 1) {
|
|
|
|
|
+ console.warn("下拉菜单配置的过滤条件" + fieldName + "不存在");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const field = Array.from(fields).find((item) => item.value);
|
|
|
|
|
+ if (field) {
|
|
|
|
|
+ url += "&" + fieldName + "=" + encodeURIComponent(field.value);
|
|
|
|
|
+ filterObj[fieldName] = field.value;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const objectPickerParam = {
|
|
|
|
|
+ ...filterObj,
|
|
|
|
|
+ input: props.inp,
|
|
|
|
|
+ codebook: pickerParam.codebook,
|
|
|
|
|
+ cascadingLevel: Array.isArray(pickerParam.fieldOrd)
|
|
|
|
|
+ ? pickerParam.fieldOrd.join(",")
|
|
|
|
|
+ : pickerParam.fieldOrd || "",
|
|
|
|
|
+ name: props.name,
|
|
|
|
|
+ cascadingName: pickerParam.name,
|
|
|
|
|
+ };
|
|
|
|
|
+ if (pickerParam.combField) {
|
|
|
|
|
+ objectPickerParam.cascadingInputsName = pickerParam.combField;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const params = new URLSearchParams();
|
|
|
|
|
+ params.append("objectpickerparam", JSON.stringify(objectPickerParam));
|
|
|
|
|
+ params.append("objectpickertype", "1");
|
|
|
|
|
+ params.append("objectpickersearchAll", searchAll ? "1" : "0");
|
|
|
|
|
+ params.append("objectpickerinput", searchAll ? "" : searchText);
|
|
|
|
|
+ if (!searchAll) {
|
|
|
|
|
+ url += "&objectpickerinput=" + encodeURIComponent(searchText);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (upperValue.value) {
|
|
|
|
|
+ params.append("upperValue", upperValue.value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const response = await axios.post(url, params, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded",
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ if (requestId !== inputRequestId) return;
|
|
|
|
|
+ if (response.data.statusText === "timeout") {
|
|
|
|
|
+ alert("网络超时!");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const normalizedResult = normalizeCcpResult(response.data.result);
|
|
|
|
|
+ props.opt.length = 0;
|
|
|
|
|
+ normalizedResult.forEach((option) => props.opt.push(option));
|
|
|
|
|
+
|
|
|
|
|
+ const matchedOptions = searchAll
|
|
|
|
|
+ ? normalizedResult
|
|
|
|
|
+ : normalizedResult.filter((option) =>
|
|
|
|
|
+ String(option.label)
|
|
|
|
|
+ .toLowerCase()
|
|
|
|
|
+ .includes(searchText.toLowerCase())
|
|
|
|
|
+ );
|
|
|
|
|
+ filteredOptions.value = matchedOptions.length
|
|
|
|
|
+ ? [{ label: "", value: "" }, ...matchedOptions]
|
|
|
|
|
+ : [];
|
|
|
|
|
+ openPopup();
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("[SsCcp] 输入筛选失败:", error);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 计算弹出方向和最大高度的方法 by xu 20251212
|
|
// 计算弹出方向和最大高度的方法 by xu 20251212
|
|
|
// 当空间不足时限制popup高度并显示滚动条
|
|
// 当空间不足时限制popup高度并显示滚动条
|
|
|
const calculatePopupDirection = () => {
|
|
const calculatePopupDirection = () => {
|
|
@@ -2564,6 +2687,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
|
|
|
|
|
//级联菜单点击事件
|
|
//级联菜单点击事件
|
|
|
const togglePopup = () => {
|
|
const togglePopup = () => {
|
|
|
|
|
+ if (canInput) {
|
|
|
|
|
+ updateOptionBYInputText(inputText.value);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (!popupWinVisible.value) {
|
|
if (!popupWinVisible.value) {
|
|
|
//如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
|
|
//如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
|
|
|
|
|
|
|
@@ -2576,6 +2703,7 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
//显示下拉菜单,在此之前先清除下拉菜单项
|
|
//显示下拉菜单,在此之前先清除下拉菜单项
|
|
|
const showPopup = () => {
|
|
const showPopup = () => {
|
|
|
//清空下拉菜单,并设置第一项的值为空
|
|
//清空下拉菜单,并设置第一项的值为空
|
|
|
|
|
+ if (canInput) filteredOptions.value = props.opt;
|
|
|
clearAndInit1stOpt();
|
|
clearAndInit1stOpt();
|
|
|
Vue.nextTick(() => {
|
|
Vue.nextTick(() => {
|
|
|
calculatePopupDirection();
|
|
calculatePopupDirection();
|
|
@@ -2785,6 +2913,23 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
popupWinVisible.value = false;
|
|
popupWinVisible.value = false;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const suffixClick = () => {
|
|
|
|
|
+ if (popupWinVisible.value) {
|
|
|
|
|
+ hidePopup();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (canInput) {
|
|
|
|
|
+ updateOptionBYInputText("");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showPopup();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleInputChange = (event) => {
|
|
|
|
|
+ inputText.value = event.target.value || "";
|
|
|
|
|
+ updateOptionBYInputText(inputText.value);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// 合并所有的 onMounted 逻辑
|
|
// 合并所有的 onMounted 逻辑
|
|
|
Vue.onMounted(() => {
|
|
Vue.onMounted(() => {
|
|
|
window.addEventListener("resize", handleViewportChange);
|
|
window.addEventListener("resize", handleViewportChange);
|
|
@@ -2831,6 +2976,7 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
);
|
|
);
|
|
|
if (matchedOption) {
|
|
if (matchedOption) {
|
|
|
selectItem.value = matchedOption;
|
|
selectItem.value = matchedOption;
|
|
|
|
|
+ inputText.value = matchedOption.label;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -2839,8 +2985,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
const item = props.opt.find((it) => it.value === newVal);
|
|
const item = props.opt.find((it) => it.value === newVal);
|
|
|
if (item) {
|
|
if (item) {
|
|
|
selectItem.value = item;
|
|
selectItem.value = item;
|
|
|
|
|
+ inputText.value = item.label;
|
|
|
} else {
|
|
} else {
|
|
|
selectItem.value = { label: "", value: "" };
|
|
selectItem.value = { label: "", value: "" };
|
|
|
|
|
+ inputText.value = "";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -2880,6 +3028,11 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
popupRef,
|
|
popupRef,
|
|
|
teleportRootStyle,
|
|
teleportRootStyle,
|
|
|
popupLayerStyle,
|
|
popupLayerStyle,
|
|
|
|
|
+ canInput,
|
|
|
|
|
+ inputText,
|
|
|
|
|
+ visibleOptions,
|
|
|
|
|
+ suffixClick,
|
|
|
|
|
+ handleInputChange,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -2894,12 +3047,19 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
:value="selectItem.value"
|
|
:value="selectItem.value"
|
|
|
/>
|
|
/>
|
|
|
<input
|
|
<input
|
|
|
|
|
+ v-if="canInput"
|
|
|
|
|
+ v-model="inputText"
|
|
|
|
|
+ @input="handleInputChange"
|
|
|
|
|
+ :placeholder="placeholder"
|
|
|
|
|
+ />
|
|
|
|
|
+ <input
|
|
|
|
|
+ v-else
|
|
|
:placeholder="placeholder"
|
|
:placeholder="placeholder"
|
|
|
:value="selectItem.label"
|
|
:value="selectItem.label"
|
|
|
disabled
|
|
disabled
|
|
|
style="pointer-events: none;"
|
|
style="pointer-events: none;"
|
|
|
/>
|
|
/>
|
|
|
- <div class="suffix">
|
|
|
|
|
|
|
+ <div class="suffix" @click.stop="suffixClick">
|
|
|
<ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
|
|
<ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -2917,10 +3077,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
class="popup-win"
|
|
class="popup-win"
|
|
|
:style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }]"
|
|
:style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }]"
|
|
|
>
|
|
>
|
|
|
- <div v-if="opt && opt.length > 0" class="popup-content">
|
|
|
|
|
|
|
+ <div v-if="visibleOptions && visibleOptions.length > 0" class="popup-content">
|
|
|
<div class="content-area">
|
|
<div class="content-area">
|
|
|
<div
|
|
<div
|
|
|
- v-for="(item, index) in opt"
|
|
|
|
|
|
|
+ v-for="(item, index) in visibleOptions"
|
|
|
:key="index"
|
|
:key="index"
|
|
|
@click="doSelectItem(item)"
|
|
@click="doSelectItem(item)"
|
|
|
:class="{ active: item.value === selectItem.value }"
|
|
:class="{ active: item.value === selectItem.value }"
|