!37 feat(inspect): DqInspectTaskForm添加必填字段校验规则

* feat(inspect): DqInspectTaskForm添加必填字段校验规则
* refactor(form): 是否需要审批字段统一替换为j-switch组件
* feat(form): 部门经办人替换为sz-dept-user-modal组件
* feat(form): 新增部门角色用户选择组件,替换各处j-select-user
This commit is contained in:
new_new_new
2026-06-15 02:47:24 +00:00
parent f649986f4a
commit c1028224c1
8 changed files with 226 additions and 79 deletions
@@ -203,7 +203,7 @@
</a-col>
<a-col v-if="showSubApproveUserSelector" :span="12">
<a-form-item label="部门经办人" :labelCol="wideLabelCol" :wrapperCol="wideWrapperCol">
<j-select-user v-model:value="subApproveUser" :disabled="savingSubApproveUser" allow-clear />
<sz-dept-user-modal v-model:value="subApproveUser" :disabled="savingSubApproveUser" />
</a-form-item>
</a-col>
</a-row>
@@ -247,6 +247,7 @@
import { useUserStore } from '/@/store/modules/user';
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
import SzDeptUserModal from '/@/components/semri/deptUserComponent/SzDeptUserModal.vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import Icon from '/@/components/Icon/index';
import { saveBpmForm, setProcessVariable, specificProblemOptions } from '../DqInspectTask.api';
@@ -32,7 +32,13 @@
</a-col>
<a-col :span="12">
<a-form-item label="完成时限" v-bind="validateInfos.deadline" id="DqInspectTaskForm-deadline" name="deadline">
<a-date-picker placeholder="请选择完成时限" v-model:value="formData.deadline" value-format="YYYY-MM-DD" style="width: 100%" allow-clear />
<a-date-picker
placeholder="请选择完成时限"
v-model:value="formData.deadline"
value-format="YYYY-MM-DD"
style="width: 100%"
allow-clear
/>
</a-form-item>
</a-col>
<a-col :span="12">
@@ -46,7 +52,12 @@
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="监督意见" v-bind="validateInfos.supervisoryOpinion" id="DqInspectTaskForm-supervisoryOpinion" name="supervisoryOpinion">
<a-form-item
label="监督意见"
v-bind="validateInfos.supervisoryOpinion"
id="DqInspectTaskForm-supervisoryOpinion"
name="supervisoryOpinion"
>
<a-input v-model:value="formData.supervisoryOpinion" placeholder="请输入监督意见" allow-clear></a-input>
</a-form-item>
</a-col>
@@ -60,39 +71,65 @@
<!-- 责任与监督 -->
<a-divider orientation="left" plain>责任与监督</a-divider>
<a-row :gutter="[16, 0]">
<a-col :span="12">
<a-form-item label="措施责任领导" v-bind="validateInfos.measureResLeader" id="DqInspectTaskForm-measureResLeader" name="measureResLeader">
<j-select-user v-model:value="formData.measureResLeader" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="措施责任部门" v-bind="validateInfos.measureResDept" id="DqInspectTaskForm-measureResDept" name="measureResDept">
<j-select-dept v-model:value="formData.measureResDept" :multiple="true" checkStrictly allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="分管所领导" v-bind="validateInfos.chargeLeaderId" id="DqInspectTaskForm-chargeLeaderId" name="chargeLeaderId">
<j-select-user v-model:value="formData.chargeLeaderId" allow-clear />
<a-form-item
label="措施责任领导"
v-bind="validateInfos.measureResLeader"
id="DqInspectTaskForm-measureResLeader"
name="measureResLeader"
>
<DeptRoleUserSelectDropDown
v-model:value="formData.measureResLeader"
:deptId="measureResDeptId"
:roleId="MEASURE_RES_LEADER_ROLE_ID"
:disabled="measureResLeaderDisabled"
placeholder="请选择措施责任领导"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="整改交付成果" v-bind="validateInfos.rectificationEvidence" id="DqInspectTaskForm-rectificationEvidence" name="rectificationEvidence">
<a-form-item label="分管所领导" v-bind="validateInfos.chargeLeaderId" id="DqInspectTaskForm-chargeLeaderId" name="chargeLeaderId">
<DeptRoleUserSelectDropDown
v-model:value="formData.chargeLeaderId"
:deptId="CHARGE_LEADER_DEPT_ID"
:roleId="CHARGE_LEADER_ROLE_ID"
placeholder="请选择分管所领导"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
label="整改交付成果"
v-bind="validateInfos.rectificationEvidence"
id="DqInspectTaskForm-rectificationEvidence"
name="rectificationEvidence"
>
<a-input v-model:value="formData.rectificationEvidence" placeholder="请输入整改交付成果" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="成效评价标准" v-bind="validateInfos.evaluationCriterion" id="DqInspectTaskForm-evaluationCriterion" name="evaluationCriterion">
<a-form-item
label="成效评价标准"
v-bind="validateInfos.evaluationCriterion"
id="DqInspectTaskForm-evaluationCriterion"
name="evaluationCriterion"
>
<a-input v-model:value="formData.evaluationCriterion" placeholder="请输入成效评价标准" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="是否需要党群领导审批" v-bind="validateInfos.isNeedAppro" id="DqInspectTaskForm-isNeedAppro" name="isNeedAppro">
<j-dict-select-tag type='radio' v-model:value="formData.isNeedAppro" dictCode="yn" placeholder="请选择是否需要党群领导审批" allow-clear />
<j-switch v-model:value="formData.isNeedAppro" />
</a-form-item>
</a-col>
<a-col v-if="formData.isNeedAppro === '1'" :span="12">
<a-form-item label="党群领导" v-bind="validateInfos.supDeptleaderid" id="DqInspectTaskForm-supDeptleaderid" name="supDeptleaderid">
<j-select-user v-model:value="formData.supDeptleaderid" allow-clear />
<DeptRoleUserSelectRadioGroup v-model:value="formData.supDeptleaderid" :deptId="PARTY_MASSES_DEPT_ID" :roleId="MEASURE_RES_LEADER_ROLE_ID" />
</a-form-item>
</a-col>
</a-row>
@@ -117,7 +154,7 @@
<!-- :toolbar="true"/>-->
<!-- </a-tab-pane>-->
<!-- </a-tabs>-->
<div v-if="showFlowSubmitButton" :span="24" style="width: 100%;text-align: center;margin-top: 10px">
<div v-if="showFlowSubmitButton" :span="24" style="width: 100%; text-align: center; margin-top: 10px">
<a-button preIcon="ant-design:check-outlined" style="width: 126px" type="primary" @click="submitForm"> </a-button>
</div>
</a-spin>
@@ -131,31 +168,40 @@
import { JVxeTable } from '/@/components/jeecg/JVxeTable';
import { dqInspectProgressColumns } from '../DqInspectTask.data';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import JSwitch from '/@/components/Form/src/jeecg/components/JSwitch.vue';
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
import DeptRoleUserSelectRadioGroup from '/@/components/semri/userComponent/DeptRoleUserSelectRadioGroup.vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import { Form } from 'ant-design-vue';
import DeptRoleUserSelectDropDown from '@/components/semri/userComponent/DeptRoleUserSelectDropDown.vue';
const useForm = Form.useForm;
export default defineComponent({
name: "DqInspectTaskForm",
components:{
name: 'DqInspectTaskForm',
components: {
DeptRoleUserSelectDropDown,
JDictSelectTag,
JSwitch,
JSelectDept,
JSelectUser,
DeptRoleUserSelectRadioGroup,
JVxeTable,
JFormContainer,
},
props:{
formDisabled:{
props: {
formDisabled: {
type: Boolean,
default: false
default: false,
},
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
formData: { type: Object, default: () => {} },
formBpm: { type: Boolean, default: true },
},
emits:['success'],
setup(props, {emit}) {
emits: ['success'],
setup(props, { emit }) {
const CHARGE_LEADER_DEPT_ID = '2044677562460508161';
const CHARGE_LEADER_ROLE_ID = '2062794430936240130';
const PARTY_MASSES_DEPT_ID = '2044677628281720834';
const MEASURE_RES_LEADER_ROLE_ID = '2044680793306591234';
const loading = ref(false);
const formRef = ref();
const dqInspectProgressTableRef = ref();
@@ -164,7 +210,7 @@
const dqInspectProgressTable = reactive<Record<string, any>>({
loading: false,
columns: dqInspectProgressColumns,
dataSource: []
dataSource: [],
});
const activeKey = ref('dqInspectProgress');
const formData = reactive<Record<string, any>>({
@@ -198,34 +244,41 @@
//表单验证
const validatorRules = reactive({
problemId: [{ required: true, message: '请选择具体问题' }],
secretLevel: [{ required: true, message: '请选择密级' }],
improveMeasure: [{ required: true, message: '请输入整改措施' }],
deadline: [{ required: true, message: '请选择完成时限' }],
measureResDept: [{ required: true, message: '请选择措施责任部门' }],
measureResLeader: [{ required: true, message: '请选择措施责任领导' }],
chargeLeaderId: [{ required: true, message: '请选择分管所领导' }],
isNeedAppro: [{ required: true, message: '请选择是否需要党群领导审批' }],
});
const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false});
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
const dbData = {};
// 表单禁用
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
const disabled = computed(() => {
if (props.formBpm === true) {
if (props.formData.disabled === false) {
return false;
}else{
} else {
return true;
}
}
return props.formDisabled;
});
onMounted(()=>{
onMounted(() => {
loadSpecificProblemOptions();
initFormData();
});
//渲染流程表单数据
const queryByIdUrl = '/dqinspecttask/dqInspectTask/queryById';
async function initFormData(){
if(props.formBpm === true){
let params = {id: props.formData.dataId};
const row = await defHttp.get({url: queryByIdUrl, params});
async function initFormData() {
if (props.formBpm === true) {
let params = { id: props.formData.dataId };
const row = await defHttp.get({ url: queryByIdUrl, params });
//设置表单的值
Object.keys(row).map(k => {
Object.keys(row).map((k) => {
formData[k] = row[k];
});
//子表数据
@@ -234,15 +287,23 @@
}
}
// 是否显示提交按钮
const showFlowSubmitButton = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return true
const showFlowSubmitButton = computed(() => {
if (props.formBpm === true) {
if (props.formData.disabled === false) {
return true;
}
}
return false
return false;
});
const measureResDeptId = computed(() => {
const val = formData.measureResDept;
if (!val) return '';
return String(val).split(',')[0];
});
const measureResLeaderDisabled = computed(() => !measureResDeptId.value);
/**
* 整改任务只能选择具体问题,分类和面上问题由后端置灰用于分组展示。
*/
@@ -276,16 +337,16 @@
resetFields();
const tmpData = {};
Object.keys(formData).forEach((key) => {
if(row.hasOwnProperty(key)){
tmpData[key] = row[key]
if (row.hasOwnProperty(key)) {
tmpData[key] = row[key];
}
})
});
//赋值
Object.assign(formData,tmpData);
Object.assign(formData, tmpData);
}
const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, {
'dqInspectProgress': dqInspectProgressTableRef,
const { getSubFormAndTableData, transformData } = useValidateAntFormAndTable(activeKey, {
dqInspectProgress: dqInspectProgressTableRef,
});
async function getFormData() {
@@ -301,7 +362,7 @@
}
return Promise.reject(errorFields);
}
return transformData(toRaw(formData))
return transformData(toRaw(formData));
}
async function submitForm() {
@@ -320,16 +381,16 @@
} catch {}
}
const values = Object.assign({}, dbData, mainData, subData);
console.log('表单提交数据', values)
const isUpdate = values.id ? true : false
console.log('表单提交数据', values);
const isUpdate = values.id ? true : false;
await saveOrUpdate(values, isUpdate);
//关闭弹窗
emit('success');
}
function setFieldsValue(values) {
if(values){
Object.keys(values).map(k=>{
if (values) {
Object.keys(values).map((k) => {
formData[k] = values[k];
});
}
@@ -344,7 +405,6 @@
formData[key] = value;
}
return {
dqInspectProgressTableRef,
dqInspectProgressTable,
@@ -361,13 +421,19 @@
wrapperCol,
disabled,
showFlowSubmitButton,
CHARGE_LEADER_DEPT_ID,
CHARGE_LEADER_ROLE_ID,
PARTY_MASSES_DEPT_ID,
MEASURE_RES_LEADER_ROLE_ID,
measureResDeptId,
measureResLeaderDisabled,
getFormData,
submitForm,
add,
edit,
formRef,
}
}
};
},
});
</script>
<style lang="less" scoped>