@tmagic/table 1.6.1 → 1.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2038,7 +2038,9 @@
2038
2038
  columns: { default: () => [] },
2039
2039
  config: { default: () => ({}) },
2040
2040
  rowkeyName: { default: "c_id" },
2041
- editState: { default: () => [] }
2041
+ editState: { default: () => [] },
2042
+ row: {},
2043
+ index: {}
2042
2044
  },
2043
2045
  emits: ["after-action"],
2044
2046
  setup(__props, { emit: __emit }) {
@@ -2048,8 +2050,20 @@
2048
2050
  if (typeof fuc === "function") {
2049
2051
  return fuc(row);
2050
2052
  }
2053
+ if (typeof fuc === "boolean") {
2054
+ return fuc;
2055
+ }
2051
2056
  return true;
2052
2057
  };
2058
+ const disabled = (fuc, row) => {
2059
+ if (typeof fuc === "function") {
2060
+ return fuc(row);
2061
+ }
2062
+ if (typeof fuc === "boolean") {
2063
+ return fuc;
2064
+ }
2065
+ return false;
2066
+ };
2053
2067
  const formatter = (fuc, row) => {
2054
2068
  if (typeof fuc === "function") {
2055
2069
  return fuc(row);
@@ -2071,7 +2085,9 @@
2071
2085
  const data = {};
2072
2086
  const row = props.editState[index];
2073
2087
  props.columns.filter((item) => item.type).forEach((column) => {
2074
- data[column.prop] = row[column.prop];
2088
+ if (column.prop) {
2089
+ data[column.prop] = row[column.prop];
2090
+ }
2075
2091
  });
2076
2092
  const res = await action({
2077
2093
  data
@@ -2090,12 +2106,10 @@
2090
2106
  }
2091
2107
  };
2092
2108
  return (_ctx, _cache) => {
2093
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
2094
- label: __props.config.label,
2095
- width: __props.config.width,
2096
- fixed: __props.config.fixed
2097
- }, {
2098
- default: vue.withCtx((scope) => [
2109
+ return vue.openBlock(), vue.createElementBlock(
2110
+ vue.Fragment,
2111
+ null,
2112
+ [
2099
2113
  (vue.openBlock(true), vue.createElementBlock(
2100
2114
  vue.Fragment,
2101
2115
  null,
@@ -2113,17 +2127,18 @@
2113
2127
  size: "small",
2114
2128
  type: action.buttonType || "primary",
2115
2129
  icon: action.icon,
2116
- onClick: ($event) => actionHandler(action, scope.row, scope.$index)
2130
+ disabled: disabled(action.disabled, __props.row),
2131
+ onClick: ($event) => actionHandler(action, __props.row, __props.index)
2117
2132
  }, {
2118
2133
  default: vue.withCtx(() => [
2119
2134
  vue.createElementVNode("span", {
2120
- innerHTML: formatter(action.text, scope.row)
2135
+ innerHTML: formatter(action.text, __props.row)
2121
2136
  }, null, 8, _hoisted_1$2)
2122
2137
  ]),
2123
2138
  _: 2
2124
2139
  /* DYNAMIC */
2125
- }, 1032, ["type", "icon", "onClick"]), [
2126
- [vue.vShow, display(action.display, scope.row) && !__props.editState[scope.$index]]
2140
+ }, 1032, ["type", "icon", "disabled", "onClick"]), [
2141
+ [vue.vShow, display(action.display, __props.row) && !__props.editState[__props.index]]
2127
2142
  ])
2128
2143
  ]),
2129
2144
  _: 2
@@ -2133,48 +2148,60 @@
2133
2148
  128
2134
2149
  /* KEYED_FRAGMENT */
2135
2150
  )),
2136
- vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
2137
- class: "action-btn",
2138
- link: "",
2139
- type: "primary",
2140
- size: "small",
2141
- onClick: ($event) => save(scope.$index, __props.config)
2142
- }, {
2143
- default: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
2144
- vue.createTextVNode(
2145
- "保存",
2146
- -1
2147
- /* CACHED */
2148
- )
2149
- ])]),
2150
- _: 1
2151
- /* STABLE */
2152
- }, 8, ["onClick"]), [
2153
- [vue.vShow, __props.editState[scope.$index]]
2151
+ vue.withDirectives(vue.createVNode(
2152
+ vue.unref(design.TMagicButton),
2153
+ {
2154
+ class: "action-btn",
2155
+ link: "",
2156
+ type: "primary",
2157
+ size: "small",
2158
+ onClick: _cache[0] || (_cache[0] = ($event) => save(__props.index, __props.config))
2159
+ },
2160
+ {
2161
+ default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
2162
+ vue.createTextVNode(
2163
+ "保存",
2164
+ -1
2165
+ /* CACHED */
2166
+ )
2167
+ ])]),
2168
+ _: 1
2169
+ /* STABLE */
2170
+ },
2171
+ 512
2172
+ /* NEED_PATCH */
2173
+ ), [
2174
+ [vue.vShow, __props.editState[__props.index]]
2154
2175
  ]),
2155
- vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
2156
- class: "action-btn",
2157
- link: "",
2158
- type: "primary",
2159
- size: "small",
2160
- onClick: ($event) => __props.editState[scope.$index] = void 0
2161
- }, {
2162
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
2163
- vue.createTextVNode(
2164
- "取消",
2165
- -1
2166
- /* CACHED */
2167
- )
2168
- ])]),
2169
- _: 1
2170
- /* STABLE */
2171
- }, 8, ["onClick"]), [
2172
- [vue.vShow, __props.editState[scope.$index]]
2176
+ vue.withDirectives(vue.createVNode(
2177
+ vue.unref(design.TMagicButton),
2178
+ {
2179
+ class: "action-btn",
2180
+ link: "",
2181
+ type: "primary",
2182
+ size: "small",
2183
+ onClick: _cache[1] || (_cache[1] = ($event) => __props.editState[__props.index] = void 0)
2184
+ },
2185
+ {
2186
+ default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
2187
+ vue.createTextVNode(
2188
+ "取消",
2189
+ -1
2190
+ /* CACHED */
2191
+ )
2192
+ ])]),
2193
+ _: 1
2194
+ /* STABLE */
2195
+ },
2196
+ 512
2197
+ /* NEED_PATCH */
2198
+ ), [
2199
+ [vue.vShow, __props.editState[__props.index]]
2173
2200
  ])
2174
- ]),
2175
- _: 1
2176
- /* STABLE */
2177
- }, 8, ["label", "width", "fixed"]);
2201
+ ],
2202
+ 64
2203
+ /* STABLE_FRAGMENT */
2204
+ );
2178
2205
  };
2179
2206
  }
2180
2207
  });
@@ -2185,7 +2212,9 @@
2185
2212
  },
2186
2213
  __name: "ComponentColumn",
2187
2214
  props: {
2188
- config: { default: () => ({}) }
2215
+ config: { default: () => ({}) },
2216
+ row: {},
2217
+ index: {}
2189
2218
  },
2190
2219
  setup(__props) {
2191
2220
  const props = __props;
@@ -2202,26 +2231,13 @@
2202
2231
  return props.config.listeners || {};
2203
2232
  };
2204
2233
  return (_ctx, _cache) => {
2205
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
2206
- "show-overflow-tooltip": "",
2207
- label: __props.config.label,
2208
- width: __props.config.width,
2209
- fixed: __props.config.fixed,
2210
- sortable: __props.config.sortable,
2211
- prop: __props.config.prop
2212
- }, {
2213
- default: vue.withCtx((scope) => [
2214
- (vue.openBlock(), vue.createBlock(
2215
- vue.resolveDynamicComponent(__props.config.component),
2216
- vue.mergeProps(componentProps(scope.row, scope.$index), vue.toHandlers(componentListeners(scope.row, scope.$index))),
2217
- null,
2218
- 16
2219
- /* FULL_PROPS */
2220
- ))
2221
- ]),
2222
- _: 1
2223
- /* STABLE */
2224
- }, 8, ["label", "width", "fixed", "sortable", "prop"]);
2234
+ return vue.openBlock(), vue.createBlock(
2235
+ vue.resolveDynamicComponent(__props.config.component),
2236
+ vue.mergeProps(componentProps(__props.row, __props.index), vue.toHandlers(componentListeners(__props.row, __props.index))),
2237
+ null,
2238
+ 16
2239
+ /* FULL_PROPS */
2240
+ );
2225
2241
  };
2226
2242
  }
2227
2243
  });
@@ -2233,7 +2249,8 @@
2233
2249
  },
2234
2250
  __name: "ExpandColumn",
2235
2251
  props: {
2236
- config: { default: () => ({}) }
2252
+ config: { default: () => ({}) },
2253
+ row: {}
2237
2254
  },
2238
2255
  setup(__props) {
2239
2256
  const props = __props;
@@ -2248,42 +2265,31 @@
2248
2265
  vue.Fragment,
2249
2266
  null,
2250
2267
  [
2251
- vue.createCommentVNode(" @ts-nocheck "),
2252
- vue.createVNode(vue.unref(design.TMagicTableColumn), {
2253
- type: "expand",
2254
- width: __props.config.width,
2255
- fixed: __props.config.fixed
2256
- }, {
2257
- default: vue.withCtx((scope) => [
2258
- __props.config.table ? (vue.openBlock(), vue.createBlock(_sfc_main, {
2259
- key: 0,
2260
- "show-header": false,
2261
- columns: __props.config.table,
2262
- data: __props.config.prop && scope.row[__props.config.prop] || []
2263
- }, null, 8, ["columns", "data"])) : vue.createCommentVNode("v-if", true),
2264
- __props.config.form ? (vue.openBlock(), vue.createBlock(vue.unref(form.MForm), {
2265
- key: 1,
2266
- config: __props.config.form,
2267
- "init-values": __props.config.values || __props.config.prop && scope.row[__props.config.prop] || {}
2268
- }, null, 8, ["config", "init-values"])) : vue.createCommentVNode("v-if", true),
2269
- __props.config.expandContent ? (vue.openBlock(), vue.createElementBlock("div", {
2270
- key: 2,
2271
- innerHTML: __props.config.expandContent(scope.row, __props.config.prop)
2272
- }, null, 8, _hoisted_1$1)) : vue.createCommentVNode("v-if", true),
2273
- __props.config.component ? (vue.openBlock(), vue.createBlock(
2274
- vue.resolveDynamicComponent(__props.config.component),
2275
- vue.normalizeProps(vue.mergeProps({ key: 3 }, componentProps(scope.row))),
2276
- null,
2277
- 16
2278
- /* FULL_PROPS */
2279
- )) : vue.createCommentVNode("v-if", true)
2280
- ]),
2281
- _: 1
2282
- /* STABLE */
2283
- }, 8, ["width", "fixed"])
2268
+ __props.config.table ? (vue.openBlock(), vue.createBlock(_sfc_main, {
2269
+ key: 0,
2270
+ "show-header": false,
2271
+ columns: __props.config.table,
2272
+ data: __props.config.prop && __props.row[__props.config.prop] || []
2273
+ }, null, 8, ["columns", "data"])) : vue.createCommentVNode("v-if", true),
2274
+ __props.config.form ? (vue.openBlock(), vue.createBlock(vue.unref(form.MForm), {
2275
+ key: 1,
2276
+ config: __props.config.form,
2277
+ "init-values": __props.config.values || __props.config.prop && __props.row[__props.config.prop] || {}
2278
+ }, null, 8, ["config", "init-values"])) : vue.createCommentVNode("v-if", true),
2279
+ __props.config.expandContent ? (vue.openBlock(), vue.createElementBlock("div", {
2280
+ key: 2,
2281
+ innerHTML: __props.config.expandContent(__props.row, __props.config.prop)
2282
+ }, null, 8, _hoisted_1$1)) : vue.createCommentVNode("v-if", true),
2283
+ __props.config.component ? (vue.openBlock(), vue.createBlock(
2284
+ vue.resolveDynamicComponent(__props.config.component),
2285
+ vue.normalizeProps(vue.mergeProps({ key: 3 }, componentProps(__props.row))),
2286
+ null,
2287
+ 16
2288
+ /* FULL_PROPS */
2289
+ )) : vue.createCommentVNode("v-if", true)
2284
2290
  ],
2285
- 2112
2286
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2291
+ 64
2292
+ /* STABLE_FRAGMENT */
2287
2293
  );
2288
2294
  };
2289
2295
  }
@@ -2313,69 +2319,46 @@
2313
2319
  },
2314
2320
  __name: "PopoverColumn",
2315
2321
  props: {
2316
- config: { default: () => ({}) }
2322
+ config: { default: () => ({}) },
2323
+ row: {},
2324
+ index: {}
2317
2325
  },
2318
2326
  setup(__props) {
2319
2327
  return (_ctx, _cache) => {
2320
- return vue.openBlock(), vue.createElementBlock(
2321
- vue.Fragment,
2322
- null,
2323
- [
2324
- vue.createCommentVNode(" @ts-nocheck "),
2325
- vue.createVNode(vue.unref(design.TMagicTableColumn), {
2326
- label: __props.config.label,
2327
- width: __props.config.width,
2328
- fixed: __props.config.fixed
2328
+ return __props.config.popover ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
2329
+ key: 0,
2330
+ placement: __props.config.popover.placement,
2331
+ width: __props.config.popover.width,
2332
+ trigger: __props.config.popover.trigger,
2333
+ "destroy-on-close": __props.config.popover.destroyOnClose ?? true
2334
+ }, {
2335
+ reference: vue.withCtx(() => [
2336
+ vue.createVNode(vue.unref(design.TMagicButton), {
2337
+ link: "",
2338
+ type: "primary"
2329
2339
  }, {
2330
- default: vue.withCtx((scope) => [
2331
- __props.config.popover ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
2332
- key: 0,
2333
- placement: __props.config.popover.placement,
2334
- width: __props.config.popover.width,
2335
- trigger: __props.config.popover.trigger,
2336
- "destroy-on-close": __props.config.popover.destroyOnClose ?? true
2337
- }, {
2338
- reference: vue.withCtx(() => [
2339
- vue.createVNode(
2340
- vue.unref(design.TMagicButton),
2341
- {
2342
- link: "",
2343
- type: "primary"
2344
- },
2345
- {
2346
- default: vue.withCtx(() => [
2347
- vue.createTextVNode(
2348
- vue.toDisplayString(__props.config.text || vue.unref(formatter)(__props.config, scope.row, { index: scope.$index })),
2349
- 1
2350
- /* TEXT */
2351
- )
2352
- ]),
2353
- _: 2
2354
- /* DYNAMIC */
2355
- },
2356
- 1024
2357
- /* DYNAMIC_SLOTS */
2358
- )
2359
- ]),
2360
- default: vue.withCtx(() => [
2361
- __props.config.popover.tableEmbed ? (vue.openBlock(), vue.createBlock(_sfc_main, {
2362
- key: 0,
2363
- "show-header": __props.config.showHeader,
2364
- columns: __props.config.table,
2365
- data: __props.config.prop && scope.row[__props.config.prop] || []
2366
- }, null, 8, ["show-header", "columns", "data"])) : vue.createCommentVNode("v-if", true)
2367
- ]),
2368
- _: 2
2369
- /* DYNAMIC */
2370
- }, 1032, ["placement", "width", "trigger", "destroy-on-close"])) : vue.createCommentVNode("v-if", true)
2340
+ default: vue.withCtx(() => [
2341
+ vue.createTextVNode(
2342
+ vue.toDisplayString(__props.config.text || vue.unref(formatter)(__props.config, __props.row, { index: __props.index })),
2343
+ 1
2344
+ /* TEXT */
2345
+ )
2371
2346
  ]),
2372
2347
  _: 1
2373
2348
  /* STABLE */
2374
- }, 8, ["label", "width", "fixed"])
2375
- ],
2376
- 2112
2377
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2378
- );
2349
+ })
2350
+ ]),
2351
+ default: vue.withCtx(() => [
2352
+ __props.config.popover.tableEmbed ? (vue.openBlock(), vue.createBlock(_sfc_main, {
2353
+ key: 0,
2354
+ "show-header": __props.config.showHeader,
2355
+ columns: __props.config.table,
2356
+ data: __props.config.prop && __props.row[__props.config.prop] || []
2357
+ }, null, 8, ["show-header", "columns", "data"])) : vue.createCommentVNode("v-if", true)
2358
+ ]),
2359
+ _: 1
2360
+ /* STABLE */
2361
+ }, 8, ["placement", "width", "trigger", "destroy-on-close"])) : vue.createCommentVNode("v-if", true);
2379
2362
  };
2380
2363
  }
2381
2364
  });
@@ -2393,129 +2376,112 @@
2393
2376
  __name: "TextColumn",
2394
2377
  props: {
2395
2378
  config: { default: () => ({}) },
2396
- editState: { default: () => ({}) }
2379
+ editState: { default: () => ({}) },
2380
+ row: {},
2381
+ index: {}
2397
2382
  },
2398
2383
  setup(__props) {
2399
2384
  return (_ctx, _cache) => {
2400
2385
  const _component_m_form_container = vue.resolveComponent("m-form-container");
2401
2386
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2402
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
2403
- "show-overflow-tooltip": "",
2404
- label: __props.config.label,
2405
- width: __props.config.width,
2406
- fixed: __props.config.fixed,
2407
- sortable: __props.config.sortable,
2408
- prop: __props.config.prop
2387
+ return __props.config.type === "index" ? (vue.openBlock(), vue.createElementBlock(
2388
+ "div",
2389
+ _hoisted_1,
2390
+ vue.toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + __props.index + 1 : __props.index + 1),
2391
+ 1
2392
+ /* TEXT */
2393
+ )) : __props.config.type && __props.editState[__props.index] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicForm), {
2394
+ key: 1,
2395
+ "label-width": "0",
2396
+ model: __props.editState[__props.index]
2409
2397
  }, {
2410
- default: vue.withCtx((scope) => [
2411
- __props.config.type === "index" ? (vue.openBlock(), vue.createElementBlock(
2398
+ default: vue.withCtx(() => [
2399
+ vue.createVNode(_component_m_form_container, {
2400
+ prop: __props.config.prop,
2401
+ rules: __props.config.rules,
2402
+ config: __props.config,
2403
+ name: __props.config.prop,
2404
+ model: __props.editState[__props.index]
2405
+ }, null, 8, ["prop", "rules", "config", "name", "model"])
2406
+ ]),
2407
+ _: 1
2408
+ /* STABLE */
2409
+ }, 8, ["model"])) : __props.config.action === "actionLink" && __props.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
2410
+ key: 2,
2411
+ link: "",
2412
+ type: "primary",
2413
+ onClick: _cache[0] || (_cache[0] = ($event) => __props.config.handler?.(__props.row))
2414
+ }, {
2415
+ default: vue.withCtx(() => [
2416
+ vue.createElementVNode("span", {
2417
+ innerHTML: vue.unref(formatter)(__props.config, __props.row, { index: __props.index })
2418
+ }, null, 8, _hoisted_2)
2419
+ ]),
2420
+ _: 1
2421
+ /* STABLE */
2422
+ })) : __props.config.action === "img" && __props.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
2423
+ key: 3,
2424
+ target: "_blank",
2425
+ href: __props.row[__props.config.prop]
2426
+ }, [
2427
+ vue.createElementVNode("img", {
2428
+ src: __props.row[__props.config.prop],
2429
+ height: "50"
2430
+ }, null, 8, _hoisted_4)
2431
+ ], 8, _hoisted_3)) : __props.config.action === "link" && __props.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
2432
+ key: 4,
2433
+ target: "_blank",
2434
+ href: __props.row[__props.config.prop],
2435
+ class: "keep-all"
2436
+ }, vue.toDisplayString(__props.row[__props.config.prop]), 9, _hoisted_5)) : __props.config.action === "tip" ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2437
+ key: 5,
2438
+ placement: "left"
2439
+ }, {
2440
+ content: vue.withCtx(() => [
2441
+ vue.createElementVNode(
2412
2442
  "div",
2413
- _hoisted_1,
2414
- vue.toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + scope.$index + 1 : scope.$index + 1),
2443
+ null,
2444
+ vue.toDisplayString(vue.unref(formatter)(__props.config, __props.row, { index: __props.index })),
2415
2445
  1
2416
2446
  /* TEXT */
2417
- )) : __props.config.type && __props.editState[scope.$index] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicForm), {
2418
- key: 1,
2419
- "label-width": "0",
2420
- model: __props.editState[scope.$index]
2421
- }, {
2422
- default: vue.withCtx(() => [
2423
- vue.createVNode(_component_m_form_container, {
2424
- prop: __props.config.prop,
2425
- rules: __props.config.rules,
2426
- config: __props.config,
2427
- name: __props.config.prop,
2428
- model: __props.editState[scope.$index]
2429
- }, null, 8, ["prop", "rules", "config", "name", "model"])
2430
- ]),
2431
- _: 2
2432
- /* DYNAMIC */
2433
- }, 1032, ["model"])) : __props.config.action === "actionLink" && __props.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
2434
- key: 2,
2447
+ )
2448
+ ]),
2449
+ default: vue.withCtx(() => [
2450
+ vue.createVNode(vue.unref(design.TMagicButton), {
2435
2451
  link: "",
2436
- type: "primary",
2437
- onClick: ($event) => __props.config.handler?.(scope.row)
2438
- }, {
2439
- default: vue.withCtx(() => [
2440
- vue.createElementVNode("span", {
2441
- innerHTML: vue.unref(formatter)(__props.config, scope.row, { index: scope.$index })
2442
- }, null, 8, _hoisted_2)
2443
- ]),
2444
- _: 2
2445
- /* DYNAMIC */
2446
- }, 1032, ["onClick"])) : __props.config.action === "img" && __props.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
2447
- key: 3,
2448
- target: "_blank",
2449
- href: scope.row[__props.config.prop]
2450
- }, [
2451
- vue.createElementVNode("img", {
2452
- src: scope.row[__props.config.prop],
2453
- height: "50"
2454
- }, null, 8, _hoisted_4)
2455
- ], 8, _hoisted_3)) : __props.config.action === "link" && __props.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
2456
- key: 4,
2457
- target: "_blank",
2458
- href: scope.row[__props.config.prop],
2459
- class: "keep-all"
2460
- }, vue.toDisplayString(scope.row[__props.config.prop]), 9, _hoisted_5)) : __props.config.action === "tip" ? (vue.openBlock(), vue.createBlock(
2461
- _component_el_tooltip,
2462
- {
2463
- key: 5,
2464
- placement: "left"
2465
- },
2466
- {
2467
- content: vue.withCtx(() => [
2468
- vue.createElementVNode(
2469
- "div",
2470
- null,
2471
- vue.toDisplayString(vue.unref(formatter)(__props.config, scope.row, { index: scope.$index })),
2472
- 1
2473
- /* TEXT */
2474
- )
2475
- ]),
2476
- default: vue.withCtx(() => [
2477
- vue.createVNode(vue.unref(design.TMagicButton), {
2478
- link: "",
2479
- type: "primary"
2480
- }, {
2481
- default: vue.withCtx(() => [
2482
- vue.createTextVNode(
2483
- vue.toDisplayString(__props.config.buttonText || "扩展配置"),
2484
- 1
2485
- /* TEXT */
2486
- )
2487
- ]),
2488
- _: 1
2489
- /* STABLE */
2490
- })
2491
- ]),
2492
- _: 2
2493
- /* DYNAMIC */
2494
- },
2495
- 1024
2496
- /* DYNAMIC_SLOTS */
2497
- )) : __props.config.action === "tag" && __props.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
2498
- key: 6,
2499
- type: typeof __props.config.type === "function" ? __props.config.type(scope.row[__props.config.prop], scope.row) : __props.config.type,
2500
- "close-transition": ""
2452
+ type: "primary"
2501
2453
  }, {
2502
2454
  default: vue.withCtx(() => [
2503
2455
  vue.createTextVNode(
2504
- vue.toDisplayString(vue.unref(formatter)(__props.config, scope.row, { index: scope.$index })),
2456
+ vue.toDisplayString(__props.config.buttonText || "扩展配置"),
2505
2457
  1
2506
2458
  /* TEXT */
2507
2459
  )
2508
2460
  ]),
2509
- _: 2
2510
- /* DYNAMIC */
2511
- }, 1032, ["type"])) : (vue.openBlock(), vue.createElementBlock("div", {
2512
- key: 7,
2513
- innerHTML: vue.unref(formatter)(__props.config, scope.row, { index: scope.$index })
2514
- }, null, 8, _hoisted_6))
2461
+ _: 1
2462
+ /* STABLE */
2463
+ })
2515
2464
  ]),
2516
2465
  _: 1
2517
2466
  /* STABLE */
2518
- }, 8, ["label", "width", "fixed", "sortable", "prop"]);
2467
+ })) : __props.config.action === "tag" && __props.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
2468
+ key: 6,
2469
+ type: typeof __props.config.type === "function" ? __props.config.type(__props.row[__props.config.prop], __props.row) : __props.config.type,
2470
+ "close-transition": ""
2471
+ }, {
2472
+ default: vue.withCtx(() => [
2473
+ vue.createTextVNode(
2474
+ vue.toDisplayString(vue.unref(formatter)(__props.config, __props.row, { index: __props.index })),
2475
+ 1
2476
+ /* TEXT */
2477
+ )
2478
+ ]),
2479
+ _: 1
2480
+ /* STABLE */
2481
+ }, 8, ["type"])) : (vue.openBlock(), vue.createElementBlock("div", {
2482
+ key: 7,
2483
+ innerHTML: vue.unref(formatter)(__props.config, __props.row, { index: __props.index })
2484
+ }, null, 8, _hoisted_6));
2519
2485
  };
2520
2486
  }
2521
2487
  });
@@ -2549,9 +2515,67 @@
2549
2515
  setup(__props, { expose: __expose, emit: __emit }) {
2550
2516
  const props = __props;
2551
2517
  const emit = __emit;
2552
- const tMagicTable = vue.ref();
2518
+ const cellRender = (config, { row = {}, $index }) => {
2519
+ if (config.type === "expand") {
2520
+ return vue.h(_sfc_main$3, {
2521
+ config,
2522
+ row
2523
+ });
2524
+ }
2525
+ if (config.type === "component") {
2526
+ return vue.h(_sfc_main$4, {
2527
+ config,
2528
+ row,
2529
+ index: $index
2530
+ });
2531
+ }
2532
+ if (config.actions) {
2533
+ return vue.h(_sfc_main$5, {
2534
+ config,
2535
+ row,
2536
+ index: $index,
2537
+ rowkeyName: props.rowkeyName,
2538
+ editState: editState.value,
2539
+ columns: props.columns
2540
+ });
2541
+ }
2542
+ if (config.type === "popover") {
2543
+ return vue.h(_sfc_main$2, {
2544
+ config,
2545
+ row,
2546
+ index: $index
2547
+ });
2548
+ }
2549
+ return vue.h(_sfc_main$1, {
2550
+ config,
2551
+ row,
2552
+ index: $index,
2553
+ editState: editState.value
2554
+ });
2555
+ };
2556
+ const tableColumns = vue.computed(
2557
+ () => props.columns.map((item) => {
2558
+ let type = "default";
2559
+ if (item.type === "expand") {
2560
+ type = "expand";
2561
+ } else if (item.selection) {
2562
+ type = "selection";
2563
+ }
2564
+ return {
2565
+ props: {
2566
+ label: item.label,
2567
+ fixed: item.fixed,
2568
+ width: item.width ?? (item.selection ? 40 : void 0),
2569
+ prop: item.prop,
2570
+ type,
2571
+ selectable: item.selectable
2572
+ },
2573
+ cell: type === "selection" ? void 0 : ({ row, $index }) => cellRender(item, { row, $index })
2574
+ };
2575
+ })
2576
+ );
2577
+ const tMagicTableRef = vue.useTemplateRef("tMagicTable");
2553
2578
  const editState = vue.ref([]);
2554
- const tableColumnComponent = design.getDesignConfig("components")?.tableColumn;
2555
2579
  const selectionColumn = vue.computed(() => {
2556
2580
  const column = props.columns.filter((item) => item.selection);
2557
2581
  return column.length ? column[0] : null;
@@ -2587,13 +2611,13 @@
2587
2611
  emit("expand-change", ...args);
2588
2612
  };
2589
2613
  const toggleRowSelection = (row, selected) => {
2590
- tMagicTable.value?.toggleRowSelection(row, selected);
2614
+ tMagicTableRef.value?.toggleRowSelection(row, selected);
2591
2615
  };
2592
2616
  const toggleRowExpansion = (row, expanded) => {
2593
- tMagicTable.value?.toggleRowExpansion(row, expanded);
2617
+ tMagicTableRef.value?.toggleRowExpansion(row, expanded);
2594
2618
  };
2595
2619
  const clearSelection = () => {
2596
- tMagicTable.value?.clearSelection();
2620
+ tMagicTableRef.value?.clearSelection();
2597
2621
  };
2598
2622
  const objectSpanMethod = (data) => {
2599
2623
  if (typeof props.spanMethod === "function") {
@@ -2612,11 +2636,11 @@
2612
2636
  return (_ctx, _cache) => {
2613
2637
  const _directive_loading = vue.resolveDirective("loading");
2614
2638
  return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTable), {
2639
+ class: "m-table",
2640
+ ref: "tMagicTable",
2641
+ "show-overflow-tooltip": true,
2615
2642
  "tooltip-effect": "dark",
2616
2643
  "tooltip-options": { popperOptions: { strategy: "absolute" } },
2617
- class: "m-table",
2618
- ref_key: "tMagicTable",
2619
- ref: tMagicTable,
2620
2644
  data: tableData.value,
2621
2645
  "show-header": __props.showHeader,
2622
2646
  "max-height": __props.bodyHeight,
@@ -2626,60 +2650,14 @@
2626
2650
  "tree-props": { children: "children" },
2627
2651
  "empty-text": __props.emptyText || "暂无数据",
2628
2652
  "span-method": objectSpanMethod,
2653
+ columns: tableColumns.value,
2629
2654
  onSortChange: sortChange,
2630
2655
  onSelect: selectHandler,
2631
2656
  onSelectAll: selectAllHandler,
2632
2657
  onSelectionChange: selectionChangeHandler,
2633
2658
  onCellClick: cellClickHandler,
2634
2659
  onExpandChange: expandChange
2635
- }, {
2636
- default: vue.withCtx(() => [
2637
- (vue.openBlock(true), vue.createElementBlock(
2638
- vue.Fragment,
2639
- null,
2640
- vue.renderList(__props.columns, (item, columnIndex) => {
2641
- return vue.openBlock(), vue.createElementBlock(
2642
- vue.Fragment,
2643
- null,
2644
- [
2645
- item.type === "expand" ? (vue.openBlock(), vue.createBlock(_sfc_main$3, {
2646
- config: item,
2647
- key: columnIndex
2648
- }, null, 8, ["config"])) : item.type === "component" ? (vue.openBlock(), vue.createBlock(_sfc_main$4, {
2649
- config: item,
2650
- key: columnIndex
2651
- }, null, 8, ["config"])) : item.selection ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tableColumnComponent)?.component || "el-table-column"), {
2652
- width: "40",
2653
- type: "selection",
2654
- key: columnIndex,
2655
- selectable: item.selectable
2656
- }, null, 8, ["selectable"])) : item.actions ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
2657
- columns: __props.columns,
2658
- config: item,
2659
- "rowkey-name": __props.rowkeyName,
2660
- "edit-state": editState.value,
2661
- key: columnIndex,
2662
- onAfterAction: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("after-action"))
2663
- }, null, 8, ["columns", "config", "rowkey-name", "edit-state"])) : item.type === "popover" ? (vue.openBlock(), vue.createBlock(_sfc_main$2, {
2664
- key: columnIndex,
2665
- config: item
2666
- }, null, 8, ["config"])) : (vue.openBlock(), vue.createBlock(_sfc_main$1, {
2667
- key: columnIndex,
2668
- config: item,
2669
- "edit-state": editState.value
2670
- }, null, 8, ["config", "edit-state"]))
2671
- ],
2672
- 64
2673
- /* STABLE_FRAGMENT */
2674
- );
2675
- }),
2676
- 256
2677
- /* UNKEYED_FRAGMENT */
2678
- ))
2679
- ]),
2680
- _: 1
2681
- /* STABLE */
2682
- }, 8, ["data", "show-header", "max-height", "default-expand-all", "border", "row-key", "empty-text"])), [
2660
+ }, null, 8, ["data", "show-header", "max-height", "default-expand-all", "border", "row-key", "empty-text", "columns"])), [
2683
2661
  [_directive_loading, __props.loading]
2684
2662
  ]);
2685
2663
  };