| | |
| | | <template> |
| | | <HMContainer type="card"> |
| | | <HMContainer type="card" v-if="supervisorMgrShow"> |
| | | <template #header> |
| | | <el-form ref="queryFormRef" :inline="true" :model="queryParams"> |
| | | <el-form-item label="标题" prop="title"> |
| | |
| | | </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-key="ID" |
| | | :tree-props="{ children: 'Children', hasChildren: 'hasChildren' }" |
| | | :expand-row-keys="treeTableExpandKeys" |
| | | @expand-change="tableExpandChange" |
| | | :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> |
| | |
| | | <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 prop="Code" label="编码" show-overflow-tooltip> </el-table-column> |
| | | <el-table-column prop="Description" label="说明" width="550" 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"> |
| | |
| | | <i class="ywifont ywicon-bianji !text-[14px] text-blue-400 cursor-pointer" @click="openOperateDialog(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="openOperateDialog(scope.row)"></i> |
| | | <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> |
| | |
| | | v-model="dialogIsShow" |
| | | :headerIcon="dialogHeaderIcon" |
| | | :title="dialogTitle" |
| | | width="400" |
| | | width="680" |
| | | @dlgClosed="closeDialog" |
| | | @submit="submitFormValue" |
| | | > |
| | | <el-form :model="dialogFormValue" ref="dialogFormRef" :rules="dialogFormRules" label-width="55"> |
| | | <el-form-item label="父级" prop="ParentID" v-if="!isEditDialog"> |
| | | <el-tree-select |
| | | filterable |
| | | style="width: 100%" |
| | | v-model="dialogFormValue.ParentID" |
| | | :data="tableTreeData" |
| | | node-key="id" |
| | | :clearable="true" |
| | | :accordion="true" |
| | | :expandNode="false" |
| | | :check-strictly="true" |
| | | > |
| | | </el-tree-select> |
| | | <el-form :model="dialogFormValue" ref="dialogFormRef" :rules="dialogFormRules" label-width="78"> |
| | | <el-form-item label="标题" prop="title"> |
| | | <el-input v-model="dialogFormValue.title"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="undefined" prop="ParentID"> |
| | | <el-input v-model="dialogFormValue.ParentID"></el-input> |
| | | <el-form-item label="提示词" prop="prompt"> |
| | | <el-input v-model="dialogFormValue.prompt"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="标题" prop="Name"> |
| | | <el-input v-model="dialogFormValue.Name"></el-input> |
| | | <el-form-item label="状态" prop="published"> |
| | | <el-select v-model="dialogFormValue.published"> |
| | | <el-option |
| | | v-for="item in Object.keys(supervisorPublishedMap)" |
| | | :key="item" |
| | | :value="item" |
| | | :label="supervisorPublishedMap[item]" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="编码" prop="Code"> |
| | | <el-input v-model="dialogFormValue.Code"></el-input> |
| | | <el-form-item label="备注" prop="note"> |
| | | <el-input v-model="dialogFormValue.note" type="textarea" :rows="3"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="说明" prop="Description"> |
| | | <el-input v-model="dialogFormValue.Description" type="textarea" :rows="3"></el-input> |
| | | </el-form-item> |
| | | <div class="flex"> |
| | | <span class="flex-0 ml-2.5">页面参数</span> |
| | | <JsonEditor class="ml-3 h-80" :showToolbar="true" currentMode="form" v-model="dialogFormValue.args" /> |
| | | </div> |
| | | </el-form> |
| | | </ywDialog> |
| | | </HMContainer> |
| | | <SqlAmisEdit v-else :supervisor="sqlEditMapSupervisor" @backLastPage="backLastPage"></SqlAmisEdit> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import type { FormInstance, FormRules } from 'element-plus'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { deleteCurrentRow } from '/@/utils/util'; |
| | | |
| | | import { computed, onMounted, ref } from 'vue'; |
| | | import ywDialog from '/@/components/dialog/yw-dialog.vue'; |
| | |
| | | // import { useValidateUniqueness } from '/@/hooks/useValidateUniqueness'; |
| | | import { deepClone } from '/@/utils/other'; |
| | | |
| | | import { supervisorPublishedMap } from './types'; |
| | | import SqlAmisEdit from './edit/SqlAmisEdit.vue'; |
| | | import { SupervisorPublished, supervisorPublishedMap } from './types'; |
| | | import * as supervisorAdminApi from '/@/api/supervisorAdmin'; |
| | | import { convertListToTree, tableCellCenterExceptColumn } from '/@/utils/util'; |
| | | import { gotoRoute } from '/@/utils/route'; |
| | | const tableTreeData = computed(() => convertListToTree(tableData.value)); |
| | | import JsonEditor from '/@/components/form/jsonEditor/JsonEditor.vue'; |
| | | |
| | | //#region ====================== 表格数据,table init ====================== |
| | | const tableLoading = ref(false); |
| | |
| | | //#region ====================== 增加、修改记录操作, dialog init====================== |
| | | const isEditDialog = ref(false); |
| | | const dialogTitle = computed(() => { |
| | | return isEditDialog.value ? '修改分组' : '添加分组'; |
| | | return isEditDialog.value ? '修改页面' : '添加页面'; |
| | | }); |
| | | const dialogHeaderIcon = computed(() => { |
| | | return isEditDialog.value ? 'ele-Edit' : 'ele-Plus'; |
| | |
| | | const dialogFormRef = ref<FormInstance>(null); |
| | | |
| | | const dialogFormRules = ref<FormRules>({ |
| | | ParentID: [{ required: true, message: '请选择undefined', trigger: 'change' }], |
| | | Name: [{ required: true, message: '请输入标题', trigger: 'blur' }], |
| | | title: [{ required: true, message: '请输入标题', trigger: 'change' }], |
| | | // prompt: [{ required: true, message: '输入提示词', trigger: 'blur' }], |
| | | }); |
| | | const openOperateDialog = (row?) => { |
| | | if (row) { |
| | | isEditDialog.value = true; |
| | | const { ID, ParentID, Name, Code, Description } = row; |
| | | const { id, note, prompt, published, title, args } = row; |
| | | |
| | | dialogFormValue.value = deepClone({ ID, ParentID, Name, Code, Description }); |
| | | dialogFormValue.value = deepClone({ id, note, prompt, published, title, args }); |
| | | } else { |
| | | isEditDialog.value = false; |
| | | |
| | | dialogFormValue.value = { ParentID: '', Name: '', Code: '', Description: '' }; |
| | | dialogFormValue.value = { title: null, prompt: null, published: SupervisorPublished.Y, note: null }; |
| | | } |
| | | dialogIsShow.value = true; |
| | | }; |
| | |
| | | const res = await supervisorAdminApi.UpdateADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData) { |
| | | getTableData(); |
| | | const foundIndex = tableData.value.find((item) => item.id === dialogFormValue.value.id); |
| | | if (foundIndex > -1) { |
| | | tableData.value[foundIndex] = { |
| | | ...tableData.value[foundIndex], |
| | | ...dialogFormValue.value, |
| | | }; |
| | | } |
| | | closeDialog(); |
| | | ElMessage.success('修改分组成功'); |
| | | ElMessage.success('修改页面成功'); |
| | | } else { |
| | | ElMessage.error('修改分组失败'); |
| | | ElMessage.error('修改页面失败'); |
| | | } |
| | | } else { |
| | | const res = await supervisorAdminApi.InsertADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData === '0') { |
| | | ElMessage.error('添加分组失败'); |
| | | ElMessage.error('添加页面失败'); |
| | | return; |
| | | } |
| | | getTableData(); |
| | | const newData = { |
| | | id: resData, |
| | | ...dialogFormValue.value, |
| | | }; |
| | | tableData.value.push(newData); |
| | | closeDialog(); |
| | | ElMessage.success('添加分组成功'); |
| | | ElMessage.success('添加页面成功'); |
| | | } |
| | | }; |
| | | |
| | |
| | | }; |
| | | usePageDisplay( |
| | | () => { |
| | | queryFormRef.value.$el.addEventListener('keypress', pressEnterSearch); |
| | | queryFormRef.value?.$el?.addEventListener('keypress', pressEnterSearch); |
| | | }, |
| | | () => { |
| | | queryFormRef.value?.$el.removeEventListener('keypress', pressEnterSearch); |
| | | queryFormRef.value?.$el?.removeEventListener('keypress', pressEnterSearch); |
| | | } |
| | | ); |
| | | //#endregion |
| | | //#region ====================== 解决拖拽展开状态失效问题 ====================== |
| | | const treeTableExpandKeys = ref([]); |
| | | const tableExpandChange = (row, expanded) => { |
| | | if (expanded) { |
| | | treeTableExpandKeys.value.push(row.ID); |
| | | } else { |
| | | const idx = treeTableExpandKeys.value.indexOf(row.ID); |
| | | treeTableExpandKeys.value.splice(idx, 1); |
| | | } |
| | | }; //#endregion |
| | | |
| | | |
| | | //#region ====================== sql ====================== |
| | | const editSqlClick = () => { |
| | | gotoRoute({ |
| | | name:'SqlAmisEdit' |
| | | }) |
| | | }; |
| | | |
| | | const supervisorMgrShow = ref(true); |
| | | const sqlEditMapSupervisor = ref(null); |
| | | const editSqlClick = (item) => { |
| | | sqlEditMapSupervisor.value = item; |
| | | supervisorMgrShow.value = false; |
| | | }; |
| | | |
| | | const backLastPage = () => { |
| | | supervisorMgrShow.value = true; |
| | | }; |
| | | //#endregion |
| | | |
| | | onMounted(() => { |
| | | getTableData(); |
| | | }); |