// 生产计划 - 二级 - 新生成及发料顺序调整 var util = require('../../../utils/util.js') const app = getApp(); Page({ data: { calcDate: util.getToday(), isShow: true, noData:'../../../images/noData.png', dataListTips: "暂无数据", g_createrId:"", inputvalue:"", statusNameList: [ { "name": "服务中", "id": "服务中" }, { "name": "已完成", "id": "已完成" }, { "name": "已撤销", "id": "已撤销" }, { "name": "超时", "id": "超时" }, ], statusIndex: "", statusName:'', isShowDel: false, delId:"", //表格请求参数~~ table: { getdataListParm: { name: 'getServiceApp', page: 1, offset: 1, pagecount: 20, returntype: 'Map', parammaps: { inputvalue: "", beginDate: util.get7daysAgo(), endDate: util.getToday(), statusName: "", userId: "", roleId: "", } }, tableKey: 0, list: [ // {"content":"想做计步器宣传,目前已让任老师帮忙做。","customerId":378,"customerName":"天津振杰","id":827,"receiverId":1497,"receiverName":"张振强","receiverTel":"","remark":"","vdate":"2020-10-16","visiterId":30,"visiterName":"高占永"}, // {"content":"兴安盟牧场已确定安装我司饲喂系统,目前正在走流程。","customerId":255,"customerName":"原阳富源牧业","id":826,"receiverId":1341,"receiverName":"贾又春","receiverTel":"","remark":"","vdate":"2020-09-27","visiterId":30,"visiterName":"高占永"}, // {"content":"沟通款项,已支付","customerId":643,"customerName":"木易牧场","id":825,"receiverId":1333,"receiverName":"李宝丽","receiverTel":"","remark":"","vdate":"2020-09-24","visiterId":30,"visiterName":"高占永"} ], total: 0, listLoading: true, }, }, onReachBottom: function () { console.log('下拉分页') var offset = this.data.table.getdataListParm.offset + 1 this.setData({['table.getdataListParm.offset']: offset}) this.getList() }, onLoad: function (options) { this.setData({ g_createrId:app.globalData.g_createrId, ['table.getdataListParm.parammaps.userId']:app.globalData.g_userId, ['table.getdataListParm.parammaps.roleId']:app.globalData.g_roleId }) this.getList() }, //搜索内容 change_inputvalue:function(e){ var value = e.detail.value console.log(value) this.setData({ ['table.getdataListParm.parammaps.inputvalue']: value }) }, //搜索按钮 on_search_tap(e) { this.setData({ ['table.getdataListParm.offset']:1, }) console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //清空按钮 on_error_tap(e) { console.log("搜索清空") this.setData({ inputvalue:"", ['table.getdataListParm.parammaps.inputvalue']:"", ['table.getdataListParm.parammaps.statusName']:"", statusIndex: "", statusName: "", }) this.setData({ ['table.getdataListParm.offset']:1, }) console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //下拉框:服务状态 change_statusName:function(e){ console.log('change_statusName的选项', e.detail.value) var newId = this.data.statusNameList[e.detail.value]['id'] console.log('change_statusName的newId', newId) this.setData({ statusIndex: e.detail.value, statusName: newId, ['table.getdataListParm.parammaps.statusName']: newId, }) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //加载表格 getList() { console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess2) }, getListSuccess1: function (res) { console.log('table数据======>', res.data.list) if (res.data.list !== null) { this.setData({ isShow: true, ['table.list']: res.data.list, ['table.getdataListParm.offset']: res.data.pageNum, ['table.total']: res.data.total }) } else { this.setData({ ['table.list']: [], ['table.getdataListParm.offset']: res.data.pageNum, isShow: false, dataListTips: "暂无数据" }) } }, getListSuccess2: function (res) { console.log('table数据======>', res.data) var tempList = res.data.list; if (res.data.list !== null) { this.setData({ isShow: true, ['table.list']: this.data.table.list.concat(tempList), ['table.getdataListParm.offset']: res.data.pageNum, ['table.total']: res.data.total }) } else { this.setData({ ['table.getdataListParm.offset']: res.data.pageNum }) } }, //搜索按钮 formSubmit(e) { console.log('搜索按钮:', e.detail.value) this.setData({ ['table.getdataListParm.parammaps.inputvalue']: e.detail.value.inputvalue, ['table.getdataListParm.offset']:1, }) console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //日期1 bindDateChange1: function (e) { this.setData({ ['table.getdataListParm.offset']:1, ['table.getdataListParm.parammaps.beginDate']: e.detail.value }) console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //日期2 bindDateChange2: function (e) { this.setData({ ['table.getdataListParm.offset']:1, ['table.getdataListParm.parammaps.endDate']: e.detail.value }) console.log("表格请求数据:", this.data.table.getdataListParm) util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1) }, //查看 on_see_tap: function (e) { var id = e.currentTarget.dataset.id; wx.navigateTo({ url:"../siteServiceSee/siteServiceSee?id=" + id}) }, //编辑 on_edit_tap: function (e) { var id = e.currentTarget.dataset.id; wx.navigateTo({ url:"../siteServiceEdit/siteServiceEdit?id=" + id}) }, //新增 on_add_tap: function (e) { wx.redirectTo({ url:"../siteServiceAdd/siteServiceAdd"}) }, //删除 on_del_tap: function (e) { var id = e.currentTarget.dataset.id; this.setData({ isShowDel: true, delId: id }) }, on_del_tap_sure(e){ console.log(e) var that = this var send_data = {"name":"delService","parammaps":{"id":this.data.delId}} util.postDataByName(send_data, that.getDelListSuccess) }, getDelListSuccess: function (res) { var that = this console.log('table数据======>', res) if (res.msg !== 'fail') { wx.showToast({ title: '删除成功', icon: 'success', duration: 2000, success: function(){ setTimeout(() => { util.getDataByName(that.data.table.getdataListParm, that.getListSuccess1) }, 1500) } }) } else { wx.showToast({ title: '删除失败'+res.data, icon: 'error', duration: 2000, }) } }, })