|
@@ -60,11 +60,6 @@ export default {
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
formModel() {
|
|
formModel() {
|
|
- // fields - use demo field trigger
|
|
|
|
- this.rows.forEach((row) => this.handleInputChanged('teacherCount', row, false))
|
|
|
|
- this.rows.forEach((row) => this.handleInputChanged('levelClassesCount', row, false))
|
|
|
|
- // summary
|
|
|
|
- this.calculateSummary()
|
|
|
|
// rebuild
|
|
// rebuild
|
|
return {
|
|
return {
|
|
rows: [...this.rows, this.sum]
|
|
rows: [...this.rows, this.sum]
|
|
@@ -98,7 +93,7 @@ export default {
|
|
label: '单科总课时数',
|
|
label: '单科总课时数',
|
|
slot: 'input',
|
|
slot: 'input',
|
|
minWidth: '130px',
|
|
minWidth: '130px',
|
|
- disabled: true
|
|
|
|
|
|
+ disabled: false
|
|
},
|
|
},
|
|
levelClassesCount: {
|
|
levelClassesCount: {
|
|
label: '等级考课时数',
|
|
label: '等级考课时数',
|
|
@@ -115,7 +110,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
facultyRules() {
|
|
facultyRules() {
|
|
- const excludeFiles = ['subjectName', 'classesCount']
|
|
|
|
|
|
+ const excludeFiles = ['subjectName']
|
|
const commonValidator = (rule, value, callback) => {
|
|
const commonValidator = (rule, value, callback) => {
|
|
const arrField = rule.field.split('.')
|
|
const arrField = rule.field.split('.')
|
|
let index = arrField.first()
|
|
let index = arrField.first()
|
|
@@ -138,6 +133,18 @@ export default {
|
|
return rules
|
|
return rules
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ 'rows': {
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler: function() {
|
|
|
|
+ // fields - use demo field trigger
|
|
|
|
+ this.rows.forEach((row) => this.handleInputChanged('teacherCount', row, false))
|
|
|
|
+ this.rows.forEach((row) => this.handleInputChanged('levelClassesCount', row, false))
|
|
|
|
+ // summary
|
|
|
|
+ this.calculateSummary()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
handleCheckAll() {
|
|
handleCheckAll() {
|
|
this.batchData.subjectIds = this.rows.map(s => s.subjectId)
|
|
this.batchData.subjectIds = this.rows.map(s => s.subjectId)
|
|
@@ -166,12 +173,16 @@ export default {
|
|
this.handleBatchCancel(key)
|
|
this.handleBatchCancel(key)
|
|
this.$emit('change')
|
|
this.$emit('change')
|
|
},
|
|
},
|
|
- handleInputChanged(key, row, calcSum = true) {
|
|
|
|
|
|
+ handleInputChanged(key, row, inputting = true) {
|
|
// auto calc
|
|
// auto calc
|
|
const helpFields = ['teacherCount', 'teacherClassesCount']
|
|
const helpFields = ['teacherCount', 'teacherClassesCount']
|
|
const linkedField = 'classesCount'
|
|
const linkedField = 'classesCount'
|
|
if (helpFields.includes(key)) {
|
|
if (helpFields.includes(key)) {
|
|
- row[linkedField] = row.teacherCount * row.teacherClassesCount
|
|
|
|
|
|
+ const currentLinkedVal = row[linkedField]
|
|
|
|
+ if (!currentLinkedVal || inputting) {
|
|
|
|
+ // 没有值,或者非执行检测程序时才强制修改(即输入真正输入teacherCount、teacherClassesCount时才关联计算)
|
|
|
|
+ row[linkedField] = row.teacherCount * row.teacherClassesCount
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// auto copy
|
|
// auto copy
|
|
const equalFields = ['levelClassesCount', 'qualifiedClassesCount']
|
|
const equalFields = ['levelClassesCount', 'qualifiedClassesCount']
|
|
@@ -180,19 +191,19 @@ export default {
|
|
otherKeys.forEach(k => row[k] = row[key])
|
|
otherKeys.forEach(k => row[k] = row[key])
|
|
}
|
|
}
|
|
// auto sum
|
|
// auto sum
|
|
- if (calcSum) this.calculateSummary()
|
|
|
|
|
|
+ if (inputting) this.calculateSummary()
|
|
return true
|
|
return true
|
|
},
|
|
},
|
|
calculateSummary() {
|
|
calculateSummary() {
|
|
const excludeFiles = ['subjectName']
|
|
const excludeFiles = ['subjectName']
|
|
Object.keys(this.facultyTableDefines).forEach(key => {
|
|
Object.keys(this.facultyTableDefines).forEach(key => {
|
|
if (!excludeFiles.includes(key)) {
|
|
if (!excludeFiles.includes(key)) {
|
|
- this.sum[key] = this.rows.sum(r => r[key])
|
|
|
|
|
|
+ const sumVal = this.rows.sum(r => r[key])
|
|
|
|
+ this.$set(this.sum, key, sumVal)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
validate() {
|
|
validate() {
|
|
- console.log('faculty-forms validate')
|
|
|
|
return this.$refs.form.validate()
|
|
return this.$refs.form.validate()
|
|
}
|
|
}
|
|
}
|
|
}
|