DevicePointTable.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <BasicModal
  3. ref="DeviceModalTable"
  4. v-bind="$attrs"
  5. @register="registerModal"
  6. title="选择关联设备预警点位"
  7. width="1000px"
  8. :showCancelBtn="false"
  9. :showOkBtn="false"
  10. :footer="null"
  11. :destroy-on-close="true"
  12. >
  13. <div>
  14. <a-button type="primary" @click="saveData"> 确定 </a-button>
  15. </div>
  16. <a-table
  17. v-if="refresh"
  18. :row-selection="{ selections: true, selectedRowKeys: selectedRowKeys, onSelect: onSelectChange }"
  19. :columns="columns"
  20. :dataSource="dataSource"
  21. :row-key="(record) => record.id"
  22. size="small"
  23. />
  24. </BasicModal>
  25. </template>
  26. <script lang="ts" setup>
  27. import { onMounted, ref, defineEmits, watch, nextTick } from 'vue';
  28. import { columns } from '../../pointTabel/point.data';
  29. import { BasicModal, useModalInner } from '/@/components/Modal';
  30. const DeviceModalTable = ref();
  31. const props = defineProps({
  32. dataSource: { type: Array, default: () => [] },
  33. selectionRowKeys: { type: Array, default: () => [] },
  34. });
  35. const emit = defineEmits(['reload', 'register']);
  36. const refresh = ref(true)
  37. const selectedRowKeys = ref<any[]>([]);
  38. const selectionRows = ref<any[]>([]);
  39. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  40. //重置表单
  41. setModalProps({ confirmLoading: false });
  42. });
  43. /**
  44. * 复选框选中事件
  45. * @param rowKeys
  46. * @param rows
  47. */
  48. function onSelectChange(record) {
  49. selectedRowKeys.value = [record['id']];
  50. selectionRows.value = [record];
  51. }
  52. const saveData = async () => {
  53. emit('reload', selectionRows.value);
  54. closeModal();
  55. };
  56. watch(() => props.selectionRowKeys, (newVal: any[]) => {
  57. selectedRowKeys.value = newVal
  58. refresh.value = false
  59. nextTick(() => {
  60. refresh.value = true
  61. })
  62. })
  63. onMounted(async () => {
  64. });
  65. </script>
  66. <style scoped lang="less"></style>