提交 ce2b04a1 编写于 作者: Cano1997's avatar Cano1997

feat: 表格列支持脚本代码模式

上级 fa1666e0
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
GridFieldColumnController, GridFieldColumnController,
GridRowController, GridRowController,
} from '@ibiz-template/controller'; } from '@ibiz-template/controller';
import { computed, defineComponent } from 'vue'; import { computed, defineComponent, ref, Ref, watch } from 'vue';
import { useNamespace } from '@ibiz-template/vue-util'; import { useNamespace } from '@ibiz-template/vue-util';
import '@ibiz-template/theme/style/components/widgets/grid/grid-field-column.scss'; import '@ibiz-template/theme/style/components/widgets/grid/grid-field-column.scss';
...@@ -70,18 +70,40 @@ export const GridFieldColumn = defineComponent({ ...@@ -70,18 +70,40 @@ export const GridFieldColumn = defineComponent({
return ns.cssVarBlock({ 'justify-content': justContent }); return ns.cssVarBlock({ 'justify-content': justContent });
}); });
return { ns, alignStyle, codeList, onCellClick, enableGridRowBreak }; const CustomHtml: Ref<string | undefined> = ref('');
if (c.isCustomCode) {
watch(
() => props.row.data,
async () => {
CustomHtml.value = await props.controller.getCustomHtml(
props.row.data,
);
},
{
deep: true,
immediate: true,
},
);
}
return {
ns,
alignStyle,
codeList,
CustomHtml,
onCellClick,
enableGridRowBreak,
};
}, },
render() { render() {
const c = this.controller; const c = this.controller;
const fieldValue = this.row.data[this.controller.model.codeName]; const fieldValue = this.row.data[this.controller.model.codeName];
return ( let content = null;
<div if (c.isCustomCode) {
class={[this.ns.b(), c.clickable && this.ns.m('clickable')]} content = <span class={this.ns.e('script')}>{this.CustomHtml}</span>;
style={this.alignStyle} } else if (this.codeList) {
onClick={this.onCellClick} content = (
>
{this.codeList ? (
<code-list <code-list
class={[ class={[
this.ns.e('text'), this.ns.e('text'),
...@@ -92,7 +114,9 @@ export const GridFieldColumn = defineComponent({ ...@@ -92,7 +114,9 @@ export const GridFieldColumn = defineComponent({
value={fieldValue} value={fieldValue}
textSeparator={c.model.source?.textSeparator} textSeparator={c.model.source?.textSeparator}
></code-list> ></code-list>
) : ( );
} else {
content = (
<span <span
class={[ class={[
this.ns.e('text'), this.ns.e('text'),
...@@ -102,7 +126,15 @@ export const GridFieldColumn = defineComponent({ ...@@ -102,7 +126,15 @@ export const GridFieldColumn = defineComponent({
{fieldValue} {fieldValue}
{fieldValue != null && c.model.unitName} {fieldValue != null && c.model.unitName}
</span> </span>
)} );
}
return (
<div
class={[this.ns.b(), c.clickable && this.ns.m('clickable')]}
style={this.alignStyle}
onClick={this.onCellClick}
>
{content}
</div> </div>
); );
}, },
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册