const CommonMethod = {}; let object = { _this: {}, _user: {}, }; //设置Vue对象和用户 CommonMethod.InitObject = function(_this, _user) { object._this = _this; object._user = _user; } //修改默认的按钮颜色 //参数 叫料按钮,按钮1 按钮2 按钮3 按钮下标 CommonMethod.SetInitColor = function(callButton, oneButton, twoButton, threeButton, index) { let one; let two; let three; if (index == 0) { one = "#4CD964"; two = ""; three = ""; } else if (index == 1) { one = ""; two = "#4CD964"; three = ""; } else if (index == 2) { one = ""; two = ""; three = "#4CD964"; } callButton.index = index + 1; if (null != oneButton) oneButton.backgroundColor = one; if (null != twoButton) twoButton.backgroundColor = two; if (null != threeButton) threeButton.backgroundColor = three; } //设置按钮颜色和下标 CommonMethod.SetButton = function(button, record_id, call_id, color, index) { if (null != record_id) button.record_id == record_id; if (null != call_id) button.call_id == call_id; if (null != color) button.backgroundColor == color; callButton.index = index + 1; } //设置按钮颜色和下标 CommonMethod.SetButtonIndex = function(button, index) { button.index = index + 1; } CommonMethod.GetRecord = function(rows, record_name, record_areaName) { if (null == record_areaName || '' == record_areaName) return rows.find(r => r.record_name == record_name); else return rows.find(r => r.record_name == record_name && r.record_areaName == record_areaName); } //叫料 //参数 叫料按钮,请求参数,请求地址 CommonMethod.CallMaterial = function(callButton, data, url) { if (callButton.backgroundColor != 'yellow') { uni.showModal({ title: '提示', content: '是否确认呼叫?', success: function(res) { if (res.confirm) { object._this.$AjaxRequest.Params('post', url, data, object._user.token); object._this.$AjaxRequest.Request().then(function(result) { if (result.data.status) { uni.showToast({ title: "呼叫成功!", duration: 2000 }); callButton.backgroundColor = 'yellow'; } else { uni.showToast({ icon: 'none', title: "请求错误:" + result.data.message, duration: 2000 }); } }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } else if (res.cancel) {} } }); } } //取消叫料 //参数 叫料按钮,请求参数,请求地址 CommonMethod.CancelCall = function(callButton, data, url) { if (callButton.backgroundColor == 'yellow') { uni.showModal({ title: '提示', content: '是否确认取消?', success: function(res) { if (res.confirm) { object._this.$AjaxRequest.Params('post', url, data, object._user.token); object._this.$AjaxRequest.Request().then(function(result) { if (result.data.status) { uni.showToast({ title: "取消成功!", duration: 2000 }); //callButton.backgroundColor = '#007AFF'; } else { uni.showToast({ icon: 'none', title: "请求错误:" + result.data.message, duration: 2000 }); } }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } else if (res.cancel) {} } }); } } //修改位置信息 //参数 叫料按钮,修改按钮,其它按钮1,其它按钮2,修改按钮下标 CommonMethod.UpdateNumberColor = function(callButton, colorButton, colourlessOne, colourlessTwo, index) { //后续需要权限验证 if (callButton.backgroundColor != 'yellow') { if (callButton.index == index) return; uni.showModal({ title: '提示', content: '是否确认修改位置信息?', success: function(res) { if (res.confirm) { let data = { mainData: { 'record_id': callButton.record_id, 'record_positionIndex': index - 1, } }; object._this.$AjaxRequest.Params('post', 'Dt_positionrecord/Update', data, object ._user.token); object._this.$AjaxRequest.Request().then(function(result) { if (result.data.status) { if (callButton.backgroundColor != 'yellow') { colorButton.backgroundColor = '#4CD964'; if (null != colourlessOne) colourlessOne.backgroundColor = ''; if (null != colourlessTwo) colourlessTwo.backgroundColor = ''; callButton.index = index; } } else { uni.showToast({ icon: 'none', title: "请求错误:" + result.data.message, duration: 2000 }); } }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } else if (res.cancel) {} } }); } else { uni.showToast({ title: "当前处于叫料状态,不可修改位置.!", duration: 3000, icon: 'none' }); } } //备货完成 //参数 是否需要确认, 叫料按钮,完成按钮,请求参数,请求地址 CommonMethod.CompleteCall = function(flag, callButton, completeButton, data, url) { if (!flag || callButton.backgroundColor == 'yellow') { uni.showModal({ title: '提示', content: '是否确认备货完成?', success: function(res) { if (res.confirm) { object._this.$AjaxRequest.Params('post', url, data, object._user.token); object._this.$AjaxRequest.Request().then(function(result) { if (result.data.status) { uni.showToast({ title: "操作成功!", duration: 2000 }); if (null != completeButton) completeButton.backgroundColor = 'yellow'; } else { uni.showToast({ icon: 'none', title: "请求错误:" + result.data.message, duration: 2000 }); } }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } else if (res.cancel) {} } }); } } //查询位置记录表 CommonMethod.QueryPositionRecord = function(where) { let data = { page: 1, rows: 9999999, sort: 'record_name', order: "asc", wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_positionrecord/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询叫料任务 CommonMethod.QueryCallTask = function(where) { let data = { page: 1, rows: 9999999, sort: 'call_createtime', order: "asc", wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'QueryCallTaskInfo/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询AGV任务 CommonMethod.QueryAGVTask = function(where) { let data = { page: 1, rows: 9999999, sort: 'agv_createtime', order: "asc", wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_agvtask/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询备货任务 CommonMethod.QueryPickingTask = function(where, order) { let data = { page: 1, rows: 9999999, sort: 'picking_createtime', order: null == order || "" == order || undefined == order ? "asc" : order, wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_pickingtask/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询备货任务 CommonMethod.QueryPickingTaskInfo = function(where, order) { let data = { page: 1, rows: 9999999, sort: 'picking_createtime', order: null == order || "" == order || undefined == order ? "asc" : order, wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'QueryPickingTaskInfo/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询位置信息 CommonMethod.QueryPositionInfo = function(where) { let data = { page: 1, rows: 9999999, sort: "position_name", order: "asc", wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_positioninfo/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //查询物料信息 CommonMethod.QueryMaterielInfo = function(where) { let data = { page: 1, rows: 9999999, sort: "materiel_position", order: "asc", wheres: where } //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_materielinfo/getPageData', data, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //读取CSV文件 CommonMethod.ReadCSVFile = function() { //Y 成功后的回调函数 this.callbackForSuccess = function(result) {}; var thisObj = this; this.post = function() { object._this.$AjaxRequest.Params('post', 'Dt_calltask/ReadCSVFile', {}, object._user.token); object._this.$AjaxRequest.RequestAsync().then(function(result) { thisObj.callbackForSuccess(result); return result; }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } } //读取CSA文件 CommonMethod.ExpCall = function(data) { //Y 成功后的回调函数 uni.showModal({ title: '提示', content: '是否确认异常呼叫?', success: function(res) { if (res.confirm) { object._this.$AjaxRequest.Params('post', 'Dt_exprecord/Add', data, object._user.token); object._this.$AjaxRequest.Request().then(function(result) { if (result.data.status) { uni.showToast({ title: "操作成功!", duration: 2000 }); } else { uni.showToast({ icon: 'none', title: "请求错误:" + result.data.message, duration: 2000 }); } }).catch(function(err) { uni.showToast({ icon: 'none', title: "请求后台异常,错误信息." + err.errMsg, duration: 2000 }); }); } else if (res.cancel) {} } }); } export default CommonMethod;