index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. let s4 = new SM4Util();
  2. let base64 = new Base64(); //声明base解码和编码类
  3. let listVue = new Vue({
  4. el: "#detailPage",
  5. data: {
  6. apiurl: apiurl, //基础的页面请求地址
  7. userId: "", //用户id
  8. userName: "", //用户中文名
  9. token: "",
  10. CARDSTART: "",
  11. CARDEND: "",
  12. usercard: {
  13. id: 0,
  14. userid: this.userId,
  15. username: this.userName,
  16. DEPNAME: "",
  17. SBTIME: "",
  18. XBTIME: ""
  19. },
  20. clickstatus:false
  21. },
  22. methods: {
  23. dateFtt: (fmt, date) => {
  24. var o = {
  25. "M+": date.getMonth() + 1, //月份
  26. "d+": date.getDate(), //日
  27. "h+": date.getHours(), //小时
  28. "m+": date.getMinutes(), //分
  29. "s+": date.getSeconds(), //秒
  30. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  31. "S": date.getMilliseconds() //毫秒
  32. };
  33. if (/(y+)/.test(fmt))
  34. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  35. for (var k in o)
  36. if (new RegExp("(" + k + ")").test(fmt))
  37. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  38. return fmt;
  39. },
  40. queryRules: () => {
  41. let postData = {
  42. sqlwhere:{}
  43. }
  44. $http({
  45. method: 'post',
  46. baseURL: _this.apiurl,
  47. url: "g2app/Attendance/queryRules",
  48. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  49. headers: {
  50. 'Content-Type': 'application/json',
  51. 'Authorization': "Bearer " + _this.token
  52. }
  53. }).then(res => {
  54. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  55. _this.CARDSTART = response.data.STARTTIEM;
  56. _this.CARDEND = response.data.ENDTIME
  57. _this.getDEPART();
  58. })
  59. },
  60. getDEPART: () => {
  61. let postData = {
  62. userid: _this.usercard.userid
  63. }
  64. $http({
  65. method: 'post',
  66. baseURL: _this.apiurl,
  67. url: "g2app/dataabase/queryDpName",
  68. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  69. headers: {
  70. 'Content-Type': 'application/json',
  71. 'Authorization': "Bearer " + _this.token
  72. }
  73. }).then(res => {
  74. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  75. _this.usercard.DEPNAME = response.data.length == 0 ? "" : response.data[0].SECTION;
  76. })
  77. },
  78. card: () => {
  79. let postData = {
  80. tablename: "ATTENDANCEMAN",
  81. colums: "*,TO_CHAR(SBTIME,'hh24:mi:ss') as SBTIME1,TO_CHAR(XBTIME,'hh24:mi:ss') as XBTIME1",
  82. order: "ID",
  83. sqlwhere: {
  84. CDATE: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
  85. CUSERID: _this.usercard.userid
  86. },
  87. sqlinwhere: "",
  88. sqllikewhere: ""
  89. }
  90. $http({
  91. method: 'post',
  92. baseURL: _this.apiurl,
  93. url: "g2app/dataabase/queryDataByCol",
  94. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  95. headers: {
  96. 'Content-Type': 'application/json',
  97. 'Authorization': "Bearer " + _this.token
  98. }
  99. }).then(res => {
  100. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  101. if (response.data.length != 0) {
  102. _this.usercard = {
  103. id: response.data[0].ID,
  104. userid: _this.usercard.userid,
  105. username: _this.usercard.username,
  106. DEPNAME: _this.usercard.DEPNAME,
  107. SBTIME: response.data[0].SBTIME ? response.data[0].SBTIME1 : "",
  108. XBTIME: response.data[0].XBTIME ? response.data[0].XBTIME1 : "",
  109. DKSTATUS: response.data[0].DKSTATUS.split(",")[0]
  110. }
  111. }
  112. $(".cardtime").html(sp.getLocalDate().slice(11, 19))
  113. setInterval(function () {
  114. $(".cardtime").html(sp.getLocalDate().slice(11, 19))
  115. }, 1000)
  116. })
  117. },
  118. clickCard: () => {
  119. if (_this.clickstatus == true || (_this.usercard.SBTIME != '' && _this.usercard.XBTIME != '')) {
  120. return;
  121. }
  122. _this.clickstatus = true;
  123. if (_this.usercard.id == 0) {
  124. let postData = {
  125. tablename: "ATTENDANCEMAN",
  126. data: {
  127. CDATE: sp.format(sp.getLocalDate()),
  128. CNAME: _this.usercard.username,
  129. CUSERID: _this.usercard.userid,
  130. DEPNAME: _this.usercard.DEPNAME,
  131. SBTIME: sp.format(sp.getLocalDate()) + " " + $(".cardtime").html(),
  132. DKSTATUS: getDKSTATUS($(".cardtime").html(), 1)
  133. }
  134. }
  135. $http({
  136. method: 'post',
  137. baseURL: _this.apiurl,
  138. url: "g2app/dataabase/insertFormData",
  139. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  140. headers: {
  141. 'Content-Type': 'application/json',
  142. 'Authorization': "Bearer " + _this.token
  143. }
  144. }).then(res => {
  145. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  146. _this.clickstatus = false;
  147. if (response.success == true) {
  148. _this.card()
  149. } else {
  150. $.alert(response.message)
  151. }
  152. })
  153. } else {
  154. let postData = {
  155. id: _this.usercard.id,
  156. tablename: "ATTENDANCEMAN",
  157. data: {
  158. CNAME: _this.usercard.username,
  159. CUSERID: _this.usercard.userid,
  160. DEPNAME: _this.usercard.DEPNAME,
  161. XBTIME: sp.format(sp.getLocalDate()) + " " + $(".cardtime").html(),
  162. DKSTATUS: _this.usercard.DKSTATUS + "," + getDKSTATUS($(".cardtime").html(), 2)
  163. }
  164. }
  165. $http({
  166. method: 'post',
  167. baseURL: _this.apiurl,
  168. url: "g2app/dataabase/upFormData",
  169. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  170. headers: {
  171. 'Content-Type': 'application/json',
  172. 'Authorization': "Bearer " + _this.token
  173. }
  174. }).then(res => {
  175. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  176. _this.clickstatus = false;
  177. if (response.success == true) {
  178. _this.card()
  179. } else {
  180. $.alert(response.message)
  181. }
  182. })
  183. }
  184. }
  185. },
  186. created: function () {
  187. _this = this;
  188. let token = localStorage.getItem("mobile-token", _this.token);
  189. let userName = localStorage.getItem("mobile-userName", _this.userName);
  190. let userId = localStorage.getItem("mobile-userId", _this.userId);
  191. _this.userId = userId;
  192. _this.token = token;
  193. _this.userName = userName;
  194. },
  195. mounted: function () {
  196. _this.card();
  197. _this.queryRules();
  198. }
  199. })