封装数据字典通用方法

This commit is contained in:
Vinjor 2024-10-18 15:13:47 +08:00
parent c3e58ddec0
commit 92a46a6b30
3 changed files with 62 additions and 8 deletions

View File

@ -25,7 +25,7 @@
{{ projectName }}
</view>
</view>
<view v-if="order.flag == 2" class="project-right">
<view v-if="order.ticketsStatus == '05'" class="project-right">
<image class="rightIcon" mode="aspectFit" src="/static/icons/success.png"></image>
<text class="rightText">已派工</text>
</view>
@ -34,7 +34,7 @@
<view>
客户信息{{ order.userName }} {{ order.userPhone }}
</view>
<view>
<view v-if="order.appointDate">
预约时间{{ order.appointDate }}
</view>
<view>
@ -42,10 +42,10 @@
</view>
</view>
<view class="footer">
<view @click="gotoDetail" v-if="order.flag == 1" class="btn pg">
<view @click="gotoDetail" v-if="order.ticketsStatus == '04'" class="btn pg">
项目派工
</view>
<view @click="gotoDetail" v-else-if="order.flag == 2" class="btn qc">
<view @click="gotoDetail" v-else-if="order.ticketsStatus == '06'" class="btn qc">
告知取车
</view>
</view>
@ -98,6 +98,7 @@ export default {
border-radius: 8rpx 8rpx 8rpx 8rpx;
border-left: 4rpx solid #FFB323;
padding: 0 30rpx;
margin-bottom: 30rpx;
}
.order-top {

View File

@ -32,7 +32,7 @@
</text>
</view>
<view class="todoList">
<scroll-view style="height: 100%;" scroll-y="true" class="itemContent" bindscrolltolower="onReachBottom"
<scroll-view scroll-y="true" class="itemContent" bindscrolltolower="onReachBottom"
refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
<order-card v-for="(item, index) in orderList" :key="index" :order="item"></order-card>
</scroll-view>
@ -49,7 +49,7 @@ import VNavigationBar from '@/components/VNavigationBar.vue'
import OrderCard from "@/components/orderCard.vue";
import config from '@/config'
import request from '@/utils/request';
import {formatTimestamp} from "@/utils/utils";
import {formatTimestamp,getOrderStatusText,getDictByCode} from "@/utils/utils";
import {
getToken,
getUserInfo,
@ -132,6 +132,7 @@ export default {
}
this.orderList = []
this.getOrderList()
getDictByCode("repair_tickets_status")
}
},
onShow() {
@ -189,7 +190,9 @@ export default {
id:order.id,
orderNo:order.ticketNo,
flag:1,
flagStr:"待处理",
ticketsStatus:order.ticketsStatus,
ticketsWorkStatus:order.ticketsWorkStatus,
flagStr:getOrderStatusText(order),
carNum:order.carNo,
carModel:order.carBrandName,
userName:order.userName,

View File

@ -1,3 +1,5 @@
import request from '@/utils/request';
function getWXStatusHeight() {
// #ifdef MP-WEIXIN
// 获取距上
@ -22,6 +24,51 @@ function getWXStatusHeight() {
// #endif
}
/**
* 根据订单的状态获取订单的文字展示状态
* @param orderInfo
*/
function getOrderStatusText(orderInfo){
let str = "";
if("04"==orderInfo.ticketsStatus){
//待派工
str = "待派工"
}else if("05"==orderInfo.ticketsStatus){
//维修中
str = "维修中"
}else if("01"==orderInfo.ticketsStatus){
//待结算
str = "待结算"
}else if("06"==orderInfo.ticketsStatus){
//挂单/记账
str = "挂单/记账"
}else if("02"==orderInfo.ticketsStatus){
//已结账
str = "已结账"
}else if("03"==orderInfo.ticketsStatus){
//已作废
str = "已作废"
}
return str;
}
/**
* 查询字典可选值
* @param dictCode
*/
function getDictByCode(dictCode){
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params:{type:dictCode}
}).then((res) => {
console.log(res)
if (res.code == 200) {
return res.data
}
})
}
function formatTimestamp(timestamp) {
// 将时间戳转换为Date对象
const date = new Date(timestamp);
@ -37,5 +84,8 @@ function formatTimestamp(timestamp) {
}
export {
getWXStatusHeight,formatTimestamp
getWXStatusHeight,
formatTimestamp,
getOrderStatusText,
getDictByCode
}