|
|
|
@ -1,6 +1,6 @@ |
|
|
|
// pages/process/order-list/index.js
|
|
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
|
import { getFactoryOrderList, cancelOrder } from "../../../api/saas" |
|
|
|
import { getFactoryOrderList, cancelOrder, getReceiptList } from "../../../api/saas" |
|
|
|
const event = require('../../../utils/event') |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const app = getApp() |
|
|
|
@ -67,56 +67,68 @@ Page({ |
|
|
|
} else { |
|
|
|
this.setData({ requesting: true }) |
|
|
|
} |
|
|
|
getFactoryOrderList(this.data.form).then(result => { |
|
|
|
if (result.data && result.data.records.length) { |
|
|
|
var respList = result.data.records |
|
|
|
// 对返回的消息列表进行处理,将同一天的消息显示在一起
|
|
|
|
for (let i = 0; i < respList.length; i++) { |
|
|
|
if (util.isEmpty(this.data.lastTime)) { |
|
|
|
this.data.lastTime = respList[i].createTime |
|
|
|
if (this.data.lastTime.length > 10) { |
|
|
|
this.data.lastTime = this.data.lastTime.substring(0, 10) |
|
|
|
} |
|
|
|
respList[i].tipsTime = this.data.lastTime |
|
|
|
} else { |
|
|
|
var itemTime = respList[i].createTime |
|
|
|
if (itemTime.length > 10) { |
|
|
|
itemTime = itemTime.substring(0, 10) |
|
|
|
} |
|
|
|
if (this.data.lastTime !== itemTime) { |
|
|
|
respList[i].tipsTime = itemTime |
|
|
|
} |
|
|
|
this.data.lastTime = itemTime |
|
|
|
if(this.data.form.funcType == 3){ |
|
|
|
getReceiptList(this.data.form).then(result => { |
|
|
|
this.handResult(result) |
|
|
|
}).catch(err => { |
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
getFactoryOrderList(this.data.form).then(result => { |
|
|
|
this.handResult(result) |
|
|
|
}).catch(err => { |
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
handResult: function(result){ |
|
|
|
if (result.data && result.data.records.length) { |
|
|
|
var respList = result.data.records |
|
|
|
// 对返回的消息列表进行处理,将同一天的消息显示在一起
|
|
|
|
for (let i = 0; i < respList.length; i++) { |
|
|
|
if (util.isEmpty(this.data.lastTime)) { |
|
|
|
this.data.lastTime = respList[i].createTime |
|
|
|
if (this.data.lastTime.length > 10) { |
|
|
|
this.data.lastTime = this.data.lastTime.substring(0, 10) |
|
|
|
} |
|
|
|
} |
|
|
|
let nowList = `orderList[${this.data.orderList.length}]` |
|
|
|
var num = this.data.form.pageNum |
|
|
|
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|
|
|
if(this.data.form.pageNum == 1){ |
|
|
|
this.setData({ |
|
|
|
[nowList]: respList, |
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
top: 0, |
|
|
|
finished, |
|
|
|
requesting: false, |
|
|
|
loading: false |
|
|
|
}) |
|
|
|
respList[i].tipsTime = this.data.lastTime |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
[nowList]: respList, |
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
finished, |
|
|
|
requesting: false, |
|
|
|
loading: false |
|
|
|
}) |
|
|
|
var itemTime = respList[i].createTime |
|
|
|
if (itemTime.length > 10) { |
|
|
|
itemTime = itemTime.substring(0, 10) |
|
|
|
} |
|
|
|
if (this.data.lastTime !== itemTime) { |
|
|
|
respList[i].tipsTime = itemTime |
|
|
|
} |
|
|
|
this.data.lastTime = itemTime |
|
|
|
} |
|
|
|
} |
|
|
|
let nowList = `orderList[${this.data.orderList.length}]` |
|
|
|
var num = this.data.form.pageNum |
|
|
|
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|
|
|
if(this.data.form.pageNum == 1){ |
|
|
|
this.setData({ |
|
|
|
[nowList]: respList, |
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
top: 0, |
|
|
|
finished, |
|
|
|
requesting: false, |
|
|
|
loading: false |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
this.setData({ |
|
|
|
[nowList]: respList, |
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
finished, |
|
|
|
requesting: false, |
|
|
|
loading: false |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
} |
|
|
|
}, |
|
|
|
cancelOrder: function(e){ |
|
|
|
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => { |
|
|
|
|