订单逻辑完善

This commit is contained in:
BianLzhaoMin 2024-12-25 18:12:01 +08:00
parent 3b98da571c
commit ac21ac8add
9 changed files with 458 additions and 74 deletions

View File

@ -0,0 +1,47 @@
<template>
<van-uploader
v-model="fileList"
:max-count="props.maxCount"
:max-size="props.maxSize * 1024"
@oversize="onOversize"
@delete="onDelete"
:after-read="onAfterRead"
/>
</template>
<script setup>
import { ref } from 'vue'
const fileList = ref([])
const fileListSuccess = ref([])
const emits = defineEmits(['onUploadSuccess'])
const props = defineProps({
maxSize: {
type: Number,
default: () => 200,
},
maxCount: {
type: Number,
default: () => 4,
},
})
const onOversize = () => {}
const onAfterRead = (file) => {
uni.uploadFile({
url: '/file/upload',
filePath: file.content,
name: 'file',
success: (res) => {
fileListSuccess.value.push(JSON.parse(res.data).data)
fileList.value = fileListSuccess.value
emits('onUploadSuccess', fileList.value)
},
fail: (err) => {},
})
}
const onDelete = () => {
emits('onUploadSuccess', fileList.value)
}
</script>

View File

@ -124,7 +124,6 @@ const getMessageListData = async () => {
messageList.value = res
}
const onJumpToMessagePages = (item) => {
console.log(item, 'item')
const { toCompany, toUser, toCompanyName, fromCompany, fromCompanyName, fromUser } = item
const isForm = userCompanyId.value == item.fromCompany
uni.navigateTo({

View File

@ -30,13 +30,13 @@
<van-grid clickable :column-num="2" :gutter="10">
<van-grid-item>
<navigator url="/pages/order-details/index">
<navigator url="/pages/order-details/index?type=1">
<van-icon name="cart" />
<text>出租订单</text>
</navigator>
</van-grid-item>
<van-grid-item>
<navigator url="/pages/order-details/index">
<navigator url="/pages/order-details/index?type=2">
<van-icon name="cart" />
<text>租赁订单</text>
</navigator>

View File

@ -48,7 +48,10 @@
</view>
<view>
装备编号{{ goods.code }}
<van-tag type="primary">待确认</van-tag>
<van-tag :type="orderType(goods.orderStatus)">
{{ orderText(goods.orderStatus) }}
</van-tag>
</view>
<view>装备型号{{ goods.typeName }}</view>
<view> 租赁时长 {{ goods.days }}</view>
@ -57,6 +60,72 @@
</van-col>
</van-row>
<van-row style="margin-top: 14px">
<van-button
type="primary"
size="mini"
style="margin-right: 6px"
class="primary-lease"
v-if="goods.orderStatus == 4"
@click="onReturnGoods(item, goods)"
>
发起退租
</van-button>
</van-row>
</view>
<van-row style="margin-top: 14px">
<van-button
type="primary"
size="small"
class="primary-lease"
style="margin-right: 6px"
v-if="
(item.orderStatus == 1 || item.orderStatus == 2) &&
orderQueryParams.flag
"
@click="onEditOrderStatus(item, parseInt(item.orderStatus))"
>
{{ initBtnText(item.orderStatus) }}
</van-button>
<van-button
type="primary"
size="small"
class="primary-lease"
style="margin-right: 6px"
v-if="
(item.orderStatus == 3 || item.orderStatus == 4) &&
!orderQueryParams.flag
"
@click="onEditOrderStatus(item, parseInt(item.orderStatus))"
>
{{ initLesseeBtnText(item.orderStatus) }}
</van-button>
<van-button
style="margin-right: 6px"
size="small"
type="primary"
class="primary-lease"
@click="onReturnRepair(item)"
v-if="item.orderStatus == 5 && orderQueryParams.flag"
>
退租检修
</van-button>
<!-- <van-button style="margin-right: 6px" round type="success" size="small">
发起退租
</van-button>
<van-button
style="margin-right: 6px"
round
type="success"
size="small"
@click="onReduction"
>
发起减免
</van-button> -->
</van-row>
<van-row style="margin-top: 14px">
总金额
<view style="color: var(--van-submit-bar-price-color)">
@ -66,97 +135,197 @@
</text>
</view>
</van-row>
<van-row style="margin-top: 14px">
<van-button style="margin-right: 6px" round type="success" size="small">
发起退租
</van-button>
<van-button
style="margin-right: 6px"
round
type="success"
size="small"
@click="onReturnRepair"
>
退租检修
</van-button>
<van-button
style="margin-right: 6px"
round
type="success"
size="small"
@click="onReduction"
>
发起减免
</van-button>
</van-row>
</view>
</view>
</scroll-view>
<van-popup
v-model:show="showBottom"
position="bottom"
closeable
close-icon="close"
:style="{ height: '60%' }"
>
<van-form
label-align="top"
style="border-bottom: 1px solid #ccc; margin: 0 10px; padding-bottom: 10px"
>
<van-cell-group inset>
<van-field name="leaseName" label="请先选择检修类型" required />
<van-popup v-model:show="showBottom" position="bottom" :style="{ height: '60%' }">
<van-cell-group>
<van-cell title="请选择检修类型">
<template #right-icon>
<van-icon
name="close"
size="18"
@click="
() => {
showBottom = false
}
"
/>
</template>
</van-cell>
</van-cell-group>
<view style="padding: 0 20px">
<van-button style="margin-right: 6px" type="success" size="small">
维修
</van-button>
<van-button style="margin-right: 6px" type="success" size="small">
报废
</van-button>
<van-button style="margin-right: 6px" type="success" size="small">
丢失
</van-button>
</view>
</van-form>
<van-cell-group inset style="box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1)">
<van-cell-group
inset
v-for="(item, index) in repairList"
:key="item.id"
style="box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1)"
>
<van-row>
<van-col span="2"></van-col>
<van-col span="22">
<van-col span="24">
<view class="items-info">
<van-image fit="cover" height="4rem" width="4rem" :src="companyBg" />
<van-image fit="cover" height="4rem" width="4rem" :src="item.url" />
<view class="info">
<view style="color: #000">
测试装备
{{ item.deviceName }}
<van-tag type="primary">已退租</van-tag>
</view>
<view> 装备编号1223 </view>
<view>租赁时长778</view>
<view> 装备编号{{ item.code }}</view>
<view>租赁时长{{ item.originDays }}</view>
</view>
</view>
</van-col>
</van-row>
<van-row style="padding: 4px 0">
<van-col span="6">
<van-button
size="mini"
type="primary"
class="primary-lease"
@click="onHandlerReturn(1, index)"
style="padding: 4px 20px"
>
维修
</van-button>
</van-col>
<van-col span="6">
<van-button
size="mini"
type="primary"
class="primary-lease"
@click="onHandlerReturn(2, index)"
style="padding: 4px 20px"
>
报废
</van-button>
</van-col>
<van-col span="6">
<van-button
size="mini"
type="primary"
class="primary-lease"
@click="onHandlerReturn(3, index)"
style="padding: 4px 20px"
>
丢失
</van-button>
</van-col>
</van-row>
<van-row style="padding: 8px 0; border-top: 1px solid #ccc">
<van-col span="12"> 丢失费用88 </van-col>
<van-col span="12"> 附件xxxx </van-col>
</van-row>
</van-cell-group>
<view style="margin: 16px">
<van-button block type="primary" size="small" @click="onSubmitRepairResult">
保存
</van-button>
</view>
</van-popup>
<!-- 操作弹框 -->
<van-popup round v-model:show="showCenter" :style="{ width: '100%', padding: '16px' }">
<!-- 维修费用输入 -->
<van-cell-group>
<van-cell :title="handleTitle">
<template #right-icon>
<van-icon
name="close"
size="18"
@click="
() => {
showCenter = false
}
"
/>
</template>
</van-cell>
</van-cell-group>
<van-form v-if="handleTitle === '维修费用'">
<van-cell-group inset>
<van-field
required
label="维修金额"
placeholder="请输入维修金额"
v-model="repairRecord.repairPrice"
/>
<van-field name="uploader" label="附件" required>
<template #input>
<UploadFile
v-model="repairRecord.fileInfoList"
@onUploadSuccess="onUploadSuccess"
/>
</template>
</van-field>
</van-cell-group>
</van-form>
<van-form v-if="handleTitle === '报废费用'">
<van-cell-group inset>
<van-field
required
label="报废金额"
placeholder="请输入报废金额"
v-model="scrapRecord.scrapPrice"
/>
<van-field name="uploader" label="附件" required>
<template #input>
<UploadFile
v-model="scrapRecord.fileInfoList"
@onUploadSuccess="onUploadSuccess"
/>
</template>
</van-field>
</van-cell-group>
</van-form>
<van-form v-if="handleTitle === '丢失费用'">
<van-cell-group inset>
<van-field
required
label="丢失金额"
placeholder="请输入丢失金额"
v-model="lossRecord.lossPrice"
/>
<van-field name="uploader" label="附件" required>
<template #input>
<UploadFile
v-model="lossRecord.fileInfoList"
@onUploadSuccess="onUploadSuccess"
/>
</template>
</van-field>
</van-cell-group>
</van-form>
<view style="margin: 16px">
<van-button block type="primary" size="small" @click="onSubmitFormResult">
提交
</van-button>
</view>
</van-popup>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { useMemberStore } from '@/stores/index.js'
import companyImg from '@/static/goods/company-img.png'
import companyBg from '@/static/goods/company-bg.png'
import cartImg from '@/static/cart/cart.png'
import UploadFile from '@/components/UploadFile'
import { onLoad } from '@dcloudio/uni-app'
import { getOrderListAPI } from '@/services/order/index.js'
import { getOrderListAPI, editOrderStatusAPI } from '@/services/order/index.js'
import { fileUploadAPI } from '@/services/common/index.js'
const showBottom = ref(false)
const showCenter = ref(false)
const activeTabs = ref(0)
const orderList = ref([])
const repairList = ref([])
const handleTitle = ref('')
const orderQueryParams = ref({
pageSize: 20,
pageNum: 1,
flag: true,
})
const statusList = [
{ id: '1', name: '待接单' },
{ id: '2', name: '待出库' },
@ -172,6 +341,38 @@ const statusList = [
{ id: '99', name: '已取消' },
]
//
const repairRecord = ref({
num: 1,
maId: '',
typeId: '',
repairNum: 1,
repairPrice: '',
deviceName: '',
fileInfoList: [],
})
//
const scrapRecord = ref({
num: 1,
maId: '',
typeId: '',
scrapNum: 1,
scrapPrice: '',
deviceName: '',
scrapReason: '无',
fileInfoList: [],
})
//
const lossRecord = ref({
num: 1,
maId: '',
typeId: '',
lossNum: 1,
lossPrice: '',
deviceName: '',
fileInfoList: [],
})
const orderText = (status) => {
return statusList.filter((e) => e.id == status)[0].name
}
@ -192,15 +393,16 @@ const tabList = ref([
{ tab_name: '已取消' },
])
//
const onClickLeft = () => {
uni.navigateBack()
}
//
const getOrderListData = async () => {
const res = await getOrderListAPI()
const res = await getOrderListAPI(orderQueryParams.value)
orderList.value = res.rows
console.log(res, '订单列表')
}
//
@ -211,10 +413,125 @@ const onReduction = () => {
}
// 退
const onReturnRepair = () => {
const onReturnRepair = (item) => {
console.log(item)
repairList.value = item.detailsList
showBottom.value = true
}
onLoad(() => {
const initBtnText = (status) => {
if (status == 1) return '接单'
if (status == 2) return '出库'
}
const initLesseeBtnText = (status) => {
if (status == 3) return '确认收货'
if (status == 4) return '全部退租'
}
//
const onEditOrderStatus = (item, status) => {
const editParams = {
orderId: item.orderId,
orderStatus: '',
}
let tipText = ''
switch (status) {
case 1:
editParams.orderStatus = 2
tipText = '接单'
break
case 2:
editParams.orderStatus = 3
tipText = '出库'
break
case 3:
editParams.orderStatus = 4
tipText = '确认收货'
break
case 4:
editParams.orderStatus = 5
tipText = '申请全部退租'
break
}
showConfirmDialog({
title: '提示',
message: `是否确定${tipText}`,
})
.then(async () => {
const res = await editOrderStatusAPI(editParams)
if (res.code === 200) {
showToast(`${editParams.orderStatus == 5 ? '申请' : tipText}成功`)
getOrderListData()
}
})
.catch(() => {})
}
// 退
const onReturnGoods = (items, goods) => {
showConfirmDialog({
title: '提示',
message: `是否确定发起退租申请`,
})
.then(async () => {
const res = await editOrderStatusAPI({
orderStatus: 5,
orderId: items.orderId,
maIds: [goods.maId],
})
if (res.code === 200) {
showToast(`申请成功`)
getOrderListData()
}
})
.catch(() => {})
}
// 退
const onHandlerReturn = (type) => {
showCenter.value = true
if (type === 1) handleTitle.value = '维修费用'
if (type === 2) handleTitle.value = '报废费用'
if (type === 3) handleTitle.value = '丢失费用'
}
const onUploadSuccess = (fileList) => {
if (handleTitle.value === '维修费用') {
repairRecord.value.fileInfoList = fileList
}
if (handleTitle.value === '报废费用') {
scrapRecord.value.fileInfoList = fileList
}
if (handleTitle.value === '丢失费用') {
lossRecord.value.fileInfoList = fileList
}
}
const onSubmitFormResult = () => {
showConfirmDialog({
title: '提示',
message: '是否确定提交',
})
.then(async () => {
console.log(repairRecord.value, 'repairRecord.value')
})
.catch(() => {})
}
const onSubmitRepairResult = () => {
showConfirmDialog({
title: '提示',
message: '是否确定保存此次维修',
})
.then(async () => {
console.log(repairRecord.value, 'repairRecord.value')
})
.catch(() => {})
}
onLoad((options) => {
orderQueryParams.value.flag = options?.type == 1 ? true : false
getOrderListData()
})
</script>
@ -252,7 +569,7 @@ onLoad(() => {
view {
padding-left: 6px;
font-size: 13px;
font-size: 16px;
font-weight: bold;
}
@ -266,13 +583,13 @@ onLoad(() => {
align-items: center;
.info {
font-size: 12px;
font-size: 14px;
flex: 1;
view {
width: 100%;
padding: 1px 0 1px 10px;
font-size: 12px;
font-size: 13px;
color: #6f6f6f;
display: flex;
align-items: center;
@ -290,9 +607,9 @@ onLoad(() => {
}
}
:deep(.van-field__value) {
display: none;
}
// :deep(.van-field__value) {
// display: none;
// }
:deep(.van-cell-group--inset) {
padding: 10px;

View File

@ -9,3 +9,13 @@ export const getEquipmentTypeAPI = () => {
url: `/material-mall/maType/getEquipmentType`,
})
}
/**
* 文件上传接口
*/
export const fileUploadAPI = (data) => {
return http({
method: 'POST',
url: `/file/upload`,
data,
})
}

View File

@ -41,7 +41,7 @@ export const isReadMessageAPI = (data) => {
})
}
/**
* 消息 消息已读
* 消息 消息已读 全部
*/
export const isReadMessageAllAPI = (data) => {
return http({

View File

@ -10,3 +10,13 @@ export const getOrderListAPI = (data) => {
data,
})
}
/**
* 订单 操作订单 修改订单状态
*/
export const editOrderStatusAPI = (data) => {
return http({
method: 'POSt',
url: '/material-mall/order/updateOrderStatus',
data,
})
}

View File

@ -5,7 +5,6 @@
--el-color-primary-dark-2:#00ad9d;
--el-color-primary-light-5:#78d3cb;
--el-text-color-primary:#00a288;
}
.h5-container {

View File

@ -28,12 +28,14 @@ export default defineConfig({
},
},
server: {
port: '8101',
proxy: {
// 在此处编写代理规则
'/api': {
// target: 'http://36.33.26.201:17788/proxyApi',
// target: 'http://192.168.2.123:28080',
target: 'http://192.168.1.175:28080',
// target: 'http://192.168.2.122:28080',
target: 'http://192.168.0.244:28580', // 测试服务
changeOrigin: true,
rewrite: (path) => {
return path.replace(/\/api/, '')