| | |
| | | <template> |
| | | <div class="h-full flex flex-col"> |
| | | <div class="grid grid-cols-2 gap-2 h-2/3 flex-0"> |
| | | <div class="h-full overflow-auto"> |
| | | <el-table |
| | | :data="tableData" |
| | | row-class-name="cursor-pointer" |
| | | class="h-full" |
| | | highlight-current-row |
| | | @current-change="dockRowChange" |
| | | > |
| | | <el-table-column prop="date" label="Date" width="180" /> |
| | | <el-table-column prop="name" label="Name" width="180" /> |
| | | <el-table-column prop="address" label="Address" /> |
| | | </el-table> |
| | | <!-- <codemirror |
| | | v-model="dockCode" |
| | | :style="{ height: '100%' }" |
| | | :autofocus="true" |
| | | :indent-with-tab="true" |
| | | :tab-size="2" |
| | | :extensions="dockEditorExtensions" |
| | | @change="log('change', $event)" |
| | | @focus="log('focus', $event)" |
| | | @blur="log('blur', $event)" |
| | | /> --> |
| | | </div> |
| | | <div class="h-full overflow-auto"> |
| | | <codemirror |
| | | class="h-full overflow-auto" |
| | | v-model="sqlCode" |
| | | :style="{ height: '100%' }" |
| | | :autofocus="true" |
| | | :indent-with-tab="true" |
| | | :tab-size="2" |
| | | :extensions="sqlEditorExtensions" |
| | | @change="log('change', $event)" |
| | | @focus="log('focus', $event)" |
| | | @blur="log('blur', $event)" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <div class="flex-auto overflow-auto mt-3"> |
| | | <codemirror |
| | | disabled |
| | | class="h-full overflow-auto" |
| | | v-model="jsonCode" |
| | | :style="{ height: '100%' }" |
| | | :autofocus="true" |
| | | :indent-with-tab="true" |
| | | :tab-size="2" |
| | | :extensions="jsonEditorExtensions" |
| | | @change="log('change', $event)" |
| | | @focus="log('focus', $event)" |
| | | @blur="log('blur', $event)" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <HMContainer type="card" v-if="supervisorMgrShow"> |
| | | <template #header> |
| | | <el-form ref="queryFormRef" :inline="true" :model="queryParams"> |
| | | <el-form-item label="标题" prop="title"> |
| | | <el-input v-model="queryParams.title" style="width: 226.4px" placeholder="标题" clearable /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-button type="primary" icon="ele-Search" @click="handleQueryTable"> 查询 </el-button> |
| | | <el-button icon="ele-Refresh" @click="resetQuery">重置 </el-button> |
| | | <el-button icon="ele-Plus" @click="openOptDlg()"> 添加 </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </template> |
| | | <template #main> |
| | | <!-- <div class="h-screen"> |
| | | <p>vue-json-editor</p> |
| | | <JsonEditorVue v-model="jsonMsg"></JsonEditorVue> |
| | | </div> --> |
| | | <el-table |
| | | v-loading="tableLoading" |
| | | ref="draggableTableRef" |
| | | class="h100" |
| | | border |
| | | :row-class-name="isDragStatus ? 'cursor-move' : 'cursor-pointer'" |
| | | :data="displayTableData" |
| | | highlight-current-row |
| | | > |
| | | <el-table-column type="expand" fixed="left"> |
| | | <template #default="scope"> |
| | | <div class="px-4"> |
| | | <h3 class="mb-2">页面参数</h3> |
| | | <JsonEditor currentMode="view" :modelValue="scope.row.args" /> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="title" label="标题" width="300" fixed="left" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column prop="prompt" label="提示词" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column prop="published" label="状态" width="80" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | {{ supervisorPublishedMap[scope.row.published] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建人" prop="creator" width="100" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column label="创建时间" prop="create_time" width="105" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column label="更新时间" prop="update_time" width="105" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column label="备注" prop="note" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column label="操作" width="120" fixed="right" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | <div class="space-x-2.5"> |
| | | <el-tooltip effect="dark" content="SQL编辑" placement="top"> |
| | | <i class="ywifont ywicon-sql !text-[14px] text-blue-400 cursor-pointer" @click="editSqlClick(scope.row)"></i> |
| | | </el-tooltip> |
| | | <el-tooltip effect="dark" content="编辑" placement="top"> |
| | | <i class="ywifont ywicon-bianji !text-[14px] text-blue-400 cursor-pointer" @click="openOptDlg(scope.row)"></i> |
| | | </el-tooltip> |
| | | <el-tooltip effect="dark" content="删除" placement="top"> |
| | | <i |
| | | class="ywifont ywicon-shanchu !text-[17px] text-red-400 cursor-pointer" |
| | | @click=" |
| | | () => { |
| | | deleteCurrentRow(scope.row, '页面', supervisorAdminApi.DeleteAAssetsEquipmentCostCategory, () => { |
| | | const foundIndex = tableData.findIndex((item) => item === scope.row); |
| | | foundIndex > -1 && tableData.splice(foundIndex, 1); |
| | | }); |
| | | } |
| | | " |
| | | ></i> |
| | | </el-tooltip> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </template> |
| | | <OptDlg v-model="optDlgIsShow" :item="optDlgMapRow" @insert="insertOpt" @update="updateOpt"></OptDlg> |
| | | </HMContainer> |
| | | <SqlAmisEdit v-else :supervisor="sqlEditMapSupervisor" @backLastPage="backLastPage"></SqlAmisEdit> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { json } from '@codemirror/lang-json'; |
| | | import { sql } from '@codemirror/lang-sql'; |
| | | import { xml } from '@codemirror/lang-xml'; |
| | | import { vscodeDark } from '@uiw/codemirror-theme-vscode'; |
| | | import { ref } from 'vue'; |
| | | import { Codemirror } from 'vue-codemirror'; |
| | | import * as codeExample from './testData'; |
| | | import _ from 'lodash'; |
| | | const log = console.log; |
| | | const jsonCode = ref(codeExample.jsonCode); |
| | | const dockCode = ref(codeExample.dockCode); |
| | | const sqlCode = ref(codeExample.sqlCode); |
| | | const tableData = [ |
| | | { |
| | | date: '2016-05-03', |
| | | name: 'Tom', |
| | | address: 'No. 189, Grove St, Los Angeles', |
| | | }, |
| | | { |
| | | date: '2016-05-02', |
| | | name: 'Tom', |
| | | address: 'No. 189, Grove St, Los Angeles', |
| | | }, |
| | | { |
| | | date: '2016-05-04', |
| | | name: 'Tom', |
| | | address: 'No. 189, Grove St, Los Angeles', |
| | | }, |
| | | { |
| | | date: '2016-05-01', |
| | | name: 'Tom', |
| | | address: 'No. 189, Grove St, Los Angeles', |
| | | }, |
| | | ]; |
| | | const jsonEditorExtensions = [json(), vscodeDark]; |
| | | const sqlEditorExtensions = [sql(), vscodeDark]; |
| | | const dockEditorExtensions = [xml(), vscodeDark]; |
| | | import { deleteCurrentRow } from '/@/utils/util'; |
| | | |
| | | const dockRowChange = (row) => {}; |
| | | /** @description 路径分隔符 */ |
| | | const PATH_SEPARATOR = '/'; |
| | | /** @description 1 退出所有循环 -1退出当次循环 0或其他值继续 */ |
| | | const travelObj = (obj, callBack?: (key?: string, value?: any, path?: string) => 1 | -1 | undefined | void | 0, path = '') => { |
| | | let entry = Object.entries(obj); |
| | | // if (entry[0] && !entry[0]['isRoot']) { |
| | | // entry = entry.map((item) => { |
| | | // item['isRoot'] = true; |
| | | // item['path'] = ''; |
| | | // return item; |
| | | // }); |
| | | // } |
| | | let res = null; |
| | | import { onMounted, ref } from 'vue'; |
| | | import HMContainer from '/@/components/layout/HMContainer.vue'; |
| | | import { usePageDisplay } from '/@/hooks/usePageDisplay'; |
| | | import { useQueryTable } from '/@/hooks/useQueryTable'; |
| | | // import { useTableSort } from '/@/hooks/useTableSort'; |
| | | // import { useValidateUniqueness } from '/@/hooks/useValidateUniqueness'; |
| | | |
| | | iterate: for (const item of entry) { |
| | | const [key, value] = item; |
| | | const currentPath = path + key; |
| | | res = callBack?.(key, value, currentPath); |
| | | switch (res) { |
| | | case 1: |
| | | break iterate; |
| | | case -1: |
| | | continue iterate; |
| | | default: |
| | | break; |
| | | } |
| | | if (!value) { |
| | | continue; |
| | | } |
| | | if (_.isObjectLike(value)) { |
| | | res = travelObj(value, callBack, currentPath); |
| | | switch (res) { |
| | | case 1: |
| | | break iterate; |
| | | case -1: |
| | | continue iterate; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | import SqlAmisEdit from './edit/SqlAmisEdit.vue'; |
| | | import OptDlg from './optDlg/OptDlg.vue'; |
| | | import { supervisorPublishedMap } from './types'; |
| | | import * as supervisorAdminApi from '/@/api/supervisorAdmin'; |
| | | import JsonEditor from '/@/components/form/jsonEditor/JsonEditor.vue'; |
| | | //#region ====================== 表格数据,table init ====================== |
| | | const tableLoading = ref(false); |
| | | const tableData = ref([]); |
| | | const isDragStatus = ref(false); |
| | | const getTableData = async () => { |
| | | tableLoading.value = true; |
| | | const res = await supervisorAdminApi.getSupervisorList().finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | tableData.value = (res.values || []).map((item) => { |
| | | item.create_time = item.create_time.slice(0, 10); |
| | | item.update_time = item.create_time.slice(0, 10); |
| | | |
| | | return item; |
| | | }); |
| | | }; |
| | | //#endregion |
| | | |
| | | //#region ====================== 表格查询、排序,search form init ====================== |
| | | |
| | | const queryParams = ref({ |
| | | title: '', |
| | | }); |
| | | const { resetQuery, handleQueryTable, displayTableData } = useQueryTable(tableData, queryParams, () => { |
| | | displayTableData.value = tableData.value; |
| | | }); |
| | | |
| | | //#endregion |
| | | |
| | | //#region ====================== 查询快捷键 ====================== |
| | | const queryFormRef = ref(null); |
| | | const pressEnterSearch = (ev: KeyboardEvent) => { |
| | | if (ev.key === 'Enter') { |
| | | handleQueryTable(); |
| | | } |
| | | return res; |
| | | }; |
| | | usePageDisplay( |
| | | () => { |
| | | queryFormRef.value?.$el?.addEventListener('keypress', pressEnterSearch); |
| | | }, |
| | | () => { |
| | | queryFormRef.value?.$el?.removeEventListener('keypress', pressEnterSearch); |
| | | } |
| | | ); |
| | | //#endregion |
| | | |
| | | //#region ====================== sql ====================== |
| | | |
| | | const supervisorMgrShow = ref(true); |
| | | const sqlEditMapSupervisor = ref(null); |
| | | const editSqlClick = (item) => { |
| | | sqlEditMapSupervisor.value = item; |
| | | supervisorMgrShow.value = false; |
| | | }; |
| | | |
| | | const enum AmisDockType { |
| | | Api, |
| | | } |
| | | type AmisDockApi = string; |
| | | type AmisDockValue = AmisDockApi; |
| | | type AmisDockConfig = { |
| | | type: AmisDockType; |
| | | value: AmisDockValue; |
| | | const backLastPage = () => { |
| | | supervisorMgrShow.value = true; |
| | | }; |
| | | const parseJSONData = (json: string) => { |
| | | if (!json) return; |
| | | const obj = JSON.parse(json); |
| | | const configList: AmisDockConfig[] = []; |
| | | travelObj( |
| | | { |
| | | id: 'u:7d4e7d100425', |
| | | body: [ |
| | | { |
| | | id: 'u:3e0a8e524d99', |
| | | }, |
| | | ], |
| | | }, |
| | | (key, value, path) => { |
| | | console.log('🚀 ~ key:', key); |
| | | console.log('🚀 ~ value:', value); |
| | | console.log('🚀 ~ path:', path); |
| | | //#endregion |
| | | |
| | | // if (key === 'api') { |
| | | // configList.push({ |
| | | // type: AmisDockType.Api, |
| | | // value: value.url, |
| | | // }); |
| | | // } |
| | | } |
| | | ); |
| | | //#region ====================== 添加修改操作 ====================== |
| | | const optDlgIsShow = ref(false); |
| | | const optDlgMapRow = ref(null); |
| | | const openOptDlg = (row?: any) => { |
| | | optDlgMapRow.value = row; |
| | | optDlgIsShow.value = true; |
| | | }; |
| | | |
| | | parseJSONData(codeExample.jsonCode); |
| | | const updateOpt = (formValue) => { |
| | | const foundIndex = tableData.value.find((item) => item.id === formValue.id); |
| | | if (foundIndex > -1) { |
| | | tableData.value[foundIndex] = { |
| | | ...tableData.value[foundIndex], |
| | | ...formValue, |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | const insertOpt = (newData) => { |
| | | tableData.value.push(newData); |
| | | }; |
| | | //#endregion |
| | | |
| | | onMounted(() => { |
| | | getTableData(); |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"></style> |