禁止变量修改上级变量和所属服务

main
expressgy 3 months ago
parent d8783898f4
commit ead6a92bd9
  1. 2
      src/main.js
  2. 21
      src/views/Auth/Env/EnvForm.vue
  3. 16
      src/views/Auth/Env/EnvPage.vue

@ -6,7 +6,7 @@ window.pino = Pino({
deb: 20, deb: 20,
}, },
browser: { browser: {
asObject: true, asObject: false,
serialize: true serialize: true
}, },
}); });

@ -3,6 +3,7 @@ import { EnvFormRulesType, EnvFormType } from '@/views/Auth/Env/DataModal.js';
import { h, onMounted, ref, watch } from 'vue'; import { h, onMounted, ref, watch } from 'vue';
import { ReloadOutlined, SettingOutlined } from '@ant-design/icons-vue'; import { ReloadOutlined, SettingOutlined } from '@ant-design/icons-vue';
import { useBaseDataStore } from '@/stores'; import { useBaseDataStore } from '@/stores';
import AntdModalTemplate from '@/components/AntDesignVue/CustomAntDesignVue/AntdModalTemplate/index.vue';
const baseDataStore = useBaseDataStore(); const baseDataStore = useBaseDataStore();
defineOptions({ defineOptions({
@ -44,29 +45,16 @@ const handleAck = () => {
if (Array.isArray(value.envVal) && value.envVal.length > 0) { if (Array.isArray(value.envVal) && value.envVal.length > 0) {
data.envVal = value.envVal.slice(-1)[0]; data.envVal = value.envVal.slice(-1)[0];
} }
props.data.handleAck(data).then(() => { props.data.handleAck(data).catch(e => e);
clearInput();
}).catch(e => e);
}) })
.catch((err) => { .catch((err) => {
formRef.value.scrollToField(err?.errorFields[0]?.name); formRef.value.scrollToField(err?.errorFields[0]?.name);
}); });
}; };
// !
const handleCancel = () => {
props.data.handleCancel();
clearInput();
};
// ! // !
function clearValidate() { function clearValidate() {
formRef.value?.clearValidate(); formRef.value?.clearValidate();
} }
// !
function clearInput() {
formRef.value.resetFields();
clearValidate();
}
// ! pid // ! pid
watch(props.data.formData, (newVal, oldVal) => { watch(props.data.formData, (newVal, oldVal) => {
if (newVal.pid != '') { if (newVal.pid != '') {
@ -106,6 +94,7 @@ onMounted(() => {
<AFlex gap="small"> <AFlex gap="small">
<ACascader <ACascader
flex="1" flex="1"
:disabled="props.data.isUpdate"
allowClear allowClear
showSearch showSearch
v-model:value="props.data.formData.pid" v-model:value="props.data.formData.pid"
@ -123,7 +112,7 @@ onMounted(() => {
<ASelect <ASelect
placeholder="请选择所属服务" placeholder="请选择所属服务"
ref="serviceKey" ref="serviceKey"
:disabled="serviceKeyDisabled" :disabled="serviceKeyDisabled || props.data.isUpdate"
v-model:value="props.data.formData.serviceKey" v-model:value="props.data.formData.serviceKey"
:options="baseDataStore.state.serviceList" :options="baseDataStore.state.serviceList"
:field-names="{ label: 'serviceName', value: 'serviceKey', options: 'children' }" :field-names="{ label: 'serviceName', value: 'serviceKey', options: 'children' }"
@ -182,7 +171,7 @@ onMounted(() => {
</AFormItem> </AFormItem>
</AForm> </AForm>
<template #footer> <template #footer>
<AButton type="dashed" @click="handleCancel">取消</AButton> <AButton type="dashed" @click="props.data.handleCancel">取消</AButton>
<AckCreateAntdButton @click="handleAck" /> <AckCreateAntdButton @click="handleAck" />
</template> </template>
</AntdModalTemplate> </AntdModalTemplate>

@ -15,14 +15,7 @@ defineOptions({
}); });
onMounted(() => { onMounted(() => {
window.pino.info('@1 EnvPage Mounted!'); window.pino.deb('@1 EnvPage Mounted!');
window.pino.deb('debug@1 EnvPage Mounted!');
window.pino.error('error@1 EnvPage Mounted!');
window.pino.fatal('fatal@1 EnvPage Mounted!');
window.pino.info('info@1 EnvPage Mounted!');
window.pino.warn('warn@1 EnvPage Mounted!');
window.pino.trace('trace@1 EnvPage Mounted!');
console.log(window.pino);
getPage(); getPage();
if(baseDataStore.state.serviceList.length == 0){ if(baseDataStore.state.serviceList.length == 0){
baseDataStore.getServiceList(); baseDataStore.getServiceList();
@ -47,7 +40,7 @@ const formData = reactive({
// //
handleAck: handleCreateAck, handleAck: handleCreateAck,
// //
handleCancel: clearFormData, handleCancel: () => clearFormData(),
}); });
// //
const tableData = reactive({ const tableData = reactive({
@ -93,6 +86,9 @@ async function handleUpdate(data) {
} }
// @4 todo // @4 todo
async function handleUpdateAck(data) { async function handleUpdateAck(data) {
if(!data.pid){
data.pid = 0;
}
await CoreEnv.updateEnv(formData.envId, data); await CoreEnv.updateEnv(formData.envId, data);
Message.success('更新变量成功!'); Message.success('更新变量成功!');
clearFormData(); clearFormData();
@ -114,7 +110,7 @@ watch(tableData.pageInfo, () => {
// @6 // @6
async function getPage() { async function getPage() {
const pageInfo = {...tableData.pageInfo}; const pageInfo = {...tableData.pageInfo};
pageInfo.hierarchy = pageInfo.hierarchy.length > 0 ? pageInfo.hierarchy[0] : undefined pageInfo.hierarchy = pageInfo.hierarchy.length > 0 ? pageInfo.hierarchy[0] : undefined;
const resd = await CoreEnv.getEnv(pageInfo); const resd = await CoreEnv.getEnv(pageInfo);
tableData.dataSource = resd.rowData; tableData.dataSource = resd.rowData;
tableData.total = Number(resd.total); tableData.total = Number(resd.total);

Loading…
Cancel
Save