From df1406d0f571972d033dffd6a93fb4b94febeb56 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期二, 24 六月 2025 16:46:44 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/index.vue | 546 +++++++++++ src/views/production/components/ProductionDetailsTable.vue | 163 +- src/views/production/components/useDialog.js | 90 .gitignore | 1 src/views/production/index.vue | 91 src/views/archiveManagement/index.vue | 207 ++-- src/views/basicInformation/mould/supplier.vue | 74 src/views/production/components/useTableData.js | 236 ++-- src/views/basicInformation/mould/customer.vue | 94 + src/views/production/components/ProductionDialog.vue | 239 ++-- src/views/basicInformation/index.vue | 205 ++-- src/views/procureMent/index.vue | 69 + src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue | 56 src/views/archiveManagement/mould/archiveDialog.vue | 77 src/views/procureMent/components/ProductionDialog.vue | 160 +- src/views/basicInformation/mould/coal.vue | 253 ++-- package.json | 2 src/components/Table/EtableModify.vue | 63 src/components/FileUpload/index.vue | 3 src/views/production/components/useCoalData.js | 152 +- src/views/basicInformation/mould/coalQualityMaintenance.vue | 49 21 files changed, 1,718 insertions(+), 1,112 deletions(-) diff --git a/.gitignore b/.gitignore index 78a752d..2d7a5c8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ package-lock.json yarn.lock +pnpm-lock.yaml \ No newline at end of file diff --git a/package.json b/package.json index 1e90630..633d6a8 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "axios": "0.28.1", "clipboard": "2.0.11", "default-passive-events": "^4.0.0", - "echarts": "5.5.1", + "echarts": "^5.6.0", "element-china-area-data": "^6.1.0", "element-plus": "2.7.6", "file-saver": "2.0.5", diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 6801d90..735fc22 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -231,10 +231,11 @@ } // 妗岄潰绔笅杞� const link = document.createElement("a"); - link.href = url; + link.href = file.downloadUrl; link.download = file.bucketFilename || file.key; link.click(); }; + // 涓婁紶鍓嶆牎楠� const handleBeforeUpload = (file) => { // 鏍¢獙鏂囦欢鍚嶇壒娈婂瓧绗� diff --git a/src/components/Table/EtableModify.vue b/src/components/Table/EtableModify.vue index 9afb58d..b42e487 100644 --- a/src/components/Table/EtableModify.vue +++ b/src/components/Table/EtableModify.vue @@ -28,33 +28,35 @@ type="index" width="60" align="center" - /> - <template v-for="col in columns" :key="col.prop"> + /> <template v-for="col in columns" :key="col.prop"> <el-table-column v-bind="col" - :show-overflow-tooltip="false" align="center" > <template #default="scope"> <template v-if="col.slot"> - <slot></slot> - </template> - <template v-else> + <slot + :name="col.prop" + :row="scope.row" + :column="scope.column" + :index="scope.$index" + ></slot> + </template> <template v-else> <div class="cell-edit" @dblclick="handleCellEdit(scope.row, col.prop)" :class="{ editable: isColumnEditable(col.prop) }" > + <!-- 鏄剧ず鐘舵�侊細浣跨敤鏍煎紡鍖栫殑鍊� --> <span v-if="!scope.row.editing || !scope.row.editing[col.prop]" class="cell-text" > {{ - scope.row[col.prop] == null || scope.row[col.prop] === "" - ? "--" - : scope.row[col.prop] + formatCellValue(scope.row, scope.column, scope.row[col.prop], col) }} </span> + <!-- 缂栬緫鐘舵�侊細浣跨敤鍘熷鍊硷紝涓嶇粡杩囨牸寮忓寲 --> <el-input v-else v-model="scope.row[col.prop]" @@ -69,34 +71,6 @@ </template> </el-table-column> </template> - <!-- 鎿嶄綔鍒� --> - <el-table-column - v-if="showOperations" - :label="operationsLabel" - :width="operationsWidth" - fixed="right" - align="center" - > - <template #default="scope"> - <slot name="operations" :row="scope.row"> - <el-button - v-if="operations.includes('edit')" - link - type="primary" - size="small" - @click="handleEdit(scope.row)" - >缂栬緫</el-button - > - <!-- <el-button--> - <!-- v-if="operations.includes('delete')"--> - <!-- link--> - <!-- type="danger"--> - <!-- size="small"--> - <!-- @click="handleDelete(scope.row)"--> - <!-- >鍒犻櫎</el-button>--> - </slot> - </template> - </el-table-column> </el-table> </template> @@ -217,7 +191,22 @@ // 妫�鏌ヨ鍒楀湪鎵�鏈夋暟鎹腑鏄惁鏈夐潪绌哄�� return data.some((row) => row[col.prop] != null && row[col.prop] !== ""); }; +// 榛樿鐨勬牸寮忓寲鍑芥暟 +const defaultFormatter = (row, column, cellValue) => { + return cellValue == null || cellValue === "" || cellValue === 0 + ? "0" + : cellValue; +}; +// 鏍煎紡鍖栧崟鍏冩牸鍊� +const formatCellValue = (row, column, cellValue, col) => { + // 濡傛灉鍒楁湁鑷畾涔夋牸寮忓寲鍣紝浣跨敤鑷畾涔夋牸寮忓寲鍣� + if (col.formatter && typeof col.formatter === 'function') { + return col.formatter(row, column, cellValue); + } + // 鍚﹀垯浣跨敤榛樿鏍煎紡鍖栧櫒 + return defaultFormatter(row, column, cellValue); +}; // 澶勭悊鍗曞厓鏍肩紪杈� const handleCellEdit = (row, prop) => { // 濡傛灉涓嶅厑璁哥紪杈戝崟鍏冩牸锛岀洿鎺ヨ繑鍥� diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue index 7e7c65d..28a4d06 100644 --- a/src/views/archiveManagement/index.vue +++ b/src/views/archiveManagement/index.vue @@ -4,84 +4,87 @@ <div class="left-content"> <div class="tree-header"> <h3>鏂囨。绠$悊</h3> - <el-button type="primary" size="small" @click="append('')" icon="Plus" - >鏂板</el-button + <el-button icon="Plus" size="small" type="primary" @click="append('')" + >鏂板 + </el-button > </div> <!-- 鎼滅储妗� --> <div class="search-box"> <el-input - v-model="filterText" - placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" - size="small" - clearable - @input="handleFilter" + v-model="filterText" + clearable + placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" + size="small" + @input="handleFilter" > <template #prefix> - <el-icon><Search /></el-icon> + <el-icon> + <Search/> + </el-icon> </template> </el-input> </div> <div class="tree-container"> <el-tree - ref="treeRef" - :data="treeData" - :props="props" - :filter-node-method="filterNode" - :expand-on-click-node="false" - :default-expand-all="false" - node-key="id" - @node-click="handleNodeClick" - class="custom-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" > <template #default="{ node, data }"> <div class="tree-node-content" @dblclick="headerDbClick(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)" - placeholder="璇疯緭鍏ヨ妭鐐瑰悕绉�" - v-model="newName" - @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) " - size="small" - class="tree-input" - autofocus /> </div> - <div class="node-actions" v-show="!data.isEdit"> + <div v-show="!data.isEdit" class="node-actions"> <el-button - link - size="small" - @click.stop="append(data)" - icon="Plus" - title="鏂板瀛愯妭鐐�" + icon="Plus" + link + size="small" + title="鏂板瀛愯妭鐐�" + @click.stop="append(data)" ></el-button> <el-button - link - size="small" - @click.stop="remove(node, data)" - icon="Delete" - title="鍒犻櫎" + icon="Delete" + link + size="small" + title="鍒犻櫎" + @click.stop="remove(node, data)" ></el-button> </div> </div> @@ -92,71 +95,64 @@ </div> <div class="right"> <el-row :gutter="24"> - <el-col :span="2" :offset="20" - ><el-button :icon="Delete" type="danger" @click="delHandler">鍒犻櫎</el-button></el-col + <el-col :offset="20" :span="2" + > + <el-button :icon="Delete" type="danger" @click="delHandler">鍒犻櫎</el-button> + </el-col > <el-col :span="2" - ><el-button - :icon="Plus" - type="primary" - @click="add" - :disabled="!tableData.length" - >鏂板</el-button - ></el-col + > + <el-button + :disabled="!tableSwitch" + :icon="Plus" + type="primary" + @click="add" + >鏂板 + </el-button + > + </el-col > </el-row> <ETable - :maxHeight="1200" - :loading="loading" - :table-data="tableData" - :columns="columns" - @selection-change="handleSelectionChange" - @edit="handleEdit" - :show-selection="true" - :border="true" + :border="true" + :columns="columns" + :loading="loading" + :maxHeight="1200" + :show-selection="true" + :table-data="tableData" + @edit="handleEdit" + @selection-change="handleSelectionChange" > </ETable> <Pagination - :total="total" - :page="queryParams.current" - :limit="queryParams.pageSize" - :show-total="true" - @pagination="handlePageChange" - :layout="'total, prev, pager, next, jumper'" + :layout="'total, prev, pager, next, jumper'" + :limit="queryParams.pageSize" + :page="queryParams.current" + :show-total="true" + :total="total" + @pagination="handlePageChange" ></Pagination> </div> <archiveDialog - v-model:centerDialogVisible="dialogVisible" - @centerDialogVisible="centerDialogVisible" - :row="row" - @submitForm="submitForm" - ref="archiveDialogs" + ref="archiveDialogs" + v-model:centerDialogVisible="dialogVisible" + :row="row" + @centerDialogVisible="centerDialogVisible" + @submitForm="submitForm" > </archiveDialog> </el-card> </template> <script setup> -import { onMounted, ref, nextTick, reactive } from "vue"; +import {nextTick, onMounted, reactive, ref} from "vue"; import ETable from "@/components/Table/ETable.vue"; -import { ElButton, ElInput, ElIcon, ElMessage } from "element-plus"; +import {ElButton, ElIcon, ElInput, ElMessage} from "element-plus"; import archiveDialog from "./mould/archiveDialog.vue"; import Pagination from "@/components/Pagination/index.vue"; -import { - Plus, - Search, - Folder, - Document, - Delete, -} from "@element-plus/icons-vue"; -import { - getTree, - addOrEditTree, - delTree, - getArchiveList, - addOrEditArchive, - delArchive, -} from "@/api/archiveManagement"; +import {Delete, Document, Folder, Plus, Search,} from "@element-plus/icons-vue"; +import {addOrEditTree, delArchive, delTree, getArchiveList, getTree,} from "@/api/archiveManagement"; + const dialogVisible = ref(false); // 鎺у埗褰掓。瀵硅瘽妗嗘樉绀� const loading = ref(false); const tableData = ref([]); @@ -167,9 +163,9 @@ const treeRef = ref(); // 鏍戠粍浠跺紩鐢� const total = ref(0); // 鎬昏褰曟暟 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 selectedRows = reactive([]); // 瀛樺偍閫変腑琛屾暟鎹� const handleSelectionChange = (selection) => { @@ -192,7 +188,6 @@ }; const submitForm = async (res) => { if (res && res.code === 200) { - ElMessage.success("鎿嶄綔鎴愬姛"); // 鍒锋柊鍒楄〃鏁版嵁 await getArchiveListData(); } else { @@ -201,8 +196,10 @@ } const centerDialogVisible = (val) => { }; +const tableSwitch = ref(false); // 澶勭悊鑺傜偣鐐瑰嚮 -const handleNodeClick = async (data) => { +const handleNodeClick = (data) => { + tableSwitch.value = true; // 鍒囨崲鑺傜偣鏃堕噸缃埌绗竴椤� queryParams.current = 1; queryParams.treeId = data.id; @@ -217,7 +214,7 @@ archiveDialogs.value.initForm(); // 閲嶇疆琛ㄥ崟 }; // 澶勭悊鍒嗛〉鍙樺寲 -const handlePageChange = ({ page }) => { +const handlePageChange = ({page}) => { queryParams.current = page; // pageSize 鍥哄畾涓�20锛屼笉鍐嶄粠鍙傛暟涓幏鍙� getArchiveListData(); @@ -238,7 +235,6 @@ total.value = 0; return; } - tableData.value = res.data?.records || res.data || []; total.value = res.data?.total || 0; // 纭繚鍒嗛〉鍙傛暟姝g‘鏇存柊 @@ -262,7 +258,7 @@ } try { const ids = selectedRows.map((row) => row.id); - const { code, msg } = await delArchive(ids); + const {code, msg} = await delArchive(ids); if (code !== 200) { ElMessage.warning("鍒犻櫎澶辫触: " + msg); } else { @@ -303,6 +299,7 @@ // 澶勭悊杈撳叆妗嗗け鐒� const handleInputBlur = async (event, comeTreeData, node) => { if (!comeTreeData.isEdit) return; // 濡傛灉涓嶆槸缂栬緫鐘舵�侊紝鐩存帴杩斿洖 + console.log("handleInputBlur", event, comeTreeData, node); if (event.relatedTarget && event.relatedTarget.tagName === "BUTTON") { return; } @@ -344,7 +341,7 @@ if (!data || !data.id) { return; } - let { code, msg } = await delTree([data.id]); + let {code, msg} = await delTree([data.id]); if (code !== 200) { ElMessage.warning("鍒犻櫎澶辫触, " + msg); } else { @@ -378,9 +375,9 @@ const isExpanded = node?.expanded; // 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣 if (hasChildren && !isExpanded) { if ( - treeRef.value && - treeRef.value.store && - treeRef.value.store.nodesMap[nodeKey] + treeRef.value && + treeRef.value.store && + treeRef.value.store.nodesMap[nodeKey] ) { treeRef.value.store.nodesMap[nodeKey].expanded = true; } @@ -439,7 +436,7 @@ } }; </script> -<style scoped lang="scss"> +<style lang="scss" scoped> .custom-tree-node { flex: 1; display: flex; @@ -630,11 +627,13 @@ } } } + .el-card { width: calc(100% - 40px); height: calc(100vh - 130px); margin: 20px; box-sizing: border-box; + .left { width: 30%; height: calc(100vh - 160px); @@ -651,13 +650,15 @@ flex-direction: column; } } + .right { width: 70%; height: calc(100vh - 160px); - padding: 0px 10px; + padding: 0 10px; float: left; } } + .archive-management-card { margin: 0; } diff --git a/src/views/archiveManagement/mould/archiveDialog.vue b/src/views/archiveManagement/mould/archiveDialog.vue index 793d222..55c359c 100644 --- a/src/views/archiveManagement/mould/archiveDialog.vue +++ b/src/views/archiveManagement/mould/archiveDialog.vue @@ -1,28 +1,28 @@ <template> <el-dialog v-model="centerDialogVisible" title="鏂囨。绠$悊" width="500" center> <el-form - ref="ruleFormRef" - style="max-width: 600px" - :model="ruleForm" - :rules="rules" - label-width="auto" + ref="ruleFormRef" + style="max-width: 600px" + :model="ruleForm" + :rules="rules" + label-width="auto" > <el-form-item label="鍚嶇О" prop="name"> - <el-input v-model="ruleForm.name" placeholder="璇疯緭鍏ユ枃妗e悕绉�" /> + <el-input v-model="ruleForm.name" placeholder="璇疯緭鍏ユ枃妗e悕绉�"/> </el-form-item> <el-form-item label="璇疯緭鍏ユ枃妗g被鍨�" prop="type"> <el-select v-model="ruleForm.type" placeholder="璇疯緭鍏ユ枃妗g被鍨�"> - <el-option label="鍚堝悓" value="鍚堝悓" /> - <el-option label="鎶ュ憡" value="鎶ュ憡" /> + <el-option label="鍚堝悓" value="鍚堝悓"/> + <el-option label="鎶ュ憡" value="鎶ュ憡"/> </el-select> </el-form-item> <el-form-item label="璇疯緭鍏ユ枃妗g姸鎬�" prop="status"> <el-select v-model="ruleForm.status" placeholder="璇疯緭鍏ユ枃妗g姸鎬�"> <el-option - v-for="option in options" - :key="option.value" - :label="option.label" - :value="option.value" + v-for="option in options" + :key="option.value" + :label="option.label" + :value="option.value" /> </el-select> </el-form-item> @@ -31,26 +31,26 @@ <el-row> <el-col :span="24" style="text-align: right"> <el-button @click="centerDialogVisible = false">鍙� 娑�</el-button> - <el-button type="primary" @click="submit"> 纭� 瀹� </el-button> + <el-button type="primary" @click="submit"> 纭� 瀹�</el-button> </el-col> </el-row> </template> <fileUpload - ref="fileUploadRef" - :fileSize="1024" - :fileType="['pdf', 'docx', 'txt', 'xlsx', 'pptx....']" - :limit="10" - :drag="false" - v-model:modelValue="modelValue" + ref="fileUploadRef" + :fileSize="1024" + :fileType="['pdf', 'docx', 'txt', 'xlsx', 'pptx....']" + :limit="10" + :drag="false" + v-model:modelValue="modelValue" /> </el-dialog> </template> <script setup> -import { ref, watch } from "vue"; -import { addOrEditArchive } from "@/api/archiveManagement"; +import {ref, watch, nextTick} from "vue"; +import {addOrEditArchive} from "@/api/archiveManagement"; import fileUpload from "@/components/FileUpload/index.vue"; -import { ElMessage } from "element-plus"; +import {ElMessage} from "element-plus"; const centerDialogVisible = defineModel("centerDialogVisible", { type: Boolean, @@ -85,22 +85,24 @@ const copyForm = ref(); // 鐩戝惉 row 鐨勫彉鍖栵紝鏇存柊 ruleForm watch( - () => props.row, - (newRow) => { - copyForm.value = initFormData(newRow); - ruleForm.value = JSON.parse(JSON.stringify(copyForm.value)); - }, - { deep: true } + () => props.row, + (newRow) => { + copyForm.value = initFormData(newRow); + ruleForm.value = JSON.parse(JSON.stringify(copyForm.value)); + }, + {deep: true} ); const rules = { - name: [{ required: true, message: "璇疯緭鍏ユ枃妗e悕绉�", trigger: "blur" }], - type: [{ required: true, message: "璇烽�夋嫨鏂囨。绫诲瀷", trigger: "blur" }], - status: [{ required: true, message: "璇烽�夋嫨鏂囨。鐘舵��", trigger: "blur" }], + name: [{required: true, message: "璇疯緭鍏ユ枃妗e悕绉�", trigger: "blur"}], + type: [{required: true, message: "璇烽�夋嫨鏂囨。绫诲瀷", trigger: "blur"}], + status: [{required: true, message: "璇烽�夋嫨鏂囨。鐘舵��", trigger: "blur"}], }; const fileUploadRef = ref(null); const initForm = () => { ruleForm.value = {}; - fileUploadRef.value.init(); + nextTick(() => { + fileUploadRef.value.init(); + }); }; const editForm = (val) => { ruleForm.value = copyForm.value; @@ -113,9 +115,9 @@ editForm, }); const options = [ - { value: "鏈夋晥", label: "鏈夋晥" }, - { value: "鏃犳晥", label: "鏃犳晥" }, - { value: "浣滃簾", label: "浣滃簾" }, + {value: "鏈夋晥", label: "鏈夋晥"}, + {value: "鏃犳晥", label: "鏃犳晥"}, + {value: "浣滃簾", label: "浣滃簾"}, ]; const emit = defineEmits(["submitForm", "update:modelValue"]); const modelValue = ref([]); @@ -132,10 +134,6 @@ // 璋冪敤 API try { const res = await addOrEditArchive(ruleForm.value); - ElMessage({ - type: "success", - message: res.msg || "鎿嶄綔鎴愬姛", - }); emit("submitForm", res); } catch (error) { ElMessage({ @@ -147,6 +145,7 @@ // 鍙戦�� emit 浜嬩欢 // 鍏抽棴瀵硅瘽妗� + ElMessage.success("鎿嶄綔鎴愬姛"); centerDialogVisible.value = false; } catch (error) { ElMessage({ diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue index fda5d65..21558f7 100644 --- a/src/views/basicInformation/index.vue +++ b/src/views/basicInformation/index.vue @@ -1,7 +1,8 @@ <template> - <div> <el-form :inline="true" :model="queryParams" class="search-form"> - <el-form-item label="鎼滅储" v-if="shouldShowSearch"> - <el-input v-model="queryParams.searchAll" :placeholder="searchPlaceholder" clearable /> + <div> + <el-form :inline="true" :model="queryParams" class="search-form"> + <el-form-item v-if="shouldShowSearch" label="鎼滅储"> + <el-input v-model="queryParams.searchAll" :placeholder="searchPlaceholder" clearable/> </el-form-item> <el-form-item> <el-button type="primary" @click="search">鏌ヨ</el-button> @@ -11,58 +12,62 @@ <el-card> <!-- 鏍囩椤� --> <el-tabs v-model="activeTab" class="info-tabs" @tab-click="handleTabClick"> - <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="tab.label" :name="tab.name" /> + <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="tab.label" :name="tab.name"/> </el-tabs> <!-- 鎿嶄綔鎸夐挳鍖� --> <el-row :gutter="24" class="table-toolbar"> - <el-button type="primary" :icon="Plus" @click="handleAdd">鏂板缓</el-button> - <el-button type="danger" :icon="Delete" @click="handleDelete">鍒犻櫎</el-button> - <el-button type="info" :icon="Download" @click="handleExport" v-show="canExport">瀵煎嚭</el-button> + <el-button :icon="Plus" type="primary" @click="handleAdd">鏂板缓</el-button> + <el-button :icon="Delete" type="danger" @click="handleDelete">鍒犻櫎</el-button> + <el-button @click="jump">admins</el-button> + <el-button v-show="canExport" :icon="Download" type="info" @click="handleExport">瀵煎嚭</el-button> </el-row> <!-- 琛ㄦ牸缁勪欢 --> <div> - <data-table :loading="loading" :table-data="tableData" :columns="columns" - @selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true"> <!-- 瀛楁鍚嶇О鍒楃殑鑷畾涔夋彃妲� - 鏄剧ず涓烘爣绛� --> + <data-table :border="true" :columns="columns" :loading="loading" + :show-selection="true" :table-data="tableData" @edit="handleEdit" @selection-change="handleSelectionChange"> + <!-- 瀛楁鍚嶇О鍒楃殑鑷畾涔夋彃妲� - 鏄剧ず涓烘爣绛� --> <template v-if="tabName === 'coalQualityMaintenance'" #fieldIds="{ row }"> <template v-if="typeof row.fieldIds === 'string' && row.fieldIds.includes(',')"> - <el-tag v-for="(field, index) in row.fieldIds.split(',')" :key="index" type="primary" size="small" - style="margin-right: 4px; margin-bottom: 2px;"> + <el-tag v-for="(field, index) in row.fieldIds.split(',')" :key="index" size="small" style="margin-right: 4px; margin-bottom: 2px;" + type="primary"> {{ getFieldDisplayName(field.trim()) }} </el-tag> </template> <template v-else> - <el-tag type="primary" size="small"> + <el-tag size="small" type="primary"> {{ getFieldDisplayName(row.fieldIds) || '--' }} </el-tag> </template> </template> </data-table> </div> - <pagination v-if="total > 0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination" - :layout="'total, prev, pager, next, jumper'" /> + <pagination v-if="total > 0" :layout="'total, prev, pager, next, jumper'" :limit="pageSizes" :page="pageNum" :total="total" + @pagination="handPagination"/> <Supplier v-if="tabName === 'supplier'" v-model:copyForm="copyForm" - v-model:supplierDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit" - @beforeClose="handleBeforeClose" @update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" /> + v-model:supplierDialogFormVisible="dialogFormVisible" :addOrEdit="addOrEdit" :form="form" :title="title" + @beforeClose="handleBeforeClose" @submit="handleSubmit" + @update:dialogFormVisible="handleDialogFormVisible"/> <Customer v-if="tabName === 'customer'" v-model:copyForm="copyForm" - v-model:customerDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit" - :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" /> - <Coal v-if="tabName === 'coal'" v-model:copyForm="copyForm" v-model:coalDialogFormVisible="dialogFormVisible" - :form="form" :title="title" :addOrEdit="addOrEdit" @submit="handleSubmit" /> - <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'" v-model:copyForm="copyForm" - v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" :form="form" :title="title" - :addOrEdit="addOrEdit" @submit="handleSubmit" /> - <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'" v-model:copyForm="copyForm" - v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible" :form="form" :title="title" :addOrEdit="addOrEdit" - @submit="handleSubmit" /> + v-model:customerDialogFormVisible="dialogFormVisible" :addOrEdit="addOrEdit" :form="form" :title="title" + @beforeClose="handleBeforeClose" @submit="handleSubmit"/> + <Coal v-if="tabName === 'coal'" v-model:coalDialogFormVisible="dialogFormVisible" v-model:copyForm="copyForm" + :addOrEdit="addOrEdit" :form="form" :title="title" @submit="handleSubmit"/> + <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'" v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" + v-model:copyForm="copyForm" :addOrEdit="addOrEdit" + :form="form" + :title="title" @submit="handleSubmit"/> + <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'" v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible" + v-model:copyForm="copyForm" :addOrEdit="addOrEdit" :form="form" + :title="title" + @submit="handleSubmit"/> </el-card> </div> </template> <script setup> -// ===== 鏍稿績渚濊禆瀵煎叆 ===== -import { ref, reactive, onMounted, computed, getCurrentInstance } from "vue"; -import { ElMessage, ElMessageBox } from "element-plus"; -import { Plus, Edit, Delete, Download } from "@element-plus/icons-vue"; +import {computed, getCurrentInstance, onMounted, reactive, ref, nextTick} from "vue"; +import {ElMessage, ElMessageBox} from "element-plus"; +import {Delete, Download, Plus} from "@element-plus/icons-vue"; // ===== 缁勪欢瀵煎叆 ===== import DataTable from "@/components/Table/ETable.vue"; @@ -74,18 +79,20 @@ import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue"; // ===== API 鏈嶅姟瀵煎叆 ===== -import { getSupply, delSupply } from "@/api/basicInformation/supplier.js"; -import { getCoalInfo, delCoalInfo } from "@/api/basicInformation/coal.js"; -import { testUserList } from "@/api/tool/publicInterface.js"; -import { getAreaOptions } from "@/api/system/area.js"; -import { getCustomerList, delCustomer } from "@/api/basicInformation/customer.js"; -import { coalField, deleteCoalField } from "@/api/basicInformation/coalFieldMaintenance.js"; -import { getCoalFieldList, getCoalPlanList } from "@/api/basicInformation/coalQualityMaintenance"; +import {delSupply, getSupply} from "@/api/basicInformation/supplier.js"; +import {delCoalInfo, getCoalInfo} from "@/api/basicInformation/coal.js"; +import {testUserList} from "@/api/tool/publicInterface.js"; +import {getAreaOptions} from "@/api/system/area.js"; +import {delCustomer, getCustomerList} from "@/api/basicInformation/customer.js"; +import {coalField, deleteCoalField} from "@/api/basicInformation/coalFieldMaintenance.js"; +import {getCoalFieldList, getCoalPlanList} from "@/api/basicInformation/coalQualityMaintenance"; -const { proxy } = getCurrentInstance(); +const {proxy} = getCurrentInstance(); +import router from "@/router"; // ===== 鍝嶅簲寮忕姸鎬佺鐞� ===== - +const jump = () => { +}; // 寮圭獥鎺у埗鐘舵�� const dialogFormVisible = ref(false); const form = ref({}); @@ -124,11 +131,11 @@ // 鏍囩椤甸厤缃� const tabs = reactive([ - { name: "supplier", label: "渚涘簲鍟嗕俊鎭�" }, - { name: "customer", label: "瀹㈡埛淇℃伅" }, - { name: "coal", label: "鐓ょ淇℃伅" }, - { name: "coalQualityMaintenance", label: "鐓よ川鏂规" }, - { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" } + {name: "supplier", label: "渚涘簲鍟嗕俊鎭�"}, + {name: "customer", label: "瀹㈡埛淇℃伅"}, + {name: "coal", label: "鐓ょ淇℃伅"}, + {name: "coalQualityMaintenance", label: "鐓よ川鏂规"}, + {name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁"} ]); // ===== 宸ュ叿鍑芥暟 ===== @@ -178,18 +185,18 @@ * @description 灏嗗湴鍧�ID鏁扮粍杞崲涓哄彲璇荤殑鍦板潃瀛楃涓� */ const formatAddressArray = (addressIds) => { - if (!addressMap.value || Object.keys(addressMap.value).length === 0 || - !addressIds || !Array.isArray(addressIds) || addressIds.length === 0 || + if (!addressMap.value || Object.keys(addressMap.value).length === 0 || + !addressIds || !Array.isArray(addressIds) || addressIds.length === 0 || addressIds.every(id => !id)) { return '--'; } - + const addressNames = addressIds.map(id => addressMap.value[id]?.name || '--'); - + if (addressNames.every(name => name === '--')) { return '--'; } - + return addressNames.filter(name => name !== '--').join(' / '); }; @@ -217,7 +224,7 @@ */ const coalFieldData = async () => { try { - const { data, code } = await getCoalFieldList(); + const {data, code} = await getCoalFieldList(); if (code === 200) { coalFieldList.value = data; } @@ -234,10 +241,10 @@ */ const getFieldDisplayName = (fieldId) => { if (!fieldId) return '--'; - + const numId = parseInt(fieldId); const matchedField = coalFieldList.value.find(item => item.id === numId); - + return matchedField ? matchedField.fieldName : numId; }; @@ -256,7 +263,7 @@ const searchPlaceholder = computed(() => { const placeholderMap = { supplier: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", - customer: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", + customer: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", coal: "璇疯緭鍏ユ悳绱俊鎭�", coalQualityMaintenance: "璇疯緭鍏ユ悳绱俊鎭�", coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ユ悳绱俊鎭�" @@ -268,7 +275,7 @@ * 鏄惁鏄剧ず鎼滅储妗� */ const shouldShowSearch = computed(() => { - return ['supplier', 'customer', 'coal', 'coalQualityMaintenance','coalMeiZhiZiDuanWeiHu'].includes(tabName.value); + return ['supplier', 'customer', 'coal', 'coalQualityMaintenance', 'coalMeiZhiZiDuanWeiHu'].includes(tabName.value); }); /** @@ -287,8 +294,8 @@ * 渚涘簲鍟嗚〃鏍煎垪閰嶇疆 */ const supplierColumns = ref([ - { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100 }, - { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170 }, + {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100}, + {prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170}, { prop: "bids", label: "缁忚惀鍦板潃", @@ -299,10 +306,10 @@ return formatAddressArray(addressIds); } }, - { prop: "businessAddress", label: "缁忚惀璇︾粏鍦板潃", minWidth: 150 }, - { prop: "bankAccount", label: "寮�鎴疯", minWidth: 120 }, - { prop: "bankName", label: "閾惰璐﹀彿", minWidth: 150 }, - { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 }, + {prop: "businessAddress", label: "缁忚惀璇︾粏鍦板潃", minWidth: 150}, + {prop: "bankAccount", label: "寮�鎴疯", minWidth: 120}, + {prop: "bankName", label: "閾惰璐﹀彿", minWidth: 150}, + {prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100}, { prop: "cids", label: "鑱旂郴浜哄湴鍧�", @@ -313,16 +320,16 @@ return formatAddressArray(addressIds); } }, - { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 }, - { prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 120 }, + {prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120}, + {prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 120}, ]); /** * 瀹㈡埛琛ㄦ牸鍒楅厤缃� */ const customerColumns = ref([ - { prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100 }, - { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 }, + {prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100}, + {prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120}, { prop: "bids", label: "缁忚惀鍦板潃", @@ -333,11 +340,11 @@ return formatAddressArray(addressIds); } }, - { prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150 }, - { prop: "bankName", label: "寮�鎴疯", minWidth: 120 }, - { prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150 }, - { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 }, - { prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100 }, + {prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150}, + {prop: "bankName", label: "寮�鎴疯", minWidth: 120}, + {prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150}, + {prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100}, + {prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100}, { prop: "cids", label: "鑱旂郴浜哄湴鍧�", @@ -348,15 +355,15 @@ return formatAddressArray(addressIds); } }, - { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150 }, - { prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100 }, + {prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150}, + {prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100}, ]); /** * 鐓ょ琛ㄦ牸鍒楅厤缃� */ const coalColumns = ref([ - { prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200 }, + {prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200}, { prop: "maintainerId", label: "缁存姢浜�", @@ -371,14 +378,14 @@ return userMap.value[cellValue] || '--'; } }, - { prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150 }, + {prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150}, ]); /** * 鐓よ川鏂规琛ㄦ牸鍒楅厤缃� */ const coalQualityMaintenanceColumns = ref([ - { prop: "plan", label: "鏂规鍚嶇О", minWidth: 100 }, + {prop: "plan", label: "鏂规鍚嶇О", minWidth: 100}, { prop: "fieldIds", label: "瀛楁鍚嶇О", @@ -392,15 +399,15 @@ return cellValue || '--'; } }, - { prop: "schemeDesc", label: "瀛楁鎻忚堪", minWidth: 100 }, + {prop: "schemeDesc", label: "瀛楁鎻忚堪", minWidth: 100}, ]); /** * 鐓よ川瀛楁琛ㄦ牸鍒楅厤缃� */ const coalMeiZhiZiDuanWeiHuColumns = ref([ - { prop: "fieldName", label: "瀛楁鍚嶇О", minWidth: 200 }, - { prop: "fieldDescription", label: "瀛楁鎻忚堪", minWidth: 200 }, + {prop: "fieldName", label: "瀛楁鍚嶇О", minWidth: 200}, + {prop: "fieldDescription", label: "瀛楁鎻忚堪", minWidth: 200}, ]); // ===== 浜嬩欢澶勭悊鍑芥暟 ===== @@ -489,10 +496,10 @@ */ const handleAddEdit = (currentTabName) => { const actionText = addOrEdit.value === "add" ? "鏂板" : "缂栬緫"; - + const tabTitleMap = { supplier: "渚涘簲鍟嗕俊鎭�", - customer: "瀹㈡埛淇℃伅", + customer: "瀹㈡埛淇℃伅", coal: "鐓ょ淇℃伅", coalQualityMaintenance: "鐓よ川鏂规缁存姢", coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢" @@ -561,27 +568,27 @@ */ const handleEdit = (row) => { form.value = JSON.parse(JSON.stringify(row)); - + // 鏋勫缓渚涘簲鍟嗕笟鍔″湴鍧�鏁扮粍 if (form.value.bprovinceId && form.value.bdistrictId && form.value.bcityId) { form.value.bids = [row.bprovinceId, row.bcityId, row.bdistrictId]; } - + // 鏋勫缓渚涘簲鍟嗚仈绯诲湴鍧�鏁扮粍 if (form.value.cprovinceId && form.value.cdistrictId && form.value.ccityId) { form.value.cids = [row.cprovinceId, row.ccityId, row.cdistrictId]; } - + // 鏋勫缓瀹㈡埛涓氬姟鍦板潃鏁扮粍 if (form.value.businessCityId && form.value.businessDistrictId && form.value.businessProvinceId) { form.value.bids = [row.businessProvinceId, row.businessCityId, row.businessDistrictId]; } - + // 鏋勫缓瀹㈡埛鑱旂郴鍦板潃鏁扮粍 if (form.value.cityId && form.value.districtId && form.value.provinceId) { form.value.cids = [row.provinceId, row.cityId, row.districtId]; } - + addOrEdit.value = "edit"; handleAddEdit(tabName.value); }; @@ -597,7 +604,7 @@ } const deleteIds = selectedRows.value.map(item => item.id); - + try { await ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", { confirmButtonText: "纭畾", @@ -608,7 +615,9 @@ const deleteApiMap = { supplier: delSupply, coal: delCoalInfo, - coalQualityMaintenance: () => { throw new Error('delCoalQuality API not imported'); }, + coalQualityMaintenance: () => { + throw new Error('delCoalQuality API not imported'); + }, customer: delCustomer, coalMeiZhiZiDuanWeiHu: deleteCoalField }; @@ -620,12 +629,12 @@ } console.log(deleteIds) const res = await deleteApi(deleteIds); - + if (res.code !== 200 && res.msg !== "鎿嶄綔鎴愬姛") { ElMessage.error("鍒犻櫎澶辫触锛�" + res.msg); return; } - + ElMessage.success("鍒犻櫎鎴愬姛"); await getList(); } catch (error) { @@ -653,10 +662,10 @@ */ const handleExport = () => { const exportConfig = { - supplier: { api: "/supply/export", name: "渚涘簲鍟嗕俊鎭�" }, - customer: { api: "/customer/export", name: "瀹㈡埛淇℃伅" }, - coal: { api: "/supply/export", name: "鐓ょ淇℃伅" }, - coalQualityMaintenance: { api: "/supply/export", name: "鐓よ川缁存姢淇℃伅" } + supplier: {api: "/supply/export", name: "渚涘簲鍟嗕俊鎭�"}, + customer: {api: "/customer/export", name: "瀹㈡埛淇℃伅"}, + coal: {api: "/supply/export", name: "鐓ょ淇℃伅"}, + coalQualityMaintenance: {api: "/supply/export", name: "鐓よ川缁存姢淇℃伅"} }; const config = exportConfig[tabName.value]; @@ -671,7 +680,7 @@ * @param {string} name - 瀵煎嚭鏂囦欢鍚嶅墠缂� */ const exportData = (api, name) => { - proxy.download(api, { ...queryParams }, `${name}${new Date().getTime()}.xlsx`); + proxy.download(api, {...queryParams}, `${name}${new Date().getTime()}.xlsx`); ElMessage.success("瀵煎嚭鏁版嵁锛�" + name); }; // ===== 鏁版嵁鑾峰彇鍑芥暟 ===== @@ -707,13 +716,13 @@ const getList = async () => { try { loading.value = true; - const { data, code } = await selectInterface(); - + const {data, code} = await selectInterface(); + if (code !== 200) { ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + (data?.msg || '鏈煡閿欒')); return; } - + tableData.value = data.records || []; total.value = data.total || 0; } catch (error) { @@ -733,7 +742,7 @@ try { // 骞惰鎵ц鍒濆鍖栨搷浣� await Promise.all([ - handleTabClick({ props: { name: "supplier" } }), + handleTabClick({props: {name: "supplier"}}), fetchAreaOptions(), getUserList() ]); @@ -778,7 +787,7 @@ /* 琛ㄦ牸宸ュ叿鏍� */ .table-toolbar, -.table-toolbar>* { +.table-toolbar > * { margin: 0 0 0 0 !important; } diff --git a/src/views/basicInformation/mould/coal.vue b/src/views/basicInformation/mould/coal.vue index a0454a3..36e599e 100644 --- a/src/views/basicInformation/mould/coal.vue +++ b/src/views/basicInformation/mould/coal.vue @@ -1,73 +1,77 @@ <template> - <div> - <el-dialog - v-model="dialogVisible" - :title="title" - width="500" - :close-on-click-modal="false" - :before-close="handleClose" - > <el-form - ref="formRef" - style="max-width: 600px; margin: 0 auto" - :model="formData" - :rules="rules" - label-width="120px" - > - <el-form-item label="鐓ょ鍚嶇О" prop="coal"> - <el-input - v-model="formData.coal" - placeholder="璇疯緭鍏ョ叅绉嶅悕绉�" - /> - </el-form-item> <el-form-item label="缁存姢浜哄鍚�" prop="maintainerId"> - <el-input - :value="userStore.name || ''" - placeholder="缁存姢浜哄鍚�" - disabled - /> - </el-form-item> <el-form-item label="缁存姢鏃ユ湡" prop="maintenanceDate"> - <el-input - :value="getCurrentDate()" - placeholder="缁存姢鏃ユ湡" - disabled - /> - </el-form-item> - - <el-form-item class="dialog-footer"> - <el-button v-if="addOrEdit === 'edit'" @click="resetForm">閲嶇疆</el-button> - <el-button v-if="addOrEdit === 'add'" @click="cancelForm">鍙栨秷</el-button> - <el-button type="primary" @click="submitForm"> - 纭畾 - </el-button> - </el-form-item> - </el-form> - </el-dialog> - </div> + <div> + <el-dialog + v-model="dialogVisible" + :title="title" + width="500" + :close-on-click-modal="false" + :before-close="handleClose" + > + <el-form + ref="formRef" + style="max-width: 600px; margin: 0 auto" + :model="formData" + :rules="rules" + label-width="120px" + > + <el-form-item label="鐓ょ鍚嶇О" prop="coal"> + <el-input + v-model="formData.coal" + placeholder="璇疯緭鍏ョ叅绉嶅悕绉�" + /> + </el-form-item> + <el-form-item label="缁存姢浜哄鍚�" prop="maintainerId"> + <el-input + :value="userStore.name || ''" + placeholder="缁存姢浜哄鍚�" + disabled + /> + </el-form-item> + <el-form-item label="缁存姢鏃ユ湡" prop="maintenanceDate"> + <el-input + :value="getCurrentDate()" + placeholder="缁存姢鏃ユ湡" + disabled + /> + </el-form-item> + + <el-form-item class="dialog-footer"> + <el-button v-if="addOrEdit === 'edit'" @click="resetForm">閲嶇疆</el-button> + <el-button v-if="addOrEdit === 'add'" @click="cancelForm">鍙栨秷</el-button> + <el-button type="primary" @click="submitForm"> + 纭畾 + </el-button> + </el-form-item> + </el-form> + </el-dialog> + </div> </template> <script setup> -import { ref, watch, defineProps, reactive, onMounted } from 'vue' -import { addOrEditCoalInfo } from '@/api/basicInformation/coal' +import {ref, watch, defineProps, reactive, onMounted} from 'vue' +import {addOrEditCoalInfo} from '@/api/basicInformation/coal' import useUserStore from '@/store/modules/user' const userStore = useUserStore() const props = defineProps({ - beforeClose: { - type: Function, - default: () => {} - }, - form: { - type: Object, - default: () => ({}) - }, - addOrEdit: { - type: String, - default: 'add' - }, - title: { - type: String, - default: '' - }, + beforeClose: { + type: Function, + default: () => { + } + }, + form: { + type: Object, + default: () => ({}) + }, + addOrEdit: { + type: String, + default: 'add' + }, + title: { + type: String, + default: '' + }, }) const copyForm = defineModel("copyForm", { required: true, @@ -75,99 +79,100 @@ }); // 鍦ㄧ粍浠舵寕杞芥椂鑾峰彇鐢ㄦ埛淇℃伅 onMounted(async () => { - // 濡傛灉store涓病鏈夌敤鎴蜂俊鎭紝鍒欒幏鍙栫敤鎴蜂俊鎭� - if (!userStore.name) { - try { - await userStore.getInfo() - // 鑷姩濉厖缁存姢浜篒D - if (props.addOrEdit === 'add') { - formData.value.maintainerId = userStore.id - } - } catch (error) { - console.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触:', error) - } - } else { - // 鑷姩濉厖缁存姢浜篒D - if (props.addOrEdit === 'add') { - formData.value.maintainerId = userStore.id - } + // 濡傛灉store涓病鏈夌敤鎴蜂俊鎭紝鍒欒幏鍙栫敤鎴蜂俊鎭� + if (!userStore.name) { + try { + await userStore.getInfo() + // 鑷姩濉厖缁存姢浜篒D + if (props.addOrEdit === 'add') { + formData.value.maintainerId = userStore.id + } + } catch (error) { + console.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触:', error) } + } else { + // 鑷姩濉厖缁存姢浜篒D + if (props.addOrEdit === 'add') { + formData.value.maintainerId = userStore.id + } + } }) -const emit = defineEmits(['submit', 'handleBeforeClose','update:coalDialogFormVisible']) +const emit = defineEmits(['submit', 'handleBeforeClose', 'update:coalDialogFormVisible']) // 琛ㄥ崟寮曠敤 const formRef = ref(null) // 琛ㄥ崟鏁版嵁 -const formData = ref({ ...props.form }) +const formData = ref({...props.form}) // 寮圭獥鍙鎬� -const dialogVisible = defineModel("coalDialogFormVisible",{required:true,type:Boolean}) +const dialogVisible = defineModel("coalDialogFormVisible", {required: true, type: Boolean}) // 鐩戝惉澶栭儴浼犲叆鐨勮〃鍗曟暟鎹彉鍖� watch(() => props.form, (newVal) => { - formData.value = { ...newVal } - // 濡傛灉鏄柊澧炴ā寮忥紝璁剧疆缁存姢浜� - if (props.addOrEdit === 'add' && userStore.id) { - formData.value.maintainerId = userStore.id - } -}, { deep: true }) + formData.value = {...newVal} + // 濡傛灉鏄柊澧炴ā寮忥紝璁剧疆缁存姢浜� + if (props.addOrEdit === 'add' && userStore.id) { + formData.value.maintainerId = userStore.id + } +}, {deep: true}) // 鐩戝惉鍐呴儴寮圭獥鐘舵�佸彉鍖� watch(() => dialogVisible.value, (newVal) => { - emit('update:coalDialogFormVisible', newVal) + emit('update:coalDialogFormVisible', newVal) }) // 鎻愪氦琛ㄥ崟 const submitForm = async () => { - if (!formRef.value) return - await formRef.value.validate(async (valid, fields) => { - if (valid) { - delete formData.value.maintainerName // 鍒犻櫎鏄剧ず鐢ㄧ殑瀛楁锛屽彧淇濈暀ID - - // 纭繚maintainerId鏈夊�� - if (!formData.value.maintainerId) { - formData.value.maintainerId = userStore.id - } - - // 璁剧疆缁存姢鏃ユ湡 - formData.value.maintenanceDate = getCurrentDate() - - let result = await addOrEditCoalInfo({ - ...formData.value, - }) - let obj = { - title: props.title, - result, - } - emit('submit', obj) - } - }) + if (!formRef.value) return + await formRef.value.validate(async (valid, fields) => { + if (valid) { + delete formData.value.maintainerName // 鍒犻櫎鏄剧ず鐢ㄧ殑瀛楁锛屽彧淇濈暀ID + + // 纭繚maintainerId鏈夊�� + if (!formData.value.maintainerId) { + formData.value.maintainerId = userStore.id + } + + // 璁剧疆缁存姢鏃ユ湡 + formData.value.maintenanceDate = getCurrentDate() + + let result = await addOrEditCoalInfo({ + ...formData.value, + }) + let obj = { + title: props.title, + result, + } + emit('submit', obj) + } + }) } // 鍙栨秷琛ㄥ崟 const cancelForm = () => { - emit('update:coalDialogFormVisible', false) - formData.value = {} + emit('update:coalDialogFormVisible', false) + formData.value = {} } // 閲嶇疆琛ㄥ崟 const resetForm = () => { - if (!formRef.value) return + if (!formRef.value) return formData.value = JSON.parse(JSON.stringify(copyForm.value)); - // formRef.value.resetFields() + // formRef.value.resetFields() } // 鍏抽棴寮圭獥 const handleClose = () => { - // 瑙﹀彂鐖剁粍浠剁殑鍏抽棴鍑芥暟 - emit("handleBeforeClose") - emit('update:coalDialogFormVisible', false) + // 瑙﹀彂鐖剁粍浠剁殑鍏抽棴鍑芥暟 + emit("handleBeforeClose") + emit('update:coalDialogFormVisible', false) } const rules = reactive({ supplierName: [ - { required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur"}, ], identifyNumber: [ - { required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, - { min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, + {required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, + {min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, ], }); + // 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD function getCurrentDate() { const today = new Date(); @@ -180,9 +185,9 @@ <style lang="scss" scoped> .dialog-footer { - display: flex; - margin-top: 20px; - flex-direction: column; - align-items: flex-end; + display: flex; + margin-top: 20px; + flex-direction: column; + align-items: flex-end; } </style> \ No newline at end of file diff --git a/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue b/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue index c7de9c3..8dddf2b 100644 --- a/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue +++ b/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue @@ -1,35 +1,38 @@ <template> <div> <el-dialog - v-model="dialogVisible" - :title="title" - width="600" - :close-on-click-modal="false" - :before-close="handleClose" + v-model="dialogVisible" + :title="title" + width="600" + :close-on-click-modal="false" + :before-close="handleClose" > <el-form - ref="formRef" - style="max-width: 400px; margin: 0 auto" - :model="formData" - :rules="rules" - label-width="auto" + ref="formRef" + style="max-width: 400px; margin: 0 auto" + :model="formData" + :rules="rules" + label-width="auto" > <el-form-item label="瀛楁鍚嶇О" prop="fieldName"> <el-input - v-model="formData.fieldName" - placeholder="璇疯緭鍏ュ瓧娈靛悕绉�" + v-model="formData.fieldName" + placeholder="璇疯緭鍏ュ瓧娈靛悕绉�" /> - </el-form-item> <el-form-item label="瀛楁鎻忚堪" prop="fieldDescription"> - <el-input v-model="formData.fieldDescription" type="textarea" placeholder="璇疯緭鍏ュ瓧娈垫弿杩�" /> + </el-form-item> + <el-form-item label="瀛楁鎻忚堪" prop="fieldDescription"> + <el-input v-model="formData.fieldDescription" type="textarea" placeholder="璇疯緭鍏ュ瓧娈垫弿杩�"/> </el-form-item> <el-form-item class="dialog-footer"> <el-button v-if="addOrEdit === 'edit'" @click="resetForm" - >閲嶇疆</el-button + >閲嶇疆 + </el-button > <el-button v-if="addOrEdit === 'add'" @click="cancelForm" - >鍙栨秷</el-button + >鍙栨秷 + </el-button > - <el-button type="primary" @click="submitForm"> 纭畾 </el-button> + <el-button type="primary" @click="submitForm"> 纭畾</el-button> </el-form-item> </el-form> </el-dialog> @@ -37,8 +40,9 @@ </template> <script setup> -import { ref, reactive, watch, defineProps } from "vue"; -import { addOrEditCoalField } from "@/api/basicInformation/coalFieldMaintenance.js"; +import {ref, reactive, watch, defineProps} from "vue"; +import {addOrEditCoalField} from "@/api/basicInformation/coalFieldMaintenance.js"; + const props = defineProps({ form: { type: Object, @@ -61,12 +65,12 @@ const formRef = ref(); const emit = defineEmits(["submit", "handleBeforeClose"]); // 琛ㄥ崟鏁版嵁 -const formData = ref({ ...props.form }); +const formData = ref({...props.form}); // 鐩戝惉props.form鐨勫彉鍖栵紝鏇存柊formData watch(() => props.form, (newForm) => { - formData.value = { ...newForm }; -}, { deep: true, immediate: true }); + formData.value = {...newForm}; +}, {deep: true, immediate: true}); // 寮圭獥鍙鎬� const dialogVisible = defineModel("coalMaintenanceFieldDialogVisible", { required: true, @@ -82,8 +86,8 @@ console.log("鎻愪氦琛ㄥ崟", formData.value); if (props.title.includes('鏂板')) { let result = await addOrEditCoalField( - {...formData.value} - ,) + {...formData.value} + ,) console.log(result); obj.value = { title: "鏂板", @@ -111,7 +115,7 @@ }; // 閲嶇疆琛ㄥ崟 const resetForm = () => { - if (!formRef.value) return + if (!formRef.value) return formData.value = JSON.parse(JSON.stringify(copyForm.value)); } // 鍏抽棴寮圭獥 @@ -122,7 +126,7 @@ }; const rules = reactive({ fieldName: [ - { required: true, message: "璇疯緭鍏ョ叅绉嶅悕绉�", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ョ叅绉嶅悕绉�", trigger: "blur"}, ], }); </script> diff --git a/src/views/basicInformation/mould/coalQualityMaintenance.vue b/src/views/basicInformation/mould/coalQualityMaintenance.vue index 64373b0..1b3d911 100644 --- a/src/views/basicInformation/mould/coalQualityMaintenance.vue +++ b/src/views/basicInformation/mould/coalQualityMaintenance.vue @@ -1,25 +1,26 @@ <!-- 鐓よ川鏂规缁存姢寮圭獥缁勪欢 --> <template> <el-dialog v-model="dialogVisible" :title="title" width="600" :close-on-click-modal="false" - :before-close="handleClose"> + :before-close="handleClose"> <!-- 琛ㄥ崟鍖哄煙 --> <el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" - style="max-width: 400px; margin: 0 auto"> + style="max-width: 400px; margin: 0 auto"> <!-- 鏂规鍚嶇О杈撳叆妗� --> <el-form-item label="鐓よ川鏂规鍚嶇О" prop="plan"> - <el-input v-model="formData.plan" placeholder="璇疯緭鍏ョ叅璐ㄦ柟妗堝悕绉�" clearable /> + <el-input v-model="formData.plan" placeholder="璇疯緭鍏ョ叅璐ㄦ柟妗堝悕绉�" clearable/> </el-form-item> <!-- 鐓よ川瀛楁澶氶�変笅鎷夋 --> <el-form-item label="鐓よ川鏂规绫诲瀷" prop="coalFieldList"> - <el-select v-model="formData.coalFieldList" placeholder="璇烽�夋嫨鐓よ川鏂规绫诲瀷" style="width: 100%" clearable multiple> - <el-option v-for="item in fieldOptions" :key="item.id" :label="item.label" :value="item" /> + <el-select v-model="formData.coalFieldList" placeholder="璇烽�夋嫨鐓よ川鏂规绫诲瀷" style="width: 100%" clearable + multiple> + <el-option v-for="item in fieldOptions" :key="item.id" :label="item.label" :value="item"/> </el-select> </el-form-item> <!-- 鏂规鎻忚堪鏂囨湰鍩� --> <el-form-item label="鐓よ川鏂规鎻忚堪" prop="schemeDesc"> - <el-input v-model="formData.schemeDesc" type="textarea" placeholder="璇疯緭鍏ョ叅璐ㄦ柟妗堟弿杩�" :rows="3" /> + <el-input v-model="formData.schemeDesc" type="textarea" placeholder="璇疯緭鍏ョ叅璐ㄦ柟妗堟弿杩�" :rows="3"/> </el-form-item> <!-- 鎿嶄綔鎸夐挳鍖哄煙 --> @@ -32,15 +33,16 @@ </el-dialog> </template> <script setup> -import { ref, reactive, watch, computed, onMounted } from "vue"; -import { getCoalFieldList, addOrEditCoalPlan } from "@/api/basicInformation/coalQualityMaintenance"; +import {ref, reactive, watch, computed, onMounted} from "vue"; +import {getCoalFieldList, addOrEditCoalPlan} from "@/api/basicInformation/coalQualityMaintenance"; // ===== 缁勪欢灞炴�у畾涔� ===== const props = defineProps({ /** 鍏抽棴寮圭獥鍓嶇殑鍥炶皟鍑芥暟 */ beforeClose: { type: Function, - default: () => { }, + default: () => { + }, }, /** 琛ㄥ崟鏁版嵁 */ form: { @@ -58,7 +60,10 @@ default: "", }, }); - +const copyForm = defineModel("copyForm", { + required: true, + type: Object, +}); // ===== 浜嬩欢瀹氫箟 ===== const emit = defineEmits(["submit", "handleBeforeClose"]); @@ -85,10 +90,10 @@ // ===== 琛ㄥ崟楠岃瘉瑙勫垯 ===== const formRules = reactive({ plan: [ - { required: true, message: "璇疯緭鍏ユ柟妗堝悕绉�", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ユ柟妗堝悕绉�", trigger: "blur"}, ], coalFieldList: [ - { required: true, message: "璇烽�夋嫨鏂规绫诲瀷", trigger: "blur" }, + {required: true, message: "璇烽�夋嫨鏂规绫诲瀷", trigger: "blur"}, ], }); @@ -99,9 +104,9 @@ const parseCoalFields = (coalFieldsStr) => { if (!coalFieldsStr || typeof coalFieldsStr !== 'string') return []; return coalFieldsStr - .split(',') - .map(id => parseInt(id.trim())) - .filter(id => !isNaN(id)); + .split(',') + .map(id => parseInt(id.trim())) + .filter(id => !isNaN(id)); }; /** @@ -117,7 +122,7 @@ * @param {Object} newForm - 鏂扮殑琛ㄥ崟鏁版嵁 */ const initFormData = (newForm) => { - formData.value = { ...newForm }; + formData.value = {...newForm}; // 澶勭悊 coalFieldList 瀛楁锛氱紪杈戞椂闇�瑕佸皢瀛楃涓茶浆鎹负鏁扮粍渚涘閫夌粍浠朵娇鐢� if (newForm.fieldIds) { if (typeof newForm.fieldIds === 'string') { @@ -125,7 +130,7 @@ const ids = parseCoalFields(newForm.fieldIds); formData.value.coalFieldList = ids.map(id => { const option = fieldOptions.find(opt => opt.value === id); - return option || { fields: `瀛楁${id}`, value: id }; + return option || {fields: `瀛楁${id}`, value: id}; }); } else if (Array.isArray(newForm.coalFieldList)) { // 纭繚鏁扮粍涓殑鍊奸兘鏄纭殑瀵硅薄鏍煎紡 @@ -136,7 +141,7 @@ // 濡傛灉鏄函ID锛岄渶瑕佸尮閰嶅搴旂殑閫夐」 const id = parseInt(item); const option = fieldOptions.find(opt => opt.value === id); - return option || { fields: `瀛楁${id}`, value: id }; + return option || {fields: `瀛楁${id}`, value: id}; } }); } @@ -152,13 +157,13 @@ */ onMounted(async () => { try { - const { data, code } = await getCoalFieldList(); + const {data, code} = await getCoalFieldList(); if (code === 200) { // 鏋勫缓閫夐」鏁版嵁锛屾牸寮忓寲涓簕 label, value } fieldOptions.push(...data.map(item => ({ label: item.fieldName, value: item.id, - fields:item.fields + fields: item.fields }))); } else { console.error("鑾峰彇鐓よ川瀛楁鍒楄〃澶辫触", data); @@ -248,8 +253,8 @@ * 閲嶇疆琛ㄥ崟 */ const resetForm = () => { - if (!formRef.value) return; - formRef.value.resetFields(); + formData.value = JSON.parse(JSON.stringify(copyForm.value)); + initFormData(formData.value); }; /** diff --git a/src/views/basicInformation/mould/customer.vue b/src/views/basicInformation/mould/customer.vue index 0aa5a62..db4d96b 100644 --- a/src/views/basicInformation/mould/customer.vue +++ b/src/views/basicInformation/mould/customer.vue @@ -1,44 +1,47 @@ <template> <div> <el-dialog v-model="dialogVisible" :title="title" width="600" :close-on-click-modal="false" - :before-close="handleClose"> - <el-form ref="formRef" style="max-width: 400px; margin: 0 auto" :model="formData" :rules="rules" label-width="auto"> + :before-close="handleClose"> + <el-form ref="formRef" style="max-width: 400px; margin: 0 auto" :model="formData" :rules="rules" + label-width="auto"> <el-form-item label="瀹㈡埛鍚嶇О" prop="customerName"> - <el-input v-model="formData.customerName" placeholder="璇疯緭鍏ュ鎴峰悕绉�" /> + <el-input v-model="formData.customerName" placeholder="璇疯緭鍏ュ鎴峰悕绉�"/> </el-form-item> <el-form-item label="绾崇◣浜鸿瘑鍒彿" prop="taxpayerId"> - <el-input v-model="formData.taxpayerId" placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�" /> + <el-input v-model="formData.taxpayerId" placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�"/> </el-form-item> <el-form-item label="缁忚惀鍦板潃" prop="bids"> - <el-cascader placeholder="璇烽�夋嫨缁忚惀鍦板潃" size="default" :options="addressSelectOptions" v-model="formData.bids" - :props="cascaderProps" @change="handleChange"> + <el-cascader placeholder="璇烽�夋嫨缁忚惀鍦板潃" size="default" :options="addressSelectOptions" + v-model="formData.bids" + :props="cascaderProps" @change="handleChange"> </el-cascader> </el-form-item> <el-form-item label="缁忚惀璇︾粏鍦板潃" prop="businessAddress"> - <el-input v-model="formData.businessAddress" placeholder="璇疯緭鍏ョ粡钀ヨ缁嗗湴鍧�" /> + <el-input v-model="formData.businessAddress" placeholder="璇疯緭鍏ョ粡钀ヨ缁嗗湴鍧�"/> </el-form-item> <el-form-item label="寮�鎴疯" prop="bankName"> - <el-input v-model="formData.bankName" placeholder="璇疯緭鍏ュ紑鎴疯" /> + <el-input v-model="formData.bankName" placeholder="璇疯緭鍏ュ紑鎴疯"/> </el-form-item> <el-form-item label="閾惰璐︽埛" prop="bankAccount"> - <el-input v-model="formData.bankAccount" placeholder="璇疯緭鍏ラ摱琛岃处鎴�" /> + <el-input v-model="formData.bankAccount" placeholder="璇疯緭鍏ラ摱琛岃处鎴�"/> </el-form-item> <el-form-item label="鑱旂郴浜�" prop="contactPerson"> - <el-input v-model="formData.contactPerson" placeholder="璇疯緭鍏ヨ仈绯讳汉" /> + <el-input v-model="formData.contactPerson" placeholder="璇疯緭鍏ヨ仈绯讳汉"/> </el-form-item> <el-form-item label="鑱旂郴鐢佃瘽" prop="contactPhone"> - <el-input v-model="formData.contactPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" /> + <el-input v-model="formData.contactPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�"/> </el-form-item> - + <el-form-item label="鑱旂郴浜哄湴鍧�" prop="cids"> - <el-cascader placeholder="璇烽�夋嫨鑱旂郴浜哄湴鍧�" size="default" :options="addressSelectOptions" v-model="formData.cids" - :props="cascaderProps" @change="handleChange"> + <el-cascader placeholder="璇烽�夋嫨鑱旂郴浜哄湴鍧�" size="default" :options="addressSelectOptions" + v-model="formData.cids" + :props="cascaderProps" @change="handleChange"> </el-cascader> </el-form-item> <el-form-item label="鑱旂郴浜鸿缁�" prop="contactAddress"> - <el-input v-model="formData.contactAddress" placeholder="璇疯緭鍏ヨ仈绯讳汉璇︾粏鍦板潃" /> + <el-input v-model="formData.contactAddress" placeholder="璇疯緭鍏ヨ仈绯讳汉璇︾粏鍦板潃"/> </el-form-item> - <el-form-item class="dialog-footer"> + <el-form-item class="dialog-footer"> <el-button v-if="addOrEdit === 'edit'" @click="resetForm">閲嶇疆</el-button> <el-button v-if="addOrEdit === 'add'" @click="cancelForm">鍙栨秷</el-button> <el-button type="primary" @click="submitForm"> @@ -51,15 +54,16 @@ </template> <script setup> -import { ref, watch, onMounted } from "vue"; -import { getAreaOptions } from "@/api/system/area.js"; +import {ref, watch, onMounted} from "vue"; +import {getAreaOptions} from "@/api/system/area.js"; import addressList from "@/api/jsonApi/areaList.json"; -import { addOrEditCustomer } from "@/api/basicInformation/customer"; +import {addOrEditCustomer} from "@/api/basicInformation/customer"; const props = defineProps({ beforeClose: { type: Function, - default: () => { }, + default: () => { + }, }, form: { type: Object, @@ -111,7 +115,7 @@ // 琛ㄥ崟寮曠敤 const formRef = ref(null); // 琛ㄥ崟鏁版嵁 -const formData = ref({ ...props.form }); +const formData = ref({...props.form}); // 寮圭獥鍙鎬� const dialogVisible = defineModel("customerDialogFormVisible", { required: true, @@ -120,26 +124,26 @@ // 鐩戝惉澶栭儴浼犲叆鐨勮〃鍗曟暟鎹彉鍖� watch( - () => props.form, - (newVal) => { - formData.value = { ...newVal }; - }, - { deep: true } + () => props.form, + (newVal) => { + formData.value = {...newVal}; + }, + {deep: true} ); watch( - () => props.form, - (newVal) => { - formData.value = { ...newVal }; - }, - { deep: true } + () => props.form, + (newVal) => { + formData.value = {...newVal}; + }, + {deep: true} ); // 鐩戝惉鍐呴儴寮圭獥鐘舵�佸彉鍖� watch( - () => dialogVisible.value, - (newVal) => { - emit("update:customerDialogFormVisible", newVal); - } + () => dialogVisible.value, + (newVal) => { + emit("update:customerDialogFormVisible", newVal); + } ); // 鎻愪氦琛ㄥ崟 @@ -191,11 +195,11 @@ }; const rules = reactive({ customerName: [ - { required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur"}, ], taxpayerId: [ - { required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, - { min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, + {required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, + {min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, ], address: [ { @@ -204,14 +208,14 @@ trigger: "change", }, ], - bankAccount: [{ required: true, message: "璇疯緭鍏ラ摱琛岃处鎴�", trigger: "blur" }], - bankName: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }], - contactPerson: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }], - cids: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }], - bids: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }], + bankAccount: [{required: true, message: "璇疯緭鍏ラ摱琛岃处鎴�", trigger: "blur"}], + bankName: [{required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur"}], + contactPerson: [{required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur"}], + cids: [{required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur"}], + bids: [{required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur"}], contactPhone: [ - { required: true, message: "璇疯緭鍏ヨ仈绯讳汉", trigger: "blur" }, - { min: 11, max: 11, message: "璇疯緭鍏�11浣嶈仈绯讳汉鐢佃瘽", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヨ仈绯讳汉", trigger: "blur"}, + {min: 11, max: 11, message: "璇疯緭鍏�11浣嶈仈绯讳汉鐢佃瘽", trigger: "blur"}, ], }); </script> diff --git a/src/views/basicInformation/mould/supplier.vue b/src/views/basicInformation/mould/supplier.vue index 15ac14d..88a2192 100644 --- a/src/views/basicInformation/mould/supplier.vue +++ b/src/views/basicInformation/mould/supplier.vue @@ -1,41 +1,44 @@ <template> <div> <el-dialog v-model="dialogVisible" :title="title" width="600" :close-on-click-modal="false" - :before-close="handleClose"> - <el-form ref="formRef" style="max-width: 400px; margin: 0 auto" :model="formData" :rules="rules" label-width="auto"> + :before-close="handleClose"> + <el-form ref="formRef" style="max-width: 400px; margin: 0 auto" :model="formData" :rules="rules" + label-width="auto"> <el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierName"> - <el-input v-model="formData.supplierName" placeholder="璇疯緭鍏ヤ緵璐у晢鍚嶇О" /> + <el-input v-model="formData.supplierName" placeholder="璇疯緭鍏ヤ緵璐у晢鍚嶇О"/> </el-form-item> <el-form-item label="绾崇◣浜鸿瘑鍒彿" prop="taxpayerId"> - <el-input v-model="formData.taxpayerId" placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�" /> + <el-input v-model="formData.taxpayerId" placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�"/> </el-form-item> <el-form-item label="缁忚惀鍦板潃" prop="bids"> - <el-cascader placeholder="璇烽�夋嫨缁忚惀鍦板潃" size="default" :options="addressSelectOptions" v-model="formData.bids" - :props="cascaderProps" @change="handleChange"> + <el-cascader placeholder="璇烽�夋嫨缁忚惀鍦板潃" size="default" :options="addressSelectOptions" + v-model="formData.bids" + :props="cascaderProps" @change="handleChange"> </el-cascader> </el-form-item> <el-form-item label="璇︾粏鍦板潃" prop="businessAddress"> - <el-input v-model="formData.businessAddress" placeholder="璇疯緭鍏ュ鎴疯缁嗗湴鍧�" /> + <el-input v-model="formData.businessAddress" placeholder="璇疯緭鍏ュ鎴疯缁嗗湴鍧�"/> </el-form-item> <el-form-item label="寮�鎴疯" prop="bankAccount"> - <el-input v-model="formData.bankAccount" placeholder="璇疯緭鍏ュ紑鎴疯" /> + <el-input v-model="formData.bankAccount" placeholder="璇疯緭鍏ュ紑鎴疯"/> </el-form-item> <el-form-item label="閾惰璐︽埛" prop="bankName"> - <el-input v-model="formData.bankName" placeholder="璇疯緭鍏ラ摱琛岃处鎴�" /> + <el-input v-model="formData.bankName" placeholder="璇疯緭鍏ラ摱琛岃处鎴�"/> </el-form-item> <el-form-item label="鑱旂郴浜�" prop="contactPerson"> - <el-input v-model="formData.contactPerson" placeholder="璇疯緭鍏ヨ仈绯讳汉" /> + <el-input v-model="formData.contactPerson" placeholder="璇疯緭鍏ヨ仈绯讳汉"/> </el-form-item> <el-form-item label="鑱旂郴浜虹數璇�" prop="contactPhone"> - <el-input v-model="formData.contactPhone" placeholder="璇疯緭鍏ヨ仈绯讳汉鐢佃瘽" /> + <el-input v-model="formData.contactPhone" placeholder="璇疯緭鍏ヨ仈绯讳汉鐢佃瘽"/> </el-form-item> <el-form-item label="鑱旂郴浜哄湴鍧�" prop="cids"> - <el-cascader placeholder="璇烽�夋嫨鑱旂郴浜哄湴鍧�" size="default" :options="addressSelectOptions" v-model="formData.cids" - :props="cascaderProps" @change="handleChange"> + <el-cascader placeholder="璇烽�夋嫨鑱旂郴浜哄湴鍧�" size="default" :options="addressSelectOptions" + v-model="formData.cids" + :props="cascaderProps" @change="handleChange"> </el-cascader> </el-form-item> <el-form-item label="鑱旂郴浜鸿缁嗗湴鍧�" prop="contactAddress"> - <el-input v-model="formData.contactAddress" placeholder="璇疯緭鍏ヨ仈绯讳汉鍦板潃" /> + <el-input v-model="formData.contactAddress" placeholder="璇疯緭鍏ヨ仈绯讳汉鍦板潃"/> </el-form-item> <el-form-item class="dialog-footer"> <el-button v-if="addOrEdit === 'edit'" @click="resetForm">閲嶇疆</el-button> @@ -48,9 +51,9 @@ </template> <script setup> -import { ref, watch, defineProps, onMounted } from "vue"; -import { addOrEditSupply } from "@/api/basicInformation/supplier"; -import { getAreaOptions } from "@/api/system/area.js"; +import {ref, watch, defineProps, onMounted} from "vue"; +import {addOrEditSupply} from "@/api/basicInformation/supplier"; +import {getAreaOptions} from "@/api/system/area.js"; const props = defineProps({ beforeClose: { @@ -111,7 +114,7 @@ // 琛ㄥ崟寮曠敤 const formRef = ref(null); // 琛ㄥ崟鏁版嵁 -const formData = ref({ ...props.form }); +const formData = ref({...props.form}); // 寮圭獥鍙鎬� const dialogVisible = defineModel("supplierDialogFormVisible", { required: true, @@ -119,19 +122,19 @@ }); // 鐩戝惉澶栭儴浼犲叆鐨勮〃鍗曟暟鎹彉鍖� watch( - () => props.form, - (newVal) => { - formData.value = { ...newVal }; - }, - { deep: true } + () => props.form, + (newVal) => { + formData.value = {...newVal}; + }, + {deep: true} ); // 鐩戝惉鍐呴儴寮圭獥鐘舵�佸彉鍖� watch( - () => dialogVisible.value, - (newVal) => { - emit("update:supplierDialogFormVisible", newVal); - } + () => dialogVisible.value, + (newVal) => { + emit("update:supplierDialogFormVisible", newVal); + } ); // 澶勭悊鍦板潃閫夋嫨鍙樺寲 const handleChange = (value) => { @@ -175,7 +178,6 @@ const resetForm = () => { if (!formRef.value) return; formData.value = JSON.parse(JSON.stringify(copyForm.value)); - // formRef.value.resetFields(); }; // 鍏抽棴寮圭獥 const handleClose = () => { @@ -185,11 +187,11 @@ }; const rules = reactive({ supplierName: [ - { required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur"}, ], taxpayerId: [ - { required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, - { min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur" }, + {required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, + {min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur"}, ], // bids: [ // { @@ -198,12 +200,12 @@ // trigger: "change", // }, // ], - bankName: [{ required: true, message: "璇疯緭鍏ラ摱琛岃处鎴�", trigger: "blur" }], - bankAccount: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }], - contactPerson: [{ required: true, message: "鑱旂郴浜�", trigger: "blur" }], + bankName: [{required: true, message: "璇疯緭鍏ラ摱琛岃处鎴�", trigger: "blur"}], + bankAccount: [{required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur"}], + contactPerson: [{required: true, message: "鑱旂郴浜�", trigger: "blur"}], contactPhone: [ - { required: true, message: "璇疯緭鍏ヨ仈绯讳汉", trigger: "blur" }, - { min: 11, max: 11, message: "璇疯緭鍏�11浣嶈仈绯讳汉鐢佃瘽", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヨ仈绯讳汉", trigger: "blur"}, + {min: 11, max: 11, message: "璇疯緭鍏�11浣嶈仈绯讳汉鐢佃瘽", trigger: "blur"}, ], }); </script> diff --git a/src/views/index.vue b/src/views/index.vue index c57322c..452fcfa 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -1,14 +1,550 @@ <template> - <div class="app-container"> - + <div class="dashboard"> + <!-- 椤堕儴缁熻鍗$墖 --> + <div class="top-cards"> + <div class="stat-card revenue"> + <div class="card-icon"> + <i class="el-icon-money"></i> + </div> + <div class="card-content"> + <div class="card-title">钀ユ敹閲戦</div> + <div class="card-value">楼1,234,567</div> + <div class="card-trend"> + <span class="trend-label">杈冩槰鏃�</span> + <span class="trend-value up">+12.5%</span> + </div> + </div> + </div> + + <div class="stat-card supply"> + <div class="card-icon"> + <i class="el-icon-truck"></i> + </div> + <div class="card-content"> + <div class="card-title">渚涘簲閲�</div> + <div class="card-value">8,965 鍚�</div> + <div class="card-trend"> + <span class="trend-label">杈冩槰鏃�</span> + <span class="trend-value up">+8.2%</span> + </div> + </div> + </div> + </div> + + <!-- 涓棿鍥捐〃鍖哄煙 --> + <div class="chart-section"> + <div class="chart-container"> + <div class="chart-title">钀ユ敹鍒嗗竷</div> + <div ref="pieChart" class="chart-content pie-chart"></div> + </div> + + <div class="chart-container"> + <div class="chart-title">渚涘簲閲忚秼鍔�</div> + <div ref="areaChart" class="chart-content area-chart"></div> + </div> + </div> + + <!-- 搴曢儴涓夋爮甯冨眬 --> + <div class="bottom-section"> + <!-- 搴撳瓨缁熻 --> + <div class="bottom-card inventory"> + <div class="card-header"> + <h3>搴撳瓨缁熻</h3> + </div> + <div class="inventory-items"> + <div class="inventory-item"> + <div class="item-name">鍘熺叅</div> + <div class="item-value">15,432 鍚�</div> + <div class="item-status normal">姝e父</div> + </div> + <div class="inventory-item"> + <div class="item-name">绮剧叅</div> + <div class="item-value">8,765 鍚�</div> + <div class="item-status normal">姝e父</div> + </div> + <div class="inventory-item"> + <div class="item-name">鐒︾叅</div> + <div class="item-value">3,241 鍚�</div> + <div class="item-status low">鍋忎綆</div> + </div> + <div class="inventory-item"> + <div class="item-name">鍧楃叅</div> + <div class="item-value">6,789 鍚�</div> + <div class="item-status normal">姝e父</div> + </div> + </div> + </div> + + <!-- 鏌辩姸鍥� --> + <div class="bottom-card chart"> + <div class="card-header"> + <h3>鏈堝害瀵规瘮</h3> + </div> + <div ref="barChart" class="chart-content bar-chart"></div> + </div> + + <!-- 閿�鍞暟鎹〃鏍� --> + <div class="bottom-card table"> + <div class="card-header"> + <h3>閿�鍞暟鎹�</h3> + </div> + <el-table + :data="salesData" + style="width: 100%" + :header-cell-style="tableHeaderStyle" + > + <el-table-column prop="product" label="浜у搧" width="80"></el-table-column> + <el-table-column prop="quantity" label="鏁伴噺" width="80"></el-table-column> + <el-table-column prop="amount" label="閲戦" width="90"></el-table-column> + <el-table-column prop="status" label="鐘舵��" width="70"> + <template #default="scope"> + <el-tag + :type="scope.row.status === '宸插畬鎴�' ? 'success' : 'warning'" + size="small" + > + {{ scope.row.status }} + </el-tag> + </template> + </el-table-column> + </el-table> + </div> + </div> </div> </template> -<script setup name="Index"> +<script> +import * as echarts from 'echarts' +export default { + name: 'Dashboard', + data() { + return { + salesData: [ + { product: '鍘熺叅', quantity: '1,234鍚�', amount: '楼456,789', status: '宸插畬鎴�' }, + { product: '绮剧叅', quantity: '567鍚�', amount: '楼234,567', status: '宸插畬鎴�' }, + { product: '鐒︾叅', quantity: '890鍚�', amount: '楼345,678', status: '杩涜涓�' }, + { product: '鍧楃叅', quantity: '432鍚�', amount: '楼123,456', status: '宸插畬鎴�' }, + { product: '鐓ゆ偿', quantity: '678鍚�', amount: '楼234,567', status: '杩涜涓�' } + ], + tableHeaderStyle: { + backgroundColor: '#f5f7fa', + color: '#606266', + fontSize: '12px' + } + } + }, + mounted() { + this.$nextTick(() => { + this.initCharts() + }) + }, + methods: { + initCharts() { + this.initPieChart() + this.initAreaChart() + this.initBarChart() + }, + + initPieChart() { + const chart = echarts.init(this.$refs.pieChart) + const option = { + tooltip: { + trigger: 'item', + formatter: '{a} <br/>{b}: {c} ({d}%)' + }, + legend: { + orient: 'vertical', + left: 'right', + top: 'center', + textStyle: { + fontSize: 12 + } + }, + series: [ + { + name: '钀ユ敹鍒嗗竷', + type: 'pie', + radius: ['30%', '70%'], + center: ['40%', '50%'], + avoidLabelOverlap: false, + label: { + show: false, + position: 'center' + }, + emphasis: { + label: { + show: true, + fontSize: '16', + fontWeight: 'bold' + } + }, + labelLine: { + show: false + }, + data: [ + { value: 335, name: '鍘熺叅', itemStyle: { color: '#409EFF' } }, + { value: 310, name: '绮剧叅', itemStyle: { color: '#67C23A' } }, + { value: 234, name: '鐒︾叅', itemStyle: { color: '#E6A23C' } }, + { value: 135, name: '鍧楃叅', itemStyle: { color: '#F56C6C' } }, + { value: 155, name: '鍏朵粬', itemStyle: { color: '#909399' } } + ] + } + ] + } + chart.setOption(option) + + // 鍝嶅簲寮� + window.addEventListener('resize', () => { + chart.resize() + }) + }, + + initAreaChart() { + const chart = echarts.init(this.$refs.areaChart) + const option = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross', + label: { + backgroundColor: '#6a7985' + } + } + }, + legend: { + data: ['渚涘簲閲�'], + top: 10 + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + boundaryGap: false, + data: ['1鏈�', '2鏈�', '3鏈�', '4鏈�', '5鏈�', '6鏈�', '7鏈�'], + axisLabel: { + fontSize: 12 + } + } + ], + yAxis: [ + { + type: 'value', + axisLabel: { + fontSize: 12 + } + } + ], + series: [ + { + name: '渚涘簲閲�', + type: 'line', + stack: 'Total', + areaStyle: { + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: 'rgba(64, 158, 255, 0.3)' }, + { offset: 1, color: 'rgba(64, 158, 255, 0.1)' } + ]) + }, + emphasis: { + focus: 'series' + }, + data: [1200, 1320, 1010, 1340, 900, 1230, 1100], + lineStyle: { + color: '#409EFF' + }, + itemStyle: { + color: '#409EFF' + } + } + ] + } + chart.setOption(option) + + // 鍝嶅簲寮� + window.addEventListener('resize', () => { + chart.resize() + }) + }, + + initBarChart() { + const chart = echarts.init(this.$refs.barChart) + const option = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: { + type: 'category', + data: ['鍘熺叅', '绮剧叅', '鐒︾叅', '鍧楃叅', '鐓ゆ偿'], + axisLabel: { + fontSize: 11 + } + }, + yAxis: { + type: 'value', + axisLabel: { + fontSize: 11 + } + }, + series: [ + { + name: '閿�閲�', + type: 'bar', + data: [320, 302, 301, 334, 290], + itemStyle: { + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: '#409EFF' }, + { offset: 1, color: '#79bbff' } + ]) + }, + barWidth: '60%' + } + ] + } + chart.setOption(option) + + // 鍝嶅簲寮� + window.addEventListener('resize', () => { + chart.resize() + }) + } + } +} </script> -<style scoped lang="scss"> +<style scoped> +.dashboard { + padding: 20px; + background-color: #f5f7fa; + min-height: 100vh; +} +/* 椤堕儴缁熻鍗$墖 */ +.top-cards { + display: flex; + gap: 20px; + margin-bottom: 20px; +} + +.stat-card { + flex: 1; + background: white; + border-radius: 8px; + padding: 20px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + display: flex; + align-items: center; + gap: 15px; +} + +.card-icon { + width: 60px; + height: 60px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: 24px; + color: white; +} + +.revenue .card-icon { + background: linear-gradient(135deg, #409EFF, #79bbff); +} + +.supply .card-icon { + background: linear-gradient(135deg, #67C23A, #95d475); +} + +.card-content { + flex: 1; +} + +.card-title { + font-size: 14px; + color: #909399; + margin-bottom: 8px; +} + +.card-value { + font-size: 24px; + font-weight: bold; + color: #303133; + margin-bottom: 5px; +} + +.card-trend { + font-size: 12px; +} + +.trend-label { + color: #909399; + margin-right: 5px; +} + +.trend-value.up { + color: #67C23A; +} + +/* 涓棿鍥捐〃鍖哄煙 */ +.chart-section { + display: flex; + gap: 20px; + margin-bottom: 20px; +} +.el-scrollbar__view{ + width: 100%; +} +.chart-container { + flex: 1; + background: white; + border-radius: 8px; + padding: 20px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +.chart-title { + font-size: 16px; + font-weight: bold; + color: #303133; + margin-bottom: 15px; + padding-bottom: 10px; + border-bottom: 2px solid #f0f0f0; +} + +.chart-content { + height: 280px; +} + +/* 搴曢儴涓夋爮甯冨眬 */ +.bottom-section { + display: flex; + gap: 20px; +} + +.bottom-card { + flex: 1; + background: white; + border-radius: 8px; + padding: 20px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +.card-header { + margin-bottom: 15px; + padding-bottom: 10px; + border-bottom: 2px solid #f0f0f0; +} + +.card-header h3 { + margin: 0; + font-size: 16px; + font-weight: bold; + color: #303133; +} + +/* 搴撳瓨缁熻鏍峰紡 */ +.inventory-items { + display: flex; + flex-direction: column; + gap: 12px; +} + +.inventory-item { + display: flex; + justify-content: space-between; + align-items: center; + padding: 12px; + background: #f8f9fa; + border-radius: 6px; + border-left: 3px solid #409EFF; +} + +.item-name { + font-weight: bold; + color: #303133; +} + +.item-value { + color: #606266; + font-size: 14px; +} + +.item-status { + padding: 2px 8px; + border-radius: 12px; + font-size: 12px; + font-weight: bold; +} + +.item-status.normal { + background: #f0f9ff; + color: #67C23A; +} + +.item-status.low { + background: #fef0e6; + color: #E6A23C; +} + +/* 鏌辩姸鍥惧鍣� */ +.bar-chart { + height: 200px; +} + +/* 琛ㄦ牸鏍峰紡璋冩暣 */ +.bottom-card.table { + min-width: 320px; +} + +.bottom-card.table .el-table { + font-size: 12px; +} + +.bottom-card.table .el-table td, +.bottom-card.table .el-table th { + padding: 8px 0; +} + +/* 鍝嶅簲寮忚璁� */ +@media (max-width: 1200px) { + .bottom-section { + flex-direction: column; + } + + .chart-section { + flex-direction: column; + } +} + +@media (max-width: 768px) { + .top-cards { + flex-direction: column; + } + + .dashboard { + padding: 10px; + } + + .stat-card { + padding: 15px; + } + + .card-value { + font-size: 20px; + } +} </style> - diff --git a/src/views/procureMent/components/ProductionDialog.vue b/src/views/procureMent/components/ProductionDialog.vue index e420fbe..3c03cbb 100644 --- a/src/views/procureMent/components/ProductionDialog.vue +++ b/src/views/procureMent/components/ProductionDialog.vue @@ -1,57 +1,48 @@ <template> <div> <el-dialog - v-model="dialogFormVisible" - :title="title" - width="600" - :close-on-click-modal="false" - @close="handleClose" + v-model="dialogFormVisible" + :title="title" + width="600" + :close-on-click-modal="false" + @close="handleClose" > <el-form - ref="formRef" - :model="form" - :rules="rules" - label-width="auto" - class="production-form" - label-position="right" - style="max-width: 400px; margin: 0 auto" + ref="formRef" + :model="form" + :rules="rules" + label-width="auto" + class="production-form" + label-position="right" + style="max-width: 400px; margin: 0 auto" > <el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierId"> <el-select v-model="form.supplierId" placeholder="璇烽�夋嫨渚涘簲鍟�"> - <el-option :label="item.label" v-for="item in supplyList" :key="item.value" :value="item.value" /> + <el-option :label="item.label" v-for="item in supplyList" :key="item.value" :value="item.value"/> </el-select> </el-form-item> <el-form-item label="鐓ょ" prop="coalId"> <el-select v-model="form.coalId" placeholder="璇烽�夋嫨鐓ょ"> - <el-option :label="item.label" v-for="item in coalList" :key="item.value" :value="item.value" /> - </el-select> - </el-form-item> - <el-form-item label="鍗曚綅" prop="unit"> - <el-select - v-model="form.unit" - placeholder="璇烽�夋嫨鍗曚綅" - clearable - style="width: 100%" - > - <el-option label="鍚�" value="鍚�" /> - <el-option label="鍗冨厠" value="鍗冨厠" /> + <el-option :label="item.label" v-for="item in coalList" :key="item.value" :value="item.value"/> </el-select> </el-form-item> <el-form-item label="閲囪喘鏁伴噺" prop="purchaseQuantity"> <el-input - v-model.number="form.purchaseQuantity" - placeholder="璇疯緭鍏�" - @blur="handleQuantityBlur" + v-model.number="form.purchaseQuantity" + placeholder="璇疯緭鍏�" + @blur="handleQuantityBlur" > <template v-slot:suffix> - <i style="font-style: normal">{{ form.unit ? form.unit : "" }}</i> + <i style="font-style: normal">鍚�</i> </template> - </el-input> </el-form-item - ><el-form-item label="绋庣巼" prop="taxRate"> + </el-input> + </el-form-item + > + <el-form-item label="绋庣巼" prop="taxRate"> <el-input - v-model.number="form.taxRate" - placeholder="璇疯緭鍏ョ◣鐜�" - @blur="handleTaxRateBlur" + v-model.number="form.taxRate" + placeholder="璇疯緭鍏ョ◣鐜�" + @blur="handleTaxRateBlur" > <template v-slot:suffix> <i style="font-style: normal">%</i> @@ -60,9 +51,9 @@ </el-form-item> <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax"> <el-input - v-model.number="form.priceExcludingTax" - placeholder="璇疯緭鍏�" - @blur="handlePriceBlur" + v-model.number="form.priceExcludingTax" + placeholder="璇疯緭鍏�" + @blur="handlePriceBlur" > <template v-slot:suffix> <i style="font-style: normal">鍏�</i> @@ -71,8 +62,8 @@ </el-form-item> <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax"> <el-input - v-model.number="form.priceIncludingTax" - placeholder="鑷姩璁$畻" + v-model.number="form.priceIncludingTax" + placeholder="鑷姩璁$畻" > <template v-slot:suffix> <i style="font-style: normal">鍏�</i> @@ -81,8 +72,8 @@ </el-form-item> <el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax"> <el-input - v-model.number="form.totalPriceExcludingTax" - placeholder="鑷姩璁$畻" + v-model.number="form.totalPriceExcludingTax" + placeholder="鑷姩璁$畻" > <template v-slot:suffix> <i style="font-style: normal">鍏�</i> @@ -91,8 +82,8 @@ </el-form-item> <el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax"> <el-input - v-model.number="form.totalPriceIncludingTax" - placeholder="鑷姩璁$畻" + v-model.number="form.totalPriceIncludingTax" + placeholder="鑷姩璁$畻" > <template v-slot:suffix> <i style="font-style: normal">鍏�</i> @@ -100,16 +91,16 @@ </el-input> </el-form-item> <el-form-item label="鐧昏浜�" prop="registrantId"> - <el-input v-model="form.registrantId" disabled placeholder="璇疯緭鍏�" /> + <el-input v-model="form.registrantId" disabled placeholder="璇疯緭鍏�"/> </el-form-item> <el-form-item label="鐧昏鏃ユ湡" prop="registrationDate"> <el-date-picker - disabled - v-model="form.registrationDate" - type="date" - placeholder="YYYY-MM-DD" - style="width: 100%" - value-format="YYYY-MM-DD" + disabled + v-model="form.registrationDate" + type="date" + placeholder="YYYY-MM-DD" + style="width: 100%" + value-format="YYYY-MM-DD" /> </el-form-item> </el-form> @@ -117,10 +108,12 @@ <div class="dialog-footer"> <!-- 閲嶇疆鍜屽彇娑� --> <el-button @click="handleClose" v-if="title.includes('鏂板')" - >鍙栨秷</el-button + >鍙栨秷 + </el-button > <el-button @click="handleReset" v-if="title.includes('缂栬緫')" - >閲嶇疆</el-button + >閲嶇疆 + </el-button > <el-button type="primary" @click="handleSubmit">纭</el-button> </div> @@ -130,12 +123,11 @@ </template> <script setup name="ProductionDialog"> -import { ref, defineProps, watch, onMounted, nextTick, computed } from "vue"; -import { ElMessage } from "element-plus"; +import {ref, defineProps, watch, onMounted, nextTick, computed} from "vue"; +import {ElMessage} from "element-plus"; import useUserStore from "@/store/modules/user"; -import { addOrEditPR,getSupplyList, getCoalInfoList } from "@/api/procureMent"; -import { getSupply } from "@/api/basicInformation/supplier"; -import { getCoalInfo } from "@/api/basicInformation/coal"; +import {addOrEditPR, getSupplyList, getCoalInfoList} from "@/api/procureMent"; + const props = defineProps({ title: { type: String, @@ -164,7 +156,6 @@ getSupplyList(), getCoalInfoList(), ]); - console.log(supplyRes, coalRes); let supplyData = supplyRes.data; let coalData = coalRes.data; supplyList.value = supplyData.map((item) => ({ @@ -188,8 +179,8 @@ return 0; } return ( - Math.floor(parseFloat(num) * Math.pow(10, precision)) / - Math.pow(10, precision) + Math.floor(parseFloat(num) * Math.pow(10, precision)) / + Math.pow(10, precision) ); }; // 鍚◣鍗曚环璁$畻 @@ -250,9 +241,9 @@ // 澶勭悊绋庣巼杈撳叆妗嗗け鐒︼紝纭繚绮惧害 const handleTaxRateBlur = () => { if ( - form.value.taxRate !== null && - form.value.taxRate !== undefined && - form.value.taxRate !== "" + form.value.taxRate !== null && + form.value.taxRate !== undefined && + form.value.taxRate !== "" ) { form.value.taxRate = toFixed(parseFloat(form.value.taxRate), 2); } @@ -261,13 +252,13 @@ // 澶勭悊涓嶅惈绋庡崟浠疯緭鍏ユ澶辩劍锛岀‘淇濈簿搴� const handlePriceBlur = () => { if ( - form.value.priceExcludingTax !== null && - form.value.priceExcludingTax !== undefined && - form.value.priceExcludingTax !== "" + form.value.priceExcludingTax !== null && + form.value.priceExcludingTax !== undefined && + form.value.priceExcludingTax !== "" ) { form.value.priceExcludingTax = toFixed( - parseFloat(form.value.priceExcludingTax), - 2 + parseFloat(form.value.priceExcludingTax), + 2 ); } }; @@ -275,13 +266,13 @@ // 澶勭悊閲囪喘鏁伴噺杈撳叆妗嗗け鐒︼紝纭繚绮惧害 const handleQuantityBlur = () => { if ( - form.value.purchaseQuantity !== null && - form.value.purchaseQuantity !== undefined && - form.value.purchaseQuantity !== "" + form.value.purchaseQuantity !== null && + form.value.purchaseQuantity !== undefined && + form.value.purchaseQuantity !== "" ) { form.value.purchaseQuantity = toFixed( - parseFloat(form.value.purchaseQuantity), - 3 + parseFloat(form.value.purchaseQuantity), + 3 ); // 鏁伴噺淇濈暀3浣嶅皬鏁� } }; @@ -293,30 +284,29 @@ }); const rules = { supplierName: [ - { required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur"}, ], - coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }], - unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }], + coal: [{required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur"}], purchaseQuantity: [ - { required: true, message: "璇疯緭鍏ラ噰璐暟閲�", trigger: "blur" }, - { type: "number", message: "閲囪喘鏁伴噺蹇呴』涓烘暟瀛�", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ラ噰璐暟閲�", trigger: "blur"}, + {type: "number", message: "閲囪喘鏁伴噺蹇呴』涓烘暟瀛�", trigger: "blur"}, ], priceExcludingTax: [ - { required: true, message: "璇疯緭鍏ュ崟浠�", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ュ崟浠�", trigger: "blur"}, ], totalPriceExcludingTax: [ - { required: true, message: "璇疯緭鍏ユ�讳环", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ユ�讳环", trigger: "blur"}, ], priceIncludingTax: [ - { required: true, message: "璇疯緭鍏ュ惈绋庡崟浠�", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ュ惈绋庡崟浠�", trigger: "blur"}, ], totalPriceIncludingTax: [ - { required: true, message: "璇疯緭鍏ュ惈绋庢�讳环", trigger: "blur" }, + {required: true, message: "璇疯緭鍏ュ惈绋庢�讳环", trigger: "blur"}, ], - taxRate: [{ required: true, message: "璇疯緭鍏ョ◣鐜�", trigger: "blur" }], - registrantId: [{ required: true, message: "璇疯緭鍏ョ櫥璁颁汉", trigger: "blur" }], + taxRate: [{required: true, message: "璇疯緭鍏ョ◣鐜�", trigger: "blur"}], + registrantId: [{required: true, message: "璇疯緭鍏ョ櫥璁颁汉", trigger: "blur"}], registrationDate: [ - { required: true, message: "璇烽�夋嫨鐧昏鏃ユ湡", trigger: "change" }, + {required: true, message: "璇烽�夋嫨鐧昏鏃ユ湡", trigger: "change"}, ], }; // 鍏抽棴寮圭獥 diff --git a/src/views/procureMent/index.vue b/src/views/procureMent/index.vue index 644b3a8..793267a 100644 --- a/src/views/procureMent/index.vue +++ b/src/views/procureMent/index.vue @@ -18,12 +18,11 @@ <!-- 鎿嶄綔鎸夐挳鍖� --> <el-row :gutter="24" class="table-toolbar"> <el-button type="primary" :icon="Plus" @click="handleAdd" - >鏂板缓</el-button - > + >鏂板缓 + </el-button> <el-button type="danger" :icon="Delete" @click="handleDelete" - >鍒犻櫎</el-button - > - <!-- <el-button type="info" :icon="Download" @click="handleExport">瀵煎嚭</el-button> --> + >鍒犻櫎 + </el-button> </el-row> <!-- 琛ㄦ牸缁勪欢 --> <data-table @@ -66,7 +65,12 @@ import DataTable from "@/components/Table/ETable.vue"; import Pagination from "@/components/Pagination"; import ProductionDialog from "./components/ProductionDialog.vue"; -import { purchaseRegistration } from "@/api/procureMent"; +import { + purchaseRegistration, + getSupplyList, + getCoalInfoList, +} from "@/api/procureMent"; + import useUserStore from "@/store/modules/user"; // 寮曞叆瀛楀吀鏁版嵁 const { proxy } = getCurrentInstance(); @@ -117,9 +121,22 @@ // supplier 渚涘簲鍟嗘暟鎹� const columns = ref([ - { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 200 }, - { prop: "coal", label: "鐓ょ绫诲瀷", minWidth: 120 }, - { prop: "unit", label: "鍗曚綅", minWidth: 150 }, + { + prop: "supplierId", + label: "渚涘簲鍟嗗悕绉�", + minWidth: 200, + formatter: (row) => { + return MatchQuery(row.supplierId, "supplyRes") || "鏈煡渚涘簲鍟�"; + }, + }, + { + prop: "coalId", + label: "鐓ょ绫诲瀷", + minWidth: 120, + formatter: (row) => { + return MatchQuery(row.coalId, "coalRes") || "鏈煡鐓ょ"; + }, + }, { prop: "purchaseQuantity", label: "閲囪喘鏁伴噺", minWidth: 100 }, { prop: "priceIncludingTax", label: "鍗曚环锛堝惈绋庯級", minWidth: 150 }, { prop: "totalPriceIncludingTax", label: "鎬讳环锛堝惈绋庯級", minWidth: 100 }, @@ -128,6 +145,16 @@ { prop: "registrantId", label: "鐧昏浜�", minWidth: 100 }, { prop: "registrationDate", label: "鐧昏鏃ユ湡", minWidth: 100 }, ]); + +// 鍖归厤鏌ヨ瀛楁 +const MatchQuery = (data, name) => { + const list = name === "supplyRes" ? supplyRes.value.data : coalRes.value.data; + const item = list.find((items) => items.id == data); + return item ? item.coal || item.supplierName : ""; +}; +// 鑾峰彇渚涘簲鍟嗗垪琛� +const supplyRes = ref([]); +const coalRes = ref([]); // 閲嶇疆鏌ヨ const resetQuery = () => { @@ -167,7 +194,7 @@ form.value = { supplierName: "", coal: "", - unit: "", + unit: "鍚�", purchaseQuantity: "", priceExcludingTax: "", totalPriceExcludingTax: "", @@ -227,17 +254,6 @@ const handleDeleteSuccess = (row) => { ElMessage.success("鍒犻櫎鎴愬姛锛�" + row.supplierName); }; -// 瀵煎嚭 -const handleExport = (row) => { - proxy.download( - "system/post/export", - { - ...queryParams.value, - }, - `post_${new Date().getTime()}.xlsx` - ); - ElMessage.success("瀵煎嚭鏁版嵁锛�" + row.supplierName); -}; // 鎴愬姛 const handleSuccess = (val) => { tableData.value.push(val); @@ -248,6 +264,10 @@ const getList = async () => { loading.value = true; try { + [supplyRes.value, coalRes.value] = await Promise.all([ + getSupplyList(), + getCoalInfoList(), + ]); // 浼犻�掑垎椤靛弬鏁� let res = await purchaseRegistration({ current: current.value, @@ -271,6 +291,7 @@ .app-container { box-sizing: border-box; } + .search-form { background-color: #fff; padding: 20px 20px 0 20px; @@ -278,6 +299,7 @@ border-radius: 4px; box-shadow: var(--el-box-shadow-light); } + .search-form :deep(.el-form-item) { margin-bottom: 16px; width: 100%; @@ -289,11 +311,13 @@ width: 50%; } } + @media screen and (min-width: 1200px) { .search-form :deep(.el-form-item) { width: 18%; } } + .table-toolbar { margin-bottom: 20px; display: flex; @@ -306,15 +330,18 @@ .table-toolbar { flex-direction: column; } + .table-toolbar .el-button { width: 100%; } } + /* 琛ㄦ牸宸ュ叿鏍� */ .table-toolbar, .table-toolbar > * { margin: 0 0 0 0 !important; } + .table-toolbar { margin-bottom: 20px !important; } diff --git a/src/views/production/components/ProductionDetailsTable.vue b/src/views/production/components/ProductionDetailsTable.vue index 7a87b17..1db3794 100644 --- a/src/views/production/components/ProductionDetailsTable.vue +++ b/src/views/production/components/ProductionDetailsTable.vue @@ -1,20 +1,20 @@ <template> - <el-table :data="tableData" :border="border" style="width: 100%"> + <el-table :data="tableData" :border="border" style="width: 100%"> <el-table-column label="鐓ょ" min-width="120"> <template #default="{ row, $index }"> - <el-select - clearable - :model-value="getCoalNameById(row.coalId) || row.coalId" - placeholder="璇烽�夋嫨鐓ょ" - @change="(value) => handleCoalSelectChange(row, value)" - filterable - :key="`coalId-select-${$index}-${weekList.length}`" + <el-select + clearable + :model-value="getCoalNameById(row.coalId) || row.coalId" + placeholder="璇烽�夋嫨鐓ょ" + @change="(value) => handleCoalSelectChange(row, value)" + filterable + :key="`coalId-select-${$index}-${weekList.length}`" > <el-option - v-for="(item, index) of weekList" - :key="`option-${index}-${item.key}`" - :label="item.value" - :value="item.value" + v-for="(item, index) of weekList" + :key="`option-${index}-${item.key}`" + :label="item.value" + :value="item.value" /> </el-select> </template> @@ -22,10 +22,10 @@ <el-table-column label="鐢熶骇鏁伴噺" min-width="120"> <template #default="{ row, $index }"> <el-input - v-model="row.productionQuantity" - placeholder="璇疯緭鍏ョ敓浜ф暟閲�" - type="number" - @input="handleInput('productionQuantity', $index, $event)" + v-model="row.productionQuantity" + placeholder="璇疯緭鍏ョ敓浜ф暟閲�" + type="number" + @input="handleInput('productionQuantity', $index, $event)" /> </template> </el-table-column> @@ -33,10 +33,10 @@ <el-table-column label="浜哄伐鎴愭湰" min-width="120"> <template #default="{ row, $index }"> <el-input - v-model="row.laborCost" - placeholder="璇疯緭鍏ヤ汉宸ユ垚鏈�" - type="number" - @input="handleInput('laborCost', $index, $event)" + v-model="row.laborCost" + placeholder="璇疯緭鍏ヤ汉宸ユ垚鏈�" + type="number" + @input="handleInput('laborCost', $index, $event)" > <template #suffix> <i style="font-style: normal">鍏�</i> @@ -48,10 +48,10 @@ <el-table-column label="鑳借�楁垚鏈�" min-width="120"> <template #default="{ row, $index }"> <el-input - v-model="row.energyConsumptionCost" - placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�" - type="number" - @input="handleInput('energyConsumptionCost', $index, $event)" + v-model="row.energyConsumptionCost" + placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�" + type="number" + @input="handleInput('energyConsumptionCost', $index, $event)" > <template #suffix> <i style="font-style: normal">鍏�</i> @@ -63,10 +63,10 @@ <el-table-column label="璁惧鎶樻棫" min-width="120"> <template #default="{ row, $index }"> <el-input - v-model="row.equipmentDepreciation" - placeholder="璇疯緭鍏ヨ澶囨姌鏃�" - type="number" - @input="handleInput('equipmentDepreciation', $index, $event)" + v-model="row.equipmentDepreciation" + placeholder="璇疯緭鍏ヨ澶囨姌鏃�" + type="number" + @input="handleInput('equipmentDepreciation', $index, $event)" > <template #suffix> <i style="font-style: normal">鍏�</i> @@ -78,10 +78,10 @@ <el-table-column label="閲囪喘鍗曚环" min-width="120"> <template #default="{ row, $index }"> <el-input - v-model="row.purchasePrice" - placeholder="璇疯緭鍏ラ噰璐崟浠�" - type="number" - @input="handleInput('purchasePrice', $index, $event)" + v-model="row.purchasePrice" + placeholder="璇疯緭鍏ラ噰璐崟浠�" + type="number" + @input="handleInput('purchasePrice', $index, $event)" > <template #suffix> <i style="font-style: normal">鍏�</i> @@ -93,12 +93,12 @@ <el-table-column label="鎬绘垚鏈�" min-width="120"> <template #default="{ row, $index }"> <el-input - disabled - v-model="row.totalCost" - placeholder="鎬绘垚鏈�" - type="number" - :readonly="autoCalculate" - @input="handleInput('totalCost', $index, $event)" + disabled + v-model="row.totalCost" + placeholder="鎬绘垚鏈�" + type="number" + :readonly="autoCalculate" + @input="handleInput('totalCost', $index, $event)" > <template #suffix> <i style="font-style: normal">鍏�</i> @@ -109,34 +109,34 @@ <el-table-column label="鐢熶骇浜�" min-width="120"> <template #default="{ row, $index }"> <el-select - clearable - :model-value="getUserNameById(row.producer) || row.producer" - placeholder="璇烽�夋嫨鐢熶骇浜�" - @change="(value) => handleUserSelectChange(row, value)" - filterable - :key="`producer-select-${$index}-${userList.length}`" + clearable + :model-value="getUserNameById(row.producer) || row.producer" + placeholder="璇烽�夋嫨鐢熶骇浜�" + @change="(value) => handleUserSelectChange(row, value)" + filterable + :key="`producer-select-${$index}-${userList.length}`" > <el-option - v-for="(item, index) of userList" - :key="`option-${index}-${item.key}`" - :label="item.value" - :value="item.value" + v-for="(item, index) of userList" + :key="`option-${index}-${item.key}`" + :label="item.value" + :value="item.value" /> </el-select> </template> </el-table-column> <el-table-column - v-if="showOperations" - label="鎿嶄綔" - width="120" - fixed="right" + v-if="showOperations" + label="鎿嶄綔" + width="120" + fixed="right" > <template #default="{ $index }"> <el-button - type="danger" - size="small" - @click="handleDelete($index)" - :icon="Delete" + type="danger" + size="small" + @click="handleDelete($index)" + :icon="Delete" > 鍒犻櫎 </el-button> @@ -146,11 +146,12 @@ </template> <script setup name="ProductionDetailsTable"> -import { ref, computed, watch, onMounted, nextTick } from "vue"; -import { Delete } from "@element-plus/icons-vue"; -import { getCoalFieldList } from "@/api/basicInformation/coalQualityMaintenance"; -import { getCoalInfoList } from "@/api/production"; -import { userListAll } from "@/api/publicApi"; +import {ref, computed, watch, onMounted, nextTick} from "vue"; +import {Delete} from "@element-plus/icons-vue"; +import {getCoalFieldList} from "@/api/basicInformation/coalQualityMaintenance"; +import {getCoalInfoList} from "@/api/production"; +import {userListAll} from "@/api/publicApi"; + const props = defineProps({ modelValue: { type: Array, @@ -189,19 +190,19 @@ // 濡傛灉寮�鍚嚜鍔ㄨ绠楁�绘垚鏈� if ( - props.autoCalculate && - [ - "laborCost", - "energyCost", - "equipmentDepreciation", - "purchasePrice", - ].includes(field) + props.autoCalculate && + [ + "laborCost", + "energyCost", + "equipmentDepreciation", + "purchasePrice", + ].includes(field) ) { calculateTotalCost(newData[index]); } tableData.value = newData; - emit("input-change", { field, index, value, row: newData[index] }); + emit("input-change", {field, index, value, row: newData[index]}); }; // 璁$畻鎬绘垚鏈� @@ -212,10 +213,10 @@ const purchasePrice = parseFloat(row.purchasePrice) || 0; row.totalCost = ( - laborCost + - energyCost + - equipmentDepreciation + - purchasePrice + laborCost + + energyCost + + equipmentDepreciation + + purchasePrice ).toFixed(2); }; @@ -254,7 +255,7 @@ if (newValue && weekList.value.length > 0) { // 褰撴暟鎹姞杞藉畬鎴愪笖weekList宸茶幏鍙栨椂锛岀‘淇濇樉绀烘纭� } -}, { deep: true }); +}, {deep: true}); // 鐩戝惉weekList鍙樺寲锛屽綋涓嬫媺鏁版嵁鍔犺浇瀹屾垚鍚庡鐞嗘樉绀� watch(weekList, (newList) => { @@ -266,23 +267,23 @@ tableData.value = tempData; }); } -}, { deep: true }); +}, {deep: true}); -onMounted(async()=>{ +onMounted(async () => { let res = await getCoalInfoList() console.log(res); res.data.forEach(item => { let obj = {}; obj.value = item.coal; obj.key = item.id; - weekList.value.push(obj); + weekList.value.push(obj); }); let ress = await userListAll(); ress.data.forEach(item => { let obj = {}; obj.value = item.nickName; obj.key = item.userId; - userList.value.push(obj); + userList.value.push(obj); }); // 閫氱煡鐖剁粍浠秝eekList宸插姞杞藉畬鎴� nextTick(() => { @@ -302,7 +303,7 @@ } }; const userList = ref([]); -const getUserList = (async()=>{ +const getUserList = (async () => { let res = await userListAll(); if (res.code === 200) { userList.value = res.data.map((item) => ({ @@ -318,7 +319,7 @@ if (newValue && userList.value.length > 0) { // 褰撴暟鎹姞杞藉畬鎴愪笖weekList宸茶幏鍙栨椂锛岀‘淇濇樉绀烘纭� } -}, { deep: true }); +}, {deep: true}); // 鐩戝惉userList鍙樺寲锛屽綋涓嬫媺鏁版嵁鍔犺浇瀹屾垚鍚庡鐞嗘樉绀� watch(userList, (newList) => { @@ -330,7 +331,7 @@ tableData.value = tempData; }); } -}, { deep: true }); +}, {deep: true}); const getUserNameById = (id) => { const producer = userList.value.find(item => item.key == id); diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue index 0cd330e..3b96834 100644 --- a/src/views/production/components/ProductionDialog.vue +++ b/src/views/production/components/ProductionDialog.vue @@ -1,25 +1,30 @@ <template> <el-dialog - v-model="dialogVisible" - :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'" - width="1200px" - :close-on-click-modal="false" - @close="handleClose" + v-model="dialogVisible" + :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'" + width="1200px" + :close-on-click-modal="false" + @close="handleClose" > <el-row :gutter="10" style="margin-bottom: 10px"> <el-col :span="3"> <el-button type="primary" @click="handlData" - ><el-icon> <Plus /> </el-icon>閫夋嫨鏁版嵁</el-button + > + <el-icon> + <Plus/> + </el-icon> + 閫夋嫨鏁版嵁 + </el-button > </el-col> <el-col :span="4"> <el-button - type="danger" - @click="removeSelectedData" - :disabled="tableData.length === 0" + type="danger" + @click="removeSelectedData" + :disabled="tableData.length === 0" > <el-icon> - <Delete /> + <Delete/> </el-icon> 娓呯┖宸查�� </el-button> @@ -34,15 +39,15 @@ </el-col> </el-row> <ETableModify - :columns="columns" - :showOperations="false" - height="200" - @cell-edit="handleCellEdit" - :tableData="tableData" - :showOverflowTooltip="false" - @row-click="handleRowClick" - :editableColumns="['usedQuantity']" - @delete="handleRemoveItem" + :columns="columns" + :showOperations="false" + height="200" + @cell-edit="handleCellEdit" + :tableData="tableData" + :showOverflowTooltip="false" + @row-click="handleRowClick" + :editableColumns="['usedQuantity']" + @delete="handleRemoveItem" /> <div class="empty-table"> <h1>鐢熶骇鏄庣粏</h1> @@ -50,7 +55,7 @@ <el-col :span="2"> <el-button type="primary" @click="addNewRow"> <el-icon> - <Plus /> + <Plus/> </el-icon> 鏂板 </el-button> @@ -65,60 +70,62 @@ </el-col> --> </el-row> <ProductionDetailsTable - v-model="detailsTableData" - :border="false" - :show-operations="true" - :auto-calculate="true" - @input-change="handleDetailsChange" - @delete-row="handleDeleteRow" + v-model="detailsTableData" + :border="false" + :show-operations="true" + :auto-calculate="true" + @input-change="handleDetailsChange" + @delete-row="handleDeleteRow" /> </div> <template #footer> <div class="dialog-footer"> <el-button - @click="handleClose" - v-if="dialogType === 'add' || dialogType === 'edit'" - >鍙� 娑�</el-button + @click="handleClose" + v-if="dialogType === 'add' || dialogType === 'edit'" + >鍙� 娑� + </el-button > <!-- <el-button @click="handleReset" v-if="dialogType === 'edit'" >閲� 缃�</el-button > --> <el-button type="primary" :loading="loading" @click="handleSubmit" - >纭� 瀹�</el-button + >纭� 瀹� + </el-button > </div> </template> </el-dialog> <el-dialog - v-model="innerVisible" - width="1000" - title="閫夋嫨閰嶇疆鏁版嵁" - center - append-to-body + v-model="innerVisible" + width="1000" + title="閫夋嫨閰嶇疆鏁版嵁" + center + append-to-body > <div style="margin-bottom: 10px"> <el-alert - v-if="tableData.length > 0" - :title="`褰撳墠宸查�夋嫨 ${tableData.length} 鏉℃暟鎹甡" - type="info" - :closable="false" - show-icon + v-if="tableData.length > 0" + :title="`褰撳墠宸查�夋嫨 ${tableData.length} 鏉℃暟鎹甡" + type="info" + :closable="false" + show-icon /> </div> <ETable - :showIndex="false" - :showOverflowTooltip="false" - @selection-change="handleSelectionChange" - :showOperations="false" - ref="etableRef" - :columns="formalDatabaseColumns" - :tableData="formalDatabaseData" - :defaultSelectedIds="selectedIds" - :rowKey="'id'" - height="400" - @cell-edit="handleCellEdit" - :show-selection="true" + :showIndex="false" + :showOverflowTooltip="false" + @selection-change="handleSelectionChange" + :showOperations="false" + ref="etableRef" + :columns="formalDatabaseColumns" + :tableData="formalDatabaseData" + :defaultSelectedIds="selectedIds" + :rowKey="'id'" + height="400" + @cell-edit="handleCellEdit" + :show-selection="true" /> <el-row :gutter="24" style="margin-top: 15px"> <el-col :span="12"> @@ -129,9 +136,9 @@ <el-col :span="12" style="text-align: right"> <el-button @click="innerVisible = false">鍙栨秷</el-button> <el-button - type="primary" - @click="handleSelectData" - :disabled="formalDatabaseSelectedData.length === 0" + type="primary" + @click="handleSelectData" + :disabled="formalDatabaseSelectedData.length === 0" > 纭畾娣诲姞 </el-button> @@ -141,34 +148,35 @@ </template> <script setup> -import { ref, reactive, watch, onMounted, nextTick, computed } from "vue"; +import {ref, reactive, watch, onMounted, nextTick, computed} from "vue"; import ETable from "@/components/Table/ETable.vue"; import ETableModify from "@/components/Table/EtableModify.vue"; import ProductionDetailsTable from "./ProductionDetailsTable.vue"; -import { ElMessage, ElMessageBox, ElAlert, ElText } from "element-plus"; -import { Delete, Warning, Plus } from "@element-plus/icons-vue"; +import {ElMessage, ElMessageBox, ElAlert, ElText} from "element-plus"; +import {Delete, Warning, Plus} from "@element-plus/icons-vue"; import { getOfficialAll, addOrEditPM, + getCoalInfoList, deleteProductionInventory, } from "@/api/production/index.js"; -import { validateFormData, validateNumber, deepClone, createDefaultProductionRow } from "@/utils/production"; -import { useCoalData } from "./useCoalData"; +import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production"; +import {useCoalData} from "./useCoalData"; import useUserStore from "@/store/modules/user"; // Props 鍜� Emits const props = defineProps({ - visible: { type: Boolean, default: false }, - type: { type: String, default: "add" }, - rowData: { type: Object, default: () => ({}) }, + visible: {type: Boolean, default: false}, + type: {type: String, default: "add"}, + rowData: {type: Object, default: () => ({})}, }); -const dialogVisible = defineModel("visible", { type: Boolean, default: false }); +const dialogVisible = defineModel("visible", {type: Boolean, default: false}); const emit = defineEmits(["update:visible", "success", "update:productionAndProcessing"]); // 鐢ㄦ埛淇℃伅鍜岀叅绉嶆暟鎹� const userStore = useUserStore(); -const { getCoalNameById } = useCoalData(); +const {getCoalNameById} = useCoalData(); let userInfo; // 瀵硅瘽妗嗙姸鎬� @@ -185,10 +193,16 @@ const selectedIds = ref([]); const currentRow = ref(null); const copyForm = ref(null); +const coalList = ref([]) +const supplierList = ref({}); // 琛ㄦ牸鍒楅厤缃� const columns = [ - { label: "鐓ょ", prop: "coal", minwidth: 120 }, - { label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100 }, + {prop: "coalId", label: "鐓ょ", minwidth: 60,slot:false, + formatter: (row) => { + return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--"; + } + }, + {label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100}, { label: "浣跨敤鏁伴噺", prop: "usedQuantity", @@ -199,18 +213,28 @@ ]; const formalDatabaseColumns = ref([ - { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150 }, - { prop: "coal", label: "鐓ょ绫诲瀷", minwidth: 60 }, - { prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80 }, - { prop: "unit", label: "鍗曚綅", minwidth: 20 }, - { prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80 }, - { prop: "createTime", label: "鐧昏鏃ユ湡", width: 200 }, + {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150 + // ,formatter: (row) => { + // console.log(row); + // return supplierList.value[row.supplierId] || "--"; + // } + }, + {prop: "coalId", label: "鐓ょ", minwidth: 60, + formatter: (row) => { + // return coalList.value[row.coalId].coal || "--"; + return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--"; + } + }, + {prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80}, + {prop: "unit", label: "鍗曚綅", minwidth: 20}, + {prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80}, + {prop: "createTime", label: "鐧昏鏃ユ湡", width: 200}, ]); // 宸ュ叿鍑芥暟 const debugIdMatching = () => { if (formalDatabaseData.value.length > 0 && selectedIds.value.length > 0) { const matchedRows = formalDatabaseData.value.filter((row) => - selectedIds.value.includes(row.id) + selectedIds.value.includes(row.id) ); } }; @@ -222,12 +246,15 @@ // 鑾峰彇閰嶇疆鏁版嵁 const handlData = async () => { innerVisible.value = true; - let res = await getOfficialAll(); - if (res.code === 200) { - formalDatabaseData.value = res.data; + let getSupplier = await getOfficialAll(); + let getCoalName = await getCoalInfoList(); + coalList.value = getCoalName.data || []; + supplierList.value = getSupplier.data || []; + if (getSupplier.code === 200) { + formalDatabaseData.value = getSupplier.data; const existingOfficialIds = tableData.value - .map((item) => item.officialId) - .filter((id) => id); + .map((item) => item.officialId) + .filter((id) => id); selectedIds.value = existingOfficialIds; debugIdMatching(); nextTick(() => { @@ -252,7 +279,7 @@ try { etableRef.value.clearSelection(); const rowsToSelect = formalDatabaseData.value.filter((row) => - ids.includes(row.id) + ids.includes(row.id) ); if (rowsToSelect.length > 0) { etableRef.value.setRowsSelection(rowsToSelect, true); @@ -277,8 +304,8 @@ detailsTableData.value = data.productionList || []; dialogType.value = "edit"; const existingOfficialIds = tableData.value - .map((item) => item.officialId) - .filter((id) => id); + .map((item) => item.officialId) + .filter((id) => id); selectedIds.value = existingOfficialIds; }; // 鐩戝惉瀵硅瘽妗嗙姸鎬侊紝鍦ㄦ墦寮�鏃惰缃�変腑鐘舵�� @@ -319,8 +346,8 @@ // 鏇存柊selectedIds锛岀‘淇濆寘鍚墍鏈夊綋鍓峵ableData涓殑officialId const allOfficialIds = tableData.value - .map((item) => item.officialId) - .filter((id) => id); + .map((item) => item.officialId) + .filter((id) => id); selectedIds.value = allOfficialIds; // 鍏抽棴閫夋嫨瀵硅瘽妗� @@ -348,13 +375,13 @@ // 楠岃瘉鐢熶骇鏄庣粏鏁版嵁 const detailsValidation = validateFormData(detailsTableData.value, [ "coalId", - "productionQuantity", + "productionQuantity", "laborCost", "energyConsumptionCost", "equipmentDepreciation", "purchasePrice" ]); - + if (!detailsValidation.isValid) { ElMessage.warning(detailsValidation.message); return; @@ -400,13 +427,13 @@ const handleCellEdit = (row, prop, value) => { if (prop === "usedQuantity") { const validation = validateNumber(value, 0, Number(row.inventoryQuantity)); - + if (!validation.isValid) { ElMessage.warning(validation.message); row.usedQuantity = validation.value; return; } - + row.usedQuantity = validation.value; } }; @@ -445,15 +472,15 @@ // 鍒犻櫎鍗曚釜宸查�夋暟鎹」 const handleRemoveItem = (row) => { const index = tableData.value.findIndex( - (item) => item.officialId === row.officialId + (item) => item.officialId === row.officialId ); if (index > -1) { tableData.value.splice(index, 1); // 鏇存柊selectedIds const updatedOfficialIds = tableData.value - .map((item) => item.officialId) - .filter((id) => id); + .map((item) => item.officialId) + .filter((id) => id); selectedIds.value = updatedOfficialIds; ElMessage.success("宸插垹闄ら�変腑椤�"); } @@ -470,21 +497,22 @@ cancelButtonText: "鍙栨秷", type: "warning", }) - .then(async () => { - if (dialogType.value === "edit") { - let res = await deleteProductionInventory({ - productionInventoryList: tableData.value, - }); - emit("update:productionAndProcessing", tableData.value, copyForm.value); - } - // [Vue warn]: Component emitted event "update:productionAndProcessing" but it is neither declared in the emits option nor as an "onUpdate:productionAndProcessing" prop. + .then(async () => { + if (dialogType.value === "edit") { + let res = await deleteProductionInventory({ + productionInventoryList: tableData.value, + }); + emit("update:productionAndProcessing", tableData.value, copyForm.value); + } + // [Vue warn]: Component emitted event "update:productionAndProcessing" but it is neither declared in the emits option nor as an "onUpdate:productionAndProcessing" prop. - formalDatabaseSelectedData.value = []; - tableData.value = []; - selectedIds.value = []; - ElMessage.success("宸叉竻绌烘墍鏈夋暟鎹�"); - }) - .catch(() => {}); + formalDatabaseSelectedData.value = []; + tableData.value = []; + selectedIds.value = []; + ElMessage.success("宸叉竻绌烘墍鏈夋暟鎹�"); + }) + .catch(() => { + }); }; // 璁$畻鎬讳娇鐢ㄩ噺 @@ -507,6 +535,7 @@ .el-row > .el-col > h1 { font-weight: bolder; } + .empty-table > .el-row { margin-bottom: 12px; } diff --git a/src/views/production/components/useCoalData.js b/src/views/production/components/useCoalData.js index 37b2245..9a86b81 100644 --- a/src/views/production/components/useCoalData.js +++ b/src/views/production/components/useCoalData.js @@ -2,9 +2,9 @@ * 鐓ょ鏁版嵁绠$悊缁勫悎寮忓嚱鏁� * 鎻愪緵鐓ょ鏁版嵁鐨勮幏鍙栥�佺紦瀛樸�佽浆鎹㈢瓑鍔熻兘 */ -import { ref, computed, watch } from 'vue'; -import { getCoalInfoList } from "@/api/production"; -import { ElMessage } from 'element-plus'; +import {ref, computed, watch} from 'vue'; +import {getCoalInfoList} from "@/api/production"; +import {ElMessage} from 'element-plus'; // 鍏ㄥ眬鐓ょ鏁版嵁缂撳瓨 const coalData = ref([]); @@ -12,85 +12,85 @@ const isLoaded = ref(false); export function useCoalData() { - - // 鑾峰彇鐓ょ鏁版嵁 - const getCoalData = async (forceRefresh = false) => { - if (isLoaded.value && !forceRefresh) { - return coalData.value; - } - if (isLoading.value) { - // 濡傛灉姝e湪鍔犺浇锛岀瓑寰呭姞杞藉畬鎴� - return new Promise((resolve) => { - const unwatch = watch(isLoading, (loading) => { - if (!loading) { - unwatch(); - resolve(coalData.value); - } - }); - }); - } + // 鑾峰彇鐓ょ鏁版嵁 + const getCoalData = async (forceRefresh = false) => { + if (isLoaded.value && !forceRefresh) { + return coalData.value; + } - isLoading.value = true; - try { - const res = await getCoalInfoList(); - if (res.code === 200) { - coalData.value = res.data; - isLoaded.value = true; - return coalData.value; - } else { - ElMessage.error('鑾峰彇鐓ょ鏁版嵁澶辫触'); - return []; - } - } catch (error) { - ElMessage.error('鑾峰彇鐓ょ鏁版嵁澶辫触'); - console.error('鐓ょ鏁版嵁鑾峰彇閿欒:', error); - return []; - } finally { - isLoading.value = false; - } - }; + if (isLoading.value) { + // 濡傛灉姝e湪鍔犺浇锛岀瓑寰呭姞杞藉畬鎴� + return new Promise((resolve) => { + const unwatch = watch(isLoading, (loading) => { + if (!loading) { + unwatch(); + resolve(coalData.value); + } + }); + }); + } - // 鏍规嵁ID鑾峰彇鐓ょ鍚嶇О - const getCoalNameById = (id) => { - if (!id || coalData.value.length === 0) return id; - const coal = coalData.value.find(item => item.id == id); - return coal ? coal.coal : id; - }; + isLoading.value = true; + try { + const res = await getCoalInfoList(); + if (res.code === 200) { + coalData.value = res.data; + isLoaded.value = true; + return coalData.value; + } else { + ElMessage.error('鑾峰彇鐓ょ鏁版嵁澶辫触'); + return []; + } + } catch (error) { + ElMessage.error('鑾峰彇鐓ょ鏁版嵁澶辫触'); + console.error('鐓ょ鏁版嵁鑾峰彇閿欒:', error); + return []; + } finally { + isLoading.value = false; + } + }; - // 鏍规嵁鍚嶇О鑾峰彇鐓ょID - const getCoalIdByName = (name) => { - if (!name || coalData.value.length === 0) return ''; - const coal = coalData.value.find(item => item.coal === name); - return coal ? coal.id : ''; - }; + // 鏍规嵁ID鑾峰彇鐓ょ鍚嶇О + const getCoalNameById = (id) => { + if (!id || coalData.value.length === 0) return id; + const coal = coalData.value.find(item => item.id == id); + return coal ? coal.coal : id; + }; - // 鐢熸垚涓嬫媺閫夐」 - const coalOptions = computed(() => { - return coalData.value.map(item => ({ - label: item.coal, - value: item.coal, - key: item.id - })); - }); + // 鏍规嵁鍚嶇О鑾峰彇鐓ょID + const getCoalIdByName = (name) => { + if (!name || coalData.value.length === 0) return ''; + const coal = coalData.value.find(item => item.coal === name); + return coal ? coal.id : ''; + }; - // 鐢熸垚key-value鏄犲皠 - const coalMap = computed(() => { - const map = {}; - coalData.value.forEach(item => { - map[item.id] = item.coal; + // 鐢熸垚涓嬫媺閫夐」 + const coalOptions = computed(() => { + return coalData.value.map(item => ({ + label: item.coal, + value: item.coal, + key: item.id + })); }); - return map; - }); - return { - coalData: computed(() => coalData.value), - coalOptions, - coalMap, - isLoading: computed(() => isLoading.value), - isLoaded: computed(() => isLoaded.value), - getCoalData, - getCoalNameById, - getCoalIdByName - }; + // 鐢熸垚key-value鏄犲皠 + const coalMap = computed(() => { + const map = {}; + coalData.value.forEach(item => { + map[item.id] = item.coal; + }); + return map; + }); + + return { + coalData: computed(() => coalData.value), + coalOptions, + coalMap, + isLoading: computed(() => isLoading.value), + isLoaded: computed(() => isLoaded.value), + getCoalData, + getCoalNameById, + getCoalIdByName + }; } diff --git a/src/views/production/components/useDialog.js b/src/views/production/components/useDialog.js index c3694b3..23eb8ad 100644 --- a/src/views/production/components/useDialog.js +++ b/src/views/production/components/useDialog.js @@ -2,55 +2,55 @@ * 瀵硅瘽妗嗙鐞嗙粍鍚堝紡鍑芥暟 * 鎻愪緵瀵硅瘽妗嗙殑鎵撳紑銆佸叧闂�佹暟鎹鐞嗙瓑鍔熻兘 */ -import { ref } from 'vue'; +import {ref} from 'vue'; export function useDialog() { - const dialogVisible = ref(false); - const dialogType = ref('add'); - const dialogRef = ref(null); - const currentRowData = ref(null); + const dialogVisible = ref(false); + const dialogType = ref('add'); + const dialogRef = ref(null); + const currentRowData = ref(null); - // 鎵撳紑瀵硅瘽妗� - const openDialog = (type = 'add', rowData = null) => { - dialogType.value = type; - currentRowData.value = rowData; - dialogVisible.value = true; - - // 璋冪敤瀵硅瘽妗嗙粍浠剁殑鍒濆鍖栨柟娉� - if (dialogRef.value) { - if (type === 'add') { - dialogRef.value.Initialization?.(); - } else if (type === 'edit' && rowData) { - dialogRef.value.editInitialization?.(rowData); - } - } - }; + // 鎵撳紑瀵硅瘽妗� + const openDialog = (type = 'add', rowData = null) => { + dialogType.value = type; + currentRowData.value = rowData; + dialogVisible.value = true; - // 鍏抽棴瀵硅瘽妗� - const closeDialog = () => { - dialogVisible.value = false; - dialogType.value = 'add'; - currentRowData.value = null; - }; + // 璋冪敤瀵硅瘽妗嗙粍浠剁殑鍒濆鍖栨柟娉� + if (dialogRef.value) { + if (type === 'add') { + dialogRef.value.Initialization?.(); + } else if (type === 'edit' && rowData) { + dialogRef.value.editInitialization?.(rowData); + } + } + }; - // 瀵硅瘽妗嗘垚鍔熷洖璋� - const handleDialogSuccess = (callback) => { - closeDialog(); - if (typeof callback === 'function') { - callback(); - } - }; + // 鍏抽棴瀵硅瘽妗� + const closeDialog = () => { + dialogVisible.value = false; + dialogType.value = 'add'; + currentRowData.value = null; + }; - return { - // 鐘舵�� - dialogVisible, - dialogType, - dialogRef, - currentRowData, - - // 鏂规硶 - openDialog, - closeDialog, - handleDialogSuccess - }; + // 瀵硅瘽妗嗘垚鍔熷洖璋� + const handleDialogSuccess = (callback) => { + closeDialog(); + if (typeof callback === 'function') { + callback(); + } + }; + + return { + // 鐘舵�� + dialogVisible, + dialogType, + dialogRef, + currentRowData, + + // 鏂规硶 + openDialog, + closeDialog, + handleDialogSuccess + }; } diff --git a/src/views/production/components/useTableData.js b/src/views/production/components/useTableData.js index ccdd846..4f48ef6 100644 --- a/src/views/production/components/useTableData.js +++ b/src/views/production/components/useTableData.js @@ -2,131 +2,131 @@ * 琛ㄦ牸鏁版嵁绠$悊缁勫悎寮忓嚱鏁� * 鎻愪緵鍒嗛〉銆佹悳绱€�侀�夋嫨绛夐�氱敤鍔熻兘 */ -import { ref, reactive } from 'vue'; -import { ElMessage, ElMessageBox } from 'element-plus'; +import {ref, reactive} from 'vue'; +import {ElMessage, ElMessageBox} from 'element-plus'; export function useTableData(apiFunction, options = {}) { - const { - pageSize = 10, - searchField = 'searchAll' - } = options; + const { + pageSize = 10, + searchField = 'searchAll' + } = options; - // 鍝嶅簲寮忔暟鎹� - const tableData = ref([]); - const loading = ref(false); - const total = ref(0); - const selectedRows = ref([]); + // 鍝嶅簲寮忔暟鎹� + const tableData = ref([]); + const loading = ref(false); + const total = ref(0); + const selectedRows = ref([]); - // 鏌ヨ鍙傛暟 - const queryParams = reactive({ - [searchField]: '', - current: 1, - size: pageSize, - }); + // 鏌ヨ鍙傛暟 + const queryParams = reactive({ + [searchField]: '', + current: 1, + size: pageSize, + }); - // 鑾峰彇鍒楄〃鏁版嵁 - const getList = async () => { - loading.value = true; - try { - const params = { - [searchField]: queryParams[searchField], - current: queryParams.current, - size: queryParams.size, - }; - console.log('鏌ヨ鍙傛暟:', params); - const res = await apiFunction(params); - tableData.value = res.data.records || []; - total.value = res.data.total || 0; - } catch (error) { - ElMessage.error('鑾峰彇鏁版嵁澶辫触'); - console.error('API閿欒:', error); - } finally { - loading.value = false; - } - }; - - // 鎼滅储 - const handleSearch = () => { - queryParams.current = 1; - getList(); - }; - - // 閲嶇疆鎼滅储 - const handleReset = () => { - queryParams[searchField] = ''; - console.log('閲嶇疆鎼滅储鍙傛暟:', queryParams); - handleSearch(); - }; - - // 鍒嗛〉澶勭悊 - const handlePageChange = ({ page, limit }) => { - if (page && page !== queryParams.current) { - queryParams.current = page; - } - if (limit && limit !== queryParams.size) { - queryParams.size = limit; - queryParams.current = 1; // 鏀瑰彉姣忛〉澶у皬鏃跺洖鍒扮涓�椤� - } - getList(); - }; - - // 琛ㄦ牸閫夋嫨澶勭悊 - const handleSelectionChange = (selection) => { - selectedRows.value = selection; - }; - - // 鎵归噺鍒犻櫎 - const deleteSelected = async (deleteFunction) => { - if (selectedRows.value.length === 0) { - ElMessage.warning('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁'); - return; - } - - try { - await ElMessageBox.confirm( - `纭鍒犻櫎閫変腑鐨� ${selectedRows.value.length} 鏉℃暟鎹悧锛焋, - '鍒犻櫎纭', - { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning' + // 鑾峰彇鍒楄〃鏁版嵁 + const getList = async () => { + loading.value = true; + try { + const params = { + [searchField]: queryParams[searchField], + current: queryParams.current, + size: queryParams.size, + }; + console.log('鏌ヨ鍙傛暟:', params); + const res = await apiFunction(params); + tableData.value = res.data.records || []; + total.value = res.data.total || 0; + } catch (error) { + ElMessage.error('鑾峰彇鏁版嵁澶辫触'); + console.error('API閿欒:', error); + } finally { + loading.value = false; } - ); + }; - const ids = selectedRows.value.map(row => row.id); - await deleteFunction(ids); - - ElMessage.success('鍒犻櫎鎴愬姛'); - selectedRows.value = []; - getList(); - } catch (error) { - if (error !== 'cancel') { - ElMessage.error('鍒犻櫎澶辫触'); - console.error('鍒犻櫎閿欒:', error); - } - } - }; + // 鎼滅储 + const handleSearch = () => { + queryParams.current = 1; + getList(); + }; - // 鍒锋柊鏁版嵁 - const refresh = () => { - getList(); - }; + // 閲嶇疆鎼滅储 + const handleReset = () => { + queryParams[searchField] = ''; + console.log('閲嶇疆鎼滅储鍙傛暟:', queryParams); + handleSearch(); + }; - return { - // 鏁版嵁 - tableData, - loading, - total, - selectedRows, - queryParams, - - // 鏂规硶 - getList, - handleSearch, - handleReset, - handlePageChange, - handleSelectionChange, - deleteSelected, - refresh - }; + // 鍒嗛〉澶勭悊 + const handlePageChange = ({page, limit}) => { + if (page && page !== queryParams.current) { + queryParams.current = page; + } + if (limit && limit !== queryParams.size) { + queryParams.size = limit; + queryParams.current = 1; // 鏀瑰彉姣忛〉澶у皬鏃跺洖鍒扮涓�椤� + } + getList(); + }; + + // 琛ㄦ牸閫夋嫨澶勭悊 + const handleSelectionChange = (selection) => { + selectedRows.value = selection; + }; + + // 鎵归噺鍒犻櫎 + const deleteSelected = async (deleteFunction) => { + if (selectedRows.value.length === 0) { + ElMessage.warning('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁'); + return; + } + + try { + await ElMessageBox.confirm( + `纭鍒犻櫎閫変腑鐨� ${selectedRows.value.length} 鏉℃暟鎹悧锛焋, + '鍒犻櫎纭', + { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + } + ); + + const ids = selectedRows.value.map(row => row.id); + await deleteFunction(ids); + + ElMessage.success('鍒犻櫎鎴愬姛'); + selectedRows.value = []; + getList(); + } catch (error) { + if (error !== 'cancel') { + ElMessage.error('鍒犻櫎澶辫触'); + console.error('鍒犻櫎閿欒:', error); + } + } + }; + + // 鍒锋柊鏁版嵁 + const refresh = () => { + getList(); + }; + + return { + // 鏁版嵁 + tableData, + loading, + total, + selectedRows, + queryParams, + + // 鏂规硶 + getList, + handleSearch, + handleReset, + handlePageChange, + handleSelectionChange, + deleteSelected, + refresh + }; } diff --git a/src/views/production/index.vue b/src/views/production/index.vue index 8ab5e23..8108dd7 100644 --- a/src/views/production/index.vue +++ b/src/views/production/index.vue @@ -4,9 +4,9 @@ <el-form :inline="true" :model="queryParams" class="search-form"> <el-form-item label="鎼滅储"> <el-input - v-model="queryParams.searchAll" - placeholder="璇疯緭鍏ュ叧閿瘝" - clearable + v-model="queryParams.searchAll" + placeholder="璇疯緭鍏ュ叧閿瘝" + clearable /> </el-form-item> <el-form-item> @@ -27,18 +27,19 @@ </el-button> </div> <!-- 鏁版嵁琛ㄦ牸 --> <ETable - :showOverflowTooltip="false" - :loading="loading" - :table-data="tableData" - :columns="columns" - :current-page="queryParams.current" - :page-size="queryParams.size" - @selection-change="handleSelectionChange" - @edit="row => openDialog('edit', row)" - :show-selection="true" - :border="true" - :maxHeight="480" - > <template #coal="{ row }"> + :showOverflowTooltip="false" + :loading="loading" + :table-data="tableData" + :columns="columns" + :current-page="queryParams.current" + :page-size="queryParams.size" + @selection-change="handleSelectionChange" + @edit="row => openDialog('edit', row)" + :show-selection="true" + :border="true" + :maxHeight="480" + > + <template #coal="{ row }"> <div class="coal-tags"> <el-tag v-for="coal in parseCoalArray(row.coal)" :key="coal" size="small"> {{ getCoalNameById(coal) }} @@ -48,47 +49,47 @@ </template> </ETable> <!-- 鍒嗛〉缁勪欢 --> <Pagination - :layout="'total, prev, pager, next, jumper'" - :total="total" - v-model:page="queryParams.current" - :limit="queryParams.size" - @pagination="handlePageChange" + :layout="'total, prev, pager, next, jumper'" + :total="total" + v-model:page="queryParams.current" + :limit="queryParams.size" + @pagination="handlePageChange" /> </el-card> <!-- 鐢熶骇瀵硅瘽妗� --> <!-- handleProductionAndProcessing --> <ProductionDialog - v-model:visible="dialogVisible" - ref="dialogRef" - :type="dialogType" - @update:productionAndProcessing="handleProductionAndProcessing" - @success="handleDialogSuccess" + v-model:visible="dialogVisible" + ref="dialogRef" + :type="dialogType" + @update:productionAndProcessing="handleProductionAndProcessing" + @success="handleDialogSuccess" /> </div> </template> <script setup> -import { onMounted } from "vue"; -import { ElMessage } from "element-plus"; -import { Plus, Delete } from "@element-plus/icons-vue"; +import {onMounted} from "vue"; +import {ElMessage} from "element-plus"; +import {Plus, Delete} from "@element-plus/icons-vue"; import ProductionDialog from "./components/ProductionDialog.vue"; import ETable from "@/components/Table/ETable.vue"; import Pagination from "@/components/Pagination/index.vue"; -import { getProductionMasterList, delPM } from "@/api/production"; -import { parseCoalArray } from "@/utils/production"; -import { useTableData } from "./components/useTableData.js"; -import { useDialog } from "./components/useDialog.js"; -import { useCoalData } from "./components/useCoalData.js"; +import {getProductionMasterList, delPM} from "@/api/production"; +import {parseCoalArray} from "@/utils/production"; +import {useTableData} from "./components/useTableData.js"; +import {useDialog} from "./components/useDialog.js"; +import {useCoalData} from "./components/useCoalData.js"; // 琛ㄦ牸鍒楅厤缃� const columns = [ - { prop: "coal", label: "鐓ょ", minWidth: 150, slot: 'coal' }, - { prop: "productionQuantity", label: "鐢熶骇鏁伴噺", minWidth: 120 }, - { prop: "laborCost", label: "浜哄伐鎴愭湰", minWidth: 150 }, - { prop: "energyConsumptionCost", label: "鑳借�楁垚鏈�", minWidth: 120 }, - { prop: "equipmentDepreciation", label: "璁惧鎶樻棫", minWidth: 143 }, - { prop: "totalCost", label: "鎬绘垚鏈�", minWidth: 150 }, + {prop: "coal", label: "鐓ょ", minWidth: 150, slot: 'coal'}, + {prop: "productionQuantity", label: "鐢熶骇鏁伴噺", minWidth: 120}, + {prop: "laborCost", label: "浜哄伐鎴愭湰", minWidth: 150}, + {prop: "energyConsumptionCost", label: "鑳借�楁垚鏈�", minWidth: 120}, + {prop: "equipmentDepreciation", label: "璁惧鎶樻棫", minWidth: 143}, + {prop: "totalCost", label: "鎬绘垚鏈�", minWidth: 150}, ]; // 浣跨敤琛ㄦ牸鏁版嵁缁勫悎寮忓嚱鏁� @@ -104,7 +105,7 @@ handlePageChange, handleSelectionChange, deleteSelected -} = useTableData(getProductionMasterList, { pageSize: 10 }); +} = useTableData(getProductionMasterList, {pageSize: 10}); // 浣跨敤瀵硅瘽妗嗙粍鍚堝紡鍑芥暟 const { @@ -116,13 +117,13 @@ } = useDialog(); // 浣跨敤鐓ょ鏁版嵁缁勫悎寮忓嚱鏁� -const { getCoalNameById, getCoalData } = useCoalData(); +const {getCoalNameById, getCoalData} = useCoalData(); // 澶勭悊鐢熶骇鏁版嵁鏇存柊 const handleProductionAndProcessing = (row, rows) => { const index = tableData.value.findIndex(item => item.id === rows.id); if (index !== -1) { - tableData.value[index] = { ...tableData.value[index], ...row }; + tableData.value[index] = {...tableData.value[index], ...row}; } }; @@ -158,6 +159,7 @@ width: 20%; } } + .search-form { display: flex; justify-content: space-between; @@ -172,15 +174,16 @@ margin-left: 10px; } } + .coal-tags { display: flex; flex-wrap: wrap; gap: 4px; - + .el-tag { margin-right: 4px; margin-bottom: 4px; - + &:last-child { margin-right: 0; } -- Gitblit v1.9.3