From fc39f41acfcb9afb8d12f3ed3799b97352bb4178 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 09 十二月 2025 16:57:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_food' into dev_food
---
src/views/productionManagement/productionDispatching/index.vue | 148 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 113 insertions(+), 35 deletions(-)
diff --git a/src/views/productionManagement/productionDispatching/index.vue b/src/views/productionManagement/productionDispatching/index.vue
index 6a61e6e..8e7e05f 100644
--- a/src/views/productionManagement/productionDispatching/index.vue
+++ b/src/views/productionManagement/productionDispatching/index.vue
@@ -9,11 +9,21 @@
<span>鎬婚噺(kg)锛�</span>
<el-input-number v-model="machineData[machine.name].workLoad" :min="0" :step="1" size="small" />
</div>
- <div><span>姝e湪宸ヤ綔閲�(kg)锛�</span><span>{{ machineData[machine.name].currentWorkLoad }}</span></div>
+ <div><span> 棰勮鎶曞叆閲�(kg)锛�</span><span>{{ machineData[machine.name].currentWorkLoad }}</span></div>
<div><span>绌轰綑宸ヤ綔閲�(kg)锛�</span><span>{{ machineData[machine.name].vacant }}</span></div>
</div>
</div>
<div class="save-button-container">
+ <div class="loss-rate-container">
+ <span class="loss-rate-label">鎹熻�楃巼(%)锛�</span>
+ <el-select v-model="rate" placeholder="璇烽�夋嫨鎹熻�楃巼" style="width: 120px" size="small">
+ <el-option label="6" :value="6" />
+ <el-option label="7" :value="7" />
+ <el-option label="8" :value="8" />
+ <el-option label="9" :value="9" />
+ <el-option label="10" :value="10" />
+ </el-select>
+ </div>
<el-button type="primary" @click="saveMachineTotals" size="small">淇濆瓨璁剧疆</el-button>
</div>
</div>
@@ -28,18 +38,24 @@
clearable
prefix-icon="Search"
/>
- <span class="search_title ml10">椤圭洰鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.projectName"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- prefix-icon="Search"
- />
+<!-- <span class="search_title ml10">椤圭洰鍚嶇О锛�</span>-->
+<!-- <el-input-->
+<!-- v-model="searchForm.projectName"-->
+<!-- style="width: 240px"-->
+<!-- placeholder="璇疯緭鍏�"-->
+<!-- @change="handleQuery"-->
+<!-- clearable-->
+<!-- prefix-icon="Search"-->
+<!-- />-->
<span class="search_title ml10">褰曞叆鏃ユ湡锛�</span>
<el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
placeholder="璇烽�夋嫨" clearable @change="changeDaterange" />
+ <el-checkbox
+ style="margin-left: 10px"
+ v-model="searchForm.status"
+ label="涓嶆樉绀哄緟鎺掓暟閲忎负0"
+ @change="handleQuery"
+ />
<el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
</div>
<div>
@@ -71,16 +87,17 @@
import FormDia from "@/views/productionManagement/productionDispatching/components/formDia.vue";
import AutoDispatchDia from "@/views/productionManagement/productionDispatching/components/autoDispatchDia.vue";
import dayjs from "dayjs";
-import {schedulingListPage, schedulingList, addSpeculatTrading, updateSpeculatTrading} from "@/api/productionManagement/productionOrder.js";
+import {schedulingListPage, schedulingList, addSpeculatTrading, updateSpeculatTrading, getLossRate, addLossRate, updateLossRate} from "@/api/productionManagement/productionOrder.js";
import { ElMessageBox } from "element-plus";
const data = reactive({
searchForm: {
customerName: "",
projectName: "",
- entryDate: null, // 褰曞叆鏃ユ湡
- entryDateStart: undefined,
- entryDateEnd: undefined,
+ status: true,
+ entryDate: [dayjs().format("YYYY-MM-DD"), dayjs().format("YYYY-MM-DD")], // 褰曞叆鏃ユ湡锛岄粯璁ゅ綋澶�
+ entryDateStart: dayjs().format("YYYY-MM-DD"),
+ entryDateEnd: dayjs().format("YYYY-MM-DD"),
},
});
const { searchForm } = toRefs(data);
@@ -90,21 +107,21 @@
prop: "salesContractNo",
width: 220,
},
- {
- label: "瀹㈡埛鍚堝悓鍙�",
- prop: "customerContractNo",
- width: 250,
- },
+ // {
+ // label: "瀹㈡埛鍚堝悓鍙�",
+ // prop: "customerContractNo",
+ // width: 250,
+ // },
{
label: "瀹㈡埛鍚嶇О",
prop: "customerName",
width: 250,
},
- {
- label: "椤圭洰鍚嶇О",
- prop: "projectName",
- width:300
- },
+ // {
+ // label: "椤圭洰鍚嶇О",
+ // prop: "projectName",
+ // width:300
+ // },
{
label: "浜у搧澶х被",
prop: "productCategory",
@@ -143,6 +160,7 @@
label: "寰呮帓鏁伴噺",
prop: "pendingQuantity",
width: 100,
+ fixed: 'right',
},
]);
const tableData = ref([]);
@@ -175,19 +193,23 @@
// 淇濆瓨鐐掓満鎬婚噺璁剧疆
const saveMachineTotals = () => {
+ // 楠岃瘉鎹熻�楃巼鏄惁宸查�夋嫨
+ if (rate.value === null || rate.value === undefined || isNaN(rate.value)) {
+ proxy.$message.warning('璇烽�夋嫨鎹熻�楃巼');
+ return;
+ }
+
// 鏋勯�犱繚瀛樻暟鎹暟缁勶紝浣跨敤machines鏁扮粍寰幆鏋勫缓
const saveData = machines.map(machine => {
const saveItem = {
name: machine.name, // 鐐掓満鍚嶇О
workLoad: machineData[machine.name].workLoad, // 鎬婚噺
- currentWorkLoad: machineData[machine.name].currentWorkLoad, // 姝e湪宸ヤ綔閲�
+ currentWorkLoad: machineData[machine.name].currentWorkLoad, // 棰勮鎶曞叆閲�
vacant: machineData[machine.name].vacant // 绌轰綑閲�
};
// 濡傛灉鏄慨鏀规搷浣滐紝闇�瑕佷紶閫抜d瀛楁
if (hasQueryData.value) {
- // 杩欓噷闇�瑕佷粠鏌ヨ鏁版嵁涓幏鍙栧搴旂殑id
- // 鍋囪鏌ヨ鏁版嵁涓瘡涓倰鏈烘暟鎹兘鏈塱d瀛楁
const queryData = getMachineQueryData(machine.id);
if (queryData && queryData.id) {
saveItem.id = queryData.id;
@@ -197,23 +219,44 @@
return saveItem;
});
- console.log('淇濆瓨鐐掓満璁剧疆鏁版嵁:', saveData);
+ // 鏋勯�犳崯鑰楃巼鏁版嵁
+ const rateData = {
+ rate: rate.value
+ };
+
+ // 濡傛灉鏈塈D锛岃鏄庢槸淇敼鎿嶄綔
+ if (rateId.value) {
+ rateData.id = rateId.value;
+ }
// 鏍规嵁鏄惁鏈夋煡璇㈡暟鎹喅瀹氳皟鐢ㄦ柊澧炴帴鍙h繕鏄慨鏀规帴鍙�
const saveApi = hasQueryData.value ? updateSpeculatTrading : addSpeculatTrading;
const successMessage = hasQueryData.value ? '鐐掓満璁剧疆淇敼鎴愬姛' : '鐐掓満璁剧疆鏂板鎴愬姛';
- console.log(`璋冪敤鎺ュ彛: ${hasQueryData.value ? '淇敼' : '鏂板'}`);
+ // 鏍规嵁鏄惁鏈塈D鍐冲畾璋冪敤鏂板鎺ュ彛杩樻槸淇敼鎺ュ彛
+ const rateApi = rateId.value ? updateLossRate : addLossRate;
+ const rateSuccessMessage = rateId.value ? '鎹熻�楃巼淇敼鎴愬姛' : '鎹熻�楃巼鏂板鎴愬姛';
- // 璋冪敤鍚庣API淇濆瓨
- saveApi(saveData).then(res => {
+ // 骞惰璋冪敤涓や釜鎺ュ彛
+ Promise.all([
+ saveApi(saveData),
+ rateApi(rateData)
+ ]).then(([saveRes, rateRes]) => {
proxy.$message.success(successMessage);
- console.log('淇濆瓨鎴愬姛:', res);
+ proxy.$message.success(rateSuccessMessage);
// 淇濆瓨鎴愬姛鍚庯紝璁剧疆hasQueryData涓簍rue锛屼笅娆′繚瀛樺皢璋冪敤淇敼鎺ュ彛
if (!hasQueryData.value) {
hasQueryData.value = true;
}
+
+ // 濡傛灉杩斿洖浜咺D锛屼繚瀛樿捣鏉�
+ if (rateRes && rateRes.data && rateRes.data.id) {
+ rateId.value = rateRes.data.id;
+ }
+
+ // 淇濆瓨鎴愬姛鍚庨噸鏂拌皟鐢ㄦ煡璇㈤〉闈�
+ getList();
}).catch(err => {
proxy.$message.error('淇濆瓨澶辫触');
console.error('淇濆瓨澶辫触:', err);
@@ -273,6 +316,10 @@
// 鏄惁鏈夋煡璇㈡暟鎹�
const hasQueryData = ref(false)
+// 鎹熻�楃巼
+const rate = ref(6)
+// 鎹熻�楃巼ID
+const rateId = ref(null)
// 鑾峰彇鐐掓満姝e湪宸ヤ綔閲忔暟鎹�
const getMachineProductionData = () => {
@@ -310,9 +357,6 @@
machineData[machineName].vacant = machineData[machineName].workLoad - machineData[machineName].currentWorkLoad;
}
});
-
- console.log('鐐掓満鏁版嵁鍒濆鍖栧畬鎴�:', machineData);
- console.log('鐐掓満鏌ヨ鏁版嵁:', machineQueryData.value);
}
}).catch(err => {
console.error('鑾峰彇鐐掓満姝e湪宸ヤ綔閲忔暟鎹け璐�:', err);
@@ -351,9 +395,29 @@
// 鍚屾椂鑾峰彇鐐掓満姝e湪宸ヤ綔閲忔暟鎹�
getMachineProductionData();
+ // 鑾峰彇鎹熻�楃巼鏁版嵁
+ getLossRateData();
}).catch(() => {
tableLoading.value = false;
})
+};
+
+// 鑾峰彇鎹熻�楃巼鏁版嵁
+const getLossRateData = () => {
+ getLossRate().then((res) => {
+ const data = res.data || res;
+ if (data && data.rate !== undefined && data.rate !== null) {
+ rate.value = Number(data.rate); // 纭繚杞崲涓烘暟瀛�
+ rateId.value = data.id || null;
+ } else {
+ rate.value = 6;
+ rateId.value = null;
+ }
+ }).catch(err => {
+ console.error('鑾峰彇鎹熻�楃巼鏁版嵁澶辫触:', err);
+ rate.value = 6;
+ rateId.value = null;
+ });
};
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
@@ -412,6 +476,7 @@
onMounted(() => {
getList();
+ getLossRateData();
});
</script>
@@ -512,8 +577,21 @@
grid-column: 1 / -1;
display: flex;
justify-content: center;
+ align-items: center;
+ gap: 16px;
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid #e9ecef;
}
+.loss-rate-container{
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+.loss-rate-label{
+ font-size: 14px;
+ color: #6c757d;
+ font-weight: 500;
+ white-space: nowrap;
+}
</style>
--
Gitblit v1.9.3