Compare commits

...

2 Commits

  1. 465
      ant-design-vue-jeecg/src/views/py/modules/PyBasicInfoModal.vue

@ -154,249 +154,258 @@
</template>
<script>
import {httpAction, getAction} from '@/api/manage'
import pick from 'lodash.pick'
import {validateDuplicateValue} from '@/utils/util'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
import JEditor from '@/components/jeecg/JEditor'
import {httpAction, getAction} from '@/api/manage'
import pick from 'lodash.pick'
import {validateDuplicateValue} from '@/utils/util'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
import JEditor from '@/components/jeecg/JEditor'
export default {
name: 'PyBasicInfoModal',
components: {
JSelectDepart,
JDictSelectTag,
JMarkdownEditor,
JEditor
},
data() {
return {
// colledge: {},
// id: "",
// dicode1: "",
form: this.$form.createForm(this),
title: '操作',
width: 1200,
visible: false,
model: {},
labelCol: {
xs: {span: 24},
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'
export default {
name: 'PyBasicInfoModal',
components: {
JSelectDepart,
JDictSelectTag,
JMarkdownEditor,
JEditor
},
data() {
return {
// colledge: {},
// id: "",
// dicode1: "",
form: this.$form.createForm(this),
title: '操作',
width: 1200,
visible: false,
model: {},
labelCol: {
xs: {span: 24},
sm: {span: 5}
},
practiceTeach: {
rules: [{required: true, message: '请输入实践性教学环节!'},
{pattern: /^[^\\]{0,500}$/, message: '输入实践性教学环节不能为空且长度不能超过500!'}],
trigger: 'blur'
wrapperCol: {
xs: {span: 24},
sm: {span: 16}
},
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: {
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: '请输入第九点富文本!' }]
}*/
},
url: {
add: '/py/basicinfo',
edit: '/py/basicinfo/ubyid/'
},
//
eduTimeOption: [
{
id: 0,
eduTime: '3年'
},
{
id: 1,
eduTime: '4年'
}
],
//
studyYearOption: [
{
id: 0,
studyYear: '3~6年'
url: {
add: '/py/basicinfo',
edit: '/py/basicinfo/ubyid/'
},
{
id: 1,
studyYear: '4~8年'
}
],
myRecord: {}
}
},
created() {
},
methods: {
add() {
this.edit({})
},
edit(record) {
console.log("basic info edit data obj ==", record);
this.myRecord = record
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
getAction('/py/basicinfo/findById/' + record.basicId)
.then(res => {
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);
})
})
//
eduTimeOption: [
{
id: 0,
eduTime: '3年'
},
{
id: 1,
eduTime: '4年'
}
],
//
studyYearOption: [
{
id: 0,
studyYear: '3~6年'
},
{
id: 1,
studyYear: '4~8年'
}
],
myRecord: {}
}
},
close() {
this.$emit('close');
this.visible = false;
created() {
},
handleOk() {
const that = this
//
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
let httpurl = ''
let method = ''
if (!this.model.basicId) {
httpurl += this.url.add
method = 'post'
} else {
// 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)
methods: {
add() {
this.edit({})
},
edit(record) {
console.log("basic info edit data obj ==", record);
this.myRecord = record
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
getAction('/py/basicinfo/findById/' + record.basicId)
.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("修改失败")
}
if (res.code == 200)
console.log("findById 查询成功==", res)
})
.finally(() => {
that.confirmLoading = false
that.close()
this.form.setFieldsValue(
pick(
this.model,
'majorCode',
'chartHead',
'collegeId',
'majorId',
'version',
'mainSubject',
'majorDirection',
'coreCourse',
'practiceTeach',
'eduTime',
'degree',
'credit',
'studyYear',
'fulltt'
)
)
// console.log(this.model);
})
}
})
},
handleCancel() {
this.close()
},
popupCallback(row) {
this.form.setFieldsValue(
pick(
row,
'majorCode',
'chartHead',
'collegeId',
'majorId',
'version',
'mainSubject',
'majorDirection',
'coreCourse',
'practiceTeach',
'eduTime',
'degree',
'credit',
'studyYear',
'fulltt'
})
},
close() {
this.$emit('close');
this.visible = false;
},
handleOk() {
const that = this
//
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
let httpurl = ''
let method = ''
if (!this.model.basicId) {
httpurl += this.url.add
method = 'post'
} else {
// 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 => {
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>
<!--<style lang="stylus">-->

Loading…
Cancel
Save