reviewDetail.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. var app = getApp()
  2. var that;
  3. var socket = null;
  4. var setTime;
  5. Page({
  6. data: {
  7. date: app.globalData.month,
  8. review_id: '',
  9. userId: '',
  10. see_log: 1,
  11. array:[],
  12. isPublisher: true,//是不是发布者
  13. isBh: false,//是否显示驳回弹窗
  14. textArea: "",
  15. disabled: false,
  16. event_review_point:1,
  17. is:true,
  18. },
  19. onLoad(e) {
  20. that = this;
  21. dd.setNavigationBar({ title: "事件详情" });
  22. that.setData({
  23. userId: app.globalData.userData.id,
  24. event_review_point:app.globalData.config.event_review_point
  25. })
  26. if (e.id) {
  27. that.setData({
  28. review_id: e.id
  29. })
  30. }
  31. if (e.is) {
  32. that.setData({
  33. is: false
  34. })
  35. }
  36. },
  37. onShow() {
  38. if (app.globalData.userData) {
  39. dd.hideLoading();
  40. that.getDetail();
  41. that.cheakAx();
  42. } else {
  43. app.login(app.globalData.corpId, function (is) {
  44. if (is) {
  45. dd.hideLoading();
  46. that.getDetail();
  47. that.cheakAx();
  48. } else {
  49. dd.reLaunch({
  50. url: '../../noJurisdiction/noJurisdiction'
  51. })
  52. }
  53. }, function () { })
  54. }
  55. },
  56. bindTextAreaBlur(e) {
  57. this.setData({
  58. textArea: e.detail.value
  59. });
  60. },
  61. bindPickerChange(e) {
  62. var page = getCurrentPages()[getCurrentPages().length - 2]//上一个页面的数据
  63. if (this.data.array[e.detail.value] == '删除事件') {
  64. dd.confirm({
  65. title: '删除事件',
  66. content: '删除事件的同时也会撤销积分,确定删除吗?',
  67. confirmButtonText: '确定',
  68. cancelButtonText: '取消',
  69. success: (result) => {
  70. if (result.confirm) {
  71. app.$post('/api/integral/statistics/integral/destroy', { event_id: that.data.review_id }).then(res => {
  72. app.globalData.showToast(res.data.msg);
  73. if (page&& page.refreshData) {
  74. page.refreshData(that.data.review_id);
  75. }
  76. setTimeout(() => {
  77. dd.navigateBack({ delta: 1 })
  78. }, 1000);
  79. });
  80. }
  81. },
  82. });
  83. } else if (this.data.array[e.detail.value] == '调整分数') {//编辑任务
  84. dd.navigateTo({
  85. url: '../tZpoint/tZpoint?id=' + this.data.review_id +'&point='+this.data.dataDetail.point
  86. })
  87. }
  88. },
  89. confirmBh() {
  90. if (that.data.textArea == '') {
  91. app.globalData.showToast("请输入不通过原因");
  92. return;
  93. }
  94. let noData={
  95. type:'event_check',
  96. action:'disagree',
  97. event_id:that.data.review_id,
  98. comment:that.data.textArea,
  99. }
  100. this.setData({ disabled: true });
  101. this.opneWebSocket(noData)
  102. },
  103. openBh(e) {
  104. var item = this.data.dataDetail;
  105. var index = e.target.dataset.index;
  106. if(index=='1'){
  107. let data={
  108. type:'event_check',
  109. action:'agree',
  110. event_id:item.event_id,
  111. point:item.point
  112. }
  113. this.opneWebSocket(data)
  114. }else{
  115. this.setData({
  116. isBh: true,
  117. })
  118. }
  119. },
  120. opneWebSocket(data) {
  121. setTime = setTimeout(() => {
  122. dd.alert({
  123. title: '温馨提示',
  124. content: '网络异常,请检查网络',
  125. buttonText: '我知道了',
  126. success: () => {
  127. clearTimeout(setTime);
  128. app.globalData.socketApi.closewebsocket();
  129. that.setData({
  130. disabled: false,
  131. isBh: false,
  132. textArea: '',
  133. });
  134. },
  135. });
  136. }, 15000)
  137. app.globalData.socketApi.sendData(data,this.onmessageWS,true);
  138. },
  139. onmessageWS(e) {
  140. // 因为作用域问题,这个函数不能使用this
  141. if (e.type == 'event_check') {
  142. clearTimeout(setTime);
  143. if(e.code==1){
  144. app.globalData.showToast("提交成功");
  145. that.setData({
  146. disabled: false,
  147. isBh: false,
  148. textArea: '',
  149. });
  150. that.getDetail();
  151. app.globalData.socketApi.closewebsocket();
  152. return false;
  153. }else{
  154. app.globalData.showToast(e.msg)
  155. app.globalData.socketApi.closewebsocket();
  156. return false;
  157. }
  158. }
  159. if (e.type == 'error') {
  160. clearTimeout(setTime);
  161. that.setData({
  162. isShowError: true,
  163. })
  164. }
  165. },
  166. cheakAx() {
  167. app.$get("api/integral/site/config", {}).then((res) => {
  168. var data = res.data.data;
  169. this.setData({ see_log: data.see_log ? data.see_log : 0 })
  170. })
  171. },
  172. // 查看日志详情
  173. openLog() {
  174. dd.navigateTo({
  175. url: '../logDetail/logDetail?id=' + this.data.review_id
  176. })
  177. },
  178. showImg(e) {
  179. var index = e.target.dataset.index;
  180. var item = e.target.dataset.item
  181. dd.previewImage({
  182. current: index,
  183. urls: item
  184. });
  185. },
  186. activeItem(e) {
  187. var index = e.target.dataset.index;
  188. this.setData({ activeIndex: index })
  189. },
  190. closeBh() {
  191. this.setData({ isBh: false, textArea: '' })
  192. },
  193. getDetail() {
  194. app.$get("api/integral/statistics/integral/info", { event_id: that.data.review_id }).then((res) => {
  195. var data = res.data.data;
  196. app.globalData.types.forEach(item => {
  197. if (item.id == data.pt_id) {
  198. data.typeName = item.name
  199. }
  200. });
  201. var actions = []
  202. // 这里比较复杂,因为团队绩效的工作详情跟我的发布的工作详情都调用这个页面
  203. if (data.dc_status == 0&&that.data.event_review_point==1) {
  204. actions.push('调整分数')
  205. actions.push('删除事件')
  206. } else {
  207. actions.push('删除事件')
  208. }
  209. this.setData({ dataDetail: data,array: actions })
  210. })
  211. },
  212. });