forked from wangjiadong/comp
parent
6a1066c0bc
commit
68335f6d8e
6 changed files with 731 additions and 27 deletions
@ -0,0 +1,156 @@ |
||||
import { defHttp } from '/@/utils/http/axios'; |
||||
import { useMessage } from "/@/hooks/web/useMessage"; |
||||
|
||||
const { createConfirm } = useMessage(); |
||||
|
||||
enum Api { |
||||
list = '/AnnualCompPoint/annualCompPoint/list', |
||||
save='/AnnualCompPoint/annualCompPoint/add', |
||||
edit='/AnnualCompPoint/annualCompPoint/edit', |
||||
edit1='/AnnualCompPoint/annualCompPoint/edit1', |
||||
deleteOne = '/AnnualCompPoint/annualCompPoint/delete', |
||||
deleteBatch = '/AnnualCompPoint/annualCompPoint/deleteBatch', |
||||
importExcel = '/AnnualCompPoint/annualCompPoint/importExcel', |
||||
exportXls = '/AnnualCompPoint/annualCompPoint/exportXls', |
||||
exportXlsMb = '/AnnualCompPoint/annualCompPoint/exportXlsMb', |
||||
updateApply = '/AnnualCompPoint/annualCompPoint/updateApply', |
||||
collectScore = '/annualScore/personalCompScore/collectScore', |
||||
pj = '/AnnualCompPoint/annualCompPoint/pj', |
||||
cjhz = '/AnnualCompPoint/annualCompPoint/cjhz', |
||||
tongfenfuping = '/AnnualCompPoint/annualCompPoint/tongfenfuping', |
||||
getProjectlevel = '/projectlevel/projectlevel/getProjectlevel', |
||||
} |
||||
|
||||
/** |
||||
* 导出api |
||||
* @param params |
||||
*/ |
||||
export const getExportUrl = Api.exportXls; |
||||
export const getExportUrlMb = Api.exportXlsMb; |
||||
|
||||
/** |
||||
* 导入api |
||||
*/ |
||||
export const getImportUrl = Api.importExcel; |
||||
|
||||
/** |
||||
* 列表接口 |
||||
* @param params |
||||
*/ |
||||
export const list = (params) => defHttp.get({ url: Api.list, params }); |
||||
|
||||
/** |
||||
* 删除单个 |
||||
* @param params |
||||
* @param handleSuccess |
||||
*/ |
||||
export const deleteOne = (params,handleSuccess) => { |
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
|
||||
export const pj = (params,handleSuccess) => { |
||||
return defHttp.get({url: Api.pj, params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
export const cjhz = (params,handleSuccess) => { |
||||
return defHttp.get({url: Api.cjhz, params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 批量删除 |
||||
* @param params |
||||
* @param handleSuccess |
||||
*/ |
||||
export const batchDelete = (params, handleSuccess) => { |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '确认删除', |
||||
content: '是否删除选中数据', |
||||
okText: '确认', |
||||
cancelText: '取消', |
||||
onOk: () => { |
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
// 个人积分汇总
|
||||
export const collectScore = (params,handleSuccess) => { |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '确认操作', |
||||
content: '确认发送请求吗', |
||||
okText: '确认', |
||||
cancelText: '取消', |
||||
onOk: () => { |
||||
return defHttp.post({url: Api.collectScore,params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 保存或者更新 |
||||
* @param params |
||||
* @param isUpdate |
||||
*/ |
||||
export const saveOrUpdate = (params, isUpdate) => { |
||||
let url = isUpdate ? Api.edit : Api.save; |
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false }); |
||||
} |
||||
|
||||
export const saveOrUpdate1 = (params, isUpdate) => { |
||||
let url = isUpdate ? Api.edit1 : Api.save; |
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false }); |
||||
} |
||||
|
||||
/** |
||||
* 提交或申请修改 |
||||
* @param params |
||||
* @param handleSuccess |
||||
*/ |
||||
export const updateApply = (params,handleSuccess) => { |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '确认操作', |
||||
content: '确认发送请求吗', |
||||
okText: '确认', |
||||
cancelText: '取消', |
||||
onOk: () => { |
||||
return defHttp.post({url: Api.updateApply,params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 同分同分复评
|
||||
export const tongfenfuping = (params,handleSuccess) => { |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '确认操作', |
||||
content: '确认发送请求吗', |
||||
okText: '确认', |
||||
cancelText: '取消', |
||||
onOk: () => { |
||||
return defHttp.post({url: Api.tongfenfuping,params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
export const getProjectlevel = (params) => { |
||||
const url = Api.getProjectlevel; |
||||
return defHttp.get({ url: url, params }); |
||||
}; |
||||
|
@ -0,0 +1,430 @@ |
||||
<template> |
||||
<a-spin :spinning="confirmLoading"> |
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
||||
<a-row> |
||||
<a-col :span="12"> |
||||
<a-form-item label="年度比赛" v-bind="validateInfos.annualCompId" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
||||
<j-popup |
||||
placeholder="请选择年度比赛" |
||||
v-model:value="formData.annualCompId_dictText" |
||||
code="ndbs" |
||||
:fieldConfig="[ |
||||
{ source: 'name', target: 'annualCompId_dictText' }, |
||||
{ source: 'id', target: 'annualCompId' }, |
||||
]" |
||||
:multi="true" |
||||
:setFieldsValue="setFieldsValue" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="12"> |
||||
<a-form-item label="项目(赛道)名称" v-bind="validateInfos.objName" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
||||
<a-input v-model:value="formData.objName" placeholder="请输入项目(赛道)名称"></a-input> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="12"> |
||||
<a-form-item label="开始时间" v-bind="validateInfos.starttime"> |
||||
<a-date-picker |
||||
placeholder="请选择开始时间" |
||||
v-model:value="formData.starttime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="12"> |
||||
<a-form-item label="结束时间" v-bind="validateInfos.endtime"> |
||||
<a-date-picker |
||||
placeholder="请选择结束时间" |
||||
v-model:value="formData.endtime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="12"> |
||||
<a-form-item label="项目(赛道)层次" v-bind="validateInfos.objLevel" :labelCol="labelCol" :wrapperCol="wrapperCol7"> |
||||
<j-dict-select-tag type="radio" v-model:value="formData.objLevel" placeholder="请选择项目(赛道)层次" dict-code="obj_lever" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="24"> |
||||
<a-form-item label="简介" v-bind="validateInfos.introduce" :labelCol="labelCol1" :wrapperCol="wrapperCol1"> |
||||
<a-textarea v-model:value="formData.introduce" rows="4" placeholder="请输入简介" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="11"> |
||||
<a-form-item label="参与形式" v-bind="validateInfos.entryForm" :labelCol="labelCol" :wrapperCol="wrapperCol8"> |
||||
<j-dict-select-tag type="radio" v-model:value="formData.entryForm" placeholder="请选择参与形式" dict-code="joinType" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="6" v-if="formData.entryForm === 'Y'"> |
||||
<a-form-item label="是否需要领队" v-bind="validateInfos.requireLeader" :labelCol="labelCol3" :wrapperCol="wrapperCol3"> |
||||
<j-switch v-model:value="formData.requireLeader"></j-switch> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="7" v-if="formData.entryForm === 'Y'"> |
||||
<a-form-item label="是否需要队伍名称" v-bind="validateInfos.requireTeamName" :labelCol="labelCol3" :wrapperCol="wrapperCol3"> |
||||
<j-switch type="radio" v-model:value="formData.requireTeamName" dictCode="" placeholder="请选择是否需要队伍名称" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="12" v-if="formData.entryForm === 'Y'"> |
||||
<a-form-item label="队伍人数" v-bind="validateInfos.teamNumber"> |
||||
<a-input-number v-model:value="formData.teamNumber" placeholder="请输入队伍人数" style="width: 100%" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="12" v-if="formData.entryForm === 'Y'"> |
||||
<a-form-item label="指导老师人数" v-bind="validateInfos.teacherNumber"> |
||||
<a-input-number v-model:value="formData.teacherNumber" placeholder="请输入指导老师人数" style="width: 100%" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="5"> |
||||
<a-form-item label="是否报名" v-bind="validateInfos.requireApply" :labelCol="labelCol4" :wrapperCol="wrapperCol4"> |
||||
<j-switch v-model:value="formData.requireApply" :disabled="disabled"></j-switch> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireApply === 'Y'"> |
||||
<a-form-item label="开始时间" v-bind="validateInfos.applyStartTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择报名开始时间" |
||||
v-model:value="formData.applyStartTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireApply === 'Y'"> |
||||
<a-form-item label="结束时间" v-bind="validateInfos.applyEndTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择报名结束时间" |
||||
v-model:value="formData.applyEndTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="5"> |
||||
<a-form-item label="是否选题" v-bind="validateInfos.requireTopic" :labelCol="labelCol4" :wrapperCol="wrapperCol4"> |
||||
<j-switch v-model:value="formData.requireTopic" :disabled="disabled"></j-switch> |
||||
</a-form-item> |
||||
</a-col> |
||||
|
||||
<a-col :span="9" v-if="formData.requireTopic === 'Y'"> |
||||
<a-form-item label="开始时间" v-bind="validateInfos.topicStartTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择选题开始时间" |
||||
v-model:value="formData.topicStartTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireTopic === 'Y'"> |
||||
<a-form-item label="结束时间" v-bind="validateInfos.topicEndTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择选题结束时间" |
||||
v-model:value="formData.topicEndTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
|
||||
<a-row> |
||||
<a-col :span="5"> |
||||
<a-form-item label="上传作品" v-bind="validateInfos.requireUploadWorks" :labelCol="labelCol4" :wrapperCol="wrapperCol4"> |
||||
<j-switch v-model:value="formData.requireUploadWorks" :disabled="disabled"></j-switch> |
||||
</a-form-item> |
||||
</a-col> |
||||
|
||||
<a-col :span="9" v-if="formData.requireUploadWorks === 'Y'"> |
||||
<a-form-item label="开始时间" v-bind="validateInfos.uploadStartTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择上传作品开始时间" |
||||
v-model:value="formData.uploadStartTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireUploadWorks === 'Y'"> |
||||
<a-form-item label="结束时间" v-bind="validateInfos.uploadEndTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择上传作品结束时间" |
||||
v-model:value="formData.uploadEndTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="24" v-if="formData.requireUploadWorks === 'Y'"> |
||||
<a-form-item label="上传作品类型" v-bind="validateInfos.uploadWorksType" :labelCol="labelCol6" :wrapperCol="wrapperCol6"> |
||||
<j-select-multiple |
||||
type="list_multi" |
||||
v-model:value="formData.uploadWorksType" |
||||
dictCode="updateWorksType" |
||||
placeholder="请选择上传作品类型" |
||||
:disabled="disabled" |
||||
:triggerChange="false" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
<a-row> |
||||
<a-col :span="5"> |
||||
<a-form-item label="是否评分" v-bind="validateInfos.requireScore" :labelCol="labelCol4" :wrapperCol="wrapperCol4"> |
||||
<j-switch v-model:value="formData.requireScore" :disabled="disabled"></j-switch> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireScore === 'Y'"> |
||||
<a-form-item label="开始时间" v-bind="validateInfos.scoreStartTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择评分开始时间" |
||||
v-model:value="formData.scoreStartTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="9" v-if="formData.requireScore === 'Y'"> |
||||
<a-form-item label="结束时间" v-bind="validateInfos.scoreEndTime" :labelCol="labelCol5" :wrapperCol="wrapperCol5"> |
||||
<a-date-picker |
||||
placeholder="请选择评分结束时间" |
||||
v-model:value="formData.scoreEndTime" |
||||
showTime |
||||
value-format="YYYY-MM-DD HH:mm:ss" |
||||
style="width: 100%" |
||||
:disabled="disabled" |
||||
/> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
<p style="color: red">如果需要评分,则需要添加开启选题</p> |
||||
<a-row v-if="formData.annualCompState === '4'"> |
||||
<a-col :span="24"> |
||||
<a-form-item label="驳回原因" v-bind="validateInfos.introduce" :labelCol="labelCol1" :wrapperCol="wrapperCol1"> |
||||
<a-textarea v-model:value="formData.backinfo" rows="4" placeholder="请输入简介" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
</a-form> |
||||
</a-spin> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue'; |
||||
import { defHttp } from '/@/utils/http/axios'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
||||
import JSwitch from '/@/components/Form/src/jeecg/components/JSwitch.vue'; |
||||
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue'; |
||||
import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue'; |
||||
import { getValueType } from '/@/utils'; |
||||
import { saveOrUpdate1 } from '../AnnualCompPoint.api'; |
||||
import { Form } from 'ant-design-vue'; |
||||
|
||||
const props = defineProps({ |
||||
formDisabled: { type: Boolean, default: false }, |
||||
formData: { |
||||
type: Object, |
||||
default: () => {}, |
||||
}, |
||||
formBpm: { type: Boolean, default: true }, |
||||
}); |
||||
const formRef = ref(); |
||||
const useForm = Form.useForm; |
||||
const emit = defineEmits(['register', 'ok']); |
||||
const formData = reactive<Record<string, any>>({ |
||||
id: '', |
||||
annualCompId: '', |
||||
objName: '', |
||||
introduce: '', |
||||
objLevel: '3', |
||||
entryForm: 'Y', |
||||
teamNumber: undefined, |
||||
teacherNumber: undefined, |
||||
requireLeader: '', |
||||
requireTeamName: '', |
||||
requireApply: 'Y', |
||||
requireTopic: 'Y', |
||||
requireUploadWorks: 'Y', |
||||
uploadWorksType: '', |
||||
requireScore: 'Y', |
||||
starttime: '', |
||||
endtime: '', |
||||
annualCompSwitch: '', |
||||
message: '', |
||||
applyStartTime: '', |
||||
applyEndTime: '', |
||||
topicStartTime: '', |
||||
topicEndTime: '', |
||||
uploadStartTime: '', |
||||
uploadEndTime: '', |
||||
scoreStartTime: '', |
||||
scoreEndTime: '', |
||||
}); |
||||
const { createMessage } = useMessage(); |
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 6 } }); |
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } }); |
||||
const labelCol1 = ref<any>({ xs: { span: 24 }, sm: { span: 3 } }); |
||||
const wrapperCol1 = ref<any>({ xs: { span: 24 }, sm: { span: 20 } }); |
||||
const labelCol2 = ref<any>({ xs: { span: 24 }, sm: { span: 9 } }); |
||||
const wrapperCol2 = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); |
||||
const labelCol3 = ref<any>({ xs: { span: 24 }, sm: { span: 13 } }); |
||||
const wrapperCol3 = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); |
||||
const labelCol4 = ref<any>({ xs: { span: 24 }, sm: { span: 14 } }); |
||||
const wrapperCol4 = ref<any>({ xs: { span: 24 }, sm: { span: 1 } }); |
||||
const labelCol5 = ref<any>({ xs: { span: 24 }, sm: { span: 8 } }); |
||||
const wrapperCol5 = ref<any>({ xs: { span: 24 }, sm: { span: 16 } }); |
||||
const labelCol6 = ref<any>({ xs: { span: 24 }, sm: { span: 8 } }); |
||||
const wrapperCol6 = ref<any>({ xs: { span: 24 }, sm: { span: 6 } }); |
||||
const labelCol7 = ref<any>({ xs: { span: 24 }, sm: { span: 8 } }); |
||||
const wrapperCol7 = ref<any>({ xs: { span: 24 }, sm: { span: 24 } }); |
||||
const wrapperCol8 = ref<any>({ xs: { span: 24 }, sm: { span: 14 } }); |
||||
const confirmLoading = ref<boolean>(false); |
||||
//表单验证 |
||||
const validatorRules = { |
||||
annualCompId: [{ required: true, message: '请输入年度比赛id!' }], |
||||
objName: [{ required: true, message: '请输入项目名称!' }], |
||||
entryForm: [{ required: true, message: '请输入参与形式!' }], |
||||
requireApply: [{ required: true, message: '请输入是否报名!' }], |
||||
requireTopic: [{ required: true, message: '请输入是否选题!' }], |
||||
requireUploadWorks: [{ required: true, message: '请输入是否上传作品!' }], |
||||
requireScore: [{ required: true, message: '请输入是否评分!' }], |
||||
starttime: [{ required: true, message: '请输入开始时间!' }], |
||||
endtime: [{ required: true, message: '请输入结束时间!' }], |
||||
}; |
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
||||
|
||||
// 表单禁用 |
||||
const disabled = computed(() => { |
||||
if (props.formBpm === true) { |
||||
if (props.formData.disabled === false) { |
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
return props.formDisabled; |
||||
}); |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
function add() { |
||||
edit({}); |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
*/ |
||||
function edit(record) { |
||||
nextTick(() => { |
||||
resetFields(); |
||||
// record.applyStartTime=''; |
||||
// record.applyStartTime=''; |
||||
// record.applyEndTime=''; |
||||
// record.topicStartTime=''; |
||||
// record.topicEndTime=''; |
||||
// record.uploadStartTime=''; |
||||
// record.uploadEndTime=''; |
||||
// record.scoreStartTime=''; |
||||
// record.scoreEndTime=''; |
||||
// record.uploadWorksType=''; |
||||
//赋值 |
||||
Object.assign(formData, record); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 提交数据 |
||||
*/ |
||||
async function submitForm() { |
||||
// 触发表单验证 |
||||
await validate(); |
||||
confirmLoading.value = true; |
||||
const isUpdate = ref<boolean>(false); |
||||
//时间格式化 |
||||
let model = formData; |
||||
if (model.id) { |
||||
isUpdate.value = true; |
||||
} |
||||
//循环数据 |
||||
for (let data in model) { |
||||
//如果该数据是数组并且是字符串类型 |
||||
if (model[data] instanceof Array) { |
||||
let valueType = getValueType(formRef.value.getProps, data); |
||||
//如果是字符串类型的需要变成以逗号分割的字符串 |
||||
if (valueType === 'string') { |
||||
model[data] = model[data].join(','); |
||||
} |
||||
} |
||||
} |
||||
await saveOrUpdate1(model, isUpdate.value) |
||||
.then((res) => { |
||||
if (res.success) { |
||||
createMessage.success(res.message); |
||||
emit('ok'); |
||||
} else { |
||||
createMessage.warning(res.message); |
||||
} |
||||
}) |
||||
.finally(() => { |
||||
confirmLoading.value = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* popup组件值改变事件 |
||||
*/ |
||||
function setFieldsValue(map) { |
||||
Object.keys(map).map((key) => { |
||||
formData[key] = map[key]; |
||||
}); |
||||
} |
||||
|
||||
defineExpose({ |
||||
add, |
||||
edit, |
||||
submitForm, |
||||
}); |
||||
</script> |
||||
|
||||
<style lang="less" scoped> |
||||
.antd-modal-form { |
||||
min-height: 500px !important; |
||||
overflow-y: auto; |
||||
padding: 24px 24px 24px 24px; |
||||
} |
||||
</style> |
@ -0,0 +1,75 @@ |
||||
<template> |
||||
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"> |
||||
<AnnualCompPointFormscgl ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AnnualCompPointFormscgl> |
||||
</a-modal> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { ref, nextTick, defineExpose } from 'vue'; |
||||
import AnnualCompPointFormscgl from './AnnualCompPointFormscgl.vue' |
||||
|
||||
const title = ref<string>(''); |
||||
const width = ref<number>(800); |
||||
const visible = ref<boolean>(false); |
||||
const disableSubmit = ref<boolean>(false); |
||||
const registerForm = ref(); |
||||
const emit = defineEmits(['register', 'success']); |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
function add() { |
||||
title.value = '新增'; |
||||
visible.value = true; |
||||
nextTick(() => { |
||||
registerForm.value.add(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
* @param record |
||||
*/ |
||||
function edit(record) { |
||||
title.value = '配置年度比赛'; |
||||
visible.value = true; |
||||
nextTick(() => { |
||||
registerForm.value.edit(record); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 确定按钮点击事件 |
||||
*/ |
||||
function handleOk() { |
||||
registerForm.value.submitForm(); |
||||
} |
||||
|
||||
/** |
||||
* form保存回调事件 |
||||
*/ |
||||
function submitCallback() { |
||||
handleCancel(); |
||||
emit('success'); |
||||
} |
||||
|
||||
/** |
||||
* 取消按钮回调事件 |
||||
*/ |
||||
function handleCancel() { |
||||
visible.value = false; |
||||
} |
||||
|
||||
defineExpose({ |
||||
add, |
||||
edit, |
||||
disableSubmit, |
||||
}); |
||||
</script> |
||||
|
||||
<style> |
||||
/**隐藏样式-modal确定按钮 */ |
||||
.jee-hidden { |
||||
display: none !important; |
||||
} |
||||
</style> |
Loading…
Reference in new issue