select.js 485 Bytes
/**
 * 传入 存放 options的数组, 把所有 第一项 不是 "" 的, 添加第一项, 然后设置 label为 全部
 * @param {*} list 存放 options的数组
 */
export function setAllOptions(list) {
	list.forEach((item, index) => {
		if (item.type === "select") {
			if (item.optionList.length && item.optionList[0][item.optionLabel] !== "全部") {
				item.optionList.unshift({
					[item.optionId]: "",
					[item.optionLabel]: "全部",
				});
			}
		}
	});
	return list;
}