<template>
  <el-dialog
    :title="!dataForm.userId ? '人员新增' : '人员修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px">
      <el-form-item label="工人姓名" prop="name">
        <el-input disabled v-model="dataForm.name" placeholder="工人姓名"></el-input>
      </el-form-item>
      <el-form-item label="工人性别" prop="sex">
        <el-select disabled v-model="dataForm.sex" placeholder="请选择">
          <el-option
            v-for="item in sexs"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="出生日期" prop="birthday">
        <el-date-picker
          disabled
          v-model="dataForm.birthday"
          type="date"
          value-format="yyyy-MM"
          placeholder=“选择日期” />
      </el-form-item>
      <el-form-item label="文化程度" prop="education">
        <el-input disabled v-model="dataForm.education" placeholder="文化程度"></el-input>
      </el-form-item>
      <el-form-item label="现住址" prop="addr">
        <el-input disabled v-model="dataForm.addr" placeholder="现住址"></el-input>
      </el-form-item>
      <el-form-item label="户籍" prop="register">
        <el-input disabled v-model="dataForm.register" placeholder="户籍"></el-input>
      </el-form-item>

      <el-form-item label="本人电话" prop="phone">
        <el-input disabled v-model="dataForm.phone" placeholder="本人电话"></el-input>
      </el-form-item>


      <el-form-item label="身高" prop="height">
        <el-input disabled v-model="dataForm.height" placeholder="身高"></el-input>
      </el-form-item>
      <el-form-item label="体重" prop="weight">
        <el-input disabled v-model="dataForm.weight" placeholder="体重"></el-input>
      </el-form-item>
      <el-form-item label="位置" prop="positionId">
        <el-select
          disabled
          v-model="dataForm.positionId"
          placeholder="选择位置"
        >
          <el-option
            v-for="item in positionList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="职位" prop="workId">
        <el-select
          disabled
          v-model="dataForm.workId"
          placeholder="选择职位"
        >
          <el-option
            v-for="item in workList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item  label="成本折算系数" prop="cbzsxs">
        <el-input disabled v-model="dataForm.cbzsxs" placeholder="成本折算系数"></el-input>
      </el-form-item>

      <el-form-item label="应急联系人" prop="urgentName">
        <el-input disabled v-model="dataForm.urgentName" placeholder="应急联系人"></el-input>
      </el-form-item>
      <el-form-item label="与本人关系" prop="urgentRelation">
        <el-input disabled v-model="dataForm.urgentRelation" placeholder="与本人关系"></el-input>
      </el-form-item>
      <el-form-item label="紧急联系人电话" prop="urgentPhone">
        <el-input disabled v-model="dataForm.urgentPhone" placeholder="紧急联系人电话"></el-input>
      </el-form-item>
      <el-form-item label="本人照片" prop="image">
        <el-upload
          disabled
          class="avatar-uploader"
          :headers="headers"
          accept="image/jpeg,image/jpg,image/png"
          :action="imageUploaderUrl"
          :show-file-list="false"
          :on-success="handleImageSuccess">
          <img v-if="imageUrl" :src="imageUrl" class="avatar">
          <img v-else-if="isUpdate && imageBase64" :src="imageBase64">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="身份证正面" prop="imageFront">
        <el-upload
          disabled
          class="avatar-uploader"
          :headers="headers"
          accept="image/jpeg,image/jpg,image/png"
          :action="imageCardUploaderUrl"
          :show-file-list="false"
          :on-success="handleImageFrontSuccess">

          <img v-if="imageFrontUrl" :src="imageFrontUrl" class="avatar">
          <img v-else-if="isUpdate && imageFrontBase64" :src="imageFrontBase64">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="身份证背面" prop="imageBack">
        <el-upload
          disabled
          class="avatar-uploader"
          :headers="headers"
          accept="image/jpeg,image/jpg,image/png"
          :action="imageCardUploaderUrl"
          :show-file-list="false"
          :on-success="handleImageBackSuccess">

          <img v-if="imageBackUrl" :src="imageBackUrl" class="avatar">
          <img v-else-if="isUpdate && imageBackBase64" :src="imageBackBase64">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="出勤记录" v-if="isUpdate">
        <el-table
          :data="tableData"
          stripe
          style="width: 100%">
          <el-table-column label="序号" width="90" align="center">
            <template slot-scope="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column
            prop="dateDay"
            label="年月"
            width="180">
            <template slot-scope="scope">
              <el-date-picker
                @change="preventSelectDate($event,scope)"
                style="width: 100%"
                v-model="scope.row.dateDay"
                type="date"
                value-format="yyyy-MM"
                placeholder=“选择日期” />
            </template>
          </el-table-column>
          <el-table-column
            prop="workDay"
            label="出勤天数"
            width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.workDay"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="remark"
            label="备注">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
      <el-form-item label="工资账目" v-if="isUpdate">
        <el-button size="mini" style="margin-left: 88% " type="primary" @click="visibleSalary = true; salaryId=''; salaryObj={}">
          新增
        </el-button>
        <template>
          <div  v-for="(item, key) in salaryDict" :key="key">
            <hr style="border: 2px solid red">

            <span>{{item.year}}年</span>
            <el-button size="mini" style="margin-left: 78%" type="warning" @click="visibleSalary = true; salaryId=key; salaryObj=salaryDict[key]">修改</el-button>

            <div>入职时间{{item.startTime}} &nbsp;&nbsp;&nbsp;&nbsp; 离职时间{{item.startTime}}</div>
            <div>1.{{item.borrowingDetails?item.borrowingDetails:'暂无'}}</div>
            <div>2.{{item.gzjsfs?item.gzjsfs:'暂无'}}</div>
            <div>3.{{item.gzjqjsjjd?item.gzjqjsjjd:'暂无'}}</div>
            <div>4.{{item.remark?item.remark:'暂无'}}</div>
            <hr style="border: 2px solid red">
          </div>
        </template>
      </el-form-item>
    </el-form>
    <el-dialog :title="!salaryId? '工资账目新增' : '工资账目修改'" :visible.sync="visibleSalary" append-to-body>
      <el-form :model="salaryObj" ref="dataFormSalary" :rules="dataRuleSalary">
        <el-form-item label="年份" prop="year">
          <el-date-picker
            :disabled="salaryObj.approval===1"
            v-model="salaryObj.year"
            type="date"
            value-format="yyyy"
            placeholder=“选择日期” />
        </el-form-item>
        <el-form-item label="入职时间" prop="year">
          <el-date-picker
            :disabled="salaryObj.approval===1"
            v-model="salaryObj.startTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder=“选择日期” />
        </el-form-item>
        <el-form-item label="离职时间" prop="year">
          <el-date-picker
            :disabled="salaryObj.approval===1"
            v-model="salaryObj.endTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder=“选择日期” />
        </el-form-item>
        <el-form-item label="借款明细" prop="borrowingDetails" >
          <el-input :disabled="salaryObj.approval===1" v-model="salaryObj.borrowingDetails"  placeholder="借款明细" ></el-input>
        </el-form-item>
        <el-form-item label="工资标准计算方式" prop="gzjsfs">
          <el-input :disabled="salaryObj.approval===1" v-model="salaryObj.gzjsfs" placeholder="工资标准计算方式"></el-input>
        </el-form-item>
        <el-form-item label="工资结清及时间结点" prop="gzjqjsjjd">
          <el-input :disabled="salaryObj.approval===1" v-model="salaryObj.gzjqjsjjd" placeholder="工资结清及时间结点"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input :disabled="salaryObj.approval===1" v-model="salaryObj.remark" placeholder="备注"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
    <div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="pass()">通过</el-button>
        <el-button type="danger" @click="noPassed()">不通过</el-button>
      </span>
    </div>
  </el-dialog>
</template>

<script>
import {cloneDeep} from 'lodash'

export default {
  data () {
    return {
      visible: false,
      visibleSalary: false,
      tableData: [], // 出勤记录
      otableData: [], // 用作判断是否有重复的日期
      ptableData: [], // 用作是否修改出勤记录
      dataForm: {
        userId: 0,
        name: '',
        sex: '',
        birthday: '',
        register: '',
        card: '',
        phone: '',
        addr: '',
        education: '',
        height: '',
        weight: '',
        urgentName: '',
        urgentRelation: '',
        urgentPhone: '',
        typeId: '',
        typeName: '',
        cbzsxs: '',
        positionId: '',
        positionName: '',
        workId: '',
        workName: '',
        status: '',
        inductionTime: '',
        quitTime: '',
        image: '',
        imageFront: '',
        imageBack: '',
        bankImage: '',
        bankName: '',
        bankCard: '',
        bankRelation: '',
        balance: '',
        settleTime: '',
        createTime: '',
        updateTime: '',
        createName: '',
        approval: ''
      },
      pdataForm: {}, // 用作是否修改人员信息
      dataFormDict: {}, // 用作是否修改人员信息
      workList: [],
      positionList: [],
      imageUploaderUrl: '',
      imageUrl: '',
      imageCardUploaderUrl: '',
      imageFrontUrl: '',
      imageBackUrl: '',
      headers: {},
      sexs: [{value: 0, label: '女'}, {value: 1, label: '男'}],
      isUpdate: false,
      imageBase64: '',
      imageFrontBase64: '',
      imageBackBase64: '',

      // 工资账目
      salaryId: '',
      salaryDict: {}, // 工资账目
      salaryObj: {},
      psalaryDict: {}, // 用于比较是否修改
      dataRuleSalary: {
        // name: [
        //   { required: true, message: '工人姓名不能为空', trigger: 'blur' }
        // ]
      }
    }
  },
  methods: {
    getDataList  (id) {
      this.isUpdate = false
      this.tableData = []
      this.imageUrl = ''
      this.imageBackUrl = ''
      this.imageFrontUrl = ''
      // this.workList = workList
      // this.positionList = positionList
      // this.imageUploaderUrl = domain + 'sys/oss/upload?categoryType=photo'
      // this.imageCardUploaderUrl = domain + 'sys/oss/upload?categoryType=card'
      // this.headers.token = token
      this.dataForm.userId = id || 0
      this.visible = true
      this.dataForm.approval = 0
      this.salaryDict = {}
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.userId) {
          this.isUpdate = true
          this.$http({
            url: this.$http.adornUrl(`/business/businessworker/info/${this.dataForm.userId}`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.dataForm.name = data.data.name
              this.dataForm.sex = data.data.sex
              this.dataForm.birthday = data.data.birthday
              this.dataForm.register = data.data.register
              this.dataForm.card = data.data.card
              this.dataForm.phone = data.data.phone
              this.dataForm.addr = data.data.addr
              this.dataForm.education = data.data.education
              this.dataForm.height = data.data.height
              this.dataForm.weight = data.data.weight
              this.dataForm.urgentName = data.data.urgentName
              this.dataForm.urgentRelation = data.data.urgentRelation
              this.dataForm.urgentPhone = data.data.urgentPhone
              this.dataForm.typeId = data.data.typeId
              this.dataForm.typeName = data.data.typeName
              this.dataForm.cbzsxs = data.data.cbzsxs
              this.dataForm.positionId = data.data.positionId
              this.dataForm.positionName = data.data.positionName
              this.dataForm.workId = data.data.workId
              this.dataForm.workName = data.data.workName
              this.dataForm.status = data.data.status
              this.dataForm.inductionTime = data.data.inductionTime
              this.dataForm.quitTime = data.data.quitTime
              this.dataForm.image = data.data.image
              this.dataForm.imageFront = data.data.imageFront
              this.dataForm.imageBack = data.data.imageBack
              this.dataForm.bankImage = data.data.bankImage
              this.dataForm.bankName = data.data.bankName
              this.dataForm.bankCard = data.data.bankCard
              this.dataForm.bankRelation = data.data.bankRelation
              this.dataForm.balance = data.data.balance
              this.dataForm.settleTime = data.data.settleTime
              this.dataForm.createTime = data.data.createTime
              this.dataForm.updateTime = data.data.updateTime
              this.dataForm.createName = data.data.createName
              this.dataForm.approval = data.data.approval

              // 获取图片base64
              this.$http.request({
                url: this.$http.adornUrl('/sys/oss/list?filePath=' + this.dataForm.image),
                method: 'get'
              }).then(({data}) => {
                this.imageBase64 = data.replace(/[\r\n]/g, '')
              })
              this.$http.request({
                url: this.$http.adornUrl('/sys/oss/list?filePath=' + this.dataForm.imageFront),
                method: 'get'
              }).then(({data}) => {
                this.imageFrontBase64 = data.replace(/[\r\n]/g, '')
              })
              this.$http.request({
                url: this.$http.adornUrl('/sys/oss/list?filePath=' + this.dataForm.imageBack),
                method: 'get'
              }).then(({data}) => {
                this.imageBackBase64 = data.replace(/[\r\n]/g, '')
              })

              this.pdataForm = cloneDeep(this.dataForm)
            }
          })

          // 获取出勤记录
          this.$http({
            url: this.$http.adornUrl('/business/businessworkercq/list?userId=' + id),
            method: 'get'
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.tableData = data.page
              let count = 12 - this.tableData.length
              for (let i = 0; i < count; i++) {
                this.tableData.push({dateDay: '', workDay: '', remark: ''})
              }
              this.otableData = cloneDeep(this.tableData)
              this.tableData.forEach((item) => {
                this.ptableData.unshift(JSON.stringify(item))
                this.dataFormDict[item.id] = cloneDeep(item)
              })
            }
          })

          // 获取工资账目
          this.$http({
            url: this.$http.adornUrl('/business/businessworkersalary/list?userId=' + id),
            method: 'get'
          }).then(({data}) => {
            if (data && data.code === 0) {
              data.page.list.forEach((item) => {
                this.salaryDict[item.id] = item
              })

              this.psalaryDict = cloneDeep(this.salaryDict)
            }
          })
        }
      })
    },

    getGzzm (id) {
      // 获取工资账目
      this.$http.request({
        url: this.$http.adornUrl('/business/businessapproval/sonList/' + id),
        method: 'get'
      }).then(({data}) => {
        if (data && data.code === 0) {
          data.page.forEach((item) => {
            this.gzList.push({id: item.id, data: JSON.parse(item.approvalData)})
            // console.log(JSON.stringify(item));
            this.gzApprovalList.push(JSON.stringify(item))
            this.gzzmListIds.push(item.approvalId)
          })
        }
      })
    },

    // 传入的id为出勤
    getCq (id) {
      this.$http.request({
        url: this.$http.adornUrl('/business/businessapproval/getCqOrGzInfo/' + id),
        method: 'get'
      }).then(({data}) => {
        const res = data.businessApproval
        // console.log(res);
        if (data && data.code === 0) {
          // console.log(this.approvalId);
          this.dataOldFroMCQ1 = {
            ...JSON.parse(res.approvalOldData)
          }
          this.dataFroMCQ1 = {
            ...JSON.parse(res.approvalData)
          }
          this.dataForm = {
            ...res
          }
          this.dataFroMCQ1.approvalId = res.id
          this.dataOldFroMCQ1.approvalId = res.id
          // -------------------------- 原始数据 -------------------------
          // 数据处理模块
          // 人像照
          if (this.dataForm.image !== null && this.dataForm.image !== '' && this.dataForm.image !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.image),
              method: 'get'
            }).then(({data}) => {
              this.filesOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // 身份证正面
          if (this.dataForm.imageFront !== null && this.dataForm.imageFront !== '' && this.dataForm.imageFront !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.imageFront),
              method: 'get'
            }).then(({data}) => {
              this.filesPositiveOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // 身份证背面
          if (this.dataForm.imageBack !== null && this.dataForm.imageBack !== '' && this.dataForm.imageBack !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.imageBack),
              method: 'get'
            }).then(({data}) => {
              this.filesBackOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // -------------------------- 原始数据 -------------------------
        }
      })
    },
    // 传入为单独的工资账目
    getGzzmOne (id) {
      this.$http.request({
        url: this.$http.adornUrl('/business/businessapproval/getCqOrGzInfo/' + id),
        method: 'get'
      }).then(({data}) => {
        const res = data.businessApproval
        console.log(res)
        if (data && data.code === 0) {
          this.id = res.id
          // console.log(this.approvalId);
          this.gzList.push({id: res.id, data: JSON.parse(res.approvalData)})
          this.approvalId = res.approvalId// 业务id 相当于工资账目id
          this.gzApprovalList.push(JSON.stringify(res))
          this.dataForm = {
            ...res
          }
          // -------------------------- 原始数据 -------------------------
          // 数据处理模块
          // 人像照
          if (this.dataForm.image !== null && this.dataForm.image !== '' && this.dataForm.image !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.image),
              method: 'get'
            }).then(({data}) => {
              this.filesOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // 身份证正面
          if (this.dataForm.imageFront !== null && this.dataForm.imageFront !== '' && this.dataForm.imageFront !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.imageFront),
              method: 'get'
            }).then(({data}) => {
              this.filesPositiveOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // 身份证背面
          if (this.dataForm.imageBack !== null && this.dataForm.imageBack !== '' && this.dataForm.imageBack !== undefined) {
            this.$http.request({
              url: this.$http.adornUrl('/sys/oss/list' + '?filePath=' + this.dataForm.imageBack),
              method: 'get'
            }).then(({data}) => {
              this.filesBackOld.push(data.replace(/[\r\n]/g, ''))
            })
          }
          // -------------------------- 原始数据 -------------------------
        }
      })
    },

    pass () {
      console.log(this.dataFroMCQ1)
      if (this.type === 0) {
        this.cqList = []
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/pass'),
          method: 'post',
          params: this.$http.adornParams({
            'id': this.id,
            'approvalType': 0,
            'approvalData': JSON.stringify(this.changDataForm)
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.closePage()
          }
        })
        // 对页面含有的表格实体进行判断如果id!== undefiend说明 有改动向数组传值
        // console.log(this.dataFroMCQ12.id === undefined);
        if (this.dataFroMCQ1.id !== undefined) {
          console.log(this.dataFroMCQ1)
          this.cqList.push(JSON.stringify(this.dataFroMCQ1))
        }
        if (this.dataFroMCQ2.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ2))
        }
        if (this.dataFroMCQ3.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ3))
        }
        if (this.dataFroMCQ4.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ4))
        }
        if (this.dataFroMCQ5.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ5))
        }
        if (this.dataFroMCQ6.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ6))
        }
        if (this.dataFroMCQ7.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ7))
        }
        if (this.dataFroMCQ8.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ8))
        }
        if (this.dataFroMCQ9.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ9))
        }
        if (this.dataFroMCQ10.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ10))
        }
        if (this.dataFroMCQ11.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ11))
        }
        if (this.dataFroMCQ12.id !== undefined) {
          this.cqList.push(JSON.stringify(this.dataFroMCQ12))
        }
        if (this.cqList.length > 0) { // 说明有出勤记录的修改 才往传入后端
          this.$http.request({
            url: this.$http.adornUrl('/business/businessapproval/pass'),
            method: 'post',
            params: this.$http.adornParams({
              'approvalType': 1,
              'approvalData': this.cqList.toString()
            })
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.closePage()
            }
          })
        }
        // console.log(this.gzApprovalList.length);
        if (this.gzApprovalList.length > 0) {
          this.$http.request({
            url: this.$http.adornUrl('/business/businessapproval/pass'),
            method: 'post',
            params: this.$http.adornParams({
              'id': this.id,
              'approvalType': 2,
              'approvalData': this.gzApprovalList.toString()
            })
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.closePage()
            }
          })
        }
      } else if (this.type === 1) {
        this.cqList.push(JSON.stringify(this.dataFroMCQ1))
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/pass'),
          method: 'post',
          params: this.$http.adornParams({
            'id': this.id,
            'approvalType': 1,
            'approvalData': this.cqList.toString()
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.closePage()
          }
        })
      } else if (this.type === 2) {
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/pass'),
          method: 'post',
          params: this.$http.adornParams({
            'id': this.id,
            'approvalType': 2,
            'approvalData': this.gzApprovalList.toString()
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.closePage()
          }
        })
      }
    },

    noPassed () {
      if (this.type === 0) {
        // 人员id传入
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/noPass'),
          method: 'post',
          body: this.$http.adornData({
            'id': this.id,
            'approvalId': this.changDataForm.userId,
            'approvalType': 0
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.closePage()
          }
        })
        // 出勤数组闲置控 等等相关数组置空
        this.cqList = []
        this.cqApprovalIds = []
        this.gzApprovalList = []
        this.gzzmAppIds = []
        if (this.dataFroMCQ1.id !== undefined) {
          this.cqList.push(this.dataFroMCQ1.id)
          this.cqApprovalIds.push(this.dataFroMCQ1.approvalId)
        }
        if (this.dataFroMCQ2.id !== undefined) {
          this.cqList.push(this.dataFroMCQ2.id)
          this.cqApprovalIds.push(this.dataFroMCQ2.approvalId)
        }
        if (this.dataFroMCQ3.id !== undefined) {
          this.cqList.push(this.dataFroMCQ3.id)
          this.cqApprovalIds.push(this.dataFroMCQ3.approvalId)
        }
        if (this.dataFroMCQ4.id !== undefined) {
          this.cqList.push(this.dataFroMCQ4.id)
          this.cqApprovalIds.push(this.dataFroMCQ4.approvalId)
        }
        if (this.dataFroMCQ5.id !== undefined) {
          this.cqList.push(this.dataFroMCQ5.id)
          this.cqApprovalIds.push(this.dataFroMCQ5.approvalId)
        }
        if (this.dataFroMCQ6.id !== undefined) {
          this.cqList.push(this.dataFroMCQ6.id)
          this.cqApprovalIds.push(this.dataFroMCQ6.approvalId)
        }
        if (this.dataFroMCQ7.id !== undefined) {
          this.cqList.push(this.dataFroMCQ7.id)
          this.cqApprovalIds.push(this.dataFroMCQ7.approvalId)
        }
        if (this.dataFroMCQ8.id !== undefined) {
          this.cqList.push(this.dataFroMCQ8.id)
          this.cqApprovalIds.push(this.dataFroMCQ8.approvalId)
        }
        if (this.dataFroMCQ9.id !== undefined) {
          this.cqList.push(this.dataFroMCQ9.id)
          this.cqApprovalIds.push(this.dataFroMCQ9.approvalId)
        }
        if (this.dataFroMCQ10.id !== undefined) {
          this.cqList.push(this.dataFroMCQ10.id)
          this.cqApprovalIds.push(this.dataFroMCQ10.approvalId)
        }
        if (this.dataFroMCQ11.id !== undefined) {
          this.cqList.push(this.dataFroMCQ11.id)
          this.cqApprovalIds.push(this.dataFroMCQ11.approvalId)
        }
        if (this.dataFroMCQ12.id !== undefined) {
          this.cqList.push(this.dataFroMCQ12.id)
          this.cqApprovalIds.push(this.dataFroMCQ12.approvalId)
        }
        if (this.cqList.length > 0) { // 说明有出勤记录的修改 才往传入后端
          this.$http.request({
            url: this.$http.adornUrl('/business/businessapproval/noPass'),
            method: 'post',
            params: this.$http.adornParams({
              'id': JSON.parse(this.cqApprovalIds),
              'approvalId': JSON.stringify(this.cqList),
              'approvalType': 1
            })
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.closePage()
            }
          })
        }
        // 工资账目
        if (this.gzzmAppIds.length > 0) {
          this.$http.request({
            url: this.$http.adornUrl('/business/businessapproval/noPass'),
            method: 'post',
            params: this.$http.adornParams({
              'id': JSON.parse(this.gzzmAppIds),
              'approvalId': JSON.stringify(this.gzzmListIds),
              'approvalType': 2
            })
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.closePage()
            }
          })
        }
      } else if (this.type === 1) {
        this.cqList.push(this.dataFroMCQ1.id)
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/noPass'),
          method: 'post',
          params: this.$http.adornParams({
            'id': JSON.parse(this.id),
            'approvalId': JSON.stringify(this.cqList),
            'approvalType': 1
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
          }
        })
      } else if (this.type === 2) {
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/noPass'),
          method: 'post',
          params: this.$http.adornParams({
            'id': this.id,
            'approvalId': this.approvalId,
            'approvalType': 2
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
          }
        })
      }
    }
  }
}
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

</style>
