liuxiaolong
2019-05-06 19e47fa0e48ac76a951bbfaa0a3e95211567f5a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
  <div>
    <h4 class="font-weight-bold py-3 mb-2 d-flex flex-wrap justify-content-between align-items-center pt-2">
      <div>
        <router-link to="/personnel">
          <span class="text-muted font-weight-light">人员管理 /</span>
        </router-link>
        人员导入 -- {{uploadInfo.officeName}}
      </div>
      <div class="mb-2">
        <b-btn variant="primary" @click="handleBack">返回</b-btn>
      </div>
    </h4>
    <b-card style="font-family: '微软雅黑'">
      <h3 class="text-center font-weight-light my-5">人员导入说明</h3>
      <div class="row">
        <div class="col-md-1"></div>
        <div class="col-md-5">
          <h4 class="mb-2 font-weight-light">照片要求</h4>
          <hr />
          <h5 class="mb-2 ui-company-text text-muted">1、所用相片必须是近期正面免冠彩色头像</h5>
          <h5 class="mb-2 ui-company-text text-muted">2、头部占照片尺寸的2/3</h5>
          <h5 class="mb-2 ui-company-text text-muted">3、白色背景无边框,人像清晰,层次丰富,神态自然,无明显畸变</h5>
          <h5 class="mb-2 ui-company-text text-muted">4、电子照片尺寸 358像素(宽)×441像素(高),分辨率350dpi</h5>
        </div>
        <div class="col-md-5">
          <h4 class="mb-2 font-weight-light">Excel要求</h4>
          <hr />
          <h5 style="text-indent: 2" class="mb-2 ui-company-text text-muted">1、Excel中插入图片时,取消压缩功能,步骤:文件 - 选项 - 高级 - [图片大小和质量] 选择 不压缩文件中的图像</h5>
          <h5 class="mb-2 ui-company-text text-muted">2、照片不要溢出 Excel 单元格</h5>
          <h5 class="mb-2 ui-company-text text-muted">3、确保Excel中的部门都已创建</h5>
          <h5 class="mb-2 ui-company-text text-muted">4、单个Excel文件不要大于20M</h5>
        </div>
        <div class="col-md-1"></div>
      </div>
      <div class="flex-center">
        <UpLoad
          :isList="false"
          limitSize="20M"
          :uploadInfo="uploadInfo"
          uploadBtntext="导入学生"
          @res="fetchResult"
          class="mr10"
        />
        <UpLoad
          :isList="false"
          limitSize="20M"
          :uploadInfo="uploadInfo"
          uploadBtntext="导入教师"
          @res="fetchResult"
          class="ml10"
        />
      </div>
    </b-card>
    <b-card v-if="errorMsg.length">
      <div class="row">
        <div class="col-md-1 mb-2"></div>
        <h4 class="font-weight-light">错误详情</h4>
        <hr />
      </div>
      <div class="row">
        <div class="col-md-1"></div>
        <div class="col-md-5">
          <h5
            class="mb-2 ui-company-text text-muted py-2"
            v-for="(item, index) in errorMsgLeft"
          >
            {{index + 1}}、 {{item}}
          </h5>
        </div>
        <div class="col-md-5">
          <h5
            class="mb-2 ui-company-text text-muted py-2"
            v-for="(item) in errorMsgRight"
          >
            {{item}}
          </h5>
        </div>
        <div class="col-md-1"></div>
      </div>
    </b-card>
  </div>
</template>
 
<script>
import UpLoad from './uploadCommon'
 
export default {
  data: () => ({
    errorMsg: []
  }),
  computed: {
    uploadInfo() {
      return JSON.parse(sessionStorage.getItem('uploadInfo'))
    },
    errorMsgLeft() {
      return this.errorMsg.filter((item, index) => index % 2 === 0)
    },
    errorMsgRight() {
      return this.errorMsg.filter((item, index) => index % 2 === 1)
    }
  },
  methods: {
    // * 打印错误信息或者成功返回列表页面
    fetchResult(res) {
      if (res && res.data.code - 0 === 0) {
        this.$toast({
          type: 'success',
          message: '上传成功'
        })
        this.$router.push({
          path: '/personnel'
        })
      } else {
        let errMsg = res.data && res.data.message ? res.data.message : ''
        if (errMsg && Array.isArray(errMsg)) {
          this.errorMsg = [ ...errMsg ]
        } else {
          this.$toast({
            type: 'error',
            message: '错误:' + errMsg,
            toastDuration: 3000
          })
        }
      }
    },
    // * 返回回调
    handleBack() {
      this.$router.push('/personnel')
    }
  },
  components: {
    UpLoad
  }
}
</script>