2025-06-12 18:41:44 +08:00

327 lines
7.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let util = require('../../../../utils/util')
let apiArr = require('../../../../api/water_filter')
// packages/WaterPurifier/pages/upKeep/upKeep.js
Page({
/**
* 页面的初始数据
*/
data: {
admin:"",
statusType: {
1: '待分配',
2: '安装中',
3: '待激活',
4: '已安装',
5: '忽略',
},
option1: [
{ text: '全部', value: 0 },
{ text: '待分配', value: 1 },
{ text: '安装中', value: 2 },
{ text: '待激活', value: 3 },
{ text: '已安装', value: 4 },
{ text: '忽略', value: 5 },
],
option2: [
{ text: '渠道', value: 'a' },
{ text: '好评排序', value: 'b' },
{ text: '销量排序', value: 'c' },
],
value1: 0,
value2: 'a',
show:false,
MasterList:[
],
searchText:"",//搜索文字
page_num:1,
page_size:10,
total:'',
deviceList:[],
sendOrders: {}, // 派单订单
flag:false
},
desc(e){
let that = this
wx.navigateTo({
url: `../orderDesc/orderDesc?install_id=${e.currentTarget.dataset.id}&type=desc`,
})
},
addWorkOrder(){
wx.navigateTo({
url: '../newWorkOrder/newWorkOrder',
})
},
onClose(){
let that = this
that.setData({
show:false
})
},
dispatch(e){
let that = this
that.setData({
show:true,
sendOrders: e.currentTarget.dataset.item
})
},
// 下拉列表选择工单状态
headerDropdownClick(e) {
console.log('headerDropdownClickheaderDropdownClick', e);
this.setData({
value1: e.detail,
orderList: [],
page_num: 1,
})
this.getNewOrderList();
},
// 撤回工单
headerRecallClick(e) {
let _this = this;
const { item } = e.currentTarget.dataset;
wx.showLoading({
title: '加载中...',
mask: true
})
util.postUrl4(apiArr.RecallNewRepair,{
install_id: item.install_id,
},res=>{
wx.hideLoading()
if (res.error) {
wx.showToast({
title: '撤回工单失败',
icon: 'none',
})
return;
}
wx.showToast({
title: res.msg,
icon: 'none',
success() {
setTimeout(() => {
_this.setData({
deviceList: [],
page_num: 1,
})
_this.getNewOrderList();
}, 1500)
}
})
})
},
ipt1(e){
let that = this
that.setData({
searchText:e.detail.value,
page_num:1,
flag:false,
deviceList:[]
})
that.getNewOrderList()
},
search(){
let that = this
that.setData({
page_num:1,
flag:false,
deviceList:[]
})
that.getNewOrderList()
},
//工单列表
getNewOrderList(){
let that = this
wx.showLoading({
title: '加载中...',
mask:true,
})
//设置加载状态
util.postUrl4(apiArr.newOrderList,{
page_size:that.data.page_size,
page_num:that.data.page_num,
search:that.data.searchText,
dealer_id: that.data.admin.shop_id
},res=>{
wx.hideLoading()
if(res.row){
let flag = false
if(res.row.length == that.data.page_size){
flag = true
}else{
flag = false
}
that.setData({
flag,
deviceList:that.data.deviceList.concat(res.row || []),
page_num:that.data.page_num +1
})
}
that.getMasterList()
})
},
// 维修师傅列表
getMasterList(){
let that = this
util.postUrl4(apiArr.MasterList,{
page_num:1,
page_size:50,
dealer_id:that.data.admin.shop_id
},res=>{
if(res.rows){
res.rows.forEach(item=>{
item.checked = false
item.avatar = util.img_url + item.avatar
})
that.setData({
MasterList:res.rows
})
}
})
},
selectMaster(e){
console.log(e);
let that = this
let MasterList = that.data.MasterList
MasterList.forEach(item=>{
item.checked = false
})
MasterList[e.currentTarget.dataset.index].checked = true
that.setData({
MasterList
})
},
cancel(){
let that = this
that.setData({
show:false,
})
},
sure(){
let that = this
that.setData({
show:false
})
const { sendOrders, MasterList } = this.data;
const checkedMaster = MasterList.filter((item) => item.checked)[0];
util.postUrl4(apiArr.newInstallAssign, {
install_id: sendOrders.install_id,
master_id: checkedMaster.info_id,
} ,res => {
console.log('新装工单 选择修为师傅', res);
if (res.error) {
wx.showToast({
title: '派单失败',
icon: 'none',
})
return;
}
wx.showToast({
title: res.msg,
icon: 'none',
})
that.setData({
page_num:1,
flag:false,
})
setTimeout(()=>{
that.setData({
deviceList:[]
})
that.getNewOrderList()
},1500)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let that = this
that.setData({
admin:wx.getStorageSync('admin')
})
that.getNewOrderList()
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
let that = this
if(that.data.flag){
that.getNewOrderList()
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage(){
return {
title: '人人爱净水', // 分享卡片标题(必填)
path: '/pages/water_filter/water_filter', // 用户点击后跳转的路径(可选,默认当前页)
imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义图片(可选,比例建议 5:4
}
},
onShareTimeline() {
return {
title: '人人爱净水', // 自定义标题
query: '', // 自定义页面路径中的参数
imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义分享图片路径
}
},
})