<template>
  <div class="app-warp">
    <div class="detail-structure">
      <el-page-header content="信息确认" @back="goBack"/>
      <div class="detail-container">
        <div class="level-title">
          <h1>变更申请</h1>
        </div>
        <div class="mb-20">
          <table class="table-ui">
            <tr>
              <td class="tbg">发起人</td>
              <td>{{ log.CREATOR }}</td>
              <td class="tbg">发起时间</td>
              <td>{{ log.CREATTIME }}</td>
            </tr>
            <tr>
              <td class="tbg" colspan="2" style="text-align: center">变更前内容</td>
              <td class="tbg" colspan="2" style="text-align: center">变更后内容</td>
            </tr>
            <tr>
              <td class="tbg">学员姓名</td>
              <td>{{ oldData.NAME }}</td>
              <td class="tbg">学员姓名</td>
              <td>{{ newData.NAME }}</td>
            </tr>
            <tr>
              <td class="tbg">证件类型</td>
              <td>{{ oldData.CERTIFICATETYPE_NAME }}</td>
              <td class="tbg">证件类型</td>
              <td>{{ newData.CERTIFICATETYPE_NAME }}</td>
            </tr>
            <tr>
              <td class="tbg">证件号码</td>
              <td>{{ oldData.USER_ID_CARD }}</td>
              <td class="tbg">证件号码</td>
              <td>{{ newData.USER_ID_CARD }}</td>
            </tr>
            <tr>
              <td class="tbg">联系电话</td>
              <td>{{ oldData.USERNAME }}</td>
              <td class="tbg">联系电话</td>
              <td>{{ newData.USERNAME }}</td>
            </tr>
            <tr>
              <td class="tbg">性别</td>
              <td>{{ oldData.SEX_NAME }}</td>
              <td class="tbg">性别</td>
              <td>{{ newData.SEX_NAME }}</td>
            </tr>
            <tr>
              <td class="tbg">工作单位</td>
              <td>{{ oldData.ENTERPRISE }}</td>
              <td class="tbg">工作单位</td>
              <td>{{ newData.ENTERPRISE }}</td>
            </tr>
            <tr>
              <td class="tbg">统一社会信用代码</td>
              <td>{{ oldData.CODE }}</td>
              <td class="tbg">统一社会信用代码</td>
              <td>{{ newData.CODE }}</td>
            </tr>
            <tr>
              <td class="tbg">证件照片</td>
              <td>
                <viewer :images="[config.fileUrl + oldData.USER_SIGN_FILE_PATH]">
                  <img :src="config.fileUrl + oldData.USER_SIGN_FILE_PATH" width="100" height="100">
                </viewer>
              </td>
              <td class="tbg">证件照片</td>
              <td>
                <viewer :images="[config.fileUrl + newData.USER_SIGN_FILE_PATH]">
                  <img :src="config.fileUrl + newData.USER_SIGN_FILE_PATH" width="100" height="100">
                </viewer>
              </td>
            </tr>
            <tr>
              <td class="tbg">签字照片</td>
              <td>
                <viewer :images="[config.fileUrl + oldData.SIGNATURE_FILE_PATH]">
                  <img :src="config.fileUrl + oldData.SIGNATURE_FILE_PATH" width="100" height="100">
                </viewer>
              </td>
              <td class="tbg">签字照片</td>
              <td>
                <viewer :images="[config.fileUrl + newData.SIGNATURE_FILE_PATH]">
                  <img :src="config.fileUrl + newData.SIGNATURE_FILE_PATH" width="100" height="100">
                </viewer>
              </td>
            </tr>
            <tr>
              <td class="tbg">认证照片</td>
              <td>
                <viewer :images="[oldData.USERAVATARPREFIX + oldData.USERAVATARURL_CONVERT]">
                  <img :src="(oldData.USERAVATARPREFIX + oldData.USERAVATARURL_CONVERT)" width="100" height="100">
                </viewer>
              </td>
              <td class="tbg">认证照片</td>
              <td>
                <viewer :images="[newData.USERAVATARPREFIX + newData.USERAVATARURL_CONVERT]">
                  <img :src="(newData.USERAVATARPREFIX + newData.USERAVATARURL_CONVERT)" width="100" height="100">
                </viewer>
              </td>
            </tr>
            <tr>
              <td class="tbg">文化水平</td>
              <td>{{ oldData.DEGREE_OF_EDUCATION_NAME }}</td>
              <td class="tbg">文化水平</td>
              <td>{{ newData.DEGREE_OF_EDUCATION_NAME }}</td>
            </tr>
            <tr>
              <td class="tbg">职务/职称</td>
              <td>{{ oldData.DUTIES }}</td>
              <td class="tbg">职务/职称</td>
              <td>{{ newData.DUTIES }}</td>
            </tr>
            <tr>
              <td class="tbg">部门</td>
              <td>{{ oldData.STUDENT_DEPARTMENT }}</td>
              <td class="tbg">部门</td>
              <td>{{ newData.STUDENT_DEPARTMENT }}</td>
            </tr>
            <tr>
              <td class="tbg">工种</td>
              <td>{{ oldData.TYPE_OF_WORK }}</td>
              <td class="tbg">工种</td>
              <td>{{ newData.TYPE_OF_WORK }}</td>
            </tr>
            <tr>
              <td class="tbg">人员类型</td>
              <td>{{ oldData.PERSONNEL_TYPE_NAME }}</td>
              <td class="tbg">人员类型</td>
              <td>{{ newData.PERSONNEL_TYPE_NAME }}</td>
            </tr>
          </table>
        </div>
        <template v-if="parentObj.InformationChangeLocation === 'list'">
          <div class="level-title">
            <h1>运营服务人员审核变更</h1>
          </div>
          <div class="mb-20">
            <table class="table-ui">
              <tr>
                <td class="tbg">审核</td>
                <td>
                  <el-radio-group v-model="STATE">
                    <el-radio label="3">通过</el-radio>
                    <el-radio label="-2">不通过</el-radio>
                  </el-radio-group>
                </td>
              </tr>
            </table>
          </div>
        </template>
        <div class="detail_foot">
          <el-button v-if="parentObj.InformationChangeLocation === 'list'" type="primary" @click="confirm">提交</el-button>
          <el-button icon="el-icon-arrow-left" @click="goBack">返回</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { requestFN } from '@/utils/request'
export default {
  data() {
    return {
      config: config,
      newData: {},
      log: {},
      oldData: {},
      STATE: ''
    }
  },
  inject: ['setActiveName', 'parentObj'],
  created() {
    this.getData()
  },
  methods: {
    getData() {
      let url = ''
      let params = {}
      if (this.parentObj.InformationChangeLocation === 'list') {
        url = '/studentlog/getNewLogByUser'
        params = {
          USER_ID: this.parentObj.USER_ID,
          STATE: '2'
        }
      } else if (this.parentObj.InformationChangeLocation === 'dialog') {
        url = '/studentlog/findByLog'
        params = {
          STUDENTLOG_ID: this.parentObj.USER_ID
        }
      }
      requestFN(url, params).then(res => {
        if (res.result === 'success') {
          this.newData = res.new
          this.log = res.log
          this.oldData = res.old
        }
      }).catch(() => {
        this.goBack()
      })
    },
    confirm() {
      if (!this.STATE) {
        this.$message.error('请选择审核状态')
        return
      }
      requestFN('/studentlog/editState', {
        STUDENTLOG_ID: this.log.STUDENTLOG_ID,
        STATE: this.STATE
      }).then(res => {
        this.$message.success('操作成功')
        this.goBack()
      })
    },
    goBack() {
      this.setActiveName('List')
    }
  }
}
</script>

<style scoped>

</style>
