55 <el-button text style =" color : #fff " :icon =" ArrowLeft" @click =" back()" />
66 {{ props.dsName }}
77 </div >
8- <el-button type =" primary" @click =" save()" > Save </el-button >
8+ <!-- < el-button type="primary" @click="save()"> Save </el-button> -- >
99 </div >
1010 <div class =" container" >
1111 <div class =" left-side" >
4343 <span >{{ currentTable.table_name }}</span >
4444 <el-divider direction =" vertical" />
4545 <span >Comment:</span >
46- <el-input style =" margin-left : 12px ;" v-model =" currentTable.custom_comment" />
46+ <span >{{ currentTable.custom_comment }}</span >
47+ <el-button style =" margin-left : 10px ;" text class =" action-btn" :icon =" IconOpeEdit" @click =" editTable" />
4748 </div >
4849 </div >
4950 <el-tabs
5859 <el-table-column prop =" field_comment" label =" Comment" />
5960 <el-table-column label =" Custom Comment" >
6061 <template #default =" scope " >
61- <div style =" display : flex ; align-items : center " >
62- <el-input v-model =" scope.row.custom_comment" />
62+ <div class =" field-comment" >
63+ <span >{{ scope.row.custom_comment }}</span >
64+ <el-button text class =" action-btn" :icon =" IconOpeEdit" @click =" editField(scope.row)" />
6365 </div >
6466 </template >
6567 </el-table-column >
6668 <el-table-column label =" Status" width =" 180" >
6769 <template #default =" scope " >
6870 <div style =" display : flex ; align-items : center " >
69- <el-switch v-model =" scope.row.checked" size =" small" />
71+ <el-switch v-model =" scope.row.checked" size =" small" @change = " changeStatus(scope.row) " />
7072 </div >
7173 </template >
7274 </el-table-column >
8991 </div >
9092 </div >
9193 </div >
94+
95+ <el-dialog
96+ v-model =" tableDialog"
97+ title =" Edit Table Comment"
98+ width =" 600"
99+ :destroy-on-close =" true"
100+ :close-on-click-modal =" false"
101+ @closed =" closeTable"
102+ >
103+ <div >Table Comment</div >
104+ <el-input v-model =" currentTable.custom_comment" />
105+
106+ <div style =" display : flex ; justify-content : flex-end ; margin-top : 20px " >
107+ <el-button @click =" closeTable" >Cancel</el-button >
108+ <el-button
109+ type =" primary"
110+ @click =" saveTable"
111+ >Confirm</el-button
112+ >
113+ </div >
114+ </el-dialog >
115+
116+ <el-dialog
117+ v-model =" fieldDialog"
118+ title =" Edit Field Comment"
119+ width =" 600"
120+ :destroy-on-close =" true"
121+ :close-on-click-modal =" false"
122+ @closed =" closeField"
123+ >
124+ <div >Field Comment</div >
125+ <el-input v-model =" currentField.custom_comment" />
126+
127+ <div style =" display : flex ; justify-content : flex-end ; margin-top : 20px " >
128+ <el-button @click =" closeField" >Cancel</el-button >
129+ <el-button
130+ type =" primary"
131+ @click =" saveField"
132+ >Confirm</el-button
133+ >
134+ </div >
135+ </el-dialog >
92136 </div >
93137</template >
94138
@@ -98,6 +142,7 @@ import { datasourceApi } from "@/api/datasource";
98142import { onMounted } from " vue" ;
99143import { ArrowLeft } from " @element-plus/icons-vue" ;
100144import type { TabsPaneContext } from " element-plus-secondary" ;
145+ import IconOpeEdit from ' @/assets/svg/operate/ope-edit.svg'
101146
102147const props = defineProps ({
103148 dsId: { type: [Number ], required: true },
@@ -108,10 +153,13 @@ const dsId = ref<Number>(0);
108153const searchValue = ref (" " );
109154const tableList = ref <any >([]);
110155const currentTable = ref <any >({});
156+ const currentField = ref <any >({});
111157const fieldList = ref <any >([]);
112158const previewData = ref <any >({});
113159
114160const activeName = ref (" schema" );
161+ const tableDialog = ref <boolean >(false )
162+ const fieldDialog = ref <boolean >(false )
115163
116164const buildData = () => {
117165 return { table: currentTable .value , fields: fieldList .value };
@@ -121,15 +169,59 @@ const back = () => {
121169 history .back ();
122170};
123171
124- const save = () => {
125- datasourceApi .edit (buildData ()).then (() => {
172+ // const save = () => {
173+ // datasourceApi.edit(buildData()).then(() => {
174+ // ElMessage({
175+ // message: "Save success",
176+ // type: "success",
177+ // showClose: true,
178+ // });
179+ // });
180+ // };
181+
182+ const editTable = () => {
183+ tableDialog .value = true
184+ }
185+
186+ const closeTable = () => {
187+ tableDialog .value = false
188+ }
189+
190+ const saveTable = () => {
191+ datasourceApi .saveTable (currentTable .value ).then (() => {
192+ closeTable ()
126193 ElMessage ({
127- message: " Save success " ,
194+ message: " Edit Success " ,
128195 type: " success" ,
129196 showClose: true ,
130- });
131- });
132- };
197+ })
198+ })
199+ }
200+
201+ const editField = (row : any ) => {
202+ currentField .value = row
203+ fieldDialog .value = true
204+ }
205+
206+ const changeStatus = (row : any ) => {
207+ currentField .value = row
208+ saveField ()
209+ }
210+
211+ const closeField = () => {
212+ fieldDialog .value = false
213+ }
214+
215+ const saveField = () => {
216+ datasourceApi .saveField (currentField .value ).then (() => {
217+ closeField ()
218+ ElMessage ({
219+ message: " Edit Success" ,
220+ type: " success" ,
221+ showClose: true ,
222+ })
223+ })
224+ }
133225
134226const clickTable = (table : any ) => {
135227 currentTable .value = table ;
@@ -200,4 +292,13 @@ onMounted(() => {
200292 }
201293 }
202294}
295+
296+ .field-comment {
297+ display : flex ;
298+ align-items : center ;
299+
300+ .action-btn {
301+ margin-left : 10px ;
302+ }
303+ }
203304 </style >
0 commit comments