或然中台小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
7.4 KiB

2 years ago
<template>
<view>
<view class="filter">
2 years ago
<uni-search-bar class="search" radius="30" placeholder="请输入客户名称,订单名称,订单号" v-model="keyword" clearButton="auto" cancelButton="none" />
<view :class="['sort', sort ? 'asc' : 'desc']" @click="switchSort"></view>
2 years ago
<uni-icons class="icon" custom-prefix="iconfont" type="icon-filter" size="22" color="#007eff" @click="popup = true"></uni-icons>
</view>
<template v-if="list.length">
<view class="list">
<uni-swipe-action>
<uni-swipe-action-item
v-for="item in list"
:threshold="0"
2 years ago
:right-options="ops"
2 years ago
:disabled="!auth('订单管理:删除')"
2 years ago
@click="e => handle(item)"
2 years ago
>
<view class="item" @click="toDetail(item)">
<view class="c-name">{{ item.orderNumber }}</view>
<view class="info">
<view class="left">
<view class="line">
<text class="name">客户名称</text>
<text class="val">{{ item.customerName }}</text>
</view>
<view class="line">
<text class="name">订单金额</text>
<text class="val">{{ item.orderAmount }}</text>
</view>
<view class="line">
<text class="name">订单内容</text>
<view class="val ell-wrap">
<view :class="{ell: !item.toggle}">{{ item.orderContent }}</view>
<view v-if="item.orderContent.length > 14" class="toggle" @click.stop="toggle(item)">{{ item.toggle ? '收起' : '展开' }}</view>
</view>
</view>
<view class="line">
<text class="name">下单日期</text>
<text class="val">{{ item.createTime }}</text>
</view>
</view>
<view :class="['type', 'type' + item.orderStatus]">
{{ filterData[1].data.find(e => e.value === item.orderStatus).title }}
2 years ago
</view>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<uni-load-more :status="status" />
</template>
<empty v-else></empty>
1 year ago
<uni-icons v-if="auth('订单管理:新建订单')" class="plus" type="plus-filled" size="60" color="#007eff" @click="toAdd"></uni-icons>
2 years ago
<filter-popup :data="filterData" :form.sync="filterForm" showArea v-model="popup" title="全部筛选" height="1104rpx" @finsh="subFinsh"></filter-popup>
2 years ago
</view>
</template>
<script>
import { querySchool, queryCustomer } from '@/apis/modules/client.js'
2 years ago
import { list, del } from '@/apis/modules/order.js'
export default {
data() {
return {
2 years ago
form: {},
2 years ago
popup: false,
//筛选表单数据
filterData: [
{
children: false,//是否有子项
title: "订单类型",
key: "orderType", //键名 接收对象名字
keyValue: "value", //获取的值是哪个
isRadio: true, //是否单选 否则多选
data: [
{
title: "正式",
value: 1
},
{
title: "试用",
value: 2
},
],
},
2 years ago
{
children: false,//是否有子项
title: "订单状态",
key: "orderStatus", //键名 接收对象名字
keyValue: "value", //获取的值是哪个
isRadio: true, //是否单选 否则多选
data: [
{
title: "待发货",
value: 0
},
{
title: "已完成",
value: 1
},
],
}
],
filterForm: {},
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
searchTimer: null,
2 years ago
sort: 0,
2 years ago
keyword: '',
list: [],
page: 1,
pageSize: 10,
ops: [
{
2 years ago
text: '删除',
style: {
2 years ago
backgroundColor: '#F56C6C'
}
2 years ago
}
],
2 years ago
}
},
watch: {
keyword () {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initList()
}, 500)
}
},
// 下拉刷新
onPullDownRefresh() {
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
this.getList()
}
},
onShow() {
1 year ago
// 清除订单缓存
2 years ago
try {
uni.removeStorageSync('courses')
1 year ago
uni.removeStorageSync('orderEdited')
2 years ago
} catch (e) {}
2 years ago
this.initList()
2 years ago
},
methods: {
getList() {
2 years ago
const per = (uni.getStorageSync('dataPermission') || []).find(e => e.permissionName === '订单管理')
2 years ago
const data = {
2 years ago
customerName: this.keyword,
pageNo: this.page,
2 years ago
pageSize: this.pageSize,
sort: this.sort,
2 years ago
supplierId: per?.supplierId,
...this.form
2 years ago
}
uni.showLoading({
title: '加载中'
})
2 years ago
list(data).then(({ orderPage }) => {
2 years ago
uni.hideLoading()
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值
2 years ago
const list = orderPage.orders
2 years ago
list.map(e => {
e.toggle = e.orderContent.length < 14 // 超过了14个字才需要显示展开按钮
})
this.list = this.reachBottom > 0 ? [...this.list, ...list] : list
this.page++ // 每次获取了数据后page+1
2 years ago
const noMore = this.list.length === orderPage.total // 是否加载完所有数据
2 years ago
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1
}).catch(e => {
uni.hideLoading()
})
},
initList() {
this.page = 1
this.reachBottom = 0
this.getList()
},
// 展开
toggle(item) {
item.toggle = !item.toggle
},
// 筛选确定回调
subFinsh(e) {
2 years ago
const { provinceId, cityId, orderType, orderStatus } = e
this.form = {
provinceId,
cityId,
orderType: orderType.length ? orderType[0] : '',
orderStatus: orderStatus.length ? orderStatus[0] : ''
}
2 years ago
this.initList()
},
// 排序
switchSort() {
2 years ago
this.sort = this.sort ? 0 : 1
2 years ago
this.initList()
},
1 year ago
toAdd() {
this.$util.to('../orderDetail/orderDetail')
// uni.redirectTo({
// url: '../orderDetail/orderDetail'
// })
},
2 years ago
// 跳转详情
toDetail(item) {
2 weeks ago
// if(!this.auth('订单管理:查看')) return
2 years ago
this.$util.to(`../orderDetail/orderDetail?orderId=${item.orderId}&show=1`)
},
// 删除
2 years ago
handle(row) {
const that = this
uni.showModal({
title: '提示',
content: '确定要删除吗?',
success(res) {
if (res.confirm) {
del({
ids: [row.orderId]
}).then(res => {
that.$util.sucMsg('删除成功')
that.initList()
}).catch(res => {})
2 years ago
}
2 years ago
}
})
2 years ago
},
}
}
</script>
<style scoped lang="scss">
.list {
margin-top: 20rpx;
background-color: #fff;
.item {
padding: 20rpx 40rpx;
border-bottom: 1px solid #f1f1f1;
}
.c-name {
font-size: 30rpx;
color: #333;
}
.info {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10rpx;
}
.left {
max-width: 70%;
}
.line {
display: flex;
padding: 10rpx 0;
}
.name {
margin-right: 10rpx;
white-space: nowrap;
font-size: 28rpx;
color: #999;
}
.val {
max-width: 88%;
font-size: 28rpx;
color: #333;
}
.ell {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.toggle {
margin-top: 10rpx;
white-space: nowrap;
font-size: 24rpx;
color: #0e92ef;
}
.type {
margin-left: 20rpx;
font-size: 28rpx;
color: #ff7b2d;
white-space: nowrap;
}
.type1 {
color: #bdbdbd;
}
}
</style>