| | |
| | | <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="openOperateDialog()"> 添加 </el-button> |
| | | <el-button icon="ele-Plus" @click="openOptDlg()"> 添加 </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </template> |
| | |
| | | <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="openOperateDialog(scope.row)"></i> |
| | | <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 |
| | |
| | | </el-table-column> |
| | | </el-table> |
| | | </template> |
| | | <ywDialog |
| | | v-model="dialogIsShow" |
| | | :headerIcon="dialogHeaderIcon" |
| | | :title="dialogTitle" |
| | | width="680" |
| | | @dlgClosed="closeDialog" |
| | | @submit="submitFormValue" |
| | | > |
| | | <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="提示词" prop="prompt"> |
| | | <el-input v-model="dialogFormValue.prompt"></el-input> |
| | | </el-form-item> |
| | | <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="note"> |
| | | <el-input v-model="dialogFormValue.note" 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> |
| | | <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 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 { 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'; |
| | | import { deepClone } from '/@/utils/other'; |
| | | |
| | | import SqlAmisEdit from './edit/SqlAmisEdit.vue'; |
| | | import { SupervisorPublished, supervisorPublishedMap } from './types'; |
| | | 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([]); |
| | |
| | | |
| | | //#endregion |
| | | |
| | | //#region ====================== 增加、修改记录操作, dialog init====================== |
| | | const isEditDialog = ref(false); |
| | | const dialogTitle = computed(() => { |
| | | return isEditDialog.value ? '修改页面' : '添加页面'; |
| | | }); |
| | | const dialogHeaderIcon = computed(() => { |
| | | return isEditDialog.value ? 'ele-Edit' : 'ele-Plus'; |
| | | }); |
| | | const dialogFormValue = ref(null); |
| | | const dialogIsShow = ref(false); |
| | | const dialogFormRef = ref<FormInstance>(null); |
| | | |
| | | const dialogFormRules = ref<FormRules>({ |
| | | title: [{ required: true, message: '请输入标题', trigger: 'change' }], |
| | | // prompt: [{ required: true, message: '输入提示词', trigger: 'blur' }], |
| | | }); |
| | | const openOperateDialog = (row?) => { |
| | | if (row) { |
| | | isEditDialog.value = true; |
| | | const { id, note, prompt, published, title, args } = row; |
| | | |
| | | dialogFormValue.value = deepClone({ id, note, prompt, published, title, args }); |
| | | } else { |
| | | isEditDialog.value = false; |
| | | |
| | | dialogFormValue.value = { title: null, prompt: null, published: SupervisorPublished.Y, note: null }; |
| | | } |
| | | dialogIsShow.value = true; |
| | | }; |
| | | const closeDialog = () => { |
| | | dialogIsShow.value = false; |
| | | dialogFormRef.value.clearValidate(); |
| | | }; |
| | | |
| | | const submitFormValue = async () => { |
| | | const valid = await dialogFormRef.value.validate().catch(() => {}); |
| | | if (!valid) return; |
| | | |
| | | if (isEditDialog.value) { |
| | | const res = await supervisorAdminApi.UpdateADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData) { |
| | | 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('修改页面成功'); |
| | | } else { |
| | | ElMessage.error('修改页面失败'); |
| | | } |
| | | } else { |
| | | const res = await supervisorAdminApi.InsertADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData === '0') { |
| | | ElMessage.error('添加页面失败'); |
| | | return; |
| | | } |
| | | const newData = { |
| | | id: resData, |
| | | ...dialogFormValue.value, |
| | | }; |
| | | tableData.value.push(newData); |
| | | closeDialog(); |
| | | ElMessage.success('添加页面成功'); |
| | | } |
| | | }; |
| | | |
| | | //#endregion |
| | | //#region ====================== 查询快捷键 ====================== |
| | | const queryFormRef = ref(null); |
| | | const pressEnterSearch = (ev: KeyboardEvent) => { |
| | |
| | | }; |
| | | //#endregion |
| | | |
| | | //#region ====================== 添加修改操作 ====================== |
| | | const optDlgIsShow = ref(false); |
| | | const optDlgMapRow = ref(null); |
| | | const openOptDlg = (row?: any) => { |
| | | optDlgMapRow.value = row; |
| | | optDlgIsShow.value = true; |
| | | }; |
| | | |
| | | 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(); |
| | | }); |