yuan
2 天以前 e83b458dad9bf8fcd98e889cf3cf234481014183
feat: 添加产品规格筛选功能,优化查询表单默认值和布局
已修改3个文件
127 ■■■■■ 文件已修改
src/views/collaborativeApproval/notificationManagement/meetIndex/index.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/procurementReport/index.vue 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/indicatorStats/index.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/collaborativeApproval/notificationManagement/meetIndex/index.vue
@@ -96,7 +96,8 @@
// 查询表单
const queryForm = reactive({
  meetingDate: dayjs().format('YYYY-MM-DD')
  // 默认查本周一(周例会日期),避免一进页面就是空看板
  meetingDate: dayjs().day(1).format('YYYY-MM-DD')
})
let loading = ref(false)
// 时间段(以半小时为间隔)
@@ -208,24 +209,23 @@
// 查询按钮操作
const handleSearch = async () => {
  loading.value = true
  let resp = await getMeetingUseList({...queryForm})
  // 后端按 date 字段过滤,必须把选择器上的 meetingDate 传成 date
  let resp = await getMeetingUseList({ date: queryForm.meetingDate })
  roomUsage.value = resp.data
  loading.value = false
}
// 重置搜索表单
const resetSearch = () => {
  queryForm.date = dayjs().format('YYYY-MM-DD')
  queryForm.meetingDate = dayjs().day(1).format('YYYY-MM-DD')
  handleSearch()
}
// 页面加载时获取数据
onMounted(() => {
  // 初始化时间槽
  initTimeSlots()
  // 默认查询今天的数据
  const today = new Date()
  queryForm.date = today.toISOString().split('T')[0]
  // 默认查询本周一的会议室使用情况
  handleSearch()
})
</script>
src/views/procurementManagement/procurementReport/index.vue
@@ -25,6 +25,22 @@
            style="width: 200px"
          />
        </el-form-item>
        <el-form-item label="产品规格:">
          <el-select
            v-model="searchForm.specificationModel"
            placeholder="请选择产品规格"
            clearable
            filterable
            style="width: 200px"
          >
            <el-option
              v-for="m in modelOptions"
              :key="m.value"
              :label="m.label"
              :value="m.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch" :loading="loading">
            查询
@@ -92,11 +108,15 @@
// 搜索表单
const searchForm = reactive({
  dateRange: [],
  productCategory: ''
  productCategory: '',
  specificationModel: ''
})
// 产品类别树选项
const productOptions = ref([])
// 产品规格选项(按报表实际出现的规格动态生成)
const modelOptions = ref([])
// 统计数据
const businessSummaryStats = ref({
@@ -234,53 +254,55 @@
  try {
    loading.value = true
    const params = {}
    // 时间范围
    if (searchForm.dateRange && searchForm.dateRange.length === 2) {
      params.entryDateStart = searchForm.dateRange[0]
      params.entryDateEnd = searchForm.dateRange[1]
    }
    // 产品类别
    // 产品大类
    if (searchForm.productCategory) {
      const categoryName = findNodeLabelById(productOptions.value, searchForm.productCategory)
      if (categoryName) {
        params.productCategory = categoryName
      }
    }
    // 分页参数
    params.current = page.current
    params.size = page.size
    // 报表按「产品大类+规格+供应商」聚合,数据量小,一次取回后按规格本地过滤
    params.current = 1
    params.size = 1000
    const res = await procurementBusinessSummaryListPage(params)
    if (res && res.data) {
      // 兼容后端可能直接返回数组/或返回分页对象
      businessSummaryData.value = Array.isArray(res.data) ? res.data : (res.data.records || [])
    const payload = res && res.data !== undefined ? res.data : res
    let rows = Array.isArray(payload) ? payload : ((payload && payload.records) || [])
      if (!Array.isArray(res.data)) {
        page.total = Number(res.data.total ?? 0)
        page.current = Number(res.data.current ?? page.current)
        page.size = Number(res.data.size ?? page.size)
      }
      // 计算统计数据
      if (businessSummaryData.value.length > 0) {
        businessSummaryStats.value.totalAmount = businessSummaryData.value.reduce((sum, item) => {
          return sum + (parseFloat(item.purchaseAmount) || 0)
        }, 0)
        businessSummaryStats.value.returnAmount = businessSummaryData.value.reduce((sum, item) => {
          return sum + (parseFloat(item.returnAmount) || 0)
        }, 0)
        businessSummaryStats.value.productTypes = businessSummaryData.value.length
      } else {
        businessSummaryStats.value = {
          totalAmount: 0,
          returnAmount: 0,
          productTypes: 0
        }
      }
    // 规格下拉选项随当前查询结果动态生成
    const specSet = []
    rows.forEach((item) => {
      const sp = item.specificationModel
      if (sp && specSet.indexOf(sp) === -1) specSet.push(sp)
    })
    modelOptions.value = specSet.sort().map((sp) => ({ label: sp, value: sp }))
    // 产品规格过滤
    if (searchForm.specificationModel) {
      rows = rows.filter((item) => item.specificationModel === searchForm.specificationModel)
    }
    page.total = rows.length
    if (page.current < 1) page.current = 1
    const startIdx = (page.current - 1) * page.size
    businessSummaryData.value = rows.slice(startIdx, startIdx + page.size)
    // 统计按全量过滤结果口径
    businessSummaryStats.value.totalAmount = rows.reduce((sum, item) => {
      return sum + (parseFloat(item.purchaseAmount) || 0)
    }, 0)
    businessSummaryStats.value.returnAmount = rows.reduce((sum, item) => {
      return sum + (parseFloat(item.returnAmount) || 0)
    }, 0)
    businessSummaryStats.value.productTypes = rows.length
  } catch (error) {
    console.error('查询失败:', error)
  } finally {
@@ -298,7 +320,8 @@
const resetSearch = () => {
  Object.assign(searchForm, {
    dateRange: [],
    productCategory: ''
    productCategory: '',
    specificationModel: ''
  })
  page.current = 1
  handleSearch()
@@ -326,7 +349,7 @@
onMounted(() => {
  // 初始化产品类别树
  // 初始化产品类别树、产品规格
  getProductOptions()
  
  // 设置默认时间范围为最近30天
src/views/salesManagement/indicatorStats/index.vue
@@ -60,21 +60,7 @@
      <!-- 图表筛选条件 -->
      <div class="chart-filter-section">
        <el-row :gutter="16" class="search-row">
          <el-col :xs="24" :sm="12" :md="6">
            <div class="filter-item">
              <label class="filter-label">产品类别</label>
              <el-tree-select
                v-model="indicatorFilter.productCategory"
                placeholder="请选择产品类别"
                clearable
                check-strictly
                :data="productOptions"
                :render-after-expand="false"
                style="width: 100%"
              />
            </div>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6">
          <el-col :xs="24" :sm="12" :md="8">
            <div class="filter-item">
              <label class="filter-label">客户</label>
              <el-select 
@@ -93,7 +79,7 @@
              </el-select>
            </div>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6">
          <el-col :xs="24" :sm="12" :md="8">
            <div class="filter-item">
              <label class="filter-label">日期范围</label>
              <el-date-picker 
@@ -107,7 +93,7 @@
              />
            </div>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6">
          <el-col :xs="24" :sm="12" :md="8">
            <div class="filter-item filter-buttons">
              <el-button type="primary" :loading="loading" @click="applyIndicatorFilter">
                <el-icon><Search /></el-icon>