UNPKG

@wocwin/t-ui-plus

Version:

Page level components developed based on Element Plus.

91 lines (88 loc) 2.15 kB
import { computed } from 'vue'; function useComputed() { const compChildName = computed(() => { return (opt) => { switch (opt.type) { case "checkbox": return "el-checkbox"; case "radio": return "el-radio"; case "select-arr": case "select-obj": return "el-option"; } }; }); const selectListType = computed(() => { return (opt) => { if (opt.listTypeInfo) { return opt.listTypeInfo[opt.list]; } else { return []; } }; }); const compChildLabel = computed(() => { return (opt, value) => { switch (opt.type) { case "radio": case "checkbox": return value[opt.arrLabel || "label"]; case "el-select-multiple": case "select-arr": return value[opt.arrLabel || "label"]; case "select-obj": return value; } }; }); const compChildValue = computed(() => { return (opt, value, key) => { switch (opt.type) { case "radio": case "checkbox": return value[opt.arrKey || "key"]; case "el-select-multiple": case "select-arr": return value[opt.arrKey || "key"]; case "select-obj": return key; } }; }); const compChildShowLabel = computed(() => { return (opt, value) => { switch (opt.type) { case "radio": case "checkbox": return value[opt.arrLabel || "label"]; case "el-select-multiple": case "select-arr": return value[opt.arrLabel || "label"]; case "select-obj": return value; } }; }); const getColLength = () => { const width = window.innerWidth; let colLength = 4; if (width > 1e3 && width < 1280) { colLength = 3; } else if (width > 768 && width <= 1e3) { colLength = 2; } else if (width <= 768) { colLength = 1; } return colLength; }; return { compChildName, selectListType, compChildLabel, compChildValue, compChildShowLabel, getColLength }; } export { useComputed };