123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- let s4 = new SM4Util();
- let base64 = new Base64(); //声明base解码和编码类
- let listVue = new Vue({
- el: "#detailPage",
- data: {
- apiurl: apiurl, //基础的页面请求地址
- userId: "", //用户id
- userName: "", //用户中文名
- token: "",
- CARDSTART: "",
- CARDEND: "",
- usercard: {
- id: 0,
- userid: this.userId,
- username: this.userName,
- DEPNAME: "",
- SBTIME: "",
- XBTIME: ""
- },
- clickstatus:false
- },
- methods: {
- dateFtt: (fmt, date) => {
- var o = {
- "M+": date.getMonth() + 1, //月份
- "d+": date.getDate(), //日
- "h+": date.getHours(), //小时
- "m+": date.getMinutes(), //分
- "s+": date.getSeconds(), //秒
- "q+": Math.floor((date.getMonth() + 3) / 3), //季度
- "S": date.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- },
- queryRules: () => {
- let postData = {
- sqlwhere:{}
- }
- $http({
- method: 'post',
- baseURL: _this.apiurl,
- url: "g2app/Attendance/queryRules",
- data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + _this.token
- }
- }).then(res => {
- let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
- _this.CARDSTART = response.data.STARTTIEM;
- _this.CARDEND = response.data.ENDTIME
- _this.getDEPART();
- })
- },
- getDEPART: () => {
- let postData = {
- userid: _this.usercard.userid
- }
- $http({
- method: 'post',
- baseURL: _this.apiurl,
- url: "g2app/dataabase/queryDpName",
- data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + _this.token
- }
- }).then(res => {
- let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
- _this.usercard.DEPNAME = response.data.length == 0 ? "" : response.data[0].SECTION;
- })
- },
- card: () => {
- let postData = {
- tablename: "ATTENDANCEMAN",
- colums: "*,TO_CHAR(SBTIME,'hh24:mi:ss') as SBTIME1,TO_CHAR(XBTIME,'hh24:mi:ss') as XBTIME1",
- order: "ID",
- sqlwhere: {
- CDATE: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
- CUSERID: _this.usercard.userid
- },
- sqlinwhere: "",
- sqllikewhere: ""
- }
- $http({
- method: 'post',
- baseURL: _this.apiurl,
- url: "g2app/dataabase/queryDataByCol",
- data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + _this.token
- }
- }).then(res => {
- let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
- if (response.data.length != 0) {
- _this.usercard = {
- id: response.data[0].ID,
- userid: _this.usercard.userid,
- username: _this.usercard.username,
- DEPNAME: _this.usercard.DEPNAME,
- SBTIME: response.data[0].SBTIME ? response.data[0].SBTIME1 : "",
- XBTIME: response.data[0].XBTIME ? response.data[0].XBTIME1 : "",
- DKSTATUS: response.data[0].DKSTATUS.split(",")[0]
- }
- }
- $(".cardtime").html(sp.getLocalDate().slice(11, 19))
- setInterval(function () {
- $(".cardtime").html(sp.getLocalDate().slice(11, 19))
- }, 1000)
- })
- },
- clickCard: () => {
- if (_this.clickstatus == true || (_this.usercard.SBTIME != '' && _this.usercard.XBTIME != '')) {
- return;
- }
- _this.clickstatus = true;
- if (_this.usercard.id == 0) {
- let postData = {
- tablename: "ATTENDANCEMAN",
- data: {
- CDATE: sp.format(sp.getLocalDate()),
- CNAME: _this.usercard.username,
- CUSERID: _this.usercard.userid,
- DEPNAME: _this.usercard.DEPNAME,
- SBTIME: sp.format(sp.getLocalDate()) + " " + $(".cardtime").html(),
- DKSTATUS: getDKSTATUS($(".cardtime").html(), 1)
- }
- }
- $http({
- method: 'post',
- baseURL: _this.apiurl,
- url: "g2app/dataabase/insertFormData",
- data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + _this.token
- }
- }).then(res => {
- let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
- _this.clickstatus = false;
- if (response.success == true) {
- _this.card()
- } else {
- $.alert(response.message)
- }
- })
- } else {
- let postData = {
- id: _this.usercard.id,
- tablename: "ATTENDANCEMAN",
- data: {
- CNAME: _this.usercard.username,
- CUSERID: _this.usercard.userid,
- DEPNAME: _this.usercard.DEPNAME,
- XBTIME: sp.format(sp.getLocalDate()) + " " + $(".cardtime").html(),
- DKSTATUS: _this.usercard.DKSTATUS + "," + getDKSTATUS($(".cardtime").html(), 2)
- }
- }
- $http({
- method: 'post',
- baseURL: _this.apiurl,
- url: "g2app/dataabase/upFormData",
- data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + _this.token
- }
- }).then(res => {
- let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
- _this.clickstatus = false;
- if (response.success == true) {
- _this.card()
- } else {
- $.alert(response.message)
- }
- })
- }
- }
- },
- created: function () {
- _this = this;
- let token = localStorage.getItem("mobile-token", _this.token);
- let userName = localStorage.getItem("mobile-userName", _this.userName);
- let userId = localStorage.getItem("mobile-userId", _this.userId);
- _this.userId = userId;
- _this.token = token;
- _this.userName = userName;
- },
- mounted: function () {
- _this.card();
- _this.queryRules();
- }
- })
|