功能优化&问题修改 9.28

dev_2307
hechao.zhu 1 year ago
parent c283e923f4
commit 13a2e90e58
  1. 465
      ant-design-vue-jeecg/src/views/py/modules/PyBasicInfoModal.vue

@ -154,249 +154,258 @@
</template> </template>
<script> <script>
import {httpAction, getAction} from '@/api/manage' import {httpAction, getAction} from '@/api/manage'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import {validateDuplicateValue} from '@/utils/util' import {validateDuplicateValue} from '@/utils/util'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart' import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JDictSelectTag from '@/components/dict/JDictSelectTag' import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index' import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
import JEditor from '@/components/jeecg/JEditor' import JEditor from '@/components/jeecg/JEditor'
export default { export default {
name: 'PyBasicInfoModal', name: 'PyBasicInfoModal',
components: { components: {
JSelectDepart, JSelectDepart,
JDictSelectTag, JDictSelectTag,
JMarkdownEditor, JMarkdownEditor,
JEditor JEditor
}, },
data() { data() {
return { return {
// colledge: {}, // colledge: {},
// id: "", // id: "",
// dicode1: "", // dicode1: "",
form: this.$form.createForm(this), form: this.$form.createForm(this),
title: '操作', title: '操作',
width: 1200, width: 1200,
visible: false, visible: false,
model: {}, model: {},
labelCol: { labelCol: {
xs: {span: 24}, xs: {span: 24},
sm: {span: 5} sm: {span: 5}
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16}
},
confirmLoading: false,
validatorRules: {
majorCode: {
rules: [{required: true, message: '请输入专业代号!'}],
trigger: 'blur'
},
collegeId: {
rules: [{required: true, message: '请输入学院!'}],
trigger: 'blur'
},
majorId: {
rules: [{required: true, message: '请输入专业!'}],
trigger: 'blur'
},
version: {
rules: [{required: true, message: '请输入版本!'},
{
pattern: /(^[0-9]{1,2}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,1}$)/,
message: '版本整数部分输入长度最长为2位,小数点后最多一位!'
}],
trigger: 'blur'
},
mainSubject: {
rules: [{required: true, message: '请输入主干学科名字!'},
{pattern: /(^[\u4e00-\u9fa5_a-zA-Z0-9_]{1,15}$)/, message: '输入主干学科名字不能为空且长度不能超过15!'}],
trigger: 'blur'
},
majorDirection: {
rules: [{required: true, message: '请输入专业方向名字!'},
{pattern: /(^[\u4e00-\u9fa5_a-zA-Z0-9_]{1,10}$)/, message: '输入专业方向名字不能为空且长度不能超过10!'}],
trigger: 'blur'
},
coreCourse: {
rules: [{required: true, message: '请输入核心课程!'},
{pattern: /^[^\\]{0,500}$/, message: '输入核心课程不能为空且长度不能超过500!'}],
trigger: 'blur'
}, },
practiceTeach: { wrapperCol: {
rules: [{required: true, message: '请输入实践性教学环节!'}, xs: {span: 24},
{pattern: /^[^\\]{0,500}$/, message: '输入实践性教学环节不能为空且长度不能超过500!'}], sm: {span: 16}
trigger: 'blur'
}, },
eduTime: {
rules: [{required: true, message: '请输入学制!'}],
confirmLoading: false,
validatorRules: {
majorCode: {
rules: [{required: true, message: '请输入专业代号!'}],
trigger: 'blur'
},
collegeId: {
rules: [{required: true, message: '请输入学院!'}],
trigger: 'blur'
},
majorId: {
rules: [{required: true, message: '请输入专业!'}],
trigger: 'blur'
},
version: {
rules: [{required: true, message: '请输入版本!'},
/*{
pattern: /(^[0-9]{1,2}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,1}$)/,
message: '版本整数部分输入长度最长为2位,小数点后最多一位!'
}*/
{
pattern: /(^[\u4e00-\u9fa5_a-zA-Z0-9_]{1,15}$)/,
message: '版本不能为空且长度不能超过15!'
}
],
trigger: 'blur'
},
mainSubject: {
rules: [{required: true, message: '请输入主干学科名字!'},
{
pattern: /(^[\u4e00-\u9fa5_a-zA-Z0-9_]{1,15}$)/,
message: '输入主干学科名字不能为空且长度不能超过15!'
}
],
trigger: 'blur'
},
majorDirection: {
rules: [{required: true, message: '请输入专业方向名字!'},
{pattern: /(^[\u4e00-\u9fa5_a-zA-Z0-9_]{1,10}$)/, message: '输入专业方向名字不能为空且长度不能超过10!'}],
trigger: 'blur'
},
coreCourse: {
rules: [{required: true, message: '请输入核心课程!'},
{pattern: /^[^\\]{0,500}$/, message: '输入核心课程不能为空且长度不能超过500!'}],
trigger: 'blur'
},
practiceTeach: {
rules: [{required: true, message: '请输入实践性教学环节!'},
{pattern: /^[^\\]{0,500}$/, message: '输入实践性教学环节不能为空且长度不能超过500!'}],
trigger: 'blur'
},
eduTime: {
rules: [{required: true, message: '请输入学制!'}],
},
degree: {
rules: [{required: true, message: '请输入学位!'}],
trigger: 'blur'
},
credit: {
rules: [
{required: true, message: '请输入学分!'},
{validator: (rule, value, callback) => validateDuplicateValue('py_basic_info', 'credit', value, this.model.id, callback)},
{pattern: /^[1-9]\d*$/, message: '学分只能输入正整数!'}
],
trigger: 'blur'
},
studyYear: {
rules: [{required: true, message: '请输入修学年限!'}],
trigger: 'blur'
}
/*,
fulltt: {
rules: [{ required: true, message: '请输入第九点富文本!' }]
}*/
}, },
degree: { url: {
rules: [{required: true, message: '请输入学位!'}], add: '/py/basicinfo',
trigger: 'blur' edit: '/py/basicinfo/ubyid/'
},
credit: {
rules: [
{required: true, message: '请输入学分!'},
{validator: (rule, value, callback) => validateDuplicateValue('py_basic_info', 'credit', value, this.model.id, callback)},
{pattern: /^[1-9]\d*$/, message: '学分只能输入正整数!'}
],
trigger: 'blur'
},
studyYear: {
rules: [{required: true, message: '请输入修学年限!'}],
trigger: 'blur'
}
/*,
fulltt: {
rules: [{ required: true, message: '请输入第九点富文本!' }]
}*/
},
url: {
add: '/py/basicinfo',
edit: '/py/basicinfo/ubyid/'
},
//
eduTimeOption: [
{
id: 0,
eduTime: '3年'
},
{
id: 1,
eduTime: '4年'
}
],
//
studyYearOption: [
{
id: 0,
studyYear: '3~6年'
}, },
{ //
id: 1, eduTimeOption: [
studyYear: '4~8年' {
} id: 0,
], eduTime: '3年'
myRecord: {} },
} {
}, id: 1,
created() { eduTime: '4年'
}, }
methods: { ],
add() { //
this.edit({}) studyYearOption: [
}, {
edit(record) { id: 0,
console.log("basic info edit data obj ==", record); studyYear: '3~6年'
this.myRecord = record },
this.form.resetFields() {
this.model = Object.assign({}, record) id: 1,
this.visible = true studyYear: '4~8年'
this.$nextTick(() => { }
getAction('/py/basicinfo/findById/' + record.basicId) ],
.then(res => { myRecord: {}
if (res.code == 200) }
console.log("findById 查询成功==", res)
})
.finally(() => {
this.form.setFieldsValue(
pick(
this.model,
'majorCode',
'chartHead',
'collegeId',
'majorId',
'version',
'mainSubject',
'majorDirection',
'coreCourse',
'practiceTeach',
'eduTime',
'degree',
'credit',
'studyYear',
'fulltt'
)
)
// console.log(this.model);
})
})
}, },
close() { created() {
this.$emit('close');
this.visible = false;
}, },
handleOk() { methods: {
const that = this add() {
// this.edit({})
this.form.validateFields((err, values) => { },
if (!err) { edit(record) {
that.confirmLoading = true console.log("basic info edit data obj ==", record);
let httpurl = '' this.myRecord = record
let method = '' this.form.resetFields()
if (!this.model.basicId) { this.model = Object.assign({}, record)
httpurl += this.url.add this.visible = true
method = 'post' this.$nextTick(() => {
} else { getAction('/py/basicinfo/findById/' + record.basicId)
// httpurl+=this.url.edit;
httpurl = httpurl + this.url.edit
method = 'put'
}
let formData = Object.assign(this.model, values)
console.log("编辑-提交数据", JSON.stringify(formData))
httpAction(httpurl, formData, method)
.then(res => { .then(res => {
this.edit(this.myRecord) if (res.code == 200)
console.log("编辑修改结果-res:" + JSON.stringify(res)) console.log("findById 查询成功==", res)
if (res.code == 0) {
// console.log("11111")
that.$message.success(res.msg)
this.close()
that.$emit('ok')
// console.log("2222")
} else {
that.$message.warning("修改失败")
}
}) })
.finally(() => { .finally(() => {
that.confirmLoading = false this.form.setFieldsValue(
that.close() pick(
this.model,
'majorCode',
'chartHead',
'collegeId',
'majorId',
'version',
'mainSubject',
'majorDirection',
'coreCourse',
'practiceTeach',
'eduTime',
'degree',
'credit',
'studyYear',
'fulltt'
)
)
// console.log(this.model);
}) })
} })
}) },
}, close() {
handleCancel() { this.$emit('close');
this.close() this.visible = false;
}, },
popupCallback(row) { handleOk() {
this.form.setFieldsValue( const that = this
pick( //
row, this.form.validateFields((err, values) => {
'majorCode', if (!err) {
'chartHead', that.confirmLoading = true
'collegeId', let httpurl = ''
'majorId', let method = ''
'version', if (!this.model.basicId) {
'mainSubject', httpurl += this.url.add
'majorDirection', method = 'post'
'coreCourse', } else {
'practiceTeach', // httpurl+=this.url.edit;
'eduTime', httpurl = httpurl + this.url.edit
'degree', method = 'put'
'credit', }
'studyYear', let formData = Object.assign(this.model, values)
'fulltt' console.log("编辑-提交数据", JSON.stringify(formData))
httpAction(httpurl, formData, method)
.then(res => {
this.edit(this.myRecord)
console.log("编辑修改结果-res:" + JSON.stringify(res))
if (res.code == 0) {
// console.log("11111")
that.$message.success(res.msg)
this.close()
that.$emit('ok')
// console.log("2222")
} else {
that.$message.warning("修改失败")
}
})
.finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
handleCancel() {
this.close()
},
popupCallback(row) {
this.form.setFieldsValue(
pick(
row,
'majorCode',
'chartHead',
'collegeId',
'majorId',
'version',
'mainSubject',
'majorDirection',
'coreCourse',
'practiceTeach',
'eduTime',
'degree',
'credit',
'studyYear',
'fulltt'
)
) )
) }
} }
} }
}
</script> </script>
<!--<style lang="stylus">--> <!--<style lang="stylus">-->

Loading…
Cancel
Save