gaoluyang
2 天以前 e6d720a5ce9a278dc0855183eef292e11fb45651
1.库存管理页面联调
已修改2个文件
76 ■■■■ 文件已修改
src/api/warehouseManagement/index.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warehouseManagement/index.vue 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/warehouseManagement/index.js
@@ -36,8 +36,16 @@
// 审核入库
export function addOrEditCoalValue(query) {
    return request({
        url: '/basic/coalValue/addOrEditCoalValue',
        url: '/pendingInventory/addOrEditCoalValue',
        method: 'post',
        data: query
    })
}
// 根据id查询煤质方案查询
export function coalPlanById(query) {
    return request({
        url: '/coalPlan/coalPlanById',
        method: 'get',
        params: query
    })
}
src/views/warehouseManagement/index.vue
@@ -56,8 +56,8 @@
          <el-table-column label="煤质" align="center" v-if="activeTab=== 'officialInventory'" width="600">
            <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/>
          </el-table-column>
          <el-table-column prop="registrant" label="登记人" width="180"/>
          <el-table-column prop="registrationTime" label="登记日期" width="180"/>
          <el-table-column prop="registrantId" label="登记人" width="180"/>
          <el-table-column prop="registrationDate" label="登记日期" width="180"/>
          <el-table-column fixed="right" label="操作" min-width="60" align="center" v-if="activeTab !== 'officialInventory'">
            <template #default="scope">
              <el-button link type="primary" size="small" @click="reviewDia(scope.row)">审核</el-button>
@@ -97,7 +97,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存数量" prop="inventoryQuantity">
              <el-input v-model="form.inventoryQuantity" placeholder="请输入库存数量" maxlength="30" />
              <el-input v-model="form.inventoryQuantity" placeholder="请输入库存数量" :max="inventoryQuantity" type="number"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -121,7 +121,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="煤质方案" prop="qualityPlan">
              <el-select v-model="form.qualityPlan" placeholder="请选择" @change="coalFieldListOption" clearable>
              <el-select v-model="form.qualityPlan" placeholder="请选择" @change="coalPlanByIdList" clearable>
                <el-option
                    v-for="dict in qualityPlanOption"
                    :key="dict.id"
@@ -204,7 +204,7 @@
import Pagination from "@/components/Pagination/index.vue";
import {
  addOrEditCoalValue,
  coalFieldList,
  coalFieldList, coalPlanById,
  coalPlanList, officialInventoryList,
  pendingInventoryList
} from "@/api/warehouseManagement/index.js";
@@ -220,6 +220,7 @@
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
const inventoryQuantity = ref(0);
// 审核弹框
const reviewVisible = ref(false);
// 合并弹框
@@ -234,7 +235,7 @@
    totalPriceIncludingTax: '',
    costPerUnit: '',
    qualityPlan: '',
    planId: '',
    pId: '',
  },
  rules: {
    supplierName: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
@@ -260,7 +261,7 @@
})
const columnTitle = ref([])
onMounted(() => {
  handleTabClick({ props: { name: "supplier" } });
  handleTabClick({ props: { name: "pendingInbound" } });
});
// 标签页点击
const handleTabClick = (tab) => {
@@ -277,24 +278,37 @@
const getList = () => {
  tableLoading.value = true;
  // 赋值煤质表头展示字段
  columnTitle.value = [
    {prop: 'value1', label: '百分比1'},
    {prop: 'value2', label: '百分比2'},
    {prop: 'value3', label: '百分比3'},
  ]
  if (tabName.value === "pendingInbound") {
    pendingInventoryList({ ...queryParams }).then(res => {
    pendingInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      total.value = res.data.total;
    })
  } else {
    officialInventoryList({ ...queryParams }).then(res => {
    officialInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      const result = flattenFields(res.data.records);
      tableData.value = result;
      total.value = res.data.total;
      coalFieldListOption()
    })
  }
};
// 扁平化处理函数
const flattenFields = (data) => {
  return data.map(item => {
    const mergedFields = item.fields.reduce((acc, obj) => {
      const key = Object.keys(obj)[0];
      acc[key] = obj[key];
      return acc;
    }, {});
    // 合并主对象与提取出的 fields 字段
    return {
      ...item,
      ...mergedFields
    };
  });
};
// 重置查询
const resetQuery = () => {
@@ -313,7 +327,8 @@
const reviewDia = (row) => {
  reviewVisible.value = true
  form.value = {...row}
  form.value.planId = form.value.id
  form.value.pId = row.id
  inventoryQuantity.value = row.inventoryQuantity
  coalPlanListOptions()
}
// 查询煤质方案下拉框
@@ -323,12 +338,24 @@
  })
}
// 查询煤质方案字段
const coalFieldListOption = (id) => {
  coalFieldList({id: id}).then(res => {
const coalPlanByIdList = (id) => {
  coalPlanById({id: id}).then(res => {
    filteredList.value = res.data
    if (!id) {
    if(!id) {
      filteredList.value = []
    }
  })
}
// 查询煤质字段
const coalFieldListOption = () => {
  coalFieldList().then(res => {
    filteredList.value = res.data
    columnTitle.value = res.data.map(item => {
      return {
        prop: item.fields,
        label: item.fieldName // 使用 fieldName 作为 label
      };
    });
  })
}
// 合并库存数据方法
@@ -354,7 +381,6 @@
      delete form.value.registrationTime
      delete form.value.createTime
      delete form.value.updateTime
      delete form.value.id
      form.value.fieldValue = filteredList.value.map(item => ({
        [item.fields]: form.value[item.fields]
      }))