UNPKG

@wocwin/t-ui-plus

Version:

Page level components developed based on Element Plus.

224 lines (221 loc) 10.2 kB
import { defineComponent, computed, resolveComponent, createElementBlock, openBlock, Fragment, createCommentVNode, createBlock, normalizeProps, mergeProps, unref, createSlots, withCtx, renderSlot, withModifiers, toDisplayString, renderList } from 'vue'; import '../../../hooks/index.mjs'; import { useLocale } from '../../../hooks/useLocale.mjs'; const _hoisted_1 = { key: 0 }; const _hoisted_2 = { key: 1 }; const _hoisted_3 = { key: 0 }; const _hoisted_4 = { key: 1 }; var _sfc_main = /* @__PURE__ */ defineComponent({ __name: "firstColumn", props: { table: {}, radioVal: {}, align: {}, isPaginationCumulative: { type: Boolean }, isShowPagination: { type: Boolean } }, emits: ["radioChange", "update:radioVal"], setup(__props, { emit: __emit }) { const { t } = useLocale(); const props = __props; const emit = __emit; const localRadio = computed({ get: () => props.radioVal, set: (val) => { emit("update:radioVal", val); } }); const radioHandleChange = (row, index) => { emit("radioChange", row, index); }; return (_ctx, _cache) => { const _component_el_table_column = resolveComponent("el-table-column"); const _component_el_radio = resolveComponent("el-radio"); return openBlock(), createElementBlock( Fragment, null, [ !Array.isArray(_ctx.table.firstColumn) && _ctx.table.firstColumn ? (openBlock(), createElementBlock( Fragment, { key: 0 }, [ _ctx.table.firstColumn.type === "selection" ? (openBlock(), createBlock( _component_el_table_column, normalizeProps(mergeProps({ key: 0 }, { type: "selection", width: _ctx.table.firstColumn.width || 55, label: _ctx.table.firstColumn.label, fixed: _ctx.table.firstColumn.fixed, align: _ctx.table.firstColumn.align || _ctx.align || "center", "reserve-selection": _ctx.table.firstColumn.isPaging || false, selectable: _ctx.table.firstColumn.selectable, ..._ctx.table.firstColumn.bind })), null, 16 /* FULL_PROPS */ )) : (openBlock(), createBlock( _component_el_table_column, normalizeProps(mergeProps({ key: 1 }, { type: _ctx.table.firstColumn.type, width: _ctx.table.firstColumn.width || 55, label: _ctx.table.firstColumn.label || _ctx.table.firstColumn.type === "radio" && unref(t)("plus.table.fistColumn.radio") || _ctx.table.firstColumn.type === "index" && unref(t)("plus.table.fistColumn.label") || _ctx.table.firstColumn.type === "expand" && "" || "", fixed: _ctx.table.firstColumn.fixed, align: _ctx.table.firstColumn.align || _ctx.align || "center", ..._ctx.table.firstColumn.bind })), createSlots({ _: 2 /* DYNAMIC */ }, [ _ctx.table.firstColumn.type !== "selection" ? { name: "default", fn: withCtx((scope) => [ _ctx.table.firstColumn.type === "radio" ? (openBlock(), createBlock(_component_el_radio, { key: 0, modelValue: localRadio.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => localRadio.value = $event), label: scope.$index + 1, disabled: scope.row.isRadioDisabled, onClick: _cache[1] || (_cache[1] = withModifiers(() => { }, ["stop"])), onChange: ($event) => radioHandleChange(scope.row, scope.$index + 1) }, null, 8, ["modelValue", "label", "disabled", "onChange"])) : createCommentVNode("v-if", true), _ctx.table.firstColumn.type === "index" ? (openBlock(), createElementBlock( Fragment, { key: 1 }, [ _ctx.isPaginationCumulative && _ctx.isShowPagination ? (openBlock(), createElementBlock( "span", _hoisted_1, toDisplayString((_ctx.table.currentPage - 1) * _ctx.table.pageSize + scope.$index + 1), 1 /* TEXT */ )) : (openBlock(), createElementBlock( "span", _hoisted_2, toDisplayString(scope.$index + 1), 1 /* TEXT */ )) ], 64 /* STABLE_FRAGMENT */ )) : createCommentVNode("v-if", true), _ctx.table.firstColumn.type === "expand" ? renderSlot(_ctx.$slots, "expand", { key: 2, scope }) : createCommentVNode("v-if", true) ]), key: "0" } : void 0 ]), 1040 /* FULL_PROPS, DYNAMIC_SLOTS */ )) ], 64 /* STABLE_FRAGMENT */ )) : createCommentVNode("v-if", true), Array.isArray(_ctx.table.firstColumn) ? (openBlock(true), createElementBlock( Fragment, { key: 1 }, renderList(_ctx.table.firstColumn, (item, index) => { return openBlock(), createElementBlock( Fragment, null, [ item.type === "selection" ? (openBlock(), createBlock( _component_el_table_column, mergeProps({ key: index + 1 }, { type: "selection", width: item.width || 55, label: item.label, fixed: item.fixed, align: item.align || _ctx.align || "center", "reserve-selection": item.isPaging || false, selectable: item.selectable, ...item.bind }), null, 16 /* FULL_PROPS */ )) : (openBlock(), createBlock( _component_el_table_column, mergeProps({ key: index + "k" }, { type: item.type, width: item.width || 55, label: item.label || item.type === "radio" && unref(t)("plus.table.fistColumn.radio") || item.type === "index" && unref(t)("plus.table.fistColumn.label") || item.type === "expand" && "" || "", fixed: item.fixed, align: item.align || _ctx.align || "center", ...item.bind }), createSlots({ _: 2 /* DYNAMIC */ }, [ item.type !== "selection" ? { name: "default", fn: withCtx((scope) => [ item.type === "radio" ? (openBlock(), createBlock(_component_el_radio, { key: 0, modelValue: localRadio.value, "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => localRadio.value = $event), label: scope.$index + 1, disabled: scope.row.isRadioDisabled, onClick: _cache[3] || (_cache[3] = withModifiers(() => { }, ["stop"])), onChange: ($event) => radioHandleChange(scope.row, scope.$index + 1) }, null, 8, ["modelValue", "label", "disabled", "onChange"])) : createCommentVNode("v-if", true), item.type === "index" ? (openBlock(), createElementBlock( Fragment, { key: 1 }, [ _ctx.isPaginationCumulative && _ctx.isShowPagination ? (openBlock(), createElementBlock( "span", _hoisted_3, toDisplayString((_ctx.table.currentPage - 1) * _ctx.table.pageSize + scope.$index + 1), 1 /* TEXT */ )) : (openBlock(), createElementBlock( "span", _hoisted_4, toDisplayString(scope.$index + 1), 1 /* TEXT */ )) ], 64 /* STABLE_FRAGMENT */ )) : createCommentVNode("v-if", true), item.type === "expand" ? renderSlot(_ctx.$slots, "expand", { key: 2, scope }) : createCommentVNode("v-if", true) ]), key: "0" } : void 0 ]), 1040 /* FULL_PROPS, DYNAMIC_SLOTS */ )) ], 64 /* STABLE_FRAGMENT */ ); }), 256 /* UNKEYED_FRAGMENT */ )) : createCommentVNode("v-if", true) ], 64 /* STABLE_FRAGMENT */ ); }; } }); export { _sfc_main as default };