【类 型】:factor 订单模块修改

【原  因】:1.弹出框影响视觉,载入页面改为loding动画。2.价格加入 价格格式化 防止浮点显示错误
【过  程】:1获取数据加入loading属性 2.写了一个格式化价格参数 保留小数点后两位
【影  响】:
This commit is contained in:
tk 2024-07-30 13:32:51 +08:00
parent ffba9da2f2
commit 61bfc7d455
3 changed files with 29 additions and 10 deletions

View File

@ -91,11 +91,6 @@ export async function getOrderList (orderSerch) {
params.append('search', orderSerch.search)
// 发送退款请求
const res = await api.post('getOrderList', params, 'Admin')
if (res.data.status === 1) {
Message.success('成功获取订单列表')
} else {
Message.error('获取订单列表失败')
}
return res
}

View File

@ -142,3 +142,19 @@ export function speakText (text) {
}
window.responsiveVoice.speak(text, 'Chinese Female')
}
/**
* 过滤价格数值 超过小数点两位得 保留两位
* @param {string} value
*/
export function formatPrice (value) {
if (isNaN(value)) return '' // 如果不是数字,则返回空字符串
// 格式化价格为保留两位小数
let formattedPrice = parseFloat(value).toFixed(2)
// 如果价格有两位小数以上,则保留两位小数,否则显示整数或者一位小数
const decimalCount = (formattedPrice.split('.')[1] || []).length
if (decimalCount > 2) {
formattedPrice = parseFloat(formattedPrice).toFixed(2)
}
return formattedPrice
}

View File

@ -24,7 +24,7 @@
</el-col>
</el-row>
<!-- 订单列表 -->
<el-table class="m-t-20 w-100" ref="myTable" show-summary :summary-method="getSummaries"
<el-table v-loading="loading" class="m-t-20 w-100" ref="myTable" show-summary :summary-method="getSummaries"
:data="orderList.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
<el-table-column align="center" type="selection" width="70" min-width="40">
</el-table-column>
@ -62,7 +62,7 @@
<script>
import { countSelIdArr, parseTime } from '@/utils'
import { countSelIdArr, parseTime, formatPrice } from '@/utils'
import { getOrderList } from '@/utils/api/table'
import SelectionShopId from '@/components/SelectionShopId'
import SelectionMainStatus from '@/components/SelectionMainStatus'
@ -79,7 +79,8 @@ export default {
pageSize: 50, //
currentPage: 1, //
shop_id: this.$store.state.user.shop_id, // id
orderList: []//
orderList: [], //
loading: true//
}
},
components: {
@ -105,7 +106,12 @@ export default {
*/
async getOrderList (orderSerch) {
const res = await getOrderList(orderSerch)
this.orderList = res.data.orderList
if (res.data.status === 1) {
this.orderList = res.data.orderList
this.loading = false
} else {
this.$message.error('获取订单列表失败')
}
},
/**
* @description: 表单提交 加入防抖
@ -121,15 +127,17 @@ export default {
return acc + (order.total_price - order.refund_price)
}, 0)
const total = this.orderList.length
return ['合计', '', '', '', '', `${total}${sum}`]
return ['合计', '', '', '', '', `${total}${formatPrice(sum)}`]
}
},
watch: {
shop_id (val) {
this.loading = true
this.$store.commit('app/setOrderSerch', { shop_id: val })
},
orderSerch: {
handler (val) {
this.loading = true
this.debouncedGetOrderList(val)//
},
deep: true