mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-22 12:58:55 +08:00
♻️优化 element-plus 全局 form item 样式,避免 select 样式失真
This commit is contained in:
parent
83b5f0c3aa
commit
01a9e0e39e
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
dist
|
||||||
|
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -29,7 +29,7 @@
|
|||||||
"eslint.validate": ["vue", "html", "javascript", "graphql", "javascriptreact", "json", "typescript", "typescriptreact", "vue-html"],
|
"eslint.validate": ["vue", "html", "javascript", "graphql", "javascriptreact", "json", "typescript", "typescriptreact", "vue-html"],
|
||||||
"eslint.format.enable": true,
|
"eslint.format.enable": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.cjson": "jsonc",
|
"*.cjson": "jsonc",
|
||||||
|
@ -86,6 +86,6 @@
|
|||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitee.com/log4j/pig"
|
"url": "https://gitee.com/log4j/pig-ui"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-form-item__content {
|
.el-form-item__content {
|
||||||
min-width: var(--el-form-inline-content-width);
|
|
||||||
.el-select {
|
.el-select {
|
||||||
width: 100% !important;
|
min-width: 180px;
|
||||||
}
|
}
|
||||||
.el-date-editor {
|
.el-date-editor {
|
||||||
width: 100% !important;
|
min-width: 180px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
<el-form-item :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity">
|
<el-form-item :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity">
|
||||||
<el-input-number :placeholder="t('client.inputRefreshTokenValidityTip')" v-model="form.refreshTokenValidity"/>
|
<el-input-number :placeholder="t('client.inputRefreshTokenValidityTip')" v-model="form.refreshTokenValidity"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="t('client.autoapprove')" prop="autoapprove" v-if="form.authorizedGrantTypes.includes('authorization_code')">
|
<el-form-item :label="t('client.autoapprove')" prop="autoapprove"
|
||||||
|
v-if="form.authorizedGrantTypes.includes('authorization_code')">
|
||||||
<el-radio-group v-model="form.autoapprove">
|
<el-radio-group v-model="form.autoapprove">
|
||||||
<el-radio :key="index" :label="item.value" border v-for="(item, index) in common_status">{{
|
<el-radio :key="index" :label="item.value" border v-for="(item, index) in common_status">{{
|
||||||
item.label
|
item.label
|
||||||
|
@ -1,90 +1,94 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="visible" :close-on-click-modal="false" :title="form.jobId ? $t('common.editBtn') : $t('common.addBtn')" draggable>
|
<el-dialog v-model="visible" :close-on-click-modal="false" :title="form.jobId ? $t('common.editBtn') : $t('common.addBtn')" draggable>
|
||||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.jobName')" prop="jobName">
|
<el-form-item :label="t('job.jobName')" prop="jobName">
|
||||||
<el-input v-model="form.jobName" :placeholder="t('job.inputjobNameTip')" />
|
<el-input v-model="form.jobName" :placeholder="t('job.inputjobNameTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.jobGroup')" prop="jobGroup">
|
<el-form-item :label="t('job.jobGroup')" prop="jobGroup">
|
||||||
<el-input v-model="form.jobGroup" :placeholder="t('job.inputjobGroupTip')" />
|
<el-input v-model="form.jobGroup" :placeholder="t('job.inputjobGroupTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.jobType')" prop="jobType">
|
<el-form-item :label="t('job.jobType')" prop="jobType">
|
||||||
<el-select v-model="form.jobType" :placeholder="t('job.jobType')">
|
<el-select v-model="form.jobType" :placeholder="t('job.jobType')">
|
||||||
<el-option v-for="(item, index) in job_type" :key="index" :label="item.label" :value="item.value"></el-option>
|
<el-option v-for="(item, index) in job_type" :key="index" :label="item.label"
|
||||||
</el-select>
|
:value="item.value"></el-option>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
</el-col>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20" v-if="['3', '4'].includes(form.jobType)">
|
<el-col :span="12" class="mb20" v-if="['3', '4'].includes(form.jobType)">
|
||||||
<el-form-item :label="t('job.executePath')" prop="executePath">
|
<el-form-item :label="t('job.executePath')" prop="executePath">
|
||||||
<el-input v-model="form.executePath" :placeholder="t('job.inputexecutePathTip')" />
|
<el-input v-model="form.executePath" :placeholder="t('job.inputexecutePathTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20" v-if="['1', '2'].includes(form.jobType)">
|
<el-col :span="12" class="mb20" v-if="['1', '2'].includes(form.jobType)">
|
||||||
<el-form-item :label="t('job.className')" prop="className">
|
<el-form-item :label="t('job.className')" prop="className">
|
||||||
<el-input v-model="form.className" :placeholder="t('job.inputclassNameTip')" />
|
<el-input v-model="form.className" :placeholder="t('job.inputclassNameTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20" v-if="['1', '2'].includes(form.jobType)">
|
<el-col :span="12" class="mb20" v-if="['1', '2'].includes(form.jobType)">
|
||||||
<el-form-item :label="t('job.methodName')" prop="methodName">
|
<el-form-item :label="t('job.methodName')" prop="methodName">
|
||||||
<el-input v-model="form.methodName" :placeholder="t('job.inputmethodNameTip')" />
|
<el-input v-model="form.methodName" :placeholder="t('job.inputmethodNameTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.methodParamsValue')" prop="methodParamsValue">
|
<el-form-item :label="t('job.methodParamsValue')" prop="methodParamsValue">
|
||||||
<el-input v-model="form.methodParamsValue" :placeholder="t('job.inputmethodParamsValueTip')" />
|
<el-input v-model="form.methodParamsValue" :placeholder="t('job.inputmethodParamsValueTip')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.cronExpression')" prop="cronExpression">
|
<el-form-item :label="t('job.cronExpression')" prop="cronExpression">
|
||||||
<crontab clearable @hide="popoverVis(false)" v-model="form.cronExpression"></crontab>
|
<crontab clearable @hide="popoverVis(false)" v-model="form.cronExpression"></crontab>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item :label="t('job.misfirePolicy')" prop="misfirePolicy">
|
<el-form-item :label="t('job.misfirePolicy')" prop="misfirePolicy">
|
||||||
<el-select v-model="form.misfirePolicy" :placeholder="t('job.inputmisfirePolicyTip')">
|
<el-select v-model="form.misfirePolicy" :placeholder="t('job.inputmisfirePolicyTip')">
|
||||||
<el-option v-for="(item, index) in misfire_policy" :key="index" :label="item.label" :value="item.value"></el-option>
|
<el-option v-for="(item, index) in misfire_policy" :key="index" :label="item.label"
|
||||||
</el-select>
|
:value="item.value"></el-option>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="24" class="mb20">
|
</el-col>
|
||||||
<el-form-item :label="t('job.remark')" prop="remark">
|
<el-col :span="24" class="mb20">
|
||||||
<el-input v-model="form.remark" :placeholder="t('job.inputremarkTip')" type="textarea" />
|
<el-form-item :label="t('job.remark')" prop="remark">
|
||||||
</el-form-item>
|
<el-input v-model="form.remark" :placeholder="t('job.inputremarkTip')" type="textarea"/>
|
||||||
</el-col>
|
</el-form-item>
|
||||||
</el-row>
|
</el-col>
|
||||||
</el-form>
|
</el-row>
|
||||||
<template #footer>
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button formDialogRef @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
<el-button formDialogRef @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
||||||
<el-button formDialogRef type="primary" @click="onSubmit" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
<el-button formDialogRef type="primary" @click="onSubmit" :disabled="loading">{{
|
||||||
|
$t('common.confirmButtonText')
|
||||||
|
}}</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="SysJobDialog" setup>
|
<script lang="ts" name="SysJobDialog" setup>
|
||||||
// 定义子组件向父组件传值/事件
|
// 定义子组件向父组件传值/事件
|
||||||
import { useDict } from '/@/hooks/dict';
|
import {useDict} from '/@/hooks/dict';
|
||||||
import { useMessage } from '/@/hooks/message';
|
import {useMessage} from '/@/hooks/message';
|
||||||
import { addObj, getObj, putObj } from '/@/api/daemon/job';
|
import {addObj, getObj, putObj} from '/@/api/daemon/job';
|
||||||
import { useI18n } from 'vue-i18n';
|
import {useI18n} from 'vue-i18n';
|
||||||
|
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(['refresh']);
|
||||||
const Crontab = defineAsyncComponent(() => import('/@/components/Crontab/index.vue'));
|
const Crontab = defineAsyncComponent(() => import('/@/components/Crontab/index.vue'));
|
||||||
|
|
||||||
const { t } = useI18n();
|
const {t} = useI18n();
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref();
|
||||||
@ -92,87 +96,88 @@ const visible = ref(false);
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
// 定义字典
|
// 定义字典
|
||||||
const { misfire_policy, job_type } = useDict('job_status', 'job_execute_status', 'misfire_policy', 'job_type');
|
const {misfire_policy, job_type} = useDict('job_status', 'job_execute_status', 'misfire_policy', 'job_type');
|
||||||
|
|
||||||
// 提交表单数据
|
// 提交表单数据
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
jobId: '',
|
jobId: '',
|
||||||
jobName: '',
|
jobName: '',
|
||||||
jobGroup: '',
|
jobGroup: '',
|
||||||
jobType: '',
|
jobType: '',
|
||||||
executePath: '',
|
executePath: '',
|
||||||
className: '',
|
className: '',
|
||||||
methodName: '',
|
methodName: '',
|
||||||
methodParamsValue: '',
|
methodParamsValue: '',
|
||||||
cronExpression: '',
|
cronExpression: '',
|
||||||
misfirePolicy: '',
|
misfirePolicy: '',
|
||||||
jobStatus: '',
|
jobStatus: '',
|
||||||
jobExecuteStatus: '',
|
jobExecuteStatus: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const popoverVis = (bol: boolean) => {
|
const popoverVis = (bol: boolean) => {
|
||||||
popoverVisible.value = bol;
|
popoverVisible.value = bol;
|
||||||
};
|
};
|
||||||
|
|
||||||
const popoverVisible = ref(false);
|
const popoverVisible = ref(false);
|
||||||
// 定义校验规则
|
// 定义校验规则
|
||||||
const dataRules = reactive({
|
const dataRules = reactive({
|
||||||
jobName: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
|
jobName: [{required: true, message: '任务名称不能为空', trigger: 'blur'}],
|
||||||
jobGroup: [{ required: true, message: '任务组名不能为空', trigger: 'blur' }],
|
jobGroup: [{required: true, message: '任务组名不能为空', trigger: 'blur'}],
|
||||||
jobType: [{ required: true, message: '任务类型不能为空', trigger: 'blur' }],
|
jobType: [{required: true, message: '任务类型不能为空', trigger: 'blur'}],
|
||||||
cronExpression: [{ required: true, message: 'cron不能为空', trigger: 'blur' }],
|
cronExpression: [{required: true, message: 'cron不能为空', trigger: 'blur'}],
|
||||||
misfirePolicy: [{ required: true, message: '策略不能为空', trigger: 'blur' }],
|
misfirePolicy: [{required: true, message: '策略不能为空', trigger: 'blur'}],
|
||||||
executePath: [{ required: true, message: '执行路径不能为空', trigger: 'blur' }],
|
executePath: [{required: true, message: '执行路径不能为空', trigger: 'blur'}],
|
||||||
className: [{ required: true, message: '执行文件不能为空', trigger: 'blur' }],
|
className: [{required: true, message: '执行文件不能为空', trigger: 'blur'}],
|
||||||
methodName: [{ required: true, message: '执行方法不能为空', trigger: 'blur' }],
|
methodName: [{required: true, message: '执行方法不能为空', trigger: 'blur'}],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = (id: string) => {
|
const openDialog = (id: string) => {
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
form.jobId = '';
|
form.jobId = '';
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dataFormRef.value?.resetFields();
|
dataFormRef.value?.resetFields();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取sysJob信息
|
// 获取sysJob信息
|
||||||
if (id) {
|
if (id) {
|
||||||
form.jobId = id;
|
form.jobId = id;
|
||||||
getsysJobData(id);
|
getsysJobData(id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
const valid = await dataFormRef.value.validate().catch(() => {
|
||||||
if (!valid) return false;
|
});
|
||||||
|
if (!valid) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
form.jobId ? await putObj(form) : await addObj(form);
|
form.jobId ? await putObj(form) : await addObj(form);
|
||||||
useMessage().success(t(form.jobId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
useMessage().success(t(form.jobId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error('任务初始化异常');
|
useMessage().error('任务初始化异常');
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 初始化表单数据
|
// 初始化表单数据
|
||||||
const getsysJobData = (id: string) => {
|
const getsysJobData = (id: string) => {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
getObj(id).then((res: any) => {
|
getObj(id).then((res: any) => {
|
||||||
Object.assign(form, res.data);
|
Object.assign(form, res.data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog,
|
openDialog,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user