|  | @@ -60,11 +60,6 @@ export default {
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |    computed: {
 | 
	
		
			
				|  |  |      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
 | 
	
		
			
				|  |  |        return {
 | 
	
		
			
				|  |  |          rows: [...this.rows, this.sum]
 | 
	
	
		
			
				|  | @@ -98,7 +93,7 @@ export default {
 | 
	
		
			
				|  |  |            label: '单科总课时数',
 | 
	
		
			
				|  |  |            slot: 'input',
 | 
	
		
			
				|  |  |            minWidth: '130px',
 | 
	
		
			
				|  |  | -          disabled: true
 | 
	
		
			
				|  |  | +          disabled: false
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          levelClassesCount: {
 | 
	
		
			
				|  |  |            label: '等级考课时数',
 | 
	
	
		
			
				|  | @@ -115,7 +110,7 @@ export default {
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      facultyRules() {
 | 
	
		
			
				|  |  | -      const excludeFiles = ['subjectName', 'classesCount']
 | 
	
		
			
				|  |  | +      const excludeFiles = ['subjectName']
 | 
	
		
			
				|  |  |        const commonValidator = (rule, value, callback) => {
 | 
	
		
			
				|  |  |          const arrField = rule.field.split('.')
 | 
	
		
			
				|  |  |          let index = arrField.first()
 | 
	
	
		
			
				|  | @@ -138,6 +133,18 @@ export default {
 | 
	
		
			
				|  |  |        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: {
 | 
	
		
			
				|  |  |      handleCheckAll() {
 | 
	
		
			
				|  |  |        this.batchData.subjectIds = this.rows.map(s => s.subjectId)
 | 
	
	
		
			
				|  | @@ -166,12 +173,16 @@ export default {
 | 
	
		
			
				|  |  |        this.handleBatchCancel(key)
 | 
	
		
			
				|  |  |        this.$emit('change')
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    handleInputChanged(key, row, calcSum = true) {
 | 
	
		
			
				|  |  | +    handleInputChanged(key, row, inputting = true) {
 | 
	
		
			
				|  |  |        // auto calc
 | 
	
		
			
				|  |  |        const helpFields = ['teacherCount', 'teacherClassesCount']
 | 
	
		
			
				|  |  |        const linkedField = 'classesCount'
 | 
	
		
			
				|  |  |        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
 | 
	
		
			
				|  |  |        const equalFields = ['levelClassesCount', 'qualifiedClassesCount']
 | 
	
	
		
			
				|  | @@ -180,19 +191,19 @@ export default {
 | 
	
		
			
				|  |  |          otherKeys.forEach(k => row[k] = row[key])
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        // auto sum
 | 
	
		
			
				|  |  | -      if (calcSum) this.calculateSummary()
 | 
	
		
			
				|  |  | +      if (inputting) this.calculateSummary()
 | 
	
		
			
				|  |  |        return true
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      calculateSummary() {
 | 
	
		
			
				|  |  |        const excludeFiles = ['subjectName']
 | 
	
		
			
				|  |  |        Object.keys(this.facultyTableDefines).forEach(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() {
 | 
	
		
			
				|  |  | -      console.log('faculty-forms validate')
 | 
	
		
			
				|  |  |        return this.$refs.form.validate()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 |