| | |
| | | v-model="dialogIsShow" |
| | | :headerIcon="dialogHeaderIcon" |
| | | :title="dialogTitle" |
| | | width="680" |
| | | width="720" |
| | | @dlgClosed="closeDialog" |
| | | @submit="submitFormValue" |
| | | > |
| | |
| | | <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> |
| | | </template> |
| | |
| | | import ywDialog from '/@/components/dialog/yw-dialog.vue'; |
| | | |
| | | import type { FormInstance, FormRules } from 'element-plus'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { ElMessage, TableInstance } from 'element-plus'; |
| | | |
| | | import { computed, ref, watch } from 'vue'; |
| | | // import { useTableSort } from '/@/hooks/useTableSort'; |
| | |
| | | import { SupervisorPublished, supervisorPublishedMap } from '../types'; |
| | | import * as supervisorAdminApi from '/@/api/supervisorAdmin'; |
| | | import JsonEditor from '/@/components/form/jsonEditor/JsonEditor.vue'; |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import EditTable from '/@/components/table/editTable/EditTable.vue'; |
| | | import EditTableColumn from '/@/components/table/editTable/EditTableColumn.vue'; |
| | | import { formatDate } from '/@/utils/formatTime'; |
| | | import { useUserInfo } from '/@/stores/userInfo'; |
| | | import { storeToRefs } from 'pinia'; |
| | | |
| | | const props = defineProps(['item']); |
| | | const props = defineProps(['item', 'groupId']); |
| | | const emit = defineEmits(['update', 'insert']); |
| | | //#region ====================== 增加、修改记录操作, dialog init====================== |
| | | const isEditDialog = ref(false); |
| | |
| | | const dialogFormRef = ref<FormInstance>(null); |
| | | |
| | | const dialogFormRules = ref<FormRules>({ |
| | | title: [{ required: true, message: '请输入标题', trigger: 'change' }], |
| | | // prompt: [{ required: true, message: '输入提示词', trigger: 'blur' }], |
| | | title: [{ required: true, message: '请输入标题', trigger: 'blur' }], |
| | | 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 }); |
| | | const { id, note, prompt, title } = row; |
| | | dialogFormValue.value = deepClone({ id, note, prompt, title }); |
| | | } else { |
| | | isEditDialog.value = false; |
| | | |
| | | dialogFormValue.value = { title: null, prompt: null, published: SupervisorPublished.Y, note: null }; |
| | | dialogFormValue.value = { group: props.groupId, title: null, prompt: null, note: null }; |
| | | } |
| | | }; |
| | | const closeDialog = () => { |
| | | dialogIsShow.value = false; |
| | | dialogFormRef.value.clearValidate(); |
| | | }; |
| | | const stores = useUserInfo(); |
| | | const { userInfos } = storeToRefs(stores); |
| | | |
| | | const submitFormValue = async () => { |
| | | const valid = await dialogFormRef.value.validate().catch(() => {}); |
| | | if (!valid) return; |
| | | |
| | | const sendForm = { ...dialogFormValue.value }; |
| | | const updateTime = formatDate(new Date()); |
| | | if (isEditDialog.value) { |
| | | const res = await supervisorAdminApi.UpdateADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData) { |
| | | emit('update', dialogFormValue.value); |
| | | const res = await supervisorAdminApi.updateSupervisor(sendForm); |
| | | emit('update', { ...dialogFormValue.value, update_time: updateTime.slice(0, 10) }); |
| | | |
| | | closeDialog(); |
| | | ElMessage.success('修改页面成功'); |
| | | } else { |
| | | ElMessage.error('修改页面失败'); |
| | | } |
| | | closeDialog(); |
| | | ElMessage.success('修改页面成功'); |
| | | } else { |
| | | const res = await supervisorAdminApi.InsertADictGroup(dialogFormValue.value); |
| | | const resData = res.Data; |
| | | if (resData === '0') { |
| | | ElMessage.error('添加页面失败'); |
| | | return; |
| | | } |
| | | const res = await supervisorAdminApi.addSupervisor(sendForm); |
| | | const newData = { |
| | | id: resData, |
| | | id: res.agent_id, |
| | | ...dialogFormValue.value, |
| | | create_time: updateTime.slice(0, 10), |
| | | update_time: updateTime.slice(0, 10), |
| | | creator: userInfos.value.userName, |
| | | }; |
| | | emit('insert', newData); |
| | | // tableData.value.push(newData); |
| | |
| | | |
| | | //#endregion |
| | | |
| | | |
| | | watch( |
| | | () => dialogIsShow.value, |
| | | (val) => { |