detail.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. id: "",
  11. tablename: "",
  12. departname: "",
  13. detail: {},
  14. array: [],
  15. plnum: 0,
  16. pllist:[],
  17. dznum: 0,
  18. canDZ: false,
  19. idDZ: 0,
  20. plcontent: ""
  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. getDetail: () => {
  41. let postData = {
  42. tablename: _this.tablename,
  43. colums: "*",
  44. order: "ID",
  45. sqlwhere: {ID: _this.id},
  46. sqlinwhere: "",
  47. sqllikewhere: ""
  48. }
  49. $http({
  50. method: 'post',
  51. baseURL: _this.apiurl,
  52. url: "g2app/dataabase/queryDataByCol",
  53. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  54. headers: {
  55. 'Content-Type': 'application/json',
  56. 'Authorization': "Bearer " + _this.token
  57. }
  58. }).then(res => {
  59. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  60. _this.detail = {
  61. ID: response.data[0].ID,
  62. GGBK: response.data[0].GGBK,
  63. FBBM: response.data[0].FBBM,
  64. FBSJ: _this.dateFtt("yyyy-MM-dd", new Date(response.data[0].FBSJ)),
  65. FBFW: response.data[0].FBFW,
  66. GGNR: base64.decode(response.data[0].GGNR),
  67. GGBT: response.data[0].GGBT
  68. }
  69. if (response.data[0].FJSC && response.data[0].FJSC != "") {
  70. _this.array = JSON.parse(response.data[0].FJSC);
  71. }
  72. })
  73. },
  74. getMyDZNum: () => {
  75. let postData = {
  76. tablename: "SX_TZGG_01",
  77. pagesize: 1,
  78. pageno: 1,
  79. colums: "*",
  80. order: "ID",
  81. sqlwhere: {
  82. PID: _this.id,
  83. DZMANID: _this.userId, //用户id
  84. },
  85. sqlorwhere: {
  86. },
  87. sqlinwhere: "",
  88. sqllikewhere: ""
  89. }
  90. $http({
  91. method: 'post',
  92. baseURL: _this.apiurl,
  93. url: "g2app/dataabase/queryDataByColWithPage",
  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.totalCount > 0) {
  102. _this.canDZ = false;
  103. _this.idDZ = response.data[0].ID;
  104. } else {
  105. _this.canDZ = true;
  106. _this.idDZ = 0;
  107. }
  108. })
  109. },
  110. addDZ: () => {
  111. let postData = {
  112. "tablename": "SX_TZGG_01",
  113. "data": []
  114. }
  115. postData.data.push({
  116. PID: _this.id,
  117. CTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
  118. STATE: "正常",
  119. DZMAN: _this.userName,
  120. DZMANID: _this.userId,
  121. });
  122. $http({
  123. method: 'post',
  124. baseURL: _this.apiurl,
  125. url: "g2app/dataabase/insertDataList",
  126. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  127. headers: {
  128. 'Content-Type': 'application/json',
  129. 'Authorization': "Bearer " + _this.token
  130. }
  131. }).then(res => {
  132. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  133. _this.getDZNum();
  134. _this.getMyDZNum();
  135. })
  136. },
  137. getDZNum: () => {
  138. let postData = {
  139. tablename: "SX_TZGG_01",
  140. pagesize: 1,
  141. pageno: 1,
  142. colums: "*",
  143. order: "ID",
  144. sqlwhere: {
  145. PID: _this.id,
  146. },
  147. sqlorwhere: {},
  148. sqlinwhere: "",
  149. sqllikewhere: ""
  150. }
  151. $http({
  152. method: 'post',
  153. baseURL: _this.apiurl,
  154. url: "g2app/dataabase/queryDataByColWithPage",
  155. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  156. headers: {
  157. 'Content-Type': 'application/json',
  158. 'Authorization': "Bearer " + _this.token
  159. }
  160. }).then(res => {
  161. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  162. _this.dznum = response.totalCount;
  163. })
  164. },
  165. deleteDZ: () => {
  166. let postData = {"id": _this.idDZ, "tablename": "SX_TZGG_01"}
  167. $http({
  168. method: 'post',
  169. baseURL: _this.apiurl,
  170. url: "g2app/richang/delDataById",
  171. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  172. headers: {
  173. 'Content-Type': 'application/json',
  174. 'Authorization': "Bearer " + _this.token
  175. }
  176. }).then(res => {
  177. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  178. _this.getDZNum();
  179. _this.getMyDZNum();
  180. })
  181. },
  182. sendPL: () => {
  183. if(_this.plcontent.trim()==""){
  184. $.alert("请先填写评论内容!", "温馨提示");
  185. return false;
  186. }
  187. let postData = {
  188. "tablename": "SX_TZGG_02",
  189. "data": []
  190. }
  191. postData.data.push({
  192. PID: _this.id,
  193. CTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
  194. PLMAN: _this.userName,
  195. PLPIC:_this.avatar,
  196. PLTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
  197. PLCONT: _this.plcontent,
  198. PLMANID: _this.userId,
  199. });
  200. $http({
  201. method: 'post',
  202. baseURL: _this.apiurl,
  203. url: "g2app/dataabase/insertDataList",
  204. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  205. headers: {
  206. 'Content-Type': 'application/json',
  207. 'Authorization': "Bearer " + _this.token
  208. }
  209. }).then(res => {
  210. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  211. if (response.success) {
  212. _this.plcontent="";
  213. $.alert("评论成功!", "温馨提示");
  214. _this.getPLList();
  215. } else {
  216. $.alert("评论失败,请联系管理员!", "温馨提示");
  217. }
  218. })
  219. },
  220. getPLList: () => {
  221. let postData = {
  222. tablename: "SX_TZGG_02",
  223. pagesize: 999,
  224. pageno: 1,
  225. colums: "*",
  226. order: "ID",
  227. sqlwhere: {
  228. PID: _this.id,
  229. },
  230. sqlorwhere: {},
  231. sqlinwhere: "",
  232. sqllikewhere: ""
  233. }
  234. $http({
  235. method: 'post',
  236. baseURL: _this.apiurl,
  237. url: "g2app/dataabase/queryDataByColWithPage",
  238. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  239. headers: {
  240. 'Content-Type': 'application/json',
  241. 'Authorization': "Bearer " + _this.token
  242. }
  243. }).then(res => {
  244. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  245. _this.plnum = response.totalCount;
  246. _this.pllist = response.data
  247. })
  248. },
  249. },
  250. created: function () {
  251. _this = this;
  252. let token = localStorage.getItem("mobile-token", _this.token);
  253. let userName = localStorage.getItem("mobile-userName", _this.userName);
  254. let userId = localStorage.getItem("mobile-userId", _this.userId);
  255. let avatar = localStorage.getItem("mobile-avatar", _this.avatar);
  256. _this.userId = userId;
  257. _this.token = token;
  258. _this.userName = userName;
  259. _this.avatar = avatar;
  260. console.log(_this.avatar);
  261. _this.id = _this.utils.getUrlName("id");
  262. _this.tablename = _this.utils.getUrlName("tablename");
  263. _this.departname = decodeURI(_this.utils.getUrlName("departname"));
  264. },
  265. mounted: function () {
  266. _this.getDetail();
  267. _this.getDZNum();
  268. _this.getMyDZNum();
  269. _this.getPLList();
  270. }
  271. })