536 lines
12 KiB
JavaScript
536 lines
12 KiB
JavaScript
import _ from '../../commons/js/commons'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
searchInp: {
|
|
value: '',
|
|
focus: false,
|
|
},
|
|
key: '', //tab状态值
|
|
list: [], //客户列表
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
flag: 1,
|
|
content: '', //短信内容
|
|
isRefresh: false, //判断返回是否需要刷新
|
|
isShowMobile: false,
|
|
v2OrderId: _.config.v2OrderId, //订单id临界切换版本
|
|
|
|
isShowfilter: false, //是否显示筛查
|
|
type: '',
|
|
order_s_time: '', //开始时间
|
|
order_e_time: '', //结束时间
|
|
|
|
staffArray: [],
|
|
staffobj: [],
|
|
employeeIndex: -1, //分配销售索引
|
|
employee_id: '', //分配销售ID
|
|
|
|
brand_id: '', //品牌id
|
|
car_id: '', //车系id
|
|
v_id: '', //车辆版本id
|
|
brandIndex: -1, //车辆品牌索引
|
|
modelIndex: -1, //车系车型索引
|
|
levelIndex: -1, //车辆版本索引
|
|
brand_page_show: false,
|
|
brand_name: ''
|
|
},
|
|
onLoad: function (options) {
|
|
for (let key in options) {
|
|
this.setData({
|
|
[key]: options[key]
|
|
})
|
|
}
|
|
this.getAppCusorderTabs()
|
|
|
|
//销售顾问
|
|
this.getAppUserAdmins()
|
|
|
|
//品牌列表
|
|
this.getAppSeriesBrands()
|
|
console.log(this.data.type)
|
|
},
|
|
|
|
//订单-tab
|
|
getAppCusorderTabs() {
|
|
_.apiQuery.getAppCusorderTabs().then(res => {
|
|
this.setData({
|
|
filters: res.data.filters,
|
|
tab: res.data.tabs,
|
|
key: this.data.key == '' ? res.data.tabs[0].key : this.data.key,
|
|
})
|
|
|
|
this.getAppCusorderList()
|
|
|
|
wx.stopPullDownRefresh()
|
|
});
|
|
},
|
|
|
|
//切换tab
|
|
changeTab(e) {
|
|
this.setData({
|
|
key: this.data.tab[e.currentTarget.dataset.index].key,
|
|
type: '',
|
|
order_s_time: '',
|
|
order_e_time: '',
|
|
})
|
|
this.searchSubmit()
|
|
},
|
|
|
|
// 显示弹框
|
|
showMobileMsg() {
|
|
this.setData({
|
|
isShowMobile: true
|
|
})
|
|
},
|
|
|
|
//获取订单列表
|
|
getAppCusorderList() {
|
|
this.setData({
|
|
load: false,
|
|
loading: true,
|
|
})
|
|
|
|
let admin_ids = ''
|
|
this.data.staffobj.forEach(item => {
|
|
if (item.checked) {
|
|
if (admin_ids == '') {
|
|
admin_ids = item.id
|
|
} else {
|
|
admin_ids = admin_ids + ',' + item.id
|
|
}
|
|
}
|
|
})
|
|
|
|
let params = {};
|
|
params['page'] = this.data.pageNo;
|
|
params['size'] = 10;
|
|
params['status'] = this.data.key;
|
|
if (this.data.searchInp.value != '') {
|
|
params['keyword'] = this.data.searchInp.value;
|
|
}
|
|
if (this.data.type != '') {
|
|
params['type'] = this.data.type;
|
|
}
|
|
if (this.data.order_s_time != '' && this.data.order_e_time != '') {
|
|
params['order_s_time'] = this.data.order_s_time;
|
|
params['order_e_time'] = this.data.order_e_time;
|
|
}
|
|
if (admin_ids != '') {
|
|
params['admin_ids'] = admin_ids;
|
|
}
|
|
if (this.data.brand_id != '') {
|
|
params['brand_id'] = this.data.brand_id;
|
|
}
|
|
if (this.data.car_id != '') {
|
|
params['car_id'] = this.data.car_id;
|
|
}
|
|
if (this.data.v_id != '') {
|
|
params['v_id'] = this.data.v_id;
|
|
}
|
|
_.apiQuery.getAppCusorderList(params).then(res => {
|
|
this.setData({
|
|
flag: this.data.flag - 1
|
|
})
|
|
if (!this.data.flag) {
|
|
this.setData({
|
|
pageNo: this.data.pageNo + 1,
|
|
list: this.data.list.concat(res.data.list),
|
|
load: true,
|
|
loading: false,
|
|
})
|
|
if (res.data.total == 0) {
|
|
this.setData({
|
|
noData: true
|
|
})
|
|
} else if (this.data.list.length == res.data.total) {
|
|
this.setData({
|
|
end: true
|
|
})
|
|
}
|
|
}
|
|
wx.stopPullDownRefresh()
|
|
});
|
|
},
|
|
|
|
// 输入
|
|
searchInput(e) {
|
|
this.setData({
|
|
'searchInp.value': e.detail.value
|
|
})
|
|
},
|
|
searchFocus() {
|
|
this.setData({
|
|
'searchInp.focus': true,
|
|
})
|
|
},
|
|
|
|
searchBlur() {
|
|
this.setData({
|
|
'searchInp.focus': false,
|
|
})
|
|
},
|
|
|
|
//提交搜索
|
|
searchSubmit() {
|
|
this.setData({
|
|
list: [],
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
flag: this.data.flag + 1
|
|
})
|
|
this.getAppCusorderList()
|
|
},
|
|
|
|
//输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
submitFlag: false,
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//推送链接
|
|
pushLink(e) {
|
|
if (e.currentTarget.dataset.url) {
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
},
|
|
|
|
//显示隐藏高级搜索
|
|
optfilter() {
|
|
this.setData({
|
|
isShowfilter: !this.data.isShowfilter
|
|
})
|
|
this.resetFilter()
|
|
},
|
|
|
|
//显示高级搜索
|
|
showfilter() {
|
|
this.setData({
|
|
isShowfilter: true,
|
|
})
|
|
},
|
|
|
|
//确定高级搜索
|
|
submitFilter() {
|
|
this.setData({
|
|
isShowfilter: false,
|
|
})
|
|
this.searchSubmit()
|
|
},
|
|
|
|
//重置高级搜索
|
|
resetFilter() {
|
|
let staffobj = this.data.staffobj
|
|
staffobj.forEach(item => {
|
|
item.checked = false
|
|
})
|
|
|
|
this.setData({
|
|
brand_name: '',
|
|
brand_id: '',
|
|
car_id: '',
|
|
v_id: '',
|
|
brandIndex: -1,
|
|
modelIndex: -1,
|
|
levelIndex: -1,
|
|
staffobj,
|
|
type: '',
|
|
order_s_time: '',
|
|
order_e_time: '',
|
|
})
|
|
},
|
|
|
|
//单选
|
|
radioPicker(e) {
|
|
if (e.currentTarget.dataset.type == 'type') {
|
|
this.setData({
|
|
type: e.currentTarget.dataset.key,
|
|
})
|
|
}
|
|
},
|
|
|
|
//开始时间
|
|
startDate(e) {
|
|
this.setData({
|
|
order_s_time: e.detail.value,
|
|
})
|
|
},
|
|
|
|
//结束时间
|
|
endDate(e) {
|
|
this.setData({
|
|
order_e_time: e.detail.value,
|
|
})
|
|
},
|
|
|
|
//获取销售顾问
|
|
getAppUserAdmins() {
|
|
let params = {};
|
|
params['page'] = 1;
|
|
params['size'] = 1000;
|
|
_.apiQuery.getAppUserAdmins(params).then(res => {
|
|
let staffArray = []
|
|
res.data.list.forEach(item => {
|
|
staffArray.push(item.uname)
|
|
})
|
|
let bizArray = []
|
|
res.data.bizs.forEach(item => {
|
|
bizArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
staffArray: staffArray,
|
|
staffobj: res.data.list,
|
|
})
|
|
});
|
|
},
|
|
|
|
//显示分配订单
|
|
showTransfer(e) {
|
|
this.setData({
|
|
ids: [e.currentTarget.dataset.id],
|
|
isShowTransfer: true,
|
|
})
|
|
},
|
|
|
|
//显示隐藏分配订单
|
|
optTransfer(e) {
|
|
this.setData({
|
|
employee_id: '',
|
|
employeeIndex: -1,
|
|
isShowTransfer: !this.data.isShowTransfer,
|
|
})
|
|
},
|
|
|
|
//选择店员
|
|
changeEmployee(e) {
|
|
let employee_id = ''
|
|
if (e.detail.value >= 0) {
|
|
employee_id = this.data.staffobj[e.detail.value].id
|
|
}
|
|
this.setData({
|
|
employee_id,
|
|
employeeIndex: e.detail.value,
|
|
})
|
|
},
|
|
|
|
//分配订单
|
|
putAppCusorderV2Admins() {
|
|
let that = this
|
|
if (that.data.employeeIndex == -1) {
|
|
wx.showToast({
|
|
title: '请选择车管家',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
that.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['ids'] = that.data.ids;
|
|
params['admin_id'] = that.data.employee_id;
|
|
_.apiQuery.putAppCusorderV2Admins(params).then(res => {
|
|
|
|
wx.showToast({
|
|
title: '移交成功',
|
|
icon: 'success',
|
|
duration: 2000
|
|
})
|
|
that.setData({
|
|
isShowTransfer: false,
|
|
submitFlag: false,
|
|
})
|
|
that.onPullDownRefresh()
|
|
|
|
}).catch(res => {
|
|
that.setData({
|
|
submitFlag: false,
|
|
})
|
|
});
|
|
}
|
|
},
|
|
|
|
//多选
|
|
checkPicker(e) {
|
|
this.setData({
|
|
['staffobj[' + e.currentTarget.dataset.index + '].checked']: !this.data.staffobj[e.currentTarget.dataset.index].checked,
|
|
})
|
|
},
|
|
|
|
//获取车型品牌
|
|
getAppSeriesBrands() {
|
|
_.apiQuery.getAppSeriesBrands().then(res => {
|
|
if (res.data.list.length > 0) {
|
|
let brandArray = []
|
|
res.data.list.forEach(item => {
|
|
brandArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
brandArray: brandArray,
|
|
brandList: res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车系车型
|
|
getAppSeries() {
|
|
let params = {};
|
|
params['brand_id'] = this.data.brand_id;
|
|
_.apiQuery.getAppSeries(params).then(res => {
|
|
if (res.data.list.length > 0) {
|
|
let modelArray = []
|
|
res.data.list.forEach(item => {
|
|
modelArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
modelArray: modelArray,
|
|
modelList: res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车辆版本
|
|
getAppSeriesAttrslevel() {
|
|
let params = {};
|
|
params['id'] = this.data.car_id;
|
|
params['type'] = 0;
|
|
_.apiQuery.getAppSeriesAttrs(params).then(res => {
|
|
if (res.data.total > 0) {
|
|
let levelArray = []
|
|
res.data.list.forEach(item => {
|
|
levelArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
levelArray: levelArray,
|
|
levelList: res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//选择品牌
|
|
changeBrand(e) {
|
|
if (this.data.brandIndex != e.detail.value && e.detail.value >= 0) {
|
|
this.setData({
|
|
brand_id: this.data.brandList[e.detail.value].id,
|
|
brandIndex: e.detail.value,
|
|
car_id: '', //车系id
|
|
v_id: '', //车辆版本id
|
|
modelIndex: -1,
|
|
levelIndex: -1,
|
|
})
|
|
this.getAppSeries()
|
|
}
|
|
},
|
|
|
|
//选择车系
|
|
changeModel(e) {
|
|
if (this.data.modelIndex != e.detail.value && e.detail.value >= 0) {
|
|
this.setData({
|
|
car_id: this.data.modelList[e.detail.value].id,
|
|
modelIndex: e.detail.value,
|
|
v_id: '', //车辆版本id
|
|
levelIndex: -1,
|
|
})
|
|
this.getAppSeriesAttrslevel()
|
|
}
|
|
},
|
|
|
|
//车辆版本
|
|
changeLevel(e) {
|
|
if (this.data.levelIndex != e.detail.value && e.detail.value >= 0) {
|
|
this.setData({
|
|
v_id: this.data.levelList[e.detail.value].id,
|
|
levelIndex: e.detail.value,
|
|
})
|
|
}
|
|
},
|
|
|
|
//页面相关事件处理函数--监听用户下拉动作
|
|
onPullDownRefresh() {
|
|
this.setData({
|
|
list: [],
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
flag: this.data.flag + 1
|
|
})
|
|
|
|
this.getAppCusorderTabs()
|
|
// this.getAppCusorderList()
|
|
},
|
|
|
|
//页面上拉触底事件的处理函数
|
|
onReachBottom() {
|
|
if (this.data.noData || this.data.end || !this.data.load) return;
|
|
this.setData({
|
|
flag: this.data.flag + 1
|
|
})
|
|
this.getAppCusorderList()
|
|
},
|
|
bindShowBrand() {
|
|
this.setData({
|
|
brand_page_show: true
|
|
})
|
|
},
|
|
//获取品牌信息
|
|
getBrandData(e) {
|
|
console.log(e.detail)
|
|
if (e.detail.index > -1 && e.detail.item) {
|
|
this.setData({
|
|
brand_id: e.detail.item.id,
|
|
brand_name: e.detail.item.name,
|
|
brandIndex: e.detail.index,
|
|
series_id: '', //车系id
|
|
modelArray: [],
|
|
modelIndex: -1, //车系车型索引
|
|
car_id: '', //车系id
|
|
carArray: [], //车辆版本列表
|
|
carIndex: -1, //车辆版本索引
|
|
})
|
|
this.getAppSeries()
|
|
}
|
|
},
|
|
// 同意核销
|
|
bindAgreeCheckCode(e) {
|
|
let that = this
|
|
let index = e.currentTarget.dataset.index
|
|
let item = that.data.list[index]
|
|
let params = {
|
|
'id': item.id
|
|
}
|
|
wx.showModal({
|
|
content: '确定核销该订单',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
_.apiQuery.postAppCusorderDestroy(params).then(res => {
|
|
if (res.code == 200) {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'success',
|
|
duration: 2000
|
|
})
|
|
that.onPullDownRefresh()
|
|
}else{
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 2000
|
|
})
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
}) |