场景:当更换月份时,工作台的饼图和柱状图、折线图都同步更新
问题1:工作台页面是由vue多个component组件组合的,实现一次提交更新全部的日期
解决1:在数据库新建中间表,字段日期作为中间属性,被所有需要用到的组件调用。
前端:
---------------------------------------------------------------- template部分
<a-col :span="3">
<a-typography-title :heading="5" style="margin-top: 0">{{ t('workplace.welcome') }} {{ userInfo.username }}</a-typography-title>
</a-col>
<a-col :span="3">
<a-form :model="formModel" label-align="right">
<a-col :span="500">
<a-form-item field="date">
<a-month-picker v-model="formModel.date" style="width: 500px" />
</a-form-item>
</a-col>
</a-form>
</a-col>
---------------------------------------------------------------- script部分
const serarchModel = () => {
return {
date: '',
}
}
const formModel = ref(serarchModel())
// 搜索
const search = () => {
// eslint-disable-next-line no-use-before-define
fetchData()
}
// 获取数据
const fetchData = async () => {
setLoading(true)
try {
const { data } = await updateBillDateService(formModel.value)
console.log(formModel.value)
} catch (err) {
Message.error(t('man.operation.fail'))
} finally {
setLoading(false)
}
}
---------------------------------------------------------------- 请求封装
// 工作台 日期数据修改
export const updateBillDateService = (params: object) => {
return interceptor.post('/dataAnalysis/lastBillDateInfoEdit', params)
}
问题2:日期显示格式
value-format="YYYY年M月"
修改前:
修改后: