<template>
  <div class="warpMain">
    <div :class="openOrCloseDb==true?'':'w50 lf'" style="position:relative;">
      <div class="schoolBox pa24">
        <div class="schoolTil">
          <span class="schoolSee rf">
            <span class="opdb" v-if="openOrCloseDb == true" @click="openHandle"><i class="opIcon"></i>督办反馈<i v-if="feedbacks > 0"><i class="yuan" v-if="readFk == 2"></i></i></span>
            <span class="opdb" v-else @click="closeHandle"><i class="opIcon"></i>关闭督办反馈<i v-if="feedbacks > 0"><i class="yuan" v-if="readFk == 2"></i></i></span>
          </span>
          <span class="gotoButton mr12 lf" @click="gotoBack"><i class="gotoIcon"></i>返回</span>
        </div>
        <div :class="openOrCloseDb==false?'':'w800Sig'">
          <div class="schoolTil"><span class="wcd rf"><strong class="wcdtxt">完整度</strong> {{ wzdNum }}%</span>{{ Bigtitle }}</div>
          <div class="jindutiao">
            <div class="cur" :style="{width: wzdNum + '%'}"></div>
          </div>
          <div v-if="lsShow">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane v-for="(item, i) in lsDatas" :key="i" :label="item.updated_at" :name="item.id"></el-tab-pane>
            </el-tabs>
          </div>
        </div>
        <div class="hidole">
          <div :class="openOrCloseDb==false?'':'w800Sig'">
            <div v-for="(item, i) in dataObjs" :key="i" class="schoolmainBox">
              <div class="sTitle">{{ item.table_name }}</div>
              <div v-if="item.scale_field.length !=0">
                <div v-for="(subItem, index) in item.scale_field" :key="index">
                  <div class="smalT" v-if="subItem.type != 8"><em v-show="subItem.required == 1">*</em> {{ subItem.name }} </div>
                  <div v-if="subItem.type == '1'" class="sigShool gjhqIpt">
                    <el-input v-model="subItem.fromVal" class="w700" placeholder="请输入内容" :disabled="reportEdit == false" @blur="inputBlur(subItem)"></el-input>
                  </div>
                  <div v-if="subItem.type == '2'" class="sigShoolTwe">
                    <span v-for="(fromItem, idx) in subItem.values" :key="idx"
                      :class="subItem.display_type == 4 ? 'sigW25':'' ||
                      subItem.display_type == 3 ? 'sigW30':'' ||
                      subItem.display_type == 2 ? 'sigW50':'' ||
                      subItem.display_type == 1 ? 'sigW100':''">
                      <el-radio-group v-model="subItem.fromVal">
                        <el-radio :label="fromItem.key" :disabled="reportEdit == false" @change.native="inputBlurCheck(subItem, fromItem)">{{ fromItem.value }}</el-radio>
                      </el-radio-group>
                    </span>
                    <el-input v-model="subItem.otherVal" class="w700" v-show="subItem.otherShow == true" :disabled="reportEdit == false" placeholder="请输入内容"></el-input>
                  </div>
                  <div v-if="subItem.type == '3'" class="sigShoolTwe">
                    <el-checkbox-group v-model="subItem.fromVal">
                    <span v-for="(fromItem, idx) in subItem.values" :key="idx"
                      :class="subItem.display_type == 4 ? 'sigW25':'' ||
                      subItem.display_type == 3 ? 'sigW30':'' ||
                      subItem.display_type == 2 ? 'sigW50':'' ||
                      subItem.display_type == 1 ? 'sigW100':''">
                        <el-checkbox :key="fromItem.key" :label="fromItem.key" :disabled="reportEdit == false" @change.native="inputBlurCheck(subItem, fromItem)">{{fromItem.value}}</el-checkbox>
                    </span>
                    </el-checkbox-group>
                    <el-input v-model="subItem.otherVal" class="w700" v-show="subItem.otherShow == true" :disabled="reportEdit == false" placeholder="请输入内容"></el-input>
                  </div>
                  <div v-if="subItem.type == '4'" class="sigShool">
                    <div>
                      <el-upload
                        :disabled="reportEdit == false"
                        class="upload-demo"
                        :headers="{
                            'laravel-session-admin' : userToken,
                        }"
                        :show-file-list="false"
                        :data="uploadData"
                        :action="uploadUrl"
                        :before-upload="
                          (file) => {
                            return beforeUpload(file)
                          }
                        "
                        :on-success="
                          (response, file) => {
                            return handleSuccess(response, file, subItem)
                          }
                        "
                        :limit="20"
                        :file-list="subItem.fromVal">
                        <div class="uploadIcon"><i class="uploadButton"></i><em class="uploadTxt">上传文件</em></div>
                        <div class="uploadtip">文件大小限制：2M以下；支持扩展名：JPEG/JPG/PNG、XLS/XLSX、DOC/DOCX、PDF</div>
                      </el-upload>
                      <div v-if="subItem.fromVal.length !=0">
                        <div class="filesListItem" v-for="(imgList, imindex) in subItem.fromVal" :key="imindex"><i @click="delImgListHandle(subItem, imindex)" class="closeIconfilesList" v-show="reportEdit == true">X</i>{{ imgList.name }}</div>
                      </div>
                    </div>
                  </div>
                  <div v-if="subItem.type == '6'" class="sigShool gjhqIpt">
                    <el-date-picker
                      @change="inputBlur(subItem)"
                      :disabled="reportEdit == false"
                      v-model="subItem.fromVal"
                      format="yyyy-MM-dd HH:mm:ss"
                      type="datetime"
                      :clearable="false"
                      placeholder="选择日期">
                    </el-date-picker>
                  </div>
                  <div v-if="subItem.type == '7'" class="sigShool gjhqIpt">
                     <el-input type="number" v-model="subItem.fromVal" min="0" maxlength="11" class="w700" placeholder="请输入内容" :disabled="reportEdit == false" @blur="inputBlur(subItem)"></el-input>
                  </div>
                  <div v-if="subItem.type == '8'" class="sigShool gjhqIpt">
                  </div>
                </div>
              </div>
            </div>
            <div class="scholBtnboxTile">填报人信息</div>
            <div class="scholBtnboxSig"><i>*</i><strong>填报人</strong>{{userDetailes.username}}</div>
            <div class="scholBtnboxSig"><i>*</i><strong>填报时间</strong>{{newTime}}</div>
          </div>
          <div style="height:100px;"></div>
        </div>
      </div>
      <div class="gjhqbtn scholBtnbox" :class="lsShow == true?'current':''" v-if="reportstatus == 2">
        <span v-if="reportEdit == false" @click="reportEdittrue()"><el-button class="gjhqprimarybtn">编辑</el-button></span>
        <span v-else>
          <span v-if="addOrEdit == 1">
            <el-button class="gjhqprimarybtn" @click="submitFormJc(lbID)">保存并返回</el-button>
          </span>
          <span v-if="addOrEdit == 2">
            <el-button class="gjhqprimarybtn" @click="submitFormEditJc(lbID)">保存并返回</el-button>
          </span>
        </span>
      </div>
    </div>
    <div class="schoolRight w50 rf" :class="openOrCloseDb==true?'':'current'">
      <div class="schoolBox pa24 ml">
        
        <div class="imgsTitle"><img src="../../assets/icon33.png" width="354" height="32"></div>
        <div class="dbxxTil">督办反馈信息</div>
        <div class="dbxxTimes">保定市公安局 {{ timeTop }}</div>
        <div class="hidole">
          <div v-for="(item, i) in dbDetailsDatas" :key="i">
            <div v-if="item.is_zhenggai == 'yes'">{{ item.table_name }}</div>
            <div class="sTitleFor" v-if="item.content != null" v-html="item.content"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
import { adminScaleField, adminLoginqx, adminscalecode, adminsumfenzhi, adminscalefieldothers, adminscalefieldothersGet, adminscalefieldothersPut, adminreport, adminifread, adminsetread } from '../../axios/api'
import {
  adminSchoolJCCJLB,
  adminSchoolequipment,
  adminschoolpersonnelinfo,
  adminqlcommitteecollection,
  adminregulationssystemcollection,
  adminpreventiveworkadvance,
  admindiscoverworkstatistics,
  adminhandleworkstatistics,
  adminRecordpreventivebehaviors,
  adminbullyingdiscoveryrecord,
  adminhandleworkrecords,
  adminfoundationscale,
  adminfoundationscaleCt,
  adminSchoolJCCJLBPut,
  adminSchoolequipmentPut,
  adminschoolpersonnelinfoPut,
  adminqlcommitteecollectionPut,
  adminregulationssystemcollectionPut,
  adminpreventiveworkadvancePut,
  admindiscoverworkstatisticsPut,
  adminhandleworkstatisticsPut,
  adminRecordpreventivebehaviorsPut,
  adminbullyingdiscoveryrecordPut,
  adminhandleworkrecordsPut,
  adminscalesubmitinfo,
  adminscalesubmitinfoGet
} from '../../axios/apiliangbiao'
export default {
  name: 'schoolscale',
  data () {
    return {
      wzdNum: 0,
      lsShow: false,
      activeName: '',
      lsDatas: '',
      openOrCloseDb: true,
      seeshowVal: false,
      uploadUrl: '',
      Bigtitle: '',
      dataObjs: '',
      dbDetailsDatas: '',
      userDetailes: '',
      newTime: '-',
      lbID: '',
      userToken: '',
      keyVal: '',
      addOrEdit: 1,
      subID: '',
      reportEdit: true,
      reportstatus: '',
      dataNum: [],
      dataNunber: 0,
      dataNumShow: false,
      subCheckID: '',
      feedbacks: 0,
      updatedat: '',
      readFk: 1
    }
  },
  created () {
    let that = this
    let datasType = JSON.parse(localStorage.getItem('basicinfollDatas'))
    that.reportstatus = datasType.report_status
    that.uploadUrl = process.env.REQUEST_URL + '/admin/upload_file'
    that.userToken = localStorage.getItem('UserToken')
    that.feedbacks = datasType.dbfk
    if (datasType.edit == '') {
      const now = new Date()
      const hours = now.getHours().toString().padStart(2, '0')
      const minutes = now.getMinutes().toString().padStart(2, '0')
      const seconds = now.getSeconds().toString().padStart(2, '0')
      that.newTime = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} ${hours}:${minutes}:${seconds}`
    }
    that.addOrEdit = datasType.if_insert
    that.reportEdit = datasType.reportEdit
    // 获取上报日期
    adminreport().then(res => {
      if (res.code == 10000) {
        if (res.data.length > 0) {
          that.updatedat = res.data[0].updated_at
        }
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    // 督办反馈是否已读
    adminifread(datasType).then(res => {
      if (res.code == 10000) {
        that.readFk = res.data.read
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    if (datasType.type == 1) {
      datasType.subid = ''
      if (datasType.dbfj == 'dbfk') {
        adminsumfenzhi(datasType).then(res => {
          if (res.code == 10000) {
            that.dbDetailsDatas = res.data
            for (var i = 0; i < that.dbDetailsDatas.length; i++) {
              let cont = that.dbDetailsDatas[i].content
              if (cont != null) {
                that.dbDetailsDatas[i].content = that.simpleMarkdownToHtml(cont)
              }
            }
            if (res.data.length > 0) {
              that.timeTop = res.data[0].data_source_time
            } else {
              that.timeTop = '-'
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
    } else {
      setTimeout(() => {
        let objs = {}
        objs.id = datasType.id
        objs.timer = that.updatedat
        adminscalesubmitinfo(objs).then(res => {
          if (res.code == 10000) {
            if (res.data.length > 0) {
              let len = res.data.length - 1
              datasType.subid = res.data[len].sub_id
              if (datasType.dbfj == 'dbfk') {
                adminsumfenzhi(datasType).then(res => {
                  if (res.code == 10000) {
                    that.dbDetailsDatas = res.data
                    for (var i = 0; i < that.dbDetailsDatas.length; i++) {
                      let cont = that.dbDetailsDatas[i].content
                      if (cont != null) {
                        that.dbDetailsDatas[i].content = that.simpleMarkdownToHtml(cont)
                      }
                    }
                    if (res.data.length > 0) {
                      that.timeTop = res.data[0].data_source_time
                    } else {
                      that.timeTop = '-'
                    }
                  } else {
                    that.$messageOne({message: res.message, type: 'error', duration: 3000})
                  }
                }).catch(error => {
                  that.$messageOne({message: error, type: 'error', duration: 3000})
                })
              }
            } else {
              datasType.subid = ''
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }, 1000)
    }
    adminLoginqx().then(res => {
      if (res.code == 10000) {
        that.userDetailes = res
      } else {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    that.queryData()
  },
  computed: {
    // 通过计算属性动态生成要发送的数据对象
    uploadData () {
      return {
        key: this.keyVal
      }
    }
  },
  methods: {
    reportEdittrue () {
      let that = this
      that.reportEdit = true
      const now = new Date()
      const hours = now.getHours().toString().padStart(2, '0')
      const minutes = now.getMinutes().toString().padStart(2, '0')
      const seconds = now.getSeconds().toString().padStart(2, '0')
      that.newTime = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} ${hours}:${minutes}:${seconds}`
    },
    findMaxDateTime (dateStrings) {
      const dates = dateStrings.map(dateString => new Date(dateString))
      const maxDate = new Date(Math.max.apply(null, dates.map(date => date.getTime())))
      let date = new Date(maxDate)
      // 获取年、月、日、时、分、秒
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      let hours = date.getHours()
      let minutes = date.getMinutes()
      let seconds = date.getSeconds()
      // 将月、日补足两位数
      month = month < 10 ? '0' + month : month
      day = day < 10 ? '0' + day : day
      hours = hours < 10 ? '0' + hours : hours
      minutes = minutes < 10 ? '0' + minutes : minutes
      seconds = seconds < 10 ? '0' + seconds : seconds

      // 格式化输出为 年-月-日 时:分:秒 的形式
      let formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
      return formattedDate
    },
    simpleMarkdownToHtml (text) {
      // 简单的 Markdown 到 HTML 的转换逻辑，只支持基本的 Markdown 语法。
      let html = text.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') // 加粗 &zwnj;**bold**&zwnj; -> <strong>bold</strong>
        .replace(/\*(.*?)\*/g, '<em>$1</em>') // 斜体 *italic* -> <em>italic</em>
        .replace(/# (.*)/g, '<h1>$1</h1>') // 标题 # Heading -> <h1>Heading</h1>
        .replace(/#/g, '')
        .replace(/-/g, '')
      return html
    },
    inputBlurCheck (obj, item) {
      let that = this
      let dataNum = that.dataNum
      if (that.dataNumShow == true) {
        var num = 1
        for (var s = 0; s < dataNum.length; s++) {
          if (dataNum[s].fromVal != '') {
            num += 1
            dataNum[s].wcNumShow = true
          }
        }
        that.dataNunber = num
        that.dataNumShow = false
      }
      for (var i = 0; i < dataNum.length; i++) {
        if (dataNum[i].id == obj.id) {
          let fieldVal = obj.fromVal
          // 单选
          if (obj.type == 2) {
            if (fieldVal != '' && dataNum[i].wcNumShow == false) {
              if (that.dataNunber < dataNum.length) {
                that.dataNunber += 1
                dataNum[i].wcNumShow = true
              }
            }
            if (fieldVal == '') {
              if (that.dataNunber < dataNum.length || that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
            if (item.value == '其它') {
              if (obj.othercheck == false) {
                obj.otherShow = true
                obj.othercheck = true
              }
            } else {
              obj.otherShow = false
              obj.othercheck = false
              obj.otherVal = ''
            }
          }
          // 多选
          if (obj.type == 3) {
            if (fieldVal != '' && dataNum[i].wcNumShow == false) {
              if (that.dataNunber < dataNum.length) {
                that.dataNunber += 1
                dataNum[i].wcNumShow = true
              }
            }
            if (fieldVal == '') {
              if (that.dataNunber < dataNum.length || that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
            if (item.value == '其它') {
              if (obj.othercheck == false) {
                obj.otherShow = true
                obj.othercheck = true
              } else {
                obj.otherShow = false
                obj.othercheck = false
                obj.otherVal = ''
              }
            }
          }
        }
      }
      that.wzdNum = parseInt(that.dataNunber / dataNum.length * 100)
      if (that.wzdNum > 100) {
        that.wzdNum = 100
      }
      if (that.wzdNum <= 0) {
        that.wzdNum = 0
      }
    },
    inputBlur (obj) {
      let that = this
      let dataNum = that.dataNum
      if (that.dataNumShow == true) {
        var num = 1
        for (var s = 0; s < dataNum.length; s++) {
          if (dataNum[s].fromVal != '') {
            num += 1
            dataNum[s].wcNumShow = true
          }
        }
        that.dataNunber = num
        that.dataNumShow = false
      }
      for (var i = 0; i < dataNum.length; i++) {
        if (dataNum[i].id == obj.id) {
          let fieldVal = obj.fromVal
          // 输入框
          if (obj.type == 1) {
            if (fieldVal != '' && dataNum[i].wcNumShow == false) {
              if (that.dataNunber < dataNum.length) {
                that.dataNunber += 1
                dataNum[i].wcNumShow = true
              }
            }
            if (fieldVal == '') {
              if (that.dataNunber < dataNum.length || that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
          }
          // 数字输入框
          if (obj.type == 7) {
            if (fieldVal != '' && dataNum[i].wcNumShow == false) {
              if (that.dataNunber < dataNum.length) {
                that.dataNunber += 1
                dataNum[i].wcNumShow = true
              }
            }
            if (fieldVal == '') {
              if (that.dataNunber < dataNum.length || that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
          }
          // 时间
          if (obj.type == 6) {
            if (fieldVal != '' && dataNum[i].wcNumShow == false) {
              if (that.dataNunber < dataNum.length) {
                that.dataNunber += 1
                dataNum[i].wcNumShow = true
              }
            }
            if (fieldVal == '') {
              if (that.dataNunber < dataNum.length && that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
          }
        }
      }
      that.wzdNum = parseInt(that.dataNunber / dataNum.length * 100)
      if (that.wzdNum > 100) {
        that.wzdNum = 100
      }
      if (that.wzdNum <= 0) {
        that.wzdNum = 0
      }
    },
    // 上传功能
    handleSuccess (response, file, item) {
      let that = this
      that.keyVal = new Date().getTime() + '/' + file.name
      if (response.code == 10000) {
        item.fromVal.push(file)
        that.$messageOne({message: '文件导入成功', type: 'success', duration: 3000})
        let dataNum = that.dataNum
        console.log('dataNumdataNum', dataNum.length - 1)
        if (that.dataNumShow == true) {
          for (var s = 0; s < dataNum.length; s++) {
            if (dataNum[s].fromVal != '') {
              that.dataNunber += 1
              dataNum[s].wcNumShow = true
            }
          }
          that.dataNumShow = false
        } else {
          for (var i = 0; i < dataNum.length; i++) {
            if (dataNum[i].id == item.id) {
              let fieldVal = item.fromVal
              if (fieldVal.length > 0 && dataNum[i].wcNumShow == false) {
                if (that.dataNunber < dataNum.length) {
                  that.dataNunber += 1
                  dataNum[i].wcNumShow = true
                }
              }
            }
          }
        }
        // let datas = JSON.parse(localStorage.getItem('basicinfollDatas'))
        that.wzdNum = parseInt(that.dataNunber / (dataNum.length) * 100)
        // if (datas.if_insert == 1) {
        //   that.wzdNum = parseInt(that.dataNunber / (dataNum.length) * 100)
        // } if (datas.if_insert == 2) {
        //   that.wzdNum = parseInt(that.dataNunber / (dataNum.length - 1) * 100)
        // }
        if (that.wzdNum > 100) {
          that.wzdNum = 100
        }
        if (that.wzdNum <= 0) {
          that.wzdNum = 0
        }
        that.$forceUpdate()
      } else {
        that.$messageOne({message: response.message, type: 'warning', duration: 3000})
      }
    },
    beforeUpload (file) {
      this.keyVal = new Date().getTime() + '/' + file.name
      return new Promise((resolve) => {
        const isLt2M = file.size / 1024 / 1024 < 2
        if (!isLt2M) {
          this.$messageOne({message: '上传文件不能超过 2MB!', type: 'warning', duration: 3000})
          return
        }
        resolve(true)
      })
    },
    delImgListHandle (obj, i) {
      let that = this
      let fromVal = obj.fromVal
      fromVal.splice(i, 1)
      let dataNum = that.dataNum
      if (that.dataNumShow == true) {
        for (var s = 0; s < dataNum.length; s++) {
          if (dataNum[s].fromVal != '') {
            that.dataNunber += 1
            dataNum[s].wcNumShow = true
          }
        }
        that.dataNumShow = false
      } else {
        for (var i = 0; i < dataNum.length; i++) {
          if (dataNum[i].id == obj.id) {
            let fieldVal = obj.fromVal
            if (fieldVal.length == 0) {
              if (that.dataNunber < dataNum.length + 1 && that.dataNunber > 0) {
                that.dataNunber -= 1
                dataNum[i].wcNumShow = false
              }
            }
          }
        }
      }
      // let datas = JSON.parse(localStorage.getItem('basicinfollDatas'))
      that.wzdNum = parseInt(that.dataNunber / (dataNum.length) * 100)
      console.log('-------------', that.dataNunber)
      // if (datas.if_insert == 1) {
      //   that.wzdNum = parseInt(that.dataNunber / (dataNum.length) * 100)
      // } if (datas.if_insert == 2) {
      //   that.wzdNum = parseInt(that.dataNunber / (dataNum.length - 1) * 100)
      // }
      if (that.wzdNum > 100) {
        that.wzdNum = 100
      }
      if (that.wzdNum <= 0) {
        that.wzdNum = 0
      }
    },
    async queryData () {
      let that = this
      let datas = JSON.parse(localStorage.getItem('basicinfollDatas'))
      that.seeshowVal = datas.if_insert
      that.Bigtitle = datas.titles
      that.lbID = datas.id
      if (datas.if_insert == 1) {
        that.wzdNum = 0
      } else {
        that.wzdNum = datas.wcd
      }
      that.openOrCloseDb = datas.dbfkshow
      const today = new Date()
      const year = today.getFullYear()
      const month = (today.getMonth() + 1).toString().padStart(2, '0') // 月份是从0开始的，所以加1
      const day = today.getDate().toString().padStart(2, '0')
      const res = await adminScaleField(datas.id)
      if (res.code == 10000) {
        let datasField = res.data
        for (var i = 0; i < datasField.length; i++) {
          let scalefield = datasField[i].scale_field
          for (var j = 0; j < scalefield.length; j++) {
            if (scalefield[j].type == 2) {
              scalefield[j].fromVal = ''
              scalefield[j].wcNumShow = false
              scalefield[j].otherVal = ''
              scalefield[j].otherShow = false
              scalefield[j].othercheck = false
              that.dataNum.push(scalefield[j])
            } else if (scalefield[j].type == 3) {
              scalefield[j].fromVal = []
              scalefield[j].wcNumShow = false
              scalefield[j].otherVal = ''
              scalefield[j].otherShow = false
              scalefield[j].othercheck = false
              that.dataNum.push(scalefield[j])
            } else if (scalefield[j].type == 4) {
              scalefield[j].fromVal = []
              scalefield[j].wcNumShow = false
              that.dataNum.push(scalefield[j])
            } else if (scalefield[j].type == 11) {
              scalefield[j].fromVal = '-'
              scalefield[j].wcNumShow = false
              that.dataNum.push(scalefield[j])
            } else if (scalefield[j].type == 8) {
              if (datas.if_insert == 1) {
                const resCode = await adminscalecode()
                if (resCode.code == 10000) {
                  scalefield[j].fromVal = resCode.scale_code
                  that.dataNunber += 1
                }
                scalefield[j].wcNumShow = false
                that.dataNum.push(scalefield[j])
              } else {
                scalefield[j].fromVal = ''
                scalefield[j].wcNumShow = false
                that.dataNum.push(scalefield[j])
              }
            } else if (scalefield[j].type == 11) {
              scalefield[j].fromVal = ''
              scalefield[j].wcNumShow = false
              scalefield[j].otherVal = ''
              scalefield[j].otherShow = false
              scalefield[j].othercheck = false
              that.dataNum.push(scalefield[j])
            } else {
              scalefield[j].fromVal = ''
              scalefield[j].wcNumShow = false
              that.dataNum.push(scalefield[j])
            }
            scalefield[j].values = JSON.parse(scalefield[j].values)
          }
        }
        that.dataObjs = datasField
        console.log('that.dataObjs', that.dataObjs)
        // let datasType = JSON.parse(localStorage.getItem('basicinfollDatas'))
        // if (datasType.if_insert == 2) {
        //   setTimeout(() => {
        //     let obj = {}
        //     obj.type = 11
        //     obj.field = 'id'
        //     obj.fromVal = ''
        //     that.dataNum.push(obj)
        //   }, 1000)
        // }
        that.$forceUpdate()
      } else if (res.code == 10002) {
        that.$router.push({name: 'Login'})
      } else {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
      this.$forceUpdate()
      if (datas.if_insert == 2) {
        if (datas.type == 2) {
          that.lsShow = true
          let obj = {}
          obj.id = datas.id
          obj.timer = year + '-' + month + '-' + day
          adminscalesubmitinfo(obj).then(res => {
            if (res.code == 10000) {
              that.lsDatas = res.data
              for (var i = 0; i < res.data.length; i++) {
                let timers = new Date(res.data[i].updated_at)
                const hours = timers.getHours().toString().padStart(2, '0') // 获取小时，并确保是两位数
                const minutes = timers.getMinutes().toString().padStart(2, '0') // 获取分钟，并确保是两位数
                // 格式化时间字符串，例如 "2023-04-01 15:30:45"
                const datetimeString = `${timers.getFullYear()}-${(timers.getMonth() + 1).toString().padStart(2, '0')}-${timers.getDate().toString().padStart(2, '0')} ${hours}:${minutes}`
                res.data[i].updated_at = datetimeString
              }
              let len = res.data.length - 1
              that.activeName = res.data[len].id
              that.subID = res.data[len].sub_id
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
      }
      setTimeout(() => {
        if (datas.if_insert == 2) {
          if (datas.type == 1) {
            let obj = {}
            obj.id = datas.id
            obj.timer = year + '-' + month + '-' + day
            adminfoundationscale(obj).then(res => {
              if (res.code == 10000) {
                let datasDetails = that.dataObjs
                let resData = res.data
                let subId = res.data[0].scale_info.sub_id
                if (datas.edit == 'edit') {
                  let infos = resData[0].scale_info
                  that.newTime = infos.updated_at
                }
                that.dataNumShow = true
                for (var i = 0; i < datasDetails.length; i++) {
                  let scaletable = datasDetails[i].scale_table
                  let scalefield = datasDetails[i].scale_field
                  let obj = {}
                  obj.type = 11
                  obj.field = 'id'
                  obj.fromVal = '-'
                  scalefield.push(obj)
                  for (var j = 0; j < resData.length; j++) {
                    let scaletableVal = resData[i].scale_table
                    let scaletableinfo = resData[i].info
                    if (scaletable == scaletableVal) {
                      for (var k = 0; k < scalefield.length; k++) {
                        let codeName = scalefield[k].field
                        for (var n = 0; n < scaletableinfo.length; n++) {
                          let codeNameVal = scaletableinfo[n].field
                          if (codeName == codeNameVal) {
                            if (scaletableinfo[n].type == 1 || scaletableinfo[n].type == 5 || scaletableinfo[n].type == 6) {
                              scalefield[k].fromVal = scaletableinfo[n].va
                            } else if (scaletableinfo[n].type == 2) {
                              scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 7) {
                              scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 3) {
                              scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 4) {
                              if (scaletableinfo[n].va != null) {
                                let fleslit = JSON.parse(scaletableinfo[n].va)
                                let fleslitAr = []
                                for (var s = 0; s < fleslit.length; s++) {
                                  let obj = {}
                                  obj.name = fleslit[s]
                                  let response = {}
                                  response.path = fleslit[s]
                                  obj.response = response
                                  fleslitAr.push(obj)
                                }
                                scalefield[k].fromVal = fleslitAr
                              }
                            } else if (scaletableinfo[n].type == 8) {
                              scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                            } else {
                              scalefield[k].fromVal = scaletableinfo[n].va
                            }
                          }
                        }
                      }
                    }
                  }
                }
                that.dataObjs = datasDetails
                adminscalefieldothersGet(subId).then(res => {
                  if (res.code == 10000) {
                    let rCdatas = res.data
                    if (rCdatas.length > 0) {
                      for (var m = 0; m < that.dataObjs.length; m++) {
                        let scaletable = that.dataObjs[m].scale_table
                        let scalefield = that.dataObjs[m].scale_field
                        for (var l = 0; l < rCdatas.length; l++) {
                          let rcscaletable = rCdatas[l].scale_table
                          let field = rCdatas[l].field
                          if (scaletable == rcscaletable) {
                            for (var k = 0; k < scalefield.length; k++) {
                              let rcField = scalefield[k].field
                              if (field == rcField) {
                                scalefield[k].otherVal = rCdatas[l].value
                                scalefield[k].otherShow = true
                                scalefield[k].othercheck = true
                              }
                            }
                          }
                        }
                      }
                    }
                  } else if (res.code == 10002) {
                    that.$router.push({name: 'Login'})
                  } else {
                    that.$messageOne({message: res.message, type: 'error', duration: 3000})
                  }
                }).catch(error => {
                  that.$messageOne({message: error, type: 'error', duration: 3000})
                })
                that.$forceUpdate()
              } else {
                that.$messageOne({message: res.message, type: 'error', duration: 3000})
              }
            }).catch(error => {
              that.$messageOne({message: error, type: 'error', duration: 3000})
            })
          }
          if (datas.type == 2) {
            let obj = {}
            obj.id = datas.id
            obj.timer = year + '-' + month + '-' + day
            adminfoundationscaleCt(obj).then(res => {
              if (res.code == 10000) {
                let datasDetails = that.dataObjs
                let resData = res.data
                let subId = res.data[0].scale_info.sub_id
                if (datas.edit == 'edit') {
                  const dateStrings = []
                  for (var j = 0; j < resData.length; j++) {
                    let resScaleinfo = resData[j].scale_info
                    dateStrings.push(resScaleinfo.updated_at)
                  }
                  that.newTime = this.findMaxDateTime(dateStrings)
                }
                that.dataNumShow = true
                for (var i = 0; i < datasDetails.length; i++) {
                  let scaletable = datasDetails[i].scale_table
                  let scalefield = datasDetails[i].scale_field
                  let obj = {}
                  obj.type = 11
                  obj.field = 'id'
                  obj.fromVal = '-'
                  scalefield.push(obj)
                  for (var j = 0; j < resData.length; j++) {
                    let scaletableVal = resData[i].scale_table
                    let scaletableinfo = resData[i].info
                    if (scaletable == scaletableVal) {
                      for (var k = 0; k < scalefield.length; k++) {
                        let codeName = scalefield[k].field
                        for (var n = 0; n < scaletableinfo.length; n++) {
                          let codeNameVal = scaletableinfo[n].field
                          if (codeName == codeNameVal) {
                            if (scaletableinfo[n].type == 1 || scaletableinfo[n].type == 5 || scaletableinfo[n].type == 6) {
                              scalefield[k].fromVal = scaletableinfo[n].va
                            } else if (scaletableinfo[n].type == 2) {
                              scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 7) {
                              scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 3) {
                              scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                            } else if (scaletableinfo[n].type == 4) {
                              if (scaletableinfo[n].va != null) {
                                let fleslit = JSON.parse(scaletableinfo[n].va)
                                let fleslitAr = []
                                for (var s = 0; s < fleslit.length; s++) {
                                  let obj = {}
                                  obj.name = fleslit[s]
                                  let response = {}
                                  response.path = fleslit[s]
                                  obj.response = response
                                  fleslitAr.push(obj)
                                }
                                scalefield[k].fromVal = fleslitAr
                              }
                            } else if (scaletableinfo[n].type == 8) {
                              scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                            } else {
                              scalefield[k].fromVal = scaletableinfo[n].va
                            }
                          }
                        }
                      }
                    }
                  }
                }
                adminscalefieldothersGet(subId).then(res => {
                  if (res.code == 10000) {
                    let rCdatas = res.data
                    if (rCdatas.length > 0) {
                      for (var m = 0; m < that.dataObjs.length; m++) {
                        let scaletable = that.dataObjs[m].scale_table
                        let scalefield = that.dataObjs[m].scale_field
                        for (var l = 0; l < rCdatas.length; l++) {
                          let rcscaletable = rCdatas[l].scale_table
                          let field = rCdatas[l].field
                          if (scaletable == rcscaletable) {
                            for (var k = 0; k < scalefield.length; k++) {
                              let rcField = scalefield[k].field
                              if (field == rcField) {
                                scalefield[k].otherVal = rCdatas[l].value
                                scalefield[k].otherShow = true
                                scalefield[k].othercheck = true
                              }
                            }
                          }
                        }
                      }
                    }
                  } else if (res.code == 10002) {
                    that.$router.push({name: 'Login'})
                  } else {
                    that.$messageOne({message: res.message, type: 'error', duration: 3000})
                  }
                }).catch(error => {
                  that.$messageOne({message: error, type: 'error', duration: 3000})
                })
                that.$forceUpdate()
              } else {
                that.$messageOne({message: res.message, type: 'error', duration: 3000})
              }
            }).catch(error => {
              that.$messageOne({message: error, type: 'error', duration: 3000})
            })
          }
        } else {
          that.lsShow = false
        }
      }, 2000)
    },
    gotoBack () {
      location.reload()
      // this.$emit('gotoBack', false)
    },
    openHandle () {
      let that = this
      that.openOrCloseDb = false
      let datasType = JSON.parse(localStorage.getItem('basicinfollDatas'))
      if (that.readFk == 2) {
        adminsetread(datasType).then(res => {
          if (res.code == 10000) {
            that.readFk = res.data.read
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
    },
    closeHandle () {
      let that = this
      this.openOrCloseDb = true
      let datasType = JSON.parse(localStorage.getItem('basicinfollDatas'))
      if (that.readFk == 2) {
        adminsetread(datasType).then(res => {
          if (res.code == 10000) {
            that.readFk = res.data.read
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
    },
    checkClick (e, obj, item) {
      if (e == true) {
        item.fromVal.push(obj.key)
        if (obj.name == '其它') {
          item.otherShow = true
        }
      } else {
        let arr = item.fromVal
        if (arr.length > 0) {
          const index = arr.indexOf(obj.key)
          if (index > -1) {
            arr.splice(index, 1)
          }
          item.fromVal = null
          item.fromVal = arr
        }
        item.otherShow = false
        item.otherVal = ''
      }
    },
    async fetchData (obj) {
      try {
        const response = await axios.get(process.env.REQUEST_URL + '/admin/scale/code')
        this.data = response.data
        obj.fromVal = response.data.scale_code
      } catch (error) {
        console.error('Error fetching data:', error)
      }
    },
    adminscalecodeFun (arrayDtas, code) {
      let that = this
      let arrObj = {}
      arrObj.sub_id = code
      arrObj.data = arrayDtas
      adminscalefieldothers(arrObj).then(res => {
        if (res.code == 10000) {
          location.reload()
        } else {
          that.$messageOne({message: res.message, type: 'error', duration: 3000})
        }
      })
    },
    adminscalecodeFunPut (arrayDtas, code) {
      let that = this
      let arrObj = {}
      arrObj.sub_id = code
      arrObj.data = arrayDtas
      adminscalefieldothersPut(arrObj).then(res => {
        if (res.code == 10000) {
          location.reload()
        } else {
          that.$messageOne({message: res.message, type: 'error', duration: 3000})
        }
      })
    },
    submitFormJc (index) {
      let that = this
      let dataObjs = that.dataObjs
      for (var i = 0; i < dataObjs.length; i++) {
        let subList = dataObjs[i].scale_field
        for (var j = 0; j < subList.length; j++) {
          if (subList[j].type == 8) {
            that.fetchData(subList[j])
          }
        }
      }
      setTimeout(() => {
        for (var i = 0; i < dataObjs.length; i++) {
          let subList = dataObjs[i].scale_field
          for (var j = 0; j < subList.length; j++) {
            if (subList[j].required == 1) {
              let fromVal = subList[j].fromVal
              if (fromVal == '') {
                that.$messageOne({message: subList[j].name + '没有填写请输入后在提交！', type: 'error', duration: 3000})
                return false
              }
            }
          }
        }
        let datas = JSON.parse(localStorage.getItem('basicinfollDatas'))
        let array = {}
        array.belong_scale = datas.id
        // array.school_code = localStorage.getItem('schoolCode') 获取动态学校编码
        array.school_code = 'gj110'
        var arrarCheck = []
        for (var i = 0; i < dataObjs.length; i++) {
          array[dataObjs[i].scale_table] = {}
          let subList = dataObjs[i].scale_field
          for (var j = 0; j < subList.length; j++) {
            let field = subList[j].field
            if (subList[j].type == '1' || subList[j].type == '5' || subList[j].type == '6') {
              array[dataObjs[i].scale_table][field] = subList[j].fromVal
            } else if (subList[j].type == '4') {
              let filelist = subList[j].fromVal
              let listArray = []
              if (filelist.length != 0) {
                for (var k = 0; k < filelist.length; k++) {
                  listArray.push(filelist[k].response.path)
                }
                array[dataObjs[i].scale_table][field] = JSON.stringify(listArray)
              } else {
                array[dataObjs[i].scale_table][field] = null
              }
            } else if (subList[j].type == '2') {
              let ary = subList[j].fromVal
              if (subList[j].fromVal == '') {
                array[dataObjs[i].scale_table][field] = null
              } else {
                array[dataObjs[i].scale_table][field] = JSON.stringify(ary)
              }
              if (subList[j].othercheck == true) {
                let objOther = {}
                objOther.scale_table = subList[j].scale_table
                objOther.field = subList[j].field
                objOther.type = subList[j].type
                objOther.value = subList[j].otherVal
                objOther.field_id = subList[j].id
                objOther.lvl_type = subList[j].lvl_type
                objOther.data_id = subList[j].id
                arrarCheck.push(objOther)
              }
            } else if (subList[j].type == '3') {
              array[dataObjs[i].scale_table][field] = JSON.stringify(subList[j].fromVal)
              if (subList[j].othercheck == true) {
                let objOther = {}
                objOther.scale_table = subList[j].scale_table
                objOther.field = subList[j].field
                objOther.type = subList[j].type
                objOther.value = subList[j].otherVal
                objOther.field_id = subList[j].id
                objOther.lvl_type = subList[j].lvl_type
                objOther.data_id = subList[j].id
                arrarCheck.push(objOther)
              }
            } else if (subList[j].type == '7') {
              array[dataObjs[i].scale_table][field] = parseInt(subList[j].fromVal)
            } else if (subList[j].type == '8') {
              array[dataObjs[i].scale_table][field] = subList[j].fromVal
            }
          }
        }
        if (index == 1) {
          adminSchoolJCCJLB(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 2) {
          adminSchoolequipment(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 3) {
          adminschoolpersonnelinfo(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 4) {
          adminqlcommitteecollection(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 5) {
          adminregulationssystemcollection(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 6) {
          adminpreventiveworkadvance(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 7) {
          admindiscoverworkstatistics(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 8) {
          adminhandleworkstatistics(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 9) {
          adminRecordpreventivebehaviors(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 10) {
          adminbullyingdiscoveryrecord(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
        if (index == 11) {
          adminhandleworkrecords(array).then(res => {
            if (res.code == 10000) {
              that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
              if (arrarCheck.length != 0) {
                that.adminscalecodeFun(arrarCheck, res.sub_id)
              } else {
                location.reload()
              }
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
      }, 2000)
    },
    submitFormEditJc (index) {
      let that = this
      let dataObjs = that.dataObjs
      let datas = JSON.parse(localStorage.getItem('basicinfollDatas'))
      for (var i = 0; i < dataObjs.length; i++) {
        let subList = dataObjs[i].scale_field
        for (var j = 0; j < subList.length; j++) {
          if (subList[j].required == 1) {
            let fromVal = subList[j].fromVal
            if (fromVal == '') {
              that.$messageOne({message: subList[j].name + '没有填写请输入后在提交！', type: 'error', duration: 3000})
              return false
            }
          }
        }
      }
      let array = {}
      array.belong_scale = datas.id
      // array.school_code = localStorage.getItem('schoolCode') 获取动态学校编码
      array.school_code = 'gj110'
      array.id = datas.id
      var arrarCheck = []
      for (var i = 0; i < dataObjs.length; i++) {
        array[dataObjs[i].scale_table] = {}
        let subList = dataObjs[i].scale_field
        for (var j = 0; j < subList.length; j++) {
          let field = subList[j].field
          if (subList[j].type == '1' || subList[j].type == '5' || subList[j].type == '6') {
            array[dataObjs[i].scale_table][field] = subList[j].fromVal
          } else if (subList[j].type == '4') {
            let filelist = subList[j].fromVal
            let listArray = []
            if (filelist.length != 0) {
              for (var k = 0; k < filelist.length; k++) {
                listArray.push(filelist[k].response.path)
              }
              array[dataObjs[i].scale_table][field] = JSON.stringify(listArray)
            } else {
              array[dataObjs[i].scale_table][field] = null
            }
          } else if (subList[j].type == '2') {
            let ary = subList[j].fromVal
            if (subList[j].fromVal == '') {
              array[dataObjs[i].scale_table][field] = null
            } else {
              array[dataObjs[i].scale_table][field] = JSON.stringify(ary)
            }
            if (subList[j].othercheck == true) {
              let objOther = {}
              objOther.scale_table = subList[j].scale_table
              objOther.field = subList[j].field
              objOther.type = subList[j].type
              objOther.value = subList[j].otherVal
              objOther.field_id = subList[j].id
              objOther.lvl_type = subList[j].lvl_type
              objOther.data_id = subList[j].id
              arrarCheck.push(objOther)
            }
          } else if (subList[j].type == '3') {
            let ary = subList[j].fromVal
            array[dataObjs[i].scale_table][field] = JSON.stringify(ary)
            if (subList[j].othercheck == true) {
              let objOther = {}
              objOther.scale_table = subList[j].scale_table
              objOther.field = subList[j].field
              objOther.type = subList[j].type
              objOther.value = subList[j].otherVal
              objOther.field_id = subList[j].id
              objOther.lvl_type = subList[j].lvl_type
              objOther.data_id = subList[j].id
              arrarCheck.push(objOther)
            }
          } else if (subList[j].type == '7') {
            array[dataObjs[i].scale_table][field] = parseInt(subList[j].fromVal)
          } else {
            array[dataObjs[i].scale_table][field] = subList[j].fromVal
          }
        }
      }
      let subids = dataObjs[0].scale_info.sub_id
      if (index == 1) {
        adminSchoolJCCJLBPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 2) {
        adminSchoolequipmentPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 3) {
        adminschoolpersonnelinfoPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 4) {
        adminqlcommitteecollectionPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 5) {
        adminregulationssystemcollectionPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 6) {
        adminpreventiveworkadvancePut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 7) {
        admindiscoverworkstatisticsPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 8) {
        adminhandleworkstatisticsPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 9) {
        array.id = that.subID
        adminRecordpreventivebehaviorsPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 10) {
        array.id = that.subID
        adminbullyingdiscoveryrecordPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
      if (index == 11) {
        array.id = that.subID
        adminhandleworkrecordsPut(array).then(res => {
          if (res.code == 10000) {
            that.$messageOne({message: '保存成功!', type: 'success', duration: 3000})
            if (arrarCheck.length != 0) {
              that.adminscalecodeFunPut(arrarCheck, subids)
            } else {
              location.reload()
            }
          } else {
            that.$messageOne({message: res.message, type: 'error', duration: 3000})
          }
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }
    },
    // 查看历史tab
    handleClick (tab) {
      let that = this
      let indx = tab.index
      let subid = that.lsDatas[indx].sub_id
      that.subID = that.lsDatas[indx].sub_id
      adminscalesubmitinfoGet(subid).then(res => {
        if (res.code == 10000) {
          let datasDetails = that.dataObjs
          let resData = res.data
          for (var i = 0; i < datasDetails.length; i++) {
            let scaletable = datasDetails[i].scale_table
            let scalefield = datasDetails[i].scale_field
            for (var j = 0; j < resData.length; j++) {
              let scaletableVal = resData[i].scale_table
              let scaletableinfo = resData[i].info
              if (scaletable == scaletableVal) {
                for (var k = 0; k < scalefield.length; k++) {
                  let codeName = scalefield[k].field
                  for (var n = 0; n < scaletableinfo.length; n++) {
                    let codeNameVal = scaletableinfo[n].field
                    if (codeName == codeNameVal) {
                      if (scaletableinfo[n].type == 1 || scaletableinfo[n].type == 5 || scaletableinfo[n].type == 6) {
                        scalefield[k].fromVal = scaletableinfo[n].va
                      } else if (scaletableinfo[n].type == 2) {
                        scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                      } else if (scaletableinfo[n].type == 7) {
                        scalefield[k].fromVal = parseInt(scaletableinfo[n].va)
                      } else if (scaletableinfo[n].type == 3) {
                        scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                      } else if (scaletableinfo[n].type == 4) {
                        if (scaletableinfo[n].va != null) {
                          let fleslit = JSON.parse(scaletableinfo[n].va)
                          let fleslitAr = []
                          for (var s = 0; s < fleslit.length; s++) {
                            let obj = {}
                            obj.name = fleslit[s]
                            let response = {}
                            response.path = fleslit[s]
                            obj.response = response
                            fleslitAr.push(obj)
                          }
                          scalefield[k].fromVal = fleslitAr
                        }
                      } else if (scaletableinfo[n].type == 8) {
                        scalefield[k].fromVal = JSON.parse(scaletableinfo[n].va)
                      } else {
                        scalefield[k].fromVal = scaletableinfo[n].va
                      }
                    }
                  }
                }
              }
            }
          }
          that.$forceUpdate()
        } else {
          that.$messageOne({message: res.message, type: 'error', duration: 3000})
        }
      }).catch(error => {
        that.$messageOne({message: error, type: 'error', duration: 3000})
      })
    }
  }
}
</script>
<style scoped>
.warpMain{width:100%;overflow:hidden;}
.ml{margin-left:10px;}
.schoolBox{background:#fff;box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.1);}
.hidole{overflow-x:hidden;overflow-y:auto;height:790px}
.pa24{padding:32px 10px 32px 24px;}
.schoolTil{height: 30px;line-height:30px;font-size: 24px;color: #161617;text-align: left;font-style: normal;margin-bottom:20px;padding-right:24px;}
.schoolTil .wcd{padding-left:24px;}
.schoolTil .wcd .wcdtxt{font-size:14px;font-weight:normal;}
.schoolTil .opdb{font-size: 20px;color: #0071DB;line-height: 28px;font-style: normal;cursor:pointer;}
.schoolTil .opdb .opIcon{background:url('../../assets/icon22.png') no-repeat 0 0/100%;width:20px;height:16px;margin-right:7px;display:inline-block;}
.w50{width:50%;}
.w800Sig{width:900px;margin:0 auto;}
.schoolRight{display:none;}
.schoolRight.current{display:block;}
.schoolmainBox{padding:0 0 0 20px;border-bottom:1px solid #E6E6E6;margin-bottom:24px;}
.schoolmainBox .sTitle{font-weight: bold;font-size: 24px;color: #161617;line-height: 28px;text-align: left;font-style: normal;margin-bottom:24px;}
.schoolmainBox .sTitle span{font-size: 14px;font-weight:normal;}
.schoolmainBox .smalT{font-size: 16px;color: #161617;line-height: 24px;text-align: left;font-style: normal;margin-bottom:10px;}
.schoolmainBox .smalT em{color:#FF2A00;position:relative;top:3px;}
.sigShoolTwe{margin-bottom:10px;width:100%;}
.sigShoolTwe .sigW25{width:24%;height:22px;margin-bottom:15px;line-height:22px;display:inline-block;margin-right:0;}
.sigShoolTwe .sigW30{width:30%;height:22px;margin-bottom:15px;line-height:22px;display:inline-block;margin-right:0;}
.sigShoolTwe .sigW50{width:50%;height:22px;margin-bottom:15px;line-height:22px;display:inline-block;margin-right:0;}
.sigShoolTwe .sigW100{width:100%;height:22px;margin-bottom:15px;line-height:22px;display:inline-block;margin-right:0;}

.sigShool{margin-bottom:24px;width:100%;}
.sigShool span{margin-right:24px;}
.w700{width:700px;}
.scholBtnbox{text-align:center;padding:16px 0;position:absolute;bottom:0;left:0;width:100%;background-color:#fff;z-index:999;border-top:1px solid #E6E6E6;z-index:999;}
.scholBtnbox.current{bottom:53px;}
.scholBtnboxTile{font-weight:bold;font-size: 20px;color: #161617;line-height: 28px;padding:0 20px;margin-bottom:24px;}
.scholBtnboxSig{font-weight: bold;font-size: 14px;color: #161617;line-height: 22px;margin-bottom:12px;padding:0 20px;font-weight: normal;}
.scholBtnboxSig i{color:#E94A1E;margin-right:4px;}
.scholBtnboxSig strong{display:inline-block;width:70px;font-weight: bold;}
.uploadIcon{height:20px;line-height:20px;font-size: 12px;color: #8D8F99;text-align: left;font-style: normal;float:left;margin-right:8px;}
.uploadIcon .uploadButton{display:block;background:url('../../assets/icon23.png') no-repeat 0 0/100%;width:20px;height:20px;margin-right:8px;float:left;}
.uploadIcon .uploadTxt{color:#0071DB}
.uploadtip{float:left;height:20px;line-height:20px;font-size: 12px;color: #8D8F99;text-align: left;font-style: normal;}
.dbxxTil{height: 30px;line-height:30px;font-size: 24px;color: #161617;text-align: left;font-style: normal;margin-bottom:4px;}
.dbxxTimes{height: 22px;font-size: 14px;color: #161617;line-height: 22px;text-align: left;font-style: normal;margin-bottom:16px;}
.detailesTile{font-size: 20px;color: #161617;line-height: 28px;text-align: left;font-style: normal;margin-bottom:16px;}
.detailesTips{font-size: 16px;color: #E94A1E;line-height: 22px;text-align: left;font-style: normal;margin-bottom:12px;}
.detailessTile{font-size: 14px;color: #161617;line-height: 22px;text-align: left;font-style: normal;font-weight:bold;}
.detailessli{font-size: 14px;color: #161617;line-height: 22px;text-align: left;font-style: normal;}
.detailesul{margin-bottom:12px;}
.schoolSee{display:block;position:relative;}
.schoolSee .yuan{width: 8px;height: 8px;background: #FF0000;border: 2px solid #FFFFFF;position:absolute;top:2px;right:-12px;border-radius: 50%;}
.schoolSee.current{display: none;}
.jindutiao{height: 8px;background: #E6E6E6;border-radius: 2px;overflow:hidden;margin:24px 0;width:100%;}
.jindutiao .cur{height: 8px;background: #3384E2;;border-radius: 2px;overflow:hidden;}
.filelistUplad{font-size: 14px;color: #303133;margin-bottom:16px;}
.filesListItem{height:24px;line-height:24px;margin-bottom:2px;padding:0 15px;background:#f9f9f9;color:#8D8F99;}
.filesListItem .closeIconfilesList{cursor:pointer;width:16px;height:16px;text-align:center;float:right;background:url('../../assets/icon8.png') no-repeat 0 0/100%;text-indent:-9999px;position:relative;top:4px;}
.sTitleTwe{font-weight: bold;font-size: 24px;color: #161617;line-height: 28px;text-align: left;font-style: normal;margin-bottom:12px;}
.sTitleThr{font-weight: normal;font-size: 16px;color: #161617;line-height: 28px;margin-bottom:8px;}
.sTitleFor,.sTitleFiv{font-size:14px;font-size: 16px;color: #161617;line-height:24px;margin-bottom:8px;padding:0 0 0 12px;}
/* 单选警告提示去除 */
/* .schoolmainBox >>> .el-upload-list__item:first-child,.schoolmainBox >>> .el-upload-list{height:0;overflow:hidden;} */
/deep/ input[aria-hidden="true"] { display: none !important; }
/deep/.el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
    box-shadow: none !important;
}
.gjhqIpt /deep/ .el-input__icon{top:0;}
.imgsTitle{height:32px;margin:0 0 12px;}
</style>
