let s4 = new SM4Util(); let base64 = new Base64(); //声明base解码和编码类 let listVue = new Vue({ el: "#detailPage", data: { apiurl: apiurl, //基础的页面请求地址 userId: "", //用户id userName: "", //用户中文名 token: "", id: "", tablename: "", departname: "", detail: {}, array: [], plnum: 0, pllist: [], dznum: 0, canDZ: false, idDZ: 0, plcontent: "" }, 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; }, getDetail: () => { let postData = { tablename: _this.tablename, colums: "*", order: "ID", sqlwhere: {ID: _this.id}, 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)); _this.detail = { ID: response.data[0].ID, GGBK: response.data[0].GGBK, FBBM: response.data[0].FBBM, FBSJ: _this.dateFtt("yyyy-MM-dd", new Date(response.data[0].FBSJ)), FBFW: response.data[0].FBFW, GGNR: base64.decode(response.data[0].GGNR), GGBT: response.data[0].GGBT } if (response.data[0].FJSC && response.data[0].FJSC != "") { _this.array = JSON.parse(response.data[0].FJSC); _this.array.forEach(function (item) { item.FILEURL = _this.apiurl + "/g2work" + item.FILEURL; }) } }) }, getMyDZNum: () => { let postData = { tablename: "SX_TZGG_01", pagesize: 1, pageno: 1, colums: "*", order: "ID", sqlwhere: { PID: _this.id, DZMANID: _this.userId, //用户id }, sqlorwhere: {}, sqlinwhere: "", sqllikewhere: "" } $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/dataabase/queryDataByColWithPage", 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.totalCount > 0) { _this.canDZ = false; _this.idDZ = response.data[0].ID; } else { _this.canDZ = true; _this.idDZ = 0; } }) }, addDZ: () => { let postData = { "tablename": "SX_TZGG_01", "data": [] } postData.data.push({ PID: _this.id, CTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()), STATE: "正常", DZMAN: _this.userName, DZMANID: _this.userId, }); $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/dataabase/insertDataList", 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.getDZNum(); _this.getMyDZNum(); }) }, getDZNum: () => { let postData = { tablename: "SX_TZGG_01", pagesize: 1, pageno: 1, colums: "*", order: "ID", sqlwhere: { PID: _this.id, }, sqlorwhere: {}, sqlinwhere: "", sqllikewhere: "" } $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/dataabase/queryDataByColWithPage", 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.dznum = response.totalCount; }) }, deleteDZ: () => { let postData = {"id": _this.idDZ, "tablename": "SX_TZGG_01"} $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/richang/delDataById", 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.getDZNum(); _this.getMyDZNum(); }) }, sendPL: () => { if (_this.plcontent.trim() == "") { $.alert("请先填写评论内容!", "温馨提示"); return false; } let postData = { "tablename": "SX_TZGG_02", "data": [] } postData.data.push({ PID: _this.id, CTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()), PLMAN: _this.userName, PLPIC: _this.avatar, PLTIME: _this.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()), PLCONT: _this.plcontent, PLMANID: _this.userId, }); $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/dataabase/insertDataList", 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.success) { _this.plcontent = ""; $.alert("评论成功!", "温馨提示"); _this.getPLList(); } else { $.alert("评论失败,请联系管理员!", "温馨提示"); } }) }, getPLList: () => { let postData = { tablename: "SX_TZGG_02", pagesize: 999, pageno: 1, colums: "*", order: "ID", sqlwhere: { PID: _this.id, }, sqlorwhere: {}, sqlinwhere: "", sqllikewhere: "" } $http({ method: 'post', baseURL: _this.apiurl, url: "g2app/dataabase/queryDataByColWithPage", 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.plnum = response.totalCount; _this.pllist = response.data }) }, }, 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); let avatar = localStorage.getItem("mobile-avatar", _this.avatar); _this.userId = userId; _this.token = token; _this.userName = userName; _this.avatar = avatar; console.log(_this.avatar); _this.id = _this.utils.getUrlName("id"); _this.tablename = _this.utils.getUrlName("tablename"); _this.departname = decodeURI(_this.utils.getUrlName("departname")); }, mounted: function () { _this.getDetail(); _this.getDZNum(); _this.getMyDZNum(); _this.getPLList(); } })