detail.js 10 KB

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