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

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

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