123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- var app = getApp()
- var that;
- var socket = null;
- var setTime;
- Page({
- data: {
- date: app.globalData.month,
- activeIndex: 1,
- keyword: '',
- page: 1,
- isBh: false,//是否显示驳回弹窗
- textArea: "",
- disabled: false,
- isPl:false,
- objectArray: [{id:'[1,2]',name: '全部'},{ id: '[1]',name: '通过'},{id: '[2]', name: '不通过'}],
- arrIndex: 0,
- isAll: true,
- minuteIndex: 0,//条件选择
- minuteArray: [
- { id: 1, name: '待复核' },
- { id: 2, name: '已复核' },
- ],
- // 长连接结果
- results: [], //提交的返回结果集合
- isResult: false,
- percentage: 0,
- resultList: [],//要发送数据的集合
- resultIndex: 0,
- isShowError: false,
- popupCx: '',
- config: {},
- showStaff: false,//显示员工选择
- staffVal: '人员',
- },
- onLoad() {
- that = this;
- dd.setNavigationBar({ title: "复核" });
- },
- onShow() {
- if (app.globalData.userData) {
- that.refreshData();
- } else {
- app.login(app.globalData.corpId, function (is) {
- if (is) {
- that.refreshData();
- } else {
- dd.reLaunch({
- url: '../../noJurisdiction/noJurisdiction'
- })
- }
- },function(){})
- }
- },
- //选择员工
- onConfirmStaff(data) {
- if (!data) {
- this.setData({ staffVal: '人员', employee_ids: '', page: 1 })
- this.getData();
- return false;
- }
- if (data.length > 0) {
- if (data.length > 1) {
- var str = "";
- var arr = [];
- data.forEach((item) => {
- str += item.name + ','
- arr.push(item.id);
- })
- var employee_ids = arr.join(',');
- this.setData({ staffVal: str.substring(0, str.length - 1), employee_ids: employee_ids, page: 1 })
- } else {
- this.setData({ staffVal: data[0].name, employee_ids: [data[0].id], page: 1 })
- }
- } else {
- this.setData({ staffVal: '人员', employee_ids: [], page: 1 })
- }
- this.getData();
- },
- //显示选择员工
- selectStaff() {
- this.setData({
- popupCx: 'container__mask',
- showStaff: true
- })
- },
- //关闭弹窗
- onClose() {
- this.setData({
- showStaff: false,
- popupCx: ''
- })
- },
- openPl(){
- this.setData({
- isPl: !that.data.isPl
- })
- },
- // 通过
- openTg() {
- let that = this;
- let selectIds = [];
- this.data.dataList.forEach(item => {
- if(item.checked){
- selectIds.push({
- type:'event_check',
- action:'agree',
- event_id:item.id,
- point:item.point,
- remark:item.remark,
- name:item.employee_name,
- pt_id:item.pt_id
- });
- }
- })
- if (selectIds.length == 0) {
- app.globalData.showToast("请先选择复核单");
- return false
- }
- dd.confirm({
- title: '批量通过',
- content: `已选中${selectIds.length}条复核单,确认全部通过?`,
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- success: (result) => {
- if (result.confirm) {
- that.webSocket(selectIds,true);
- }
- },
- });
- },
- selectAll() {
- let dataList = this.data.dataList.map(item => {
- item.checked = this.data.isAll;
- return item;
- })
- this.setData({
- dataList: dataList,
- isAll:!this.data.isAll,
- })
- },
- //选择规则分类
- bindKeyInput(e) {
- this.setData({
- keyword: e.detail.value,
- page: 1,
- isVal: e.detail.value ? true : false,
- });
- this.getData();
- },
- bindObjPickerChange(e) {
- this.setData({
- arrIndex: e.detail.value,
- page: 1,
- isPl:false,
- })
- this.getData();
- },
- //当在详情返回时刷新列表,但你请求接口
- refreshData(id) {
- if (this.data.page == 1) {
- dd.hideLoading();
- that.getData();
- } else {
- if (id) {//当page不为一并下一页返回上一页不执行onshow()
- var arr = this.data.dataList;
- arr.forEach((element, index) => {
- if (element.id == id) {
- arr.splice(index, 1);
- }
- });
- this.setData({
- dataList: arr
- })
- }
- }
- },
-
- bindTextAreaBlur(e) {
- this.setData({
- textArea: e.detail.value
- });
- },
- confirmBh() {
- if (that.data.textArea == '') {
- app.globalData.showToast("请输入不通过原因");
- return;
- }
- let noData={
- type:'event_check',
- action:'disagree',
- event_id:that.data.bhItem.id,
- comment:that.data.textArea,
- }
- this.setData({ disabled: true });
- this.webSocket(noData)
- },
- closeBh() {
- this.setData({ isBh: false, textArea: '' })
- },
- openBh(e) {
- var item = e.target.dataset.item;
- var index = e.target.dataset.index;
- if(index=='1'){
- let data={
- type:'event_check',
- action:'agree',
- event_id:item.id,
- point:item.point
- }
- this.webSocket(data)
- }else{
- this.setData({
- isBh: true,
- bhItem: item
- })
- }
- },
- webSocket(data,is) {
- let resultList=is? data:[data];
- this.setData({
- resultList:resultList,
- resultIndex: 0,
- percentage: 0,
- results: [],
- isResult:resultList.length!=1,
- })
- this.opneWebSocket()
- },
- opneWebSocket() {
- let wsData = this.data.resultList;
- if (wsData[this.data.resultIndex]) {
- setTime = setTimeout(() => {
- dd.alert({
- title: '温馨提示',
- content: '网络异常,请检查网络',
- buttonText: '我知道了',
- success: () => {
- clearTimeout(setTime);
- app.globalData.socketApi.closewebsocket();
- that.closeTc();
- },
- });
- }, 15000)
- app.globalData.socketApi.sendData(wsData[this.data.resultIndex],this.onmessageWS,true);
- }
- },
- onmessageWS(e) {
- // 因为作用域问题,这个函数不能使用this
- if (e.type == 'event_check') {
- clearTimeout(setTime);
- if(that.data.resultList.length==1){ //单条
- if(e.code==1){
- app.globalData.showToast("提交成功");
- that.setData({
- disabled: false,
- isBh: false,
- textArea: '',
- });
- that.refreshData(e.result.task.msg.event_id);
- return false;
- }else{
- that.setData({
- disabled: false,
- });
- app.globalData.showToast(e.msg)
- return false;
- }
- }
- let user;
- if(e.code==1){
- user={
- name:e.result.task.msg.name,
- point:e.result.task.msg.point,
- remark:e.result.task.msg.remark,
- pt_id:e.result.task.msg.pt_id,
- msg:'提交成功'
- }
- }else{
- user={
- name:e.result.task.msg.name,
- point:e.result.task.msg.point,
- remark:e.result.task.msg.remark,
- pt_id:e.result.task.msg.pt_id,
- msg:e.msg
- }
- }
- let results=that.data.results
- results.push(user);
- that.setData({
- results: results,
- resultIndex: that.data.resultIndex + 1
- })
- that.opneWebSocket();
- // 进度条
- let lng = that.data.resultList.length;
- that.setData({
- percentage: that.data.percentage + Math.floor(100 / lng),
- })
- if (lng == that.data.results.length) {
- that.setData({
- percentage: 100,
- })
- }
- }
- if (e.type == 'error') {
- clearTimeout(setTime);
- that.setData({
- isShowError: true,
- })
- }
- },
- closeTc() {
- this.setData({
- results: [], //提交的返回结果集合
- isResult: false,
- percentage: 0,
- resultList: [],//要发送数据的集合
- resultIndex: 0,
- isBh: false,//是否显示驳回弹窗
- isShowError: false,
- textArea: '',
- page: 1,
- })
- app.globalData.socketApi.closewebsocket();
- this.getData();
- },
- activeItem(e) {
- this.setData({
- minuteIndex: e.detail.value,
- page: 1,
- dataList: [],
- isPl:false,
- })
- this.getData();
- },
- onReset() {
- this.setData({
- keyword: '',
- isVal: false,
- page: 1,
- })
- this.getData();
- },
- openDetail(e) {
- var item = e.target.dataset.item;
- if(this.data.isPl){
- let dataList = this.data.dataList.map(e => {
- if(item.id==e.id){
- e.checked = !e.checked;
- }
- return e;
- })
- this.setData({
- dataList: dataList,
- })
- return false
- }
- dd.navigateTo({
- url: '../reviewDetail/reviewDetail?id=' + item.id
- })
- },
- getData(type) {
- let dc_status=that.data.minuteIndex==0? "[0]":'[1,2]';
- if(that.data.minuteIndex=="1"){
- if(that.data.arrIndex==0){
- dc_status='[1,2]'
- }else if(that.data.arrIndex==1){
- dc_status='[1]'
- }else{
- dc_status='[2]'
- }
- }
- let data={
- dc_status:dc_status,
- page: that.data.page,
- order_key:that.data.minuteIndex=='0'? 'create_time':'update_time',
- page_size: 20,
- keyword: that.data.keyword,
- employee_ids:this.data.employee_ids
- }
- app.$get("api/integral/statistics/integral",data).then((res) => {
- var list = res.data.data.list || [];
- list.forEach(element => {
- element.checked = false
- });
- if(that.data.page==1){
- this.setData({
- dataList:[]
- })
- }
- var dataList = that.data.dataList || [];
- if (type == '2') {
- this.setData({
- dataList: dataList.concat(list),
- isData: list.length < 20
- })
- } else {
- this.setData({ dataList: list, isData: false })
- }
- })
- },
- //上啦加载
- onScrollToLower() {
- if (!that.data.isData) {
- this.setData({ page: ++that.data.page })
- this.getData("2");
- }
- },
- });
|