提交 0ec288fd authored 作者: lidongxu's avatar lidongxu

refactor(all): 取消全选-选项使用

格式化金额千分位,接入列表查询接口
上级 db1c71b2
...@@ -9,6 +9,12 @@ export const getFinanceListAPI = (data) => { ...@@ -9,6 +9,12 @@ export const getFinanceListAPI = (data) => {
return request({ return request({
url: '/bi/finance/cost/list', url: '/bi/finance/cost/list',
method: 'POST', method: 'POST',
data data: {
zbjQdType: data.brand,
flavor: data.taste,
specName: data.spec,
series: data.series,
goodsName: data.goods
}
}) })
} }
\ No newline at end of file
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
<el-select v-bind="$attrs" <el-select v-bind="$attrs"
v-model="selectedOptions" v-model="selectedOptions"
@change="handleChange"> @change="handleChange">
<li class="el-select-dropdown__item all_item "
:class="{ 'is-selected': isAll }"
@click="selectAll">
<span>全选</span>
</li>
<el-option v-for="str in options" <el-option v-for="str in options"
:label="str" :label="str"
:value="str"> :value="str">
</el-option> </el-option>
<li class="el-select-dropdown__item all_item"
:class="{ 'is-selected': isAll }"
@click.stop="selectAll"
@mouseenter.stop="over"
@mouseleave.stop="out">
<span>全选</span>
</li>
</el-select> </el-select>
</template> </template>
...@@ -26,7 +28,7 @@ const props = defineProps({ ...@@ -26,7 +28,7 @@ const props = defineProps({
default: () => [], default: () => [],
}, },
modelValue: { modelValue: {
type: Array, type: [Array, String],
default: () => [] default: () => []
} }
}) })
...@@ -38,6 +40,12 @@ watch(() => props.modelValue, val => { ...@@ -38,6 +40,12 @@ watch(() => props.modelValue, val => {
deep: true, deep: true,
immediate: true immediate: true
}) })
// 设置样式
const noHover = () => {
const list = document.querySelectorAll('.el-select-dropdown .el-select-dropdown__item')
list.forEach(el => el.classList.add('no-hovering'))
}
// 全选点击 // 全选点击
const selectAll = () => { const selectAll = () => {
...@@ -49,12 +57,22 @@ const selectAll = () => { ...@@ -49,12 +57,22 @@ const selectAll = () => {
selectedOptions.value = []; selectedOptions.value = [];
emits('update:modelValue', selectedOptions.value); emits('update:modelValue', selectedOptions.value);
} }
nextTick(() => {
noHover()
})
} }
const handleChange = (val) => { const handleChange = (val) => {
isAll.value = val.length === props.options.length isAll.value = val.length === props.options.length
emits('update:modelValue', val) emits('update:modelValue', val)
} }
const over = () => {
noHover()
}
const out = () => {
noHover()
}
</script> </script>
<style scoped <style scoped
...@@ -68,7 +86,7 @@ const handleChange = (val) => { ...@@ -68,7 +86,7 @@ const handleChange = (val) => {
background-color: var(--el-fill-color-light); background-color: var(--el-fill-color-light);
} }
.all_item:hover+.is-hovering { .no-hovering {
background-color: transparent; background-color: transparent;
} }
......
...@@ -77,8 +77,12 @@ export function formatNumberWithUnit({ value, carry = true, fixed = 2, round = t ...@@ -77,8 +77,12 @@ export function formatNumberWithUnit({ value, carry = true, fixed = 2, round = t
resultNum = Math.abs(resultNum); resultNum = Math.abs(resultNum);
} }
if (comma) { if (comma) {
// 是否添加千分位符号 // 将整数部分和小数部分分开
resultNum = resultNum.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); const parts = resultNum.toString().split('.');
// 只在整数部分添加逗号
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
// 重新组合整数部分和小数部分
resultNum = parts.join('.');
} }
return `${resultNum} ${unit}${des}`; return `${resultNum} ${unit}${des}`;
} }
......
...@@ -6,15 +6,18 @@ ...@@ -6,15 +6,18 @@
label-position="right" label-position="right"
label-width="68px" label-width="68px"
inline> inline>
<el-form-item label="直播间" ref="ab"> <el-form-item label="直播间">
<xl-select v-model="queryParams.brand" <el-select v-model="queryParams.brand"
:options="brandList"
multiple multiple
clearable clearable
collapse-tags collapse-tags
collapse-tags-tooltip collapse-tags-tooltip
@change="getList"> @change="getList">
</xl-select> <el-option v-for="str in brandList"
:label="str"
:value="str">
</el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="口味"> <el-form-item label="口味">
<el-select v-model="queryParams.taste" <el-select v-model="queryParams.taste"
...@@ -87,10 +90,8 @@ ...@@ -87,10 +90,8 @@
<el-table-column v-for="item in columns" <el-table-column v-for="item in columns"
:key="item.prop" :key="item.prop"
:label="item.label" :label="item.label"
:prop="item.prop"> :prop="item.prop"
<template v-slot="scope"> :formatter="formatter">
{{ scope.row[item.prop] }}
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
...@@ -116,22 +117,23 @@ ...@@ -116,22 +117,23 @@
<script setup> <script setup>
import { getFinanceListAPI } from '@/api' import { getFinanceListAPI } from '@/api'
import { useDatePickerOptions } from '@/hooks' import { useDatePickerOptions } from '@/hooks'
import { formatNumberWithUnit } from '@/utils'
const { pickerOptions } = useDatePickerOptions() const { pickerOptions } = useDatePickerOptions()
const detailVisible = ref(false) // 详情 const detailVisible = ref(false) // 详情
const brandList = ref(['a', 'b', 'c']) // 直播间 const brandList = ref(["虎皮01", "IP礼盒直播间", "礼盒直播间", "去骨直播间"]) // 直播间
const tasteList = ref([]) // 口味 const tasteList = ref(["香辣", "原味", "椒麻", "混合"]) // 口味
const specList = ref([]) // 规则 const specList = ref([]) // 规则
const seriesList = ref([]) // 系列 const seriesList = ref([]) // 系列
const goodsList = ref([]) // 商品 const goodsList = ref([]) // 商品
const data = reactive({ const data = reactive({
queryParams: { queryParams: {
brand: ['a', 'b', 'c'], // 直播间 brand: ["虎皮01", "IP礼盒直播间", "礼盒直播间", "去骨直播间"], // 直播间
taste: '', // 口味 taste: ["香辣", "原味", "椒麻", "混合"], // 口味
spec: '', // 规格 spec: [], // 规格
series: '', // 系列 series: [], // 系列
goods: '', // 商品 goods: [], // 商品
date: [] // 日期 date: [] // 日期
} }
}) })
...@@ -142,27 +144,27 @@ const queryChange = () => { ...@@ -142,27 +144,27 @@ const queryChange = () => {
} }
// 获取数据 // 表格数据
const columns = ref([ const columns = ref([
{ {
label: '直播间', label: '直播间',
prop: 'queryType' prop: 'zbjQdType'
}, },
{ {
label: '口味', label: '口味',
prop: 'queryType' prop: 'flavorErp'
}, },
{ {
label: '规格', label: '规格',
prop: 'queryType' prop: 'specNameErp'
}, },
{ {
label: '系列', label: '系列',
prop: 'queryType' prop: ''
}, },
{ {
label: '商品', label: '商品',
prop: 'queryType' prop: 'goodsName'
}, },
{ {
label: '分摊后总价', label: '分摊后总价',
...@@ -173,16 +175,16 @@ const columns = ref([ ...@@ -173,16 +175,16 @@ const columns = ref([
prop: 'actualCostSum' prop: 'actualCostSum'
}, },
{ {
label: '标准成本', label: '实际成本毛利',
prop: 'standardCostSum' prop: 'actualCostGrossProfitSum'
}, },
{ {
label: '实际成本毛利', label: '标准成本',
prop: 'standardCostSum' prop: 'standardCostSum'
}, },
{ {
label: '标准成本毛利', label: '标准成本毛利',
prop: 'standardCostSum' prop: 'standardCostGrossProfitSum'
} }
]) ])
const tableData = ref([ const tableData = ref([
...@@ -193,6 +195,16 @@ const getList = async () => { ...@@ -193,6 +195,16 @@ const getList = async () => {
} }
getList() getList()
const formatter = (row, column, value) => {
if (['shareAmountSum', 'actualCostSum', 'actualCostGrossProfitSum', 'standardCostSum', 'standardCostGrossProfitSum'].includes(column.property)) {
console.log(value)
return formatNumberWithUnit({ value, carry: false, fixed: 4, round: false, post: false, comma: true, des: '' })
} else {
return value
}
}
// 详情数据
const detailTableData = ref([]) const detailTableData = ref([])
const detailColumns = ref([ const detailColumns = ref([
{ {
...@@ -273,7 +285,6 @@ const detailColumns = ref([ ...@@ -273,7 +285,6 @@ const detailColumns = ref([
prop: '' prop: ''
} }
]) ])
const ab = ref(null)
</script> </script>
<style scoped <style scoped
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论