智慧保安打卡签到系统
+
liuyg
2021-11-22 0ebbd4a9d22dce39369a6ef9973e751ccfdbdda7
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<template>
  <basic-container class="formsss">
    <div class="formssstitle">身份证信息</div>
    <avue-form
      ref="form"
      v-model="obj"
      :option="option"
      @reset-change="emptytChange"
    >
      <!-- @submit="submit" -->
      <template slot-scope="{ type, disabled }" slot="imgs">
        <div class="imgss">
          <img :src="obj.imgs" alt="" />
        </div>
      </template>
      <template slot-scope="{ type, disabled }" slot="fingerprintForm">
        <div class="zhiwenMain">
          <iframe
            id="zhiwen"
            ref="zhiwen"
            src="/zhiwenDemo/CID.html"
            frameborder="0"
            width="100%"
            height="100%"
            name="zhiwen"
          ></iframe>
        </div>
      </template>
    </avue-form>
  </basic-container>
</template>
 
<script>
import CertCtl from "./sfzJS";
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters(["userInfo", "cardInfor", "haveCardid", "useZhiWen"]),
  },
  mounted() {
    // console.log(CertCtl);
    try {
      // 开始连接设备
      //调用对应的连接方法,并赋值给result
      this.cardShebei = CertCtl.connect();
      //如果result为空,代表读卡插件未启动
      if (this.cardShebei == "") {
        console.log("未启动读卡插件!");
      } else {
        //result页面回显
        console.log("ok!");
      }
    } catch (e) {}
 
    if (this.intTime) {
      clearInterval(this.intTime);
      this.setIntervals();
    } else {
      this.setIntervals();
    }
  },
  data() {
    return {
      cardShebei: "",
      intTime: "", //自动获取身份证;
      obj: {},
      option: {
        // mockBtn: true,
        // submitText: "完成",
        // printBtn: true,
        submitBtn: false,
        disabled: true,
        column: [
          {
            label: "姓名",
            prop: "name",
          },
          {
            label: "性别",
            prop: "sex",
          },
          {
            label: "民族",
            prop: "national",
          },
          {
            label: "出生日期",
            prop: "birthday",
          },
          {
            label: "照片",
            prop: "imgs",
            // listType: "picture-img",
            // type: "upload",
            // disabled: true,
          },
          {
            label: "指纹",
            prop: "fingerprintForm",
          },
          {
            label: "身份号码",
            prop: "id",
          },
          {
            label: "签发机关",
            prop: "qfjg",
          },
          {
            label: "起始日期",
            prop: "yxqstart",
          },
          {
            label: "截止日期",
            prop: "yxqend",
          },
          {
            label: "住址",
            prop: "certAddress",
            span: 24,
          },
          // {
          //   label: "最新住址",
          //   prop: "address",
          // },
        ],
      },
    };
  },
  methods: {
    setIntervals: function () {
      let that = this;
      this.intTime = setInterval(function () {
        if (!that.haveCardid) {
          //定时读卡
          let result = CertCtl.readCert();
          if (result == "") {
            console.log("未启动读卡插件!");
          } else {
            var resultObj = eval("(" + result + ")");
            //resultFlag为0代表读卡成功
            if (resultObj.resultFlag == "0") {
              //回显相关数据
              // console.log(resultObj, 123);
              const data = resultObj.resultContent;
              //赋值数据
              that.obj = {
                name: data.partyName,
                national: data.nation,
                certAddress: data.certAddress,
                sex:
                  data.certType == 0
                    ? "未知"
                    : data.certType == 1
                    ? "男"
                    : data.certType == 2
                    ? "女"
                    : data.certType == 9
                    ? "未说明"
                    : "未能识别",
                imgs: "data:image/bmp;base64," + data.identityPic,
                yxqend:
                  data.expDate.slice(0, 4) +
                  "-" +
                  data.expDate.slice(4, 6) +
                  "-" +
                  data.expDate.slice(6, 8),
                yxqstart:
                  data.effDate.slice(0, 4) +
                  "-" +
                  data.effDate.slice(4, 6) +
                  "-" +
                  data.effDate.slice(6, 8),
                birthday:
                  data.bornDay.slice(0, 4) +
                  "-" +
                  data.bornDay.slice(4, 6) +
                  "-" +
                  data.bornDay.slice(6, 8),
                id: data.certNumber,
                qfjg: data.certOrg,
              };
              that.$store.commit("setCardInfor", that.obj);
              that.$store.commit("setCardidState", true);
            } else if (resultObj.resultFlag == "-1") {
              if (resultObj.errorMsg == "端口打开失败") {
                console.log("读卡器未连接");
              } else {
                // console.log(resultObj.errorMsg);
                //无卡片提醒
              }
            } else if (resultObj.resultFlag == "-2") {
              console.log(resultObj.errorMsg);
            }
          }
        }
      }, 1000);
    },
    emptytChange() {
      this.$store.commit("setCardidState", false);
      let zhiwen = {
        featuredatas: "",
        imgBMP: "",
        url: "",
        isoks: false,
        clear: true,
      };
      this.useZhiWen("setZhiwenData", zhiwen);
      this.$message.success("清空身份证数据");
    },
    // useZhiWen: function (fn, vals) {
    //   //读取指纹实例
    //   let val = vals || "";
    //   var winzhiwen = document.getElementById("zhiwen").contentWindow;
    //   return winzhiwen[fn](val);
    // },
  },
};
</script>
<style lang="scss" scoped>
.zhiwenMain {
  width: 255px;
  height: 215px;
  // border: 1px solid rgba($color: #d3d3d3, $alpha: 1);
}
.imgss {
  height: 182px;
  width: 138px;
  border: 1px solid rgba($color: #d3d3d3, $alpha: 1);
  border-radius: 5px;
  img {
    width: 100%;
    height: 100%;
  }
}
</style>