vben admin中table内自定义点击元素打开具体模态框

 {
    title: `${i18nData[locale].projectName}`,
    dataIndex: 'projectName',
    customRender: ({ record }) => {
      if (isUndefined(record.projectName) || isNull(record.projectName)) {
        return '';
      } else {
        return h(OpenTableModal, {
          columnTab: 'projectName',
          value: record,
        });
      }
    },
  },
  {
    title: `${i18nData[locale].entrypoint}`,
    dataIndex: 'entrypoint',
    customRender: ({ record }) => {
      if (isUndefined(record.entrypoint) || isNull(record.entrypoint)) {
        return '';
      } else {
        const data = record.entrypoint;
        const go = useGo();
        return h(
          'div',
          {
            onClick: () => {
              go('/specific/ship-detail/' + record.entrypoint);
            },
            style: {
              color: '#0960bd',
              cursor: 'pointer',
            },
          },
          `${data}`,
        );
      }
    },
  },
<template>
  <!-- <QRCodeModal @register="registerQRCodeModal" /> -->
  <div @click="openSth" style="color: #0960bd; cursor: pointer">{{ data.showData }}</div>
  <ProjectViewModal @register="registerProjectDetailModal" />
  <BatteryViewModal @register="registerBatteryDetailModal" />
  <BmsViewModal @register="registerBmsDetailModal" />
</template>
<script lang="ts" setup>
  import ProjectViewModal from '../project-mgmt/ProjectViewModal.vue';
  import BatteryViewModal from '../battery-mgmt/batteryViewModal.vue';
  import BmsViewModal from '../bms-mgmt/BmsViewModal.vue';
  import { reactive } from 'vue';
  import { useModal } from '@/components/Modal';

  const props = defineProps({
    columnTab: String,
    value: Object,
  });

  const [registerBatteryDetailModal, { openModal }] = useModal();
  const [registerProjectDetailModal, { openModal: openProjectModal }] = useModal();
  const [registerBmsDetailModal, { openModal: openBmsModal }] = useModal();
  let data = reactive({
    showData: '',
  });
  // table展示
  switch (props.columnTab) {
    case 'projectName':
      data.showData = props.value.projectName;
      break;
    case 'batteryName':
      data.showData = props.value.batteryName;
      break;
    case 'bmsSn':
      data.showData = props.value.bmsSn;
      break;
  }
  // 打开模态框
  function openSth() {
    switch (props.columnTab) {
      case 'projectName':
        openProjectModal(undefined, props.value.projectId);
        break;
      case 'batteryName':
        openModal(undefined, props.value.batteryId);
        break;
      case 'bmsSn':
        openBmsModal(undefined, props.value.bmsBaseInfoId);
        break;
    }
  }
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值