提交 19b17451 authored 作者: lidongxu's avatar lidongxu

feat(bi/finance): 口味规格和直播间支持全选

watch 观察表单参数有值显示对应列,暂时注释了,默认全都显示所有列
上级 4069f78a
......@@ -42,9 +42,12 @@ export const getFinanceListAPI = (data) => {
url: '/bi/finance/cost/list',
method: 'POST',
data: {
zbjQdType: data.brand,
flavor: data.taste,
specName: data.spec,
zbjQdType: data.zbjQdType,
flavor: data.flavorErp,
specName: data.specNameErp,
zbjQdTypeAll: data.zbjQdTypeAll,
flavorErpAll: data.flavorErpAll,
specNameErpAll: data.specNameErpAll,
series: data.seriesPrdMap.map(o => o[0]),
goodsName: data.seriesPrdMap.map(o => o[1]),
startDate: parseTime(data.date[0], `{y}-{m}-{d}`),
......@@ -58,9 +61,12 @@ export const getFinanceDetailAPI = (data) => {
url: '/bi/finance/cost/detail/list',
method: 'POST',
data: {
zbjQdType: data.brand,
flavor: data.taste,
specName: data.spec,
zbjQdType: data.zbjQdType,
flavor: data.flavorErp,
specName: data.specNameErp,
zbjQdTypeAll: data.zbjQdTypeAll,
flavorErpAll: data.flavorErpAll,
specNameErpAll: data.specNameErpAll,
series: data.seriesPrdMap.map(o => o[0]),
goodsName: data.seriesPrdMap.map(o => o[1]),
startDate: parseTime(data.date[0], `{y}-{m}-{d}`),
......
......@@ -2,17 +2,18 @@
<el-select v-bind="$attrs"
v-model="selectedOptions"
@change="handleChange">
<el-option v-for="str in options"
:label="str"
:value="str">
</el-option>
<li class="el-select-dropdown__item all_item"
:class="{ 'is-selected': isAll }"
v-if="props.options.length > 0"
@click.stop="selectAll"
@mouseenter.stop="over"
@mouseleave.stop="out">
<span>全选</span>
</li>
<el-option v-for="obj in options"
:label="obj.label"
:value="obj.value">
</el-option>
</el-select>
</template>
......@@ -20,7 +21,7 @@
const selectedOptions = ref([]) // 当前选中的值集合
const isAll = ref(false) // 全选状态
const emits = defineEmits(['update:modelValue']);
const emits = defineEmits(['update:modelValue', 'change']);
const props = defineProps({
options: {
......@@ -35,43 +36,45 @@ const props = defineProps({
watch(() => props.modelValue, val => {
selectedOptions.value = val;
if (props.options.length > 0) {
isAll.value = val.length === props.options.length
}
}, {
deep: 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 = () => {
isAll.value = !isAll.value
if (isAll.value) {
selectedOptions.value = [...props.options];
selectedOptions.value = props.options.map(item => item.value);
emits('update:modelValue', selectedOptions.value);
emits('change')
} else {
selectedOptions.value = [];
emits('update:modelValue', selectedOptions.value);
emits('change')
}
nextTick(() => {
noHover()
const list = document.querySelectorAll('.el-select-dropdown .el-select-dropdown__item')
list.forEach(el => el.classList.add('no-hovering'))
})
}
const handleChange = (val) => {
isAll.value = val.length === props.options.length
emits('update:modelValue', val)
emits('change')
}
const over = () => {
noHover()
const list = document.querySelectorAll('.el-select-dropdown .el-select-dropdown__item')
list.forEach(el => el.classList.add('no-hovering'))
}
const out = () => {
noHover()
const list = document.querySelectorAll('.el-select-dropdown .el-select-dropdown__item')
list.forEach(el => el.classList.remove('no-hovering'))
}
</script>
......
......@@ -3,9 +3,10 @@
* @param {*} type 0:从今天开始往前,-1 则是 T - 1 开始日期往前
* @returns {}
*/
export const useDatePickerOptions = (type = -1,) => {
export const useDatePickerOptions = (type = -1) => {
const last30Date = [new Date().setDate((new Date().getDate() - (30 - 1))), new Date().setDate((new Date().getDate() + type))]
const last7Date = [new Date().setDate((new Date().getDate() - (7 - 1))), new Date().setDate((new Date().getDate() + type))]
const lastDate = [new Date().setDate((new Date().getDate() + type)), new Date().setDate((new Date().getDate() + type))]
const recentPickerOptions = ref([// 日期选项配置
{
text: '最近一周',
......@@ -47,9 +48,10 @@ export const useDatePickerOptions = (type = -1,) => {
}
])
return {
lastDate, // 昨天
last30Date, // 前 30 天
last7Date, // 前 7 天
recentPickerOptions, // 最近一周/一月
lastPickerOptions
lastPickerOptions // 上一周/上一月
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论