zhang_12370
2025-06-30 c13c4e05372c7b9c462ce28ce78d81b4ffeb5e4b
配煤计算器-已有煤 匹配上煤种下拉信息
文档管理添加根据文档名查询文档
已修改2个文件
157 ■■■■ 文件已修改
src/views/archiveManagement/index.vue 115 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/calculator/index.vue 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/archiveManagement/index.vue
@@ -6,8 +6,7 @@
          <h3>文档管理</h3>
          <el-button icon="Plus" size="small" type="primary" @click="append('')"
          >新增
          </el-button
          >
          </el-button>
        </div>
        <!-- 搜索框 -->
@@ -40,7 +39,10 @@
              @node-click="handleNodeClick"
          >
            <template #default="{ node, data }">
              <div class="tree-node-content" @dblclick="headerDbClick(node,data)">
              <div
                class="tree-node-content"
                @dblclick="headerDbClick(node, data)"
              >
                <div class="node-icon">
                  <el-icon
                      v-if="!node.isLeaf"
@@ -66,9 +68,7 @@
                      placeholder="请输入节点名称"
                      size="small"
                      @blur="(event) => handleInputBlur(event, data, node)"
                      @keyup.enter="
                      (event) => handleInputBlur(event, data, node)
                    "
                    @keyup.enter="(event) => handleInputBlur(event, data, node)"
                  />
                </div>
                <div v-show="!data.isEdit" class="node-actions">
@@ -95,23 +95,43 @@
    </div>
    <div class="right">
      <el-row :gutter="24">
        <el-col :offset="20" :span="2"
        <el-col :span="10">
          <div>
            <el-input
              style="float: left; width: 50%"
              v-model="searchText"
              placeholder="请输入关键字查询文件"
              clearable
              @input="handleSearch"
              @clear="handleSearch"
        >
          <el-button :icon="Delete" type="danger" @click="delHandler">删除</el-button>
        </el-col
              <template #prefix>
                <el-icon>
                  <Search />
                </el-icon>
              </template>
              <template #suffix>
                <el-button @click="handleSearch" link style="border: none">
                  <span>搜索</span>
                </el-button>
              </template>
            </el-input>
          </div>
        </el-col>
        <el-col :offset="10" :span="2">
          <el-button :icon="Delete" type="danger" @click="delHandler"
            >删除</el-button
        >
        <el-col :span="2"
        >
        </el-col>
        <el-col :span="2">
          <el-button
              :disabled="!tableSwitch"
              :icon="Plus"
              type="primary"
              @click="add"
          >新增
          </el-button
          >
        </el-col
        >
          </el-button>
        </el-col>
      </el-row>
      <ETable
          :border="true"
@@ -139,7 +159,6 @@
        :row="row"
        @centerDialogVisible="centerDialogVisible"
        @submitForm="submitForm"
    >
    </archiveDialog>
  </el-card>
@@ -147,13 +166,32 @@
<script setup>
import {nextTick, onMounted, reactive, ref} from "vue";
import ETable from "@/components/Table/ETable.vue";
import {ElButton, ElIcon, ElInput, ElMessage, ElMessageBox} from "element-plus";
import {
  ElButton,
  ElIcon,
  ElInput,
  ElMessage,
  ElMessageBox,
} from "element-plus";
import archiveDialog from "./mould/archiveDialog.vue";
import Pagination from "@/components/Pagination/index.vue";
import {Delete, Document, Folder, Plus, Search,} from "@element-plus/icons-vue";
import {addOrEditTree, delArchive, delTree, getArchiveList, getTree,} from "@/api/archiveManagement";
import {
  Delete,
  Document,
  Folder,
  Plus,
  Search,
} from "@element-plus/icons-vue";
import {
  addOrEditTree,
  delArchive,
  delTree,
  getArchiveList,
  getTree,
} from "@/api/archiveManagement";
// ===== 响应式状态管理 =====
const searchText = ref("");
const dialogVisible = ref(false);
const loading = ref(false);
const tableData = ref([]);
@@ -199,11 +237,18 @@
  ElMessage.success(msg);
};
// 搜索查询函数
const handleSearch = () => {
  queryParams.searchAll = searchText.value;
  queryParams.current = 1; // 重置到第一页
  getArchiveListData();
};
const showConfirm = (message, title = "确认操作") => {
  return ElMessageBox.confirm(message, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  });
};
@@ -228,7 +273,8 @@
const getList = async () => {
  try {
    const res = await getTree();
    treeData.value = res.code === 200 ? (res.data?.records || res.data || []) : [];
    treeData.value =
      res.code === 200 ? res.data?.records || res.data || [] : [];
  } catch (error) {
    handleError(error, "获取树结构数据失败");
    treeData.value = [];
@@ -309,14 +355,14 @@
    
    nextTick(() => {
      if (archiveDialogs.value) {
        const method = isEdit ? 'editForm' : 'initForm';
        if (typeof archiveDialogs.value[method] === 'function') {
        const method = isEdit ? "editForm" : "initForm";
        if (typeof archiveDialogs.value[method] === "function") {
          archiveDialogs.value[method](isEdit ? rowData : rowClickData.value);
        }
      }
    });
  } catch (error) {
    handleError(error, `打开${isEdit ? '编辑' : '新增'}界面失败`);
    handleError(error, `打开${isEdit ? "编辑" : "新增"}界面失败`);
  }
};
@@ -331,7 +377,10 @@
  }
  try {
    await showConfirm(`确定要删除选中的 ${selectedRows.length} 条记录吗?`, '删除确认');
    await showConfirm(
      `确定要删除选中的 ${selectedRows.length} 条记录吗?`,
      "删除确认"
    );
    
    const ids = selectedRows.map((row) => row.id);
    const { code, msg } = await delArchive(ids);
@@ -344,9 +393,8 @@
    showSuccess("删除成功");
    await getArchiveListData();
    selectedRows.splice(0, selectedRows.length);
  } catch (error) {
    if (error !== 'cancel') {
    if (error !== "cancel") {
      handleError(error, "删除操作失败");
    }
  }
@@ -359,7 +407,7 @@
  }
  try {
    await showConfirm(`确定要删除节点 "${data.name}" 吗?`, '删除确认');
    await showConfirm(`确定要删除节点 "${data.name}" 吗?`, "删除确认");
    
    const { code, msg } = await delTree([data.id]);
    
@@ -370,9 +418,8 @@
    showSuccess("删除成功");
    await getList();
  } catch (error) {
    if (error !== 'cancel') {
    if (error !== "cancel") {
      handleError(error, "删除节点失败");
    }
  }
@@ -405,7 +452,8 @@
const handleInputBlur = async (event, comeTreeData, node) => {
  try {
    if (!comeTreeData.isEdit || (event.relatedTarget?.tagName === "BUTTON")) return;
    if (!comeTreeData.isEdit || event.relatedTarget?.tagName === "BUTTON")
      return;
    
    comeTreeData.isEdit = false;
    const newValue = newName.value.trim();
@@ -449,7 +497,6 @@
      comeTreeData.name = comeTreeData.name || "新节点";
      ElMessage.error("保存失败: " + (result.msg || "未知错误"));
    }
  } catch (error) {
    handleError(error, "保存节点失败");
    comeTreeData.name = comeTreeData.name || "新节点";
src/views/calculator/index.vue
@@ -68,7 +68,8 @@
                  style="margin-bottom: 15px"
                >
                  <el-row :gutter="16">
                    <el-col :span="6">                      <el-form-item label="煤种类型">
                    <el-col :span="6">
                      <el-form-item label="煤种类型">
                        <el-select
                          v-model="item.type"
                          placeholder="请选择"
@@ -79,7 +80,8 @@
                          <el-option label="未知煤" value="未知煤" />
                        </el-select>
                      </el-form-item>
                    </el-col>                    <el-col :span="6">
                    </el-col>
                    <el-col :span="6">
                      <el-form-item :label="'煤种' + (index + 1)">
                        <div class="input-wrapper">
                          <el-input
@@ -88,14 +90,20 @@
                            placeholder="请输入"
                            style="width: 100%"
                          />
                          <el-select
                            v-model="item.name"
                            v-show="item.type === '已有煤'"
                            placeholder="请选择"
                            style="width: 100%"
                          >
                            <el-option label="已有煤" value="已有煤" />
                            <el-option label="未知煤" value="未知煤" />
                            <el-option
                              v-for="ele in coalInfoList"
                              :key="ele.key"
                              :label="ele.value"
                              :value="ele.key"
                            >{{ ele.value }}
                          </el-option>
                          </el-select>
                        </div>
                      </el-form-item>
@@ -397,8 +405,9 @@
</template>
<script setup>
import { reactive, toRefs, nextTick } from "vue";
import { reactive, toRefs, nextTick, onMounted } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { getCoalInfoList } from "@/api/procureMent"; // 假设有一个API获取煤种信息
const data = reactive({
  formInline: {
@@ -450,7 +459,22 @@
    error: null,
  },
});
const coalInfoList = ref([]);
// onMounted
onMounted(async () => {
  let result = await getCoalInfoList();
  if (result.code === 200) {
    result.data.forEach((item) => {
      let obj = {
        value: item.coal,
        key: item.id,
      };
      coalInfoList.value.push(obj);
    });
  } else {
    ElMessage.error("获取煤种信息失败,请稍后重试");
  }
});
// 线性规划求解函数
const solveBlend = (coals, constraints) => {
  // 数据验证
@@ -594,6 +618,7 @@
};
const submitForm = () => {
  console.log(coalForms.value)
  // 数据验证
  let validCoals = coalForms.value.filter(
    (coal) => coal.name && coal.cv && coal.price
@@ -724,13 +749,14 @@
      sulfur: "",
      ash: "",
      moisture: "",
    });  }
    });
  }
};
// 处理煤种类型变化
const handleCoalTypeChange = (index) => {
  // 当煤种类型改变时,清空煤种名称,避免数据混乱
  coalForms.value[index].name = '';
  coalForms.value[index].name = "";
};
</script>