gaoluyang
3 天以前 ecb800b7af57ecf5d14c41a6cf54a16c3be61094
src/views/production/components/useCoalData.js
@@ -3,7 +3,7 @@
 * 提供煤种数据的获取、缓存、转换等功能
 */
import { ref, computed, watch } from 'vue';
import { getCoalFieldList } from '@/api/basicInformation/coalQualityMaintenance';
import { getCoalInfoList } from "@/api/production";
import { ElMessage } from 'element-plus';
// 全局煤种数据缓存
@@ -33,7 +33,7 @@
    isLoading.value = true;
    try {
      const res = await getCoalFieldList();
      const res = await getCoalInfoList();
      if (res.code === 200) {
        coalData.value = res.data;
        isLoaded.value = true;
@@ -55,21 +55,21 @@
  const getCoalNameById = (id) => {
    if (!id || coalData.value.length === 0) return id;
    const coal = coalData.value.find(item => item.id == id);
    return coal ? coal.fieldName : id;
    return coal ? coal.coal : id;
  };
  // 根据名称获取煤种ID
  const getCoalIdByName = (name) => {
    if (!name || coalData.value.length === 0) return '';
    const coal = coalData.value.find(item => item.fieldName === name);
    const coal = coalData.value.find(item => item.coal === name);
    return coal ? coal.id : '';
  };
  // 生成下拉选项
  const coalOptions = computed(() => {
    return coalData.value.map(item => ({
      label: item.fieldName,
      value: item.fieldName,
      label: item.coal,
      value: item.coal,
      key: item.id
    }));
  });
@@ -78,7 +78,7 @@
  const coalMap = computed(() => {
    const map = {};
    coalData.value.forEach(item => {
      map[item.id] = item.fieldName;
      map[item.id] = item.coal;
    });
    return map;
  });