Compare commits
No commits in common. 'ab75c20b78b4070947233ce201f88b4de852e562' and 'b55bce7086c4ecb34e612ce44f00331d761273c5' have entirely different histories.
ab75c20b78
...
b55bce7086
13 changed files with 28 additions and 600 deletions
@ -1,188 +0,0 @@ |
||||
<template> |
||||
<a-spin :spinning="confirmLoading"> |
||||
<JFormContainer :disabled="disabled"> |
||||
<template #detail> |
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="ExpertForm"> |
||||
<a-row> |
||||
|
||||
|
||||
<a-col :span="24"> |
||||
<a-form-item label="驳回原因" v-bind="validateInfos.errinfo" id="ExpertForm-backinfo" name="backinfo"> |
||||
<a-input v-model:value="formData.backinfo" placeholder="请输入驳回原因" allow-clear ></a-input> |
||||
</a-form-item> |
||||
</a-col> |
||||
|
||||
|
||||
</a-row> |
||||
</a-form> |
||||
</template> |
||||
</JFormContainer> |
||||
</a-spin> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { usePermission } from '/@/hooks/web/usePermission'; |
||||
const { hasPermission } = usePermission(); |
||||
import JDictSelectTag from '/src/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
||||
import JSelectDept from '/src/components/Form/src/jeecg/components/JSelectDept.vue'; |
||||
import JImageUpload from '/src/components/Form/src/jeecg/components/JImageUpload.vue'; |
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue'; |
||||
import { defHttp } from '/src/utils/http/axios'; |
||||
import { useMessage } from '/src/hooks/web/useMessage'; |
||||
import JSwitch from '/src/components/Form/src/jeecg/components/JSwitch.vue'; |
||||
import { getValueType } from '/src/utils'; |
||||
import { saveOrUpdateadminbh } from '../Expert.api'; |
||||
import { Form } from 'ant-design-vue'; |
||||
import JFormContainer from '/src/components/Form/src/container/JFormContainer.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: '', |
||||
seusername: '', |
||||
psd: '', |
||||
sepsd: '', |
||||
realname: '', |
||||
workon: '', |
||||
sex: '', |
||||
ssdep: '', |
||||
topPic: '', |
||||
phone: '', |
||||
emails: '', |
||||
colleges: '', |
||||
major: '', |
||||
directioncal: '', |
||||
research: '', |
||||
educationcal: '', |
||||
expinfo: '', |
||||
compopen: '', |
||||
adminopen: '', |
||||
backinfo: '', |
||||
zc: '', |
||||
expsture: '', |
||||
errinfo: '', |
||||
}); |
||||
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 = reactive({ |
||||
psd: [{ required: true, message: '请输入密码!'},], |
||||
sepsd: [{ required: true, message: '请输入确认密码!'},], |
||||
workon: [{ required: true, message: '请输入工号!'},], |
||||
ssdep: [{ required: true, message: '请输入部门!'},], |
||||
emails: [{ required: true, message: '请输入邮箱!'},], |
||||
phone: [{ required: true, message: '请输入电话!'},], |
||||
seusername: [{ required: true, message: '请输入用户名!'},], |
||||
}); |
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false }); |
||||
|
||||
// 表单禁用 |
||||
const disabled = computed(()=>{ |
||||
if(props.formBpm === true){ |
||||
if(props.formData.disabled === false){ |
||||
return false; |
||||
}else{ |
||||
return true; |
||||
} |
||||
} |
||||
return props.formDisabled; |
||||
}); |
||||
|
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
const isEit = ref(false) |
||||
function add() { |
||||
isEit.value = true |
||||
console.log(11111) |
||||
// edit({}); |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
*/ |
||||
function edit(record) { |
||||
isEit.value = false |
||||
console.log(22222) |
||||
nextTick(() => { |
||||
resetFields(); |
||||
const tmpData = {}; |
||||
Object.keys(formData).forEach((key) => { |
||||
if(record.hasOwnProperty(key)){ |
||||
tmpData[key] = record[key] |
||||
} |
||||
}) |
||||
//赋值 |
||||
Object.assign(formData, tmpData); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 提交数据 |
||||
*/ |
||||
async function submitForm() { |
||||
try { |
||||
// 触发表单验证 |
||||
await validate(); |
||||
} catch ({ errorFields }) { |
||||
if (errorFields) { |
||||
const firstField = errorFields[0]; |
||||
if (firstField) { |
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); |
||||
} |
||||
} |
||||
return Promise.reject(errorFields); |
||||
} |
||||
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 saveOrUpdateadminbh(model, isUpdate.value) |
||||
.then((res) => { |
||||
if (res.success) { |
||||
createMessage.success(res.message); |
||||
emit('ok'); |
||||
} else { |
||||
createMessage.warning(res.message); |
||||
} |
||||
}) |
||||
.finally(() => { |
||||
confirmLoading.value = false; |
||||
}); |
||||
} |
||||
|
||||
|
||||
defineExpose({ |
||||
add, |
||||
edit, |
||||
submitForm, |
||||
}); |
||||
</script> |
||||
|
||||
<style lang="less" scoped> |
||||
.antd-modal-form { |
||||
padding: 14px; |
||||
} |
||||
</style> |
@ -1,78 +0,0 @@ |
||||
<template> |
||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"> |
||||
<ExpertForm1 ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ExpertForm1> |
||||
</j-modal> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { ref, nextTick, defineExpose } from 'vue'; |
||||
import ExpertForm1 from './ExpertForm1.vue' |
||||
import JModal from '/src/components/Modal/src/JModal/JModal.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) { |
||||
console.log(record,'record') |
||||
title.value = disableSubmit.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 lang="less"> |
||||
/**隐藏样式-modal确定按钮 */ |
||||
.jee-hidden { |
||||
display: none !important; |
||||
} |
||||
</style> |
||||
<style lang="less" scoped></style> |
@ -1,182 +0,0 @@ |
||||
<template> |
||||
<a-spin :spinning="confirmLoading"> |
||||
<JFormContainer :disabled="disabled"> |
||||
<template #detail> |
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="ExpertForm"> |
||||
<a-row> |
||||
|
||||
<a-col :span="24"> |
||||
<a-form-item label="驳回原因" v-bind="validateInfos.errinfo" id="ExpertForm-backinfo" name="backinfo"> |
||||
<a-input v-model:value="formData.backinfo" placeholder="请输入驳回原因" allow-clear ></a-input> |
||||
</a-form-item> |
||||
</a-col> |
||||
|
||||
</a-row> |
||||
</a-form> |
||||
</template> |
||||
</JFormContainer> |
||||
</a-spin> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import JDictSelectTag from '/src/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
||||
import JSelectDept from '/src/components/Form/src/jeecg/components/JSelectDept.vue'; |
||||
import JImageUpload from '/src/components/Form/src/jeecg/components/JImageUpload.vue'; |
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue'; |
||||
import { defHttp } from '/src/utils/http/axios'; |
||||
import { useMessage } from '/src/hooks/web/useMessage'; |
||||
import JSwitch from '/src/components/Form/src/jeecg/components/JSwitch.vue'; |
||||
import { getValueType } from '/src/utils'; |
||||
import { saveOrUpdateadminbh } from '../Expert.api'; |
||||
import { Form } from 'ant-design-vue'; |
||||
import JFormContainer from '/src/components/Form/src/container/JFormContainer.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: '', |
||||
seusername: '', |
||||
psd: '', |
||||
sepsd: '', |
||||
realname: '', |
||||
workon: '', |
||||
sex: '', |
||||
ssdep: '', |
||||
topPic: '', |
||||
phone: '', |
||||
emails: '', |
||||
colleges: '', |
||||
major: '', |
||||
directioncal: '', |
||||
research: '', |
||||
educationcal: '', |
||||
expinfo: '', |
||||
compopen: '', |
||||
adminopen: '', |
||||
errinfo: '', |
||||
expsture: '', |
||||
backinfo: '', |
||||
zc: '', |
||||
}); |
||||
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 = reactive({ |
||||
psd: [{ required: true, message: '请输入密码!'},], |
||||
sepsd: [{ required: true, message: '请输入确认密码!'},], |
||||
workon: [{ required: true, message: '请输入工号!'},], |
||||
ssdep: [{ required: true, message: '请输入部门!'},], |
||||
emails: [{ required: true, message: '请输入邮箱!'},], |
||||
phone: [{ required: true, message: '请输入电话!'},], |
||||
seusername: [{ required: true, message: '请输入用户名!'},], |
||||
}); |
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false }); |
||||
|
||||
// 表单禁用 |
||||
const disabled = computed(()=>{ |
||||
if(props.formBpm === true){ |
||||
if(props.formData.disabled === false){ |
||||
return false; |
||||
}else{ |
||||
return true; |
||||
} |
||||
} |
||||
return props.formDisabled; |
||||
}); |
||||
|
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
const isEit = ref(false) |
||||
function add() { |
||||
isEit.value = true |
||||
// edit({}); |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
*/ |
||||
function edit(record) { |
||||
isEit.value = false |
||||
nextTick(() => { |
||||
resetFields(); |
||||
const tmpData = {}; |
||||
Object.keys(formData).forEach((key) => { |
||||
if(record.hasOwnProperty(key)){ |
||||
tmpData[key] = record[key] |
||||
} |
||||
}) |
||||
//赋值 |
||||
Object.assign(formData, tmpData); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 提交数据 |
||||
*/ |
||||
async function submitForm() { |
||||
try { |
||||
// 触发表单验证 |
||||
await validate(); |
||||
} catch ({ errorFields }) { |
||||
if (errorFields) { |
||||
const firstField = errorFields[0]; |
||||
if (firstField) { |
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); |
||||
} |
||||
} |
||||
return Promise.reject(errorFields); |
||||
} |
||||
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 saveOrUpdateadminbh(model, isUpdate.value) |
||||
.then((res) => { |
||||
if (res.success) { |
||||
createMessage.success(res.message); |
||||
emit('ok'); |
||||
} else { |
||||
createMessage.warning(res.message); |
||||
} |
||||
}) |
||||
.finally(() => { |
||||
confirmLoading.value = false; |
||||
}); |
||||
} |
||||
|
||||
|
||||
defineExpose({ |
||||
add, |
||||
edit, |
||||
submitForm, |
||||
}); |
||||
</script> |
||||
|
||||
<style lang="less" scoped> |
||||
.antd-modal-form { |
||||
padding: 14px; |
||||
} |
||||
</style> |
@ -1,77 +0,0 @@ |
||||
<template> |
||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"> |
||||
<ExpertForm1 ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ExpertForm1> |
||||
</j-modal> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { ref, nextTick, defineExpose } from 'vue'; |
||||
import ExpertForm1 from './ExpertForm1.vue' |
||||
import JModal from '/src/components/Modal/src/JModal/JModal.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 = disableSubmit.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 lang="less"> |
||||
/**隐藏样式-modal确定按钮 */ |
||||
.jee-hidden { |
||||
display: none !important; |
||||
} |
||||
</style> |
||||
<style lang="less" scoped></style> |
Loading…
Reference in new issue