From ffb1bd190e9d4263c8c7d6c0096e0ec844cb3b52 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 19 六月 2025 17:30:55 +0800
Subject: [PATCH] 1.系统管理样式修改
---
src/views/production/index.vue | 169 ++++++++++++++++++-------------------------------------
1 files changed, 56 insertions(+), 113 deletions(-)
diff --git a/src/views/production/index.vue b/src/views/production/index.vue
index 531640a..4827925 100644
--- a/src/views/production/index.vue
+++ b/src/views/production/index.vue
@@ -22,59 +22,64 @@
<el-button type="success" :icon="Plus" @click="openDialog('add')">
鏂板鍔犲伐
</el-button>
- <el-button type="danger" :icon="Delete" :disabled="!selectedRows.length">
+ <el-button type="danger" :icon="Delete" :disabled="!selectedRows.length" @click="() => deleteSelected(delPM)">
鍒犻櫎
</el-button>
- </div>
-
- <!-- 鏁版嵁琛ㄦ牸 -->
+ </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 }">
+ > <template #coal="{ row }">
<div class="coal-tags">
<el-tag v-for="coal in parseCoalArray(row.coal)" :key="coal" size="small">
- {{ coal }}
+ {{ getCoalNameById(coal) }}
</el-tag>
<span v-if="!row.coal">--</span>
</div>
</template>
- </ETable>
-
- <!-- 鍒嗛〉缁勪欢 -->
+ </ETable> <!-- 鍒嗛〉缁勪欢 -->
<Pagination
+ :layout="'total, prev, pager, next, jumper'"
:total="total"
- :page="queryParams.current"
+ 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"
/>
</div>
</template>
<script setup>
-import { ref, reactive, onMounted } from "vue";
-import { ElMessage, ElMessageBox } from "element-plus";
+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 } from "@/api/production";
+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 = [
@@ -87,115 +92,53 @@
{ prop: "producer", label: "鐢熶骇浜�", minWidth: 150 },
];
-// 鍝嶅簲寮忔暟鎹�
-const tableData = ref([]);
-const loading = ref(false);
-const total = ref(0);
-const selectedRows = ref([]);
-const dialogVisible = ref(false);
-const dialogType = ref("add");
-const dialogRef = ref(null);
+// 浣跨敤琛ㄦ牸鏁版嵁缁勫悎寮忓嚱鏁�
+const {
+ tableData,
+ loading,
+ total,
+ selectedRows,
+ queryParams,
+ getList,
+ handleSearch,
+ handleReset,
+ handlePageChange,
+ handleSelectionChange,
+ deleteSelected
+} = useTableData(getProductionMasterList, { pageSize: 10 });
-// 鏌ヨ鍙傛暟
-const queryParams = reactive({
- searchAll: "",
- current: 1,
- size: 10,
-});
+// 浣跨敤瀵硅瘽妗嗙粍鍚堝紡鍑芥暟
+const {
+ dialogVisible,
+ dialogType,
+ dialogRef,
+ openDialog,
+ handleDialogSuccess: onDialogSuccess
+} = useDialog();
-// 鑾峰彇琛ㄦ牸鏁版嵁
-// 鑾峰彇琛ㄦ牸鏁版嵁
-const getList = async () => {
- loading.value = true;
- try {
- // 鏋勫缓姝g‘鐨勫垎椤靛弬鏁�
- const params = {
- searchAll: queryParams.searchAll,
- // 灏濊瘯澶氱甯歌鐨勫垎椤靛弬鏁版牸寮�
- current: queryParams.current,
- size: queryParams.size,
- page: queryParams.current,
- pageSize: queryParams.size,
- pageNum: queryParams.current,
- limit: queryParams.size,
- offset: (queryParams.current - 1) * queryParams.size
- };
-
- console.log('鍙戦�佸垎椤靛弬鏁�:', params);
- console.log(`绗�${queryParams.current}椤靛簲璇ユ樉绀虹${(queryParams.current - 1) * queryParams.size + 1}-${queryParams.current * queryParams.size}鏉℃暟鎹甡);
-
- const res = await getProductionMasterList(params);
- tableData.value = res.data.records || [];
- total.value = res.data.total || 0;
-
- console.log('鎺ユ敹鍒扮殑鏁版嵁:', {
- 褰撳墠椤�: queryParams.current,
- 杩斿洖鏉℃暟: tableData.value.length,
- 鎬绘潯鏁�: total.value
- });
- } catch (error) {
- ElMessage.error("鑾峰彇鏁版嵁澶辫触");
- console.error('API閿欒:', error);
- } finally {
- loading.value = false;
- }
-};
+// 浣跨敤鐓ょ鏁版嵁缁勫悎寮忓嚱鏁�
+const { getCoalNameById, getCoalData } = useCoalData();
-// 鎼滅储鍜岄噸缃�
-const handleSearch = () => {
- queryParams.current = 1;
- getList();
-};
-
-const handleReset = () => {
- queryParams.searchAll = "";
- handleSearch();
-};
-
-// 鍒嗛〉澶勭悊
-const handlePageChange = ({ page }) => {
- queryParams.current = page;
- getList();
-};
-
-// 琛ㄦ牸閫夋嫨澶勭悊
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-
-// 鎵撳紑瀵硅瘽妗� - 缁熶竴澶勭悊鏂板鍜岀紪杈�
-const openDialog = (type, row = null) => {
- dialogType.value = type;
- dialogVisible.value = true;
-
- if (type === 'add') {
- dialogRef.value?.Initialization();
- } else if (type === 'edit' && row) {
- dialogRef.value?.editInitialization({ ...row });
+// 澶勭悊鐢熶骇鏁版嵁鏇存柊
+const handleProductionAndProcessing = (row, rows) => {
+ const index = tableData.value.findIndex(item => item.id === rows.id);
+ if (index !== -1) {
+ tableData.value[index] = { ...tableData.value[index], ...row };
}
};
// 瀵硅瘽妗嗘垚鍔熷洖璋�
const handleDialogSuccess = () => {
- getList();
- ElMessage.success("鎿嶄綔鎴愬姛");
+ onDialogSuccess(() => {
+ getList();
+ ElMessage.success("鎿嶄綔鎴愬姛");
+ });
};
-
-// 瑙f瀽鐓ょ鏁扮粍 - 绠�鍖栭�昏緫
-const parseCoalArray = (coalString) => {
- if (!coalString) return [];
-
- if (Array.isArray(coalString)) return coalString;
-
- return String(coalString)
- .replace(/^\[|\]$/g, '')
- .split(',')
- .map(item => item.trim())
- .filter(Boolean);
-};
-
// 缁勪欢鎸傝浇鏃跺姞杞芥暟鎹�
-onMounted(getList);
+onMounted(async () => {
+ await getCoalData(); // 棰勫姞杞界叅绉嶆暟鎹�
+ getList();
+});
</script>
<style scoped lang="scss">
--
Gitblit v1.9.3