acdr-ui/dist/dev/mp-weixin/hooks/useColPickerData.js
2024-10-01 09:15:35 +08:00

25 lines
657 B
JavaScript

"use strict";
const common_vendor = require("../common/vendor.js");
function useColPickerData() {
const colPickerData = common_vendor.useCascaderAreaData();
function findChildrenByCode(data, code) {
if (!code) {
return data;
}
for (const item of data) {
if (item.value === code) {
return item.children || null;
}
if (item.children) {
const childrenResult = findChildrenByCode(item.children, code);
if (childrenResult) {
return childrenResult;
}
}
}
return null;
}
return { colPickerData, findChildrenByCode };
}
exports.useColPickerData = useColPickerData;