ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<script lang="ts" setup>
import { computed, nextTick, reactive, ref, toRefs, unref } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
 
import { getAliasInfo, saveAlias } from '#/api/onlineDev/visualDev';
import logoImg from '#/assets/images/jnpf.png';
import { $t } from '#/locales';
 
interface State {
  id: string;
  fullName: string;
  list: any[];
  loading: boolean;
  btnLoading: boolean;
  expandedRowKeys: string[];
}
 
defineEmits(['register']);
const tipTxt = '规范名称命名规则:(1)只能由字母、数字、下划线组成,且不能以数字开头;(2)不能使用系统关键字或开发语言关键字';
const descTxt =
  '系统关键字包含:tenantid、id、foreignid、flowid、flowtaskid、deleteuserid、deletetime、deletemark、version、tenant_id、foreign_id、flow_id、flow_task_id、delete_user_id、delete_time、delete_mark、f_tenant_id、f_id、f_foreign_id、f_flow_id、f_flow_task_id、f_delete_user_id、f_delete_time、f_delete_mark、f_version';
const { createMessage } = useMessage();
const [registerModal, { closeModal, changeLoading }] = useModalInner(init);
const alertElRef = ref<any>(null);
const tableElRef = ref<any>(null);
const columns = [
  { width: 50, title: '序号', dataIndex: 'index', key: 'index', align: 'center', customRender: ({ index }) => index + 1 },
  { title: '表名', dataIndex: 'table', key: 'table' },
  { title: '规范名称', dataIndex: 'aliasName', key: 'aliasName' },
  { title: '说明', dataIndex: 'comment', key: 'comment' },
];
const childColumns = [
  { width: 50, title: '序号', dataIndex: 'index', key: 'index', align: 'center', customRender: ({ index }) => index + 1 },
  { title: '字段', dataIndex: 'field', key: 'field' },
  { title: '规范名称', dataIndex: 'aliasName', key: 'aliasName' },
  { title: '说明', dataIndex: 'fieldName', key: 'fieldName' },
];
const state = reactive<State>({
  id: '',
  fullName: '',
  list: [],
  loading: false,
  btnLoading: false,
  expandedRowKeys: [],
});
const { list, loading, btnLoading, expandedRowKeys, fullName } = toRefs(state);
 
const getHeaderHeight = computed(() => {
  const alertEl = alertElRef.value?.$el;
  if (!alertEl) return 120;
  return alertEl?.offsetHeight;
});
const getScrollY = computed(() => window.innerHeight - unref(getHeaderHeight) - 150);
const getTableBindValues = computed(() => {
  return {
    columns,
    pagination: false,
    size: 'small',
    rowKey: 'table',
    scroll: { y: unref(getScrollY) },
  };
});
const getChildTableBindValues = computed(() => {
  return {
    columns: childColumns,
    pagination: false,
    size: 'small',
    rowKey: 'field',
  };
});
 
function init(data) {
  state.id = data.id;
  state.fullName = data.fullName || '';
  state.loading = true;
  state.expandedRowKeys = [];
  changeLoading(true);
  getAliasInfo(data.id).then((res) => {
    state.list = res.data;
    state.expandedRowKeys = res.data.map((e) => e.table);
    nextTick(() => {
      const tableEl = tableElRef.value?.$el;
      const bodyEl = tableEl.querySelector('.ant-table-body');
      bodyEl!.style.height = `${unref(getScrollY)}px`;
      changeLoading(false);
      state.loading = false;
    });
  });
}
function handleSubmit() {
  state.btnLoading = true;
  changeLoading(true);
  saveAlias(state.id, { tableList: state.list })
    .then((res) => {
      state.btnLoading = false;
      changeLoading(false);
      createMessage.success(res.msg);
      closeModal();
    })
    .catch(() => {
      state.btnLoading = false;
      changeLoading(false);
    });
}
</script>
<template>
  <BasicModal
    v-bind="$attrs"
    @register="registerModal"
    default-fullscreen
    :footer="null"
    :closable="false"
    :keyboard="false"
    class="jnpf-full-modal full-modal designer-modal">
    <template #title>
      <div class="jnpf-full-modal-header">
        <div class="header-title">
          <img :src="logoImg" class="header-logo" />
          <span class="header-dot"></span>
          <a-tooltip :title="fullName">
            <p class="header-txt">{{ fullName }}</p>
          </a-tooltip>
        </div>
        <a-steps :current="1" type="navigation" size="small" class="header-steps tab-steps">
          <a-step title="命名规范" />
        </a-steps>
        <a-space class="options" :size="10">
          <a-button type="primary" @click="handleSubmit()" :disabled="loading" :loading="btnLoading">{{ $t('common.saveText') }}</a-button>
          <a-button @click="closeModal()">{{ $t('common.closeText') }}</a-button>
        </a-space>
      </div>
    </template>
    <div class="jnpf-content-wrapper">
      <div class="jnpf-content-wrapper-center">
        <div class="jnpf-content-wrapper-content bg-white p-[10px]">
          <a-alert :message="tipTxt" :description="descTxt" type="warning" show-icon class="mb-[10px]" ref="alertElRef" />
          <a-table :data-source="list" v-bind="getTableBindValues" v-model:expanded-row-keys="expandedRowKeys" ref="tableElRef">
            <template #expandedRowRender="{ record }">
              <a-table :data-source="record.fields" v-bind="getChildTableBindValues">
                <template #bodyCell="{ column, record: childRecord }">
                  <template v-if="column.key === 'field'">
                    <a-input v-model:value="childRecord.field" disabled detailed />
                  </template>
                  <template v-if="column.key === 'aliasName'">
                    <a-input v-model:value="childRecord.aliasName" placeholder="请输入" :maxlength="100" />
                  </template>
                  <template v-if="column.key === 'fieldName'">
                    <a-input v-model:value="childRecord.fieldName" disabled detailed />
                  </template>
                </template>
              </a-table>
            </template>
            <template #bodyCell="{ column, record }">
              <template v-if="column.key === 'table'">
                <a-input v-model:value="record.table" disabled detailed />
              </template>
              <template v-if="column.key === 'aliasName'">
                <a-input v-model:value="record.aliasName" placeholder="请输入" :maxlength="100" />
              </template>
              <template v-if="column.key === 'comment'">
                <a-input v-model:value="record.comment" disabled detailed />
              </template>
            </template>
          </a-table>
        </div>
      </div>
    </div>
  </BasicModal>
</template>