You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

470 lines
10 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pages/WORKDETAIL/WORKDETAIL.js
Page({
/**
* 页面的初始数据
*/
data: {
headData: {
//FuelPrice:0,
FuelQty: 0,
Amount: 0,
RealMil: 0,
StartMil: 0,
EndMil: 0,
JYZ: '',
CtnList: [],
DocList: [],
FeeList: [],
FuelList: [],
FHFEEGroup:[],
JYZList: ['中石油', '中石化', '金盾', '大象']
},
histype: "",
gid: "",
diabled: false,
JYindex: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
//console.log('options:'+options);
this.setData({
gid: options.gid,
histype: options.histype
})
this.query();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
handleAddjiayou() {
this.data.headData.FuelList.push({
JYTYPE: ''
//,JYCOUNT:1
})
this.setData({
headData: this.data.headData
})
},
handleSelectType(e) {
const index = e.currentTarget.dataset.index
this.data.headData.FuelList[index].JYTYPE = this.data.headData.JYZList[e.detail.value]
this.setData({
headData: this.data.headData,
JYindex: e.detail.value
})
},
query() {
var that = this;
var openid = getApp().globalData.baseInfo.OPENID;
var gid = this.data.gid;
var jsonstr = JSON.stringify({
openid: openid,
formname: '派车业务',
GId: gid
});
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
console.log(r)
if (!r.data.Data.FuelList) {
r.data.Data.FuelList = []
}
that.setData({
headData: r.data.Data
})
}
})
},
showinfofile(e) {
var that = this
var url = e.currentTarget.dataset.url;
console.log(url);
wx.navigateTo({
url: '/pages/Doc/Doc?url=' + url
})
},
radioChange(e){
const index = e.currentTarget.dataset.index
this.data.headData.FuelList[index].REMARK = e.detail.value
this.setData({
headData: this.data.headData,
})
},
handleInput(e){
const index = e.currentTarget.dataset.index
const type = e.currentTarget.dataset.type
this.data.headData.FuelList[index][type] = e.detail.value
this.setData({
headData: this.data.headData,
})
},
vmodel(e) {
var that = this;
that.data.headData[e.currentTarget.id] = e.detail.value;
this.setData({
headData: that.data.headData
/**
* e.currentTarget.dataset.value 拿到我要改变的数据 input
* e.detail.value 拿到 我改变以后的值
*/
})
},
vmodel_fee(e) {
console.log(e, 11)
var that = this;
var gid = e.currentTarget.dataset.item;
//that.data.headData.FeeList[e.currentTarget.id]=e.detail.value;
that.data.headData.FHFEEGroup.forEach((x) => {
x.FeeList.forEach(i => {
if (i.GID == gid) {
console.log(i)
if (e.currentTarget.id == 'FEENAME') {
i.F_NO = e.detail.value;
}
if (e.currentTarget.id == 'AMOUNT') {
i.AMOUNT = e.detail.value;
}
}
})
})
this.setData({
headData: that.data.headData
/**
* e.currentTarget.dataset.value 拿到我要改变的数据 input
* e.detail.value 拿到 我改变以后的值
*/
})
},
selectJYZ(e) {
console.log(e)
var that = this;
var gid = e.currentTarget.dataset.item;
//that.data.headData.FeeList[e.currentTarget.id]=e.detail.value;
that.data.headData.JYZ = e.detail.value;
this.setData({
headData: that.data.headData
/**
* e.currentTarget.dataset.value 拿到我要改变的数据 input
* e.detail.value 拿到 我改变以后的值
*/
})
},
SaveClick(res) {
wx.showLoading({
title: '请稍候'
});
var that = this;
var openid = getApp().globalData.baseInfo.OPENID;
var headData = this.data.headData;
var jsonstr = JSON.stringify({
openid: openid,
formname: '保存业务',
headData: headData
});
console.log(headData)
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
that.query();
wx.hideLoading();
}
})
},
AddFeeClick(res) {
console.log(res)
const type = res.currentTarget.dataset.type
var that = this;
var headData = this.data.headData;
var GID = this.getGuid();
headData.FHFEEGroup[type].FeeList.push({
GID: GID
});
this.setData({
headData: that.data.headData
});
},
DelFeeClick(res) {
var that = this;
var gid = res.currentTarget.dataset.item;
var newFeeList = [];
var openid = getApp().globalData.baseInfo.OPENID;
that.data.headData.FHFEEGroup.forEach((x) => {
x.FeeList.forEach(i => {
if (i.GID == gid) {
var jsonstr = JSON.stringify({
openid: openid,
formname: '删除费用',
headData: that.data.headData,
FEEID: gid
});
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
that.query();
//wx.hideLoading();
}
})
} else {
newFeeList.push(i);
}
})
})
that.data.headData.FeeList = newFeeList;
this.setData({
headData: that.data.headData
})
},
DelFuelClick(e) {
//console.log(e);
var that = this;
var gid = e.currentTarget.dataset.item;
var newFeeList = [];
var openid = getApp().globalData.baseInfo.OPENID;
that.data.headData.FuelList.forEach((x) => {
if (x.GID == gid) {
//console.log('删除加油1');
var jsonstr = JSON.stringify({
openid: openid,
formname: '删除加油',
headData: that.data.headData,
GID: gid
});
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
//that.query();
//wx.hideLoading();
}
})
} else {
newFeeList.push(x);
}
})
that.data.headData.FuelList = newFeeList;
this.setData({
headData: that.data.headData
})
},
SubmitClick(res) {
wx.showLoading({
title: '请稍候'
});
var that = this;
var openid = getApp().globalData.baseInfo.OPENID;
var headData = this.data.headData;
var jsonstr = JSON.stringify({
openid: openid,
formname: '提交审核',
headData: headData
});
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
//r: data:{
// Data: null
// DataBody: null
// Message: "数据保存成功"
// Message2: null
// Success: true
// }
console.log(r)
that.query();
wx.hideLoading();
}
})
},
CallBackClick(res) {
wx.showLoading({
title: '请稍候'
});
var that = this;
var openid = getApp().globalData.baseInfo.OPENID;
var headData = this.data.headData;
var jsonstr = JSON.stringify({
openid: openid,
formname: '撤回审核',
headData: headData
});
wx.request({
url: getApp().globalData.serverUrl + '/FHDriverInterface',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
jsonstr
},
success: function (r) {
that.query();
wx.hideLoading();
}
})
},
showDocList(e) {
var that = this;
var gid = this.data.gid;
// console.log("触发查询附件");
// console.log(e);
// console.log("e_end");
console.log(e.currentTarget.dataset.receipttype);
var receipttype=e.currentTarget.dataset.receipttype;
wx.navigateTo({
url: '/pages/INFO_FILES/INFO_FILES?gid=' + gid+'&receipttype='+receipttype+'&r_gid='
})
},
showDocList_Detail(e) {
//显示费用的图片。用receipt_doc.r_gid来关联费用或者加油ID
var that = this;
var gid = this.data.gid;
// console.log("触发查询附件");
// console.log(e);
// console.log("e_end");
console.log(e.currentTarget.dataset.rgid);
if(!e.currentTarget.dataset.rgid){
wx.showToast({
icon: 'none',
title: '请先执行保存',
});
return;
}
var r_gid=e.currentTarget.dataset.rgid;
wx.navigateTo({
url: '/pages/INFO_FILES/INFO_FILES?gid=' + gid+'&r_gid='+r_gid
})
},
// bindPickerChange: function(e) {
// //console.log('picker发送选择改变携带值为', e.detail.value)
// this.setData({
// index: e.detail.value
// })
// },
getGuid: function () {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4";
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid;
}
})