wf-toolbar.tsx 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import { defineComponent } from 'vue';
import { useNamespace } from '@ibiz-template/vue-util';
import { WFLink } from '@ibiz-template/controller';
import '@ibiz-template/theme/style/components/common/wf-toolbar/wf-toolbar.scss';

export const WFToolbar = defineComponent({
  name: 'WFToolbar',
  props: {
    wfLinks: {
      type: Array<WFLink>,
      required: true,
    },
  },
  setup(props, { emit }) {
    const ns = useNamespace('wf-toolbar');

    // 点击事件抛给表格执行
18
    const _handleClick = async (link: WFLink, event: MouseEvent) => {
19 20 21
      emit('wf-link-click', link, event);
    };

22 23 24 25 26 27 28
    // 按钮点击加延时。解决子界面行编辑没有失焦的情况下先触发了按钮的行为。
    const handleClick = async (link: WFLink, event: MouseEvent) => {
      setTimeout(() => {
        _handleClick(link, event);
      }, 30);
    };

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    return { ns, handleClick };
  },
  render() {
    const wfLinks = this.wfLinks || [];
    return (
      <div class={`${this.ns.b()}`}>
        {wfLinks.length > 0 &&
          wfLinks.map(link => {
            return (
              <div key={link.sequenceFlowId} class={this.ns.e('item')}>
                <i-button
                  title={link.sequenceFlowName}
                  on-click={(e: MouseEvent) => this.handleClick(link, e)}
                >
                  {link.sequenceFlowName || ''}
                </i-button>
              </div>
            );
          })}
      </div>
    );
  },
});