|
|
|
@ -4,36 +4,38 @@ |
|
|
|
|
<a-row> |
|
|
|
|
<a-col :span="24"> |
|
|
|
|
<a-form-item label="年度" v-bind="validateInfos.annualid"> |
|
|
|
|
<j-dict-select-tag v-model:value="formData.annualid" dictCode="annual,annual_name,id" placeholder="请选择年度" :disabled="disabled"/> |
|
|
|
|
<j-dict-select-tag v-model:value="formData.annualid" dictCode="annual,annual_name,id" placeholder="请选择年度" |
|
|
|
|
:disabled="disabled || isT" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col> |
|
|
|
|
<a-col :span="24"> |
|
|
|
|
<a-form-item label="年度比赛" v-bind="validateInfos.annalComp"> |
|
|
|
|
<j-search-select v-model:value="formData.annalComp" :dict="strst" :disabled="disabled" /> |
|
|
|
|
<j-search-select v-model:value="formData.annalComp" :dict="strst" :disabled="disabled || isT" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col> |
|
|
|
|
<a-col :span="24"> |
|
|
|
|
<a-form-item label="年度比赛项目" v-bind="validateInfos.annualCompP"> |
|
|
|
|
<j-search-select v-model:value="formData.annualCompP" :dict="ndbsxm" :disabled="disabled" /> |
|
|
|
|
<j-search-select v-model:value="formData.annualCompP" :dict="ndbsxm" :disabled="disabled || isT" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col> |
|
|
|
|
<a-col :span="24"> |
|
|
|
|
<a-form-item label="报名编号" v-bind="validateInfos.enrollCode"> |
|
|
|
|
<a-input v-model:value="formData.enrollCode" placeholder="请输入报名编号" :disabled="disabled"></a-input> |
|
|
|
|
<a-input v-model:value="formData.enrollCode" placeholder="请输入报名编号" :disabled="disabled || isT"></a-input> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col> |
|
|
|
|
<a-col :span="24"> |
|
|
|
|
<a-form-item label="奖项名称" v-bind="validateInfos.awardname"> |
|
|
|
|
<j-dict-select-tag v-model:value="formData.awardname" dictCode="" :options="options" placeholder="请选择奖项名称" :disabled="disabled"/> |
|
|
|
|
<j-dict-select-tag v-model:value="formData.awardname" dictCode="" :options="options" placeholder="请选择奖项名称" |
|
|
|
|
:disabled="disabled" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col> |
|
|
|
|
<!-- <a-col :span="24"> |
|
|
|
|
<!-- <a-col :span="24"> |
|
|
|
|
<a-form-item label="状态" v-bind="validateInfos.status"> |
|
|
|
|
<j-dict-select-tag v-model:value="formData.status" dictCode="sh_status" placeholder="请选择状态" :disabled="disabled"/> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-col>--> |
|
|
|
|
<a-input v-model:value="formData.awardsort" hidden/> |
|
|
|
|
<!-- <a-col :span="24"> |
|
|
|
|
<a-input v-model:value="formData.awardsort" hidden /> |
|
|
|
|
<!-- <a-col :span="24"> |
|
|
|
|
<a-form-item label="奖项" v-bind="validateInfos.awardid"> |
|
|
|
|
<a-input v-model:value="formData.awardid" placeholder="请输入奖项" :disabled="disabled"></a-input> |
|
|
|
|
</a-form-item> |
|
|
|
@ -44,174 +46,182 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted,watch } 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 JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue'; |
|
|
|
|
import { getValueType } from '/@/utils'; |
|
|
|
|
import { saveOrUpdate,queryCompId,queryOptions } from '../AwardPersion.api'; |
|
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
|
import { duplicateValidate } from '/@/utils/helper/validator' |
|
|
|
|
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, watch } 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 JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue'; |
|
|
|
|
import { getValueType } from '/@/utils'; |
|
|
|
|
import { saveOrUpdate, queryCompId, queryOptions } from '../AwardPersion.api'; |
|
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
|
import { duplicateValidate } from '/@/utils/helper/validator' |
|
|
|
|
|
|
|
|
|
let strst = ref(); |
|
|
|
|
let ndbsxm = ref(); |
|
|
|
|
let options= ref(); |
|
|
|
|
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: '', |
|
|
|
|
annualid: '', |
|
|
|
|
annalComp: '', |
|
|
|
|
annualCompP: '', |
|
|
|
|
enrollCode: '', |
|
|
|
|
awardname: '', |
|
|
|
|
status: undefined, |
|
|
|
|
awardsort: undefined, |
|
|
|
|
awardid: '', |
|
|
|
|
}); |
|
|
|
|
const { createMessage } = useMessage(); |
|
|
|
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); |
|
|
|
|
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } }); |
|
|
|
|
const confirmLoading = ref<boolean>(false); |
|
|
|
|
//表单验证 |
|
|
|
|
const validatorRules = { |
|
|
|
|
annualid: [{ required: true, message: '请输入年度!'},], |
|
|
|
|
annalComp: [{ required: true, message: '请输入年度比赛!'},], |
|
|
|
|
annualCompP: [{ required: true, message: '请输入年度比赛项目!'},], |
|
|
|
|
enrollCode: [{ required: true, message: '请输入报名编号!'}, { validator: enrollCodeDuplicatevalidate }], |
|
|
|
|
awardname: [{ required: true, message: '请输入奖项名称!'},], |
|
|
|
|
}; |
|
|
|
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
|
|
|
|
let strst = ref(); |
|
|
|
|
let ndbsxm = ref(); |
|
|
|
|
let options = ref(); |
|
|
|
|
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: '', |
|
|
|
|
annualid: '', |
|
|
|
|
annalComp: '', |
|
|
|
|
annualCompP: '', |
|
|
|
|
enrollCode: '', |
|
|
|
|
awardname: '', |
|
|
|
|
status: undefined, |
|
|
|
|
awardsort: undefined, |
|
|
|
|
awardid: '', |
|
|
|
|
}); |
|
|
|
|
const { createMessage } = useMessage(); |
|
|
|
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); |
|
|
|
|
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } }); |
|
|
|
|
const confirmLoading = ref<boolean>(false); |
|
|
|
|
//表单验证 |
|
|
|
|
const validatorRules = { |
|
|
|
|
annualid: [{ required: true, message: '请输入年度!' },], |
|
|
|
|
annalComp: [{ required: true, message: '请输入年度比赛!' },], |
|
|
|
|
annualCompP: [{ required: true, message: '请输入年度比赛项目!' },], |
|
|
|
|
enrollCode: [{ required: true, message: '请输入报名编号!' }, { validator: enrollCodeDuplicatevalidate }], |
|
|
|
|
awardname: [{ 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; |
|
|
|
|
} |
|
|
|
|
// 表单禁用 |
|
|
|
|
const disabled = computed(() => { |
|
|
|
|
if (props.formBpm === true) { |
|
|
|
|
if (props.formData.disabled === false) { |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return props.formDisabled; |
|
|
|
|
}); |
|
|
|
|
watch(formData, (newVal) => { |
|
|
|
|
if(formData.annualid==null||formData.annualid==""){ |
|
|
|
|
} |
|
|
|
|
return props.formDisabled; |
|
|
|
|
}); |
|
|
|
|
watch(formData, (newVal) => { |
|
|
|
|
if (formData.annualid == null || formData.annualid == "") { |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
queryCompId("").then((result)=>{ |
|
|
|
|
//console.log(result); |
|
|
|
|
const str = result; |
|
|
|
|
if (str!=null&&str!="") { |
|
|
|
|
//const ndbs = "annual_comp,name,id,annualid='1691982939857920001' and (compid='1696134761153875969' or compid='1697137689830363138')"; |
|
|
|
|
var ndbsstr="annual_comp,name,id,annualid='"+formData.annualid+"' and "+"("+str+")"; |
|
|
|
|
strst.value=ndbsstr; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if(formData.annalComp!=""){ |
|
|
|
|
ndbsxm.value = "annual_comp_point,obj_name,id,annual_comp_id='"+formData.annalComp+"'"; |
|
|
|
|
} |
|
|
|
|
if(formData.annualCompP!=""&&formData.annualCompP!=null&&formData.annualCompP!=undefined){ |
|
|
|
|
queryOptions({annucompid:formData.annualCompP}).then((result)=>{ |
|
|
|
|
//console.log(result); |
|
|
|
|
if (result!=null&&result!=""&&result!=undefined) { |
|
|
|
|
options.value = result; |
|
|
|
|
if(formData.awardname!=""&&formData.awardname!=null&&formData.awardname!=undefined){ |
|
|
|
|
if(formData.awardname==1||formData.awardname==2||formData.awardname==3||formData.awardname==4||formData.awardname==5){ |
|
|
|
|
formData.awardsort = result[formData.awardname-1].label; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
queryCompId("").then((result) => { |
|
|
|
|
//console.log(result); |
|
|
|
|
const str = result; |
|
|
|
|
if (str != null && str != "") { |
|
|
|
|
//const ndbs = "annual_comp,name,id,annualid='1691982939857920001' and (compid='1696134761153875969' or compid='1697137689830363138')"; |
|
|
|
|
var ndbsstr = "annual_comp,name,id,annualid='" + formData.annualid + "' and " + "(" + str + ")"; |
|
|
|
|
strst.value = ndbsstr; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (formData.annalComp != "") { |
|
|
|
|
ndbsxm.value = "annual_comp_point,obj_name,id,annual_comp_id='" + formData.annalComp + "'"; |
|
|
|
|
} |
|
|
|
|
if (formData.annualCompP != "" && formData.annualCompP != null && formData.annualCompP != undefined) { |
|
|
|
|
queryOptions({ annucompid: formData.annualCompP }).then((result) => { |
|
|
|
|
//console.log(result); |
|
|
|
|
if (result != null && result != "" && result != undefined) { |
|
|
|
|
options.value = result; |
|
|
|
|
if (formData.awardname != "" && formData.awardname != null && formData.awardname != undefined) { |
|
|
|
|
if (formData.awardname == 1 || formData.awardname == 2 || formData.awardname == 3 || formData.awardname == 4 || formData.awardname == 5) { |
|
|
|
|
formData.awardsort = result[formData.awardname - 1].label; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 特定的禁用 |
|
|
|
|
*/ |
|
|
|
|
let isT = ref(false) |
|
|
|
|
function setIsT(bool=false){ |
|
|
|
|
isT.value=bool |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增 |
|
|
|
|
*/ |
|
|
|
|
function add() { |
|
|
|
|
edit({}); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 新增 |
|
|
|
|
*/ |
|
|
|
|
function add() { |
|
|
|
|
edit({}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 编辑 |
|
|
|
|
*/ |
|
|
|
|
function edit(record) { |
|
|
|
|
nextTick(() => { |
|
|
|
|
resetFields(); |
|
|
|
|
//赋值 |
|
|
|
|
Object.assign(formData, record); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 编辑 |
|
|
|
|
*/ |
|
|
|
|
function edit(record) { |
|
|
|
|
nextTick(() => { |
|
|
|
|
resetFields(); |
|
|
|
|
//赋值 |
|
|
|
|
Object.assign(formData, record); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 提交数据 |
|
|
|
|
*/ |
|
|
|
|
async function submitForm() { |
|
|
|
|
// 触发表单验证 |
|
|
|
|
await validate(); |
|
|
|
|
confirmLoading.value = true; |
|
|
|
|
const isUpdate = ref<boolean>(false); |
|
|
|
|
//时间格式化 |
|
|
|
|
let model = formData; |
|
|
|
|
if(model.awardname==1||model.awardname==2||model.awardname==3||model.awardname==4||model.awardname==5){ |
|
|
|
|
let awardsort = model.awardname; |
|
|
|
|
let awardname = model.awardsort; |
|
|
|
|
model.awardname = awardname; |
|
|
|
|
model.awardsort = awardsort; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 提交数据 |
|
|
|
|
*/ |
|
|
|
|
async function submitForm() { |
|
|
|
|
// 触发表单验证 |
|
|
|
|
await validate(); |
|
|
|
|
confirmLoading.value = true; |
|
|
|
|
const isUpdate = ref<boolean>(false); |
|
|
|
|
//时间格式化 |
|
|
|
|
let model = formData; |
|
|
|
|
if (model.awardname == 1 || model.awardname == 2 || model.awardname == 3 || model.awardname == 4 || model.awardname == 5) { |
|
|
|
|
let awardsort = model.awardname; |
|
|
|
|
let awardname = model.awardsort; |
|
|
|
|
model.awardname = awardname; |
|
|
|
|
model.awardsort = awardsort; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(','); |
|
|
|
|
} |
|
|
|
|
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 saveOrUpdate(model, isUpdate.value) |
|
|
|
|
.then((res) => { |
|
|
|
|
if (res.success) { |
|
|
|
|
createMessage.success(res.message); |
|
|
|
|
emit('ok'); |
|
|
|
|
} else { |
|
|
|
|
createMessage.warning(res.message); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.finally(() => { |
|
|
|
|
confirmLoading.value = false; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
await saveOrUpdate(model, isUpdate.value) |
|
|
|
|
.then((res) => { |
|
|
|
|
if (res.success) { |
|
|
|
|
createMessage.success(res.message); |
|
|
|
|
emit('ok'); |
|
|
|
|
} else { |
|
|
|
|
createMessage.warning(res.message); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.finally(() => { |
|
|
|
|
confirmLoading.value = false; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function enrollCodeDuplicatevalidate(_r, value) { |
|
|
|
|
return duplicateValidate('award_persion', 'enroll_code', value, formData.id || '') |
|
|
|
|
} |
|
|
|
|
defineExpose({ |
|
|
|
|
add, |
|
|
|
|
edit, |
|
|
|
|
submitForm, |
|
|
|
|
}); |
|
|
|
|
async function enrollCodeDuplicatevalidate(_r, value) { |
|
|
|
|
return duplicateValidate('award_persion', 'enroll_code', value, formData.id || '') |
|
|
|
|
} |
|
|
|
|
defineExpose({ |
|
|
|
|
add, |
|
|
|
|
edit, |
|
|
|
|
submitForm, |
|
|
|
|
setIsT |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<style lang="less" scoped> |
|
|
|
|
.antd-modal-form { |
|
|
|
|
min-height: 500px !important; |
|
|
|
|
overflow-y: auto; |
|
|
|
|
padding: 24px 24px 24px 24px; |
|
|
|
|
} |
|
|
|
|
.antd-modal-form { |
|
|
|
|
min-height: 500px !important; |
|
|
|
|
overflow-y: auto; |
|
|
|
|
padding: 24px 24px 24px 24px; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|