From c13c4e05372c7b9c462ce28ce78d81b4ffeb5e4b Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期一, 30 六月 2025 14:38:44 +0800
Subject: [PATCH] 配煤计算器-已有煤 匹配上煤种下拉信息 文档管理添加根据文档名查询文档
---
src/views/calculator/index.vue | 42 +++++-
src/views/archiveManagement/index.vue | 291 ++++++++++++++++++++++++++++--------------------
2 files changed, 203 insertions(+), 130 deletions(-)
diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue
index af8c450..ac6274d 100644
--- a/src/views/archiveManagement/index.vue
+++ b/src/views/archiveManagement/index.vue
@@ -5,23 +5,22 @@
<div class="tree-header">
<h3>鏂囨。绠$悊</h3>
<el-button icon="Plus" size="small" type="primary" @click="append('')"
- >鏂板
- </el-button
- >
+ >鏂板
+ </el-button>
</div>
<!-- 鎼滅储妗� -->
<div class="search-box">
<el-input
- v-model="filterText"
- clearable
- placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
- size="small"
- @input="handleFilter"
+ v-model="filterText"
+ clearable
+ placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
+ size="small"
+ @input="handleFilter"
>
<template #prefix>
<el-icon>
- <Search/>
+ <Search />
</el-icon>
</template>
</el-input>
@@ -29,62 +28,63 @@
<div class="tree-container">
<el-tree
- ref="treeRef"
- :data="treeData"
- :default-expand-all="false"
- :expand-on-click-node="false"
- :filter-node-method="filterNode"
- :props="props"
- class="custom-tree"
- node-key="id"
- @node-click="handleNodeClick"
+ ref="treeRef"
+ :data="treeData"
+ :default-expand-all="false"
+ :expand-on-click-node="false"
+ :filter-node-method="filterNode"
+ :props="props"
+ class="custom-tree"
+ node-key="id"
+ @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"
- :class="{ expanded: node.expanded }"
+ v-if="!node.isLeaf"
+ :class="{ expanded: node.expanded }"
>
- <Folder/>
+ <Folder />
</el-icon>
<el-icon v-else>
- <Document/>
+ <Document />
</el-icon>
</div>
<div class="node-label">
<span v-if="!data.isEdit" class="label-text">{{
- node.label
- }}</span>
+ node.label
+ }}</span>
<el-input
- v-else
- :ref="(el) => setInputRef(el, data)"
- v-model="newName"
- autofocus
- class="tree-input"
- placeholder="璇疯緭鍏ヨ妭鐐瑰悕绉�"
- size="small"
- @blur="(event) => handleInputBlur(event, data, node)"
- @keyup.enter="
- (event) => handleInputBlur(event, data, node)
- "
+ v-else
+ :ref="(el) => setInputRef(el, data)"
+ v-model="newName"
+ autofocus
+ class="tree-input"
+ placeholder="璇疯緭鍏ヨ妭鐐瑰悕绉�"
+ size="small"
+ @blur="(event) => handleInputBlur(event, data, node)"
+ @keyup.enter="(event) => handleInputBlur(event, data, node)"
/>
</div>
<div v-show="!data.isEdit" class="node-actions">
<el-button
- icon="Plus"
- link
- size="small"
- title="鏂板瀛愯妭鐐�"
- @click.stop="append(data)"
+ icon="Plus"
+ link
+ size="small"
+ title="鏂板瀛愯妭鐐�"
+ @click.stop="append(data)"
></el-button>
<el-button
- icon="Delete"
- link
- size="small"
- title="鍒犻櫎"
- @click.stop="remove(node, data)"
+ icon="Delete"
+ link
+ size="small"
+ title="鍒犻櫎"
+ @click.stop="remove(node, data)"
></el-button>
</div>
</div>
@@ -95,65 +95,103 @@
</div>
<div class="right">
<el-row :gutter="24">
- <el-col :offset="20" :span="2"
- >
- <el-button :icon="Delete" type="danger" @click="delHandler">鍒犻櫎</el-button>
- </el-col
- >
- <el-col :span="2"
- >
- <el-button
- :disabled="!tableSwitch"
- :icon="Plus"
- type="primary"
- @click="add"
- >鏂板
- </el-button
+ <el-col :span="10">
+ <div>
+ <el-input
+ style="float: left; width: 50%"
+ v-model="searchText"
+ placeholder="璇疯緭鍏ュ叧閿瓧鏌ヨ鏂囦欢"
+ clearable
+ @input="handleSearch"
+ @clear="handleSearch"
+ >
+ <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
- >
+ </el-col>
+ <el-col :span="2">
+ <el-button
+ :disabled="!tableSwitch"
+ :icon="Plus"
+ type="primary"
+ @click="add"
+ >鏂板
+ </el-button>
+ </el-col>
</el-row>
<ETable
- :border="true"
- :columns="columns"
- :loading="loading"
- :maxHeight="1200"
- :show-selection="true"
- :table-data="tableData"
- @edit="handleEdit"
- @selection-change="handleSelectionChange"
+ :border="true"
+ :columns="columns"
+ :loading="loading"
+ :maxHeight="1200"
+ :show-selection="true"
+ :table-data="tableData"
+ @edit="handleEdit"
+ @selection-change="handleSelectionChange"
>
</ETable>
<Pagination
- :layout="'total, prev, pager, next, jumper'"
- :limit="queryParams.pageSize"
- :page="queryParams.current"
- :show-total="true"
- :total="total"
- @pagination="handlePageChange"
+ :layout="'total, prev, pager, next, jumper'"
+ :limit="queryParams.pageSize"
+ :page="queryParams.current"
+ :show-total="true"
+ :total="total"
+ @pagination="handlePageChange"
></Pagination>
</div>
<archiveDialog
- ref="archiveDialogs"
- v-model:centerDialogVisible="dialogVisible"
- :row="row"
- @centerDialogVisible="centerDialogVisible"
- @submitForm="submitForm"
-
+ ref="archiveDialogs"
+ v-model:centerDialogVisible="dialogVisible"
+ :row="row"
+ @centerDialogVisible="centerDialogVisible"
+ @submitForm="submitForm"
>
</archiveDialog>
</el-card>
</template>
<script setup>
-import {nextTick, onMounted, reactive, ref} from "vue";
+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([]);
@@ -171,9 +209,9 @@
// ===== 閰嶇疆甯搁噺 =====
const columns = [
- {prop: "name", label: "鍚嶇О", minWidth: 180},
- {prop: "type", label: "绫诲瀷", minWidth: 120},
- {prop: "status", label: "鐘舵��", minWidth: 100},
+ { prop: "name", label: "鍚嶇О", minWidth: 180 },
+ { prop: "type", label: "绫诲瀷", minWidth: 120 },
+ { prop: "status", label: "鐘舵��", minWidth: 100 },
];
const queryParams = reactive({
@@ -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 = [];
@@ -250,10 +296,10 @@
total.value = 0;
return;
}
-
+
tableData.value = res.data?.records || res.data || [];
total.value = res.data?.total || 0;
-
+
if (res.data?.current) {
queryParams.current = res.data.current;
}
@@ -306,17 +352,17 @@
row.value = isEdit ? { ...rowData } : {};
newName.value = "";
dialogVisible.value = true;
-
+
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,11 +377,14 @@
}
try {
- await showConfirm(`纭畾瑕佸垹闄ら�変腑鐨� ${selectedRows.length} 鏉¤褰曞悧锛焋, '鍒犻櫎纭');
-
+ await showConfirm(
+ `纭畾瑕佸垹闄ら�変腑鐨� ${selectedRows.length} 鏉¤褰曞悧锛焋,
+ "鍒犻櫎纭"
+ );
+
const ids = selectedRows.map((row) => row.id);
const { code, msg } = await delArchive(ids);
-
+
if (code !== 200) {
ElMessage.error("鍒犻櫎澶辫触: " + msg);
return;
@@ -344,9 +393,8 @@
showSuccess("鍒犻櫎鎴愬姛");
await getArchiveListData();
selectedRows.splice(0, selectedRows.length);
-
} catch (error) {
- if (error !== 'cancel') {
+ if (error !== "cancel") {
handleError(error, "鍒犻櫎鎿嶄綔澶辫触");
}
}
@@ -359,10 +407,10 @@
}
try {
- await showConfirm(`纭畾瑕佸垹闄よ妭鐐� "${data.name}" 鍚楋紵`, '鍒犻櫎纭');
-
+ await showConfirm(`纭畾瑕佸垹闄よ妭鐐� "${data.name}" 鍚楋紵`, "鍒犻櫎纭");
+
const { code, msg } = await delTree([data.id]);
-
+
if (code !== 200) {
ElMessage.error("鍒犻櫎澶辫触: " + msg);
return;
@@ -370,9 +418,8 @@
showSuccess("鍒犻櫎鎴愬姛");
await getList();
-
} catch (error) {
- if (error !== 'cancel') {
+ if (error !== "cancel") {
handleError(error, "鍒犻櫎鑺傜偣澶辫触");
}
}
@@ -405,37 +452,38 @@
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();
-
+
if (comeTreeData.name === newValue) return;
-
+
if (!newValue) {
newName.value = comeTreeData.name || "鏂拌妭鐐�";
ElMessage.warning("鑺傜偣鍚嶇О涓嶈兘涓虹┖");
return;
}
-
+
const parentId = node?.parent?.data?.id || null;
-
+
const result = await addOrEditTree({
name: newValue,
parentId,
id: comeTreeData.id || null,
});
-
+
if (result.code === 200) {
comeTreeData.name = newValue;
if (!comeTreeData.id && result.data) {
comeTreeData.id = result.data.id || result.data;
}
showSuccess("淇濆瓨鎴愬姛");
-
+
const currentNodeId = comeTreeData.id;
await getList();
-
+
nextTick(() => {
if (currentNodeId && treeRef.value) {
const targetNode = treeRef.value.getNode(currentNodeId);
@@ -449,7 +497,6 @@
comeTreeData.name = comeTreeData.name || "鏂拌妭鐐�";
ElMessage.error("淇濆瓨澶辫触: " + (result.msg || "鏈煡閿欒"));
}
-
} catch (error) {
handleError(error, "淇濆瓨鑺傜偣澶辫触");
comeTreeData.name = comeTreeData.name || "鏂拌妭鐐�";
@@ -489,14 +536,14 @@
const nodeKey = data.id || data;
const node = treeRef.value?.getNode(nodeKey);
const isExpanded = node?.expanded;
-
+
// 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣
if (hasChildren && !isExpanded && treeRef.value?.store?.nodesMap[nodeKey]) {
treeRef.value.store.nodesMap[nodeKey].expanded = true;
}
-
+
const newNode = createNewNode("鏂板瓙鑺傜偣");
-
+
if (!data.children) {
data.children = [];
}
diff --git a/src/views/calculator/index.vue b/src/views/calculator/index.vue
index 9e6fe8c..1080232 100644
--- a/src/views/calculator/index.vue
+++ b/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"; // 鍋囪鏈変竴涓狝PI鑾峰彇鐓ょ淇℃伅
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("鑾峰彇鐓ょ淇℃伅澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+});
// 绾挎�ц鍒掓眰瑙e嚱鏁�
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>
--
Gitblit v1.9.3