123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- var app = getApp()
- var that;
- var socket = null;
- var setTime;
- Page({
- data: {
- date: app.globalData.month,
- review_id: '',
- userId: '',
- see_log: 1,
- array:[],
- isPublisher: true,//是不是发布者
- isBh: false,//是否显示驳回弹窗
- textArea: "",
- disabled: false,
- event_review_point:1,
- is:true,
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "事件详情" });
- that.setData({
- userId: app.globalData.userData.id,
- event_review_point:app.globalData.config.event_review_point
- })
- if (e.id) {
- that.setData({
- review_id: e.id
- })
- }
- if (e.is) {
- that.setData({
- is: false
- })
- }
- },
- onShow() {
- if (app.globalData.userData) {
- dd.hideLoading();
- that.getDetail();
- that.cheakAx();
- } else {
- app.login(app.globalData.corpId, function (is) {
- if (is) {
- dd.hideLoading();
- that.getDetail();
- that.cheakAx();
- } else {
- dd.reLaunch({
- url: '../../noJurisdiction/noJurisdiction'
- })
- }
- }, function () { })
- }
- },
- bindTextAreaBlur(e) {
- this.setData({
- textArea: e.detail.value
- });
- },
- bindPickerChange(e) {
- var page = getCurrentPages()[getCurrentPages().length - 2]//上一个页面的数据
- if (this.data.array[e.detail.value] == '删除事件') {
- dd.confirm({
- title: '删除事件',
- content: '删除事件的同时也会撤销积分,确定删除吗?',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- success: (result) => {
- if (result.confirm) {
- app.$post('/api/integral/statistics/integral/destroy', { event_id: that.data.review_id }).then(res => {
- app.globalData.showToast(res.data.msg);
- if (page&& page.refreshData) {
- page.refreshData(that.data.review_id);
- }
- setTimeout(() => {
- dd.navigateBack({ delta: 1 })
- }, 1000);
- });
- }
- },
- });
- } else if (this.data.array[e.detail.value] == '调整分数') {//编辑任务
- dd.navigateTo({
- url: '../tZpoint/tZpoint?id=' + this.data.review_id +'&point='+this.data.dataDetail.point
- })
- }
- },
- confirmBh() {
- if (that.data.textArea == '') {
- app.globalData.showToast("请输入不通过原因");
- return;
- }
- let noData={
- type:'event_check',
- action:'disagree',
- event_id:that.data.review_id,
- comment:that.data.textArea,
- }
- this.setData({ disabled: true });
- this.opneWebSocket(noData)
- },
- openBh(e) {
- var item = this.data.dataDetail;
- var index = e.target.dataset.index;
- if(index=='1'){
- let data={
- type:'event_check',
- action:'agree',
- event_id:item.event_id,
- point:item.point
- }
- this.opneWebSocket(data)
- }else{
- this.setData({
- isBh: true,
- })
- }
- },
- opneWebSocket(data) {
- setTime = setTimeout(() => {
- dd.alert({
- title: '温馨提示',
- content: '网络异常,请检查网络',
- buttonText: '我知道了',
- success: () => {
- clearTimeout(setTime);
- app.globalData.socketApi.closewebsocket();
- that.setData({
- disabled: false,
- isBh: false,
- textArea: '',
- });
- },
- });
- }, 15000)
- app.globalData.socketApi.sendData(data,this.onmessageWS,true);
- },
- onmessageWS(e) {
- // 因为作用域问题,这个函数不能使用this
- if (e.type == 'event_check') {
- clearTimeout(setTime);
- if(e.code==1){
- app.globalData.showToast("提交成功");
- that.setData({
- disabled: false,
- isBh: false,
- textArea: '',
- });
- that.getDetail();
- app.globalData.socketApi.closewebsocket();
- return false;
- }else{
- app.globalData.showToast(e.msg)
- app.globalData.socketApi.closewebsocket();
- return false;
- }
- }
- if (e.type == 'error') {
- clearTimeout(setTime);
- that.setData({
- isShowError: true,
- })
- }
- },
- cheakAx() {
- app.$get("api/integral/site/config", {}).then((res) => {
- var data = res.data.data;
- this.setData({ see_log: data.see_log ? data.see_log : 0 })
- })
- },
- // 查看日志详情
- openLog() {
- dd.navigateTo({
- url: '../logDetail/logDetail?id=' + this.data.review_id
- })
- },
- showImg(e) {
- var index = e.target.dataset.index;
- var item = e.target.dataset.item
- dd.previewImage({
- current: index,
- urls: item
- });
- },
- activeItem(e) {
- var index = e.target.dataset.index;
- this.setData({ activeIndex: index })
- },
- closeBh() {
- this.setData({ isBh: false, textArea: '' })
- },
- getDetail() {
- app.$get("api/integral/statistics/integral/info", { event_id: that.data.review_id }).then((res) => {
- var data = res.data.data;
- app.globalData.types.forEach(item => {
- if (item.id == data.pt_id) {
- data.typeName = item.name
- }
- });
- var actions = []
- // 这里比较复杂,因为团队绩效的工作详情跟我的发布的工作详情都调用这个页面
- if (data.dc_status == 0&&that.data.event_review_point==1) {
- actions.push('调整分数')
- actions.push('删除事件')
- } else {
- actions.push('删除事件')
- }
- this.setData({ dataDetail: data,array: actions })
- })
- },
- });
|