From 7efe917a161f7c6965cfa75ac5ad7e664dcc1eb4 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 14 十一月 2025 09:59:03 +0800
Subject: [PATCH] 1.生产派工-加一个损耗率新增修改
---
src/views/personnelManagement/scheduling/index.vue | 22 ++++-
src/views/productionManagement/operationScheduling/components/formDia.vue | 73 ++++++++++--------
src/api/productionManagement/productionOrder.js | 26 ++++++
src/components/PIMTable/Pagination.vue | 2
src/views/productionManagement/productionDispatching/index.vue | 96 ++++++++++++++++++++---
src/views/salesManagement/salesLedger/index.vue | 2
6 files changed, 169 insertions(+), 52 deletions(-)
diff --git a/src/api/productionManagement/productionOrder.js b/src/api/productionManagement/productionOrder.js
index 6335136..e573224 100644
--- a/src/api/productionManagement/productionOrder.js
+++ b/src/api/productionManagement/productionOrder.js
@@ -52,4 +52,30 @@
method: "post",
data: query,
});
+}
+
+// 鏌ヨ鎹熻�楃巼
+export function getLossRate() {
+ return request({
+ url: "/salesLedger/scheduling/loss",
+ method: "get",
+ });
+}
+
+// 鏂板鎹熻�楃巼
+export function addLossRate(data) {
+ return request({
+ url: "/salesLedger/scheduling/addLoss",
+ method: "post",
+ data: data,
+ });
+}
+
+// 淇敼鎹熻�楃巼
+export function updateLossRate(data) {
+ return request({
+ url: "/salesLedger/scheduling/updateLoss",
+ method: "post",
+ data: data,
+ });
}
\ No newline at end of file
diff --git a/src/components/PIMTable/Pagination.vue b/src/components/PIMTable/Pagination.vue
index 7639e64..47a63cf 100644
--- a/src/components/PIMTable/Pagination.vue
+++ b/src/components/PIMTable/Pagination.vue
@@ -71,6 +71,7 @@
})
const handleSizeChange = (val) => {
+ console.log('handleSizeChange', val)
if (currentPage.value * val > props.total) {
currentPage.value = 1
}
@@ -81,6 +82,7 @@
}
const handleCurrentChange = (val) => {
+ console.log('handleCurrentChange---', val)
emit('pagination', { page: val, limit: pageSize.value })
if (props.autoScroll) {
scrollTo(0, 800)
diff --git a/src/views/personnelManagement/scheduling/index.vue b/src/views/personnelManagement/scheduling/index.vue
index 7c6324f..15bf05c 100644
--- a/src/views/personnelManagement/scheduling/index.vue
+++ b/src/views/personnelManagement/scheduling/index.vue
@@ -48,13 +48,13 @@
{{ (department_type.find(i => i.value === String(scope.row.department)) || {}).label }}
</template>
</el-table-column> -->
- <!-- <el-table-column prop="shiftType" label="鐝绫诲瀷" width="100">
+ <el-table-column prop="shiftType" label="鐝绫诲瀷" width="120">
<template #default="scope">
<el-tag :type="getShiftTagType(scope.row.shiftType)">
- {{ (shift_type.find(i => i.value === String(scope.row.shiftType)) || {}).label }}
+ {{ (shift_type.find(i => i.value === String(scope.row.shiftType)) || {}).label || '鏈煡' }}
</el-tag>
</template>
- </el-table-column> -->
+ </el-table-column>
<!-- <el-table-column prop="workDate" label="宸ヤ綔鏃ユ湡" width="120"/> -->
<el-table-column prop="workStartTime" label="寮�濮嬫椂闂�"/>
<el-table-column prop="workEndTime" label="缁撴潫鏃堕棿"/>
@@ -147,6 +147,16 @@
</el-form-item>
</el-col>
</el-row> -->
+
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鐝绫诲瀷锛�" prop="shiftType">
+ <el-select v-model="scheduleForm.shiftType" placeholder="璇烽�夋嫨鐝绫诲瀷" style="width: 100%">
+ <el-option v-for="item in shift_type" :label="item.label" :value="item.value" :key="item.value"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
<!-- <el-row :gutter="20">
<el-col :span="12">
@@ -284,7 +294,7 @@
staffIds: [],
// staffNo: '',
// department: '',
- // shiftType: '',
+ shiftType: '',
// workDate: '',
workStartTime: '',
workEndTime: '',
@@ -300,7 +310,7 @@
const scheduleRules = reactive({
staffIds: [{required: true, message: '璇烽�夋嫨鍛樺伐', trigger: 'change'}],
// department: [{required: true, message: '璇烽�夋嫨閮ㄩ棬', trigger: 'change'}],
- // shiftType: [{required: true, message: '璇烽�夋嫨鐝绫诲瀷', trigger: 'change'}],
+ shiftType: [{required: true, message: '璇烽�夋嫨鐝绫诲瀷', trigger: 'change'}],
// workDate: [{required: true, message: '璇烽�夋嫨宸ヤ綔鏃ユ湡', trigger: 'change'}],
workStartTime: [{required: true, message: '璇烽�夋嫨寮�濮嬫椂闂�', trigger: 'change'}],
workEndTime: [{required: true, message: '璇烽�夋嫨缁撴潫鏃堕棿', trigger: 'change'}],
@@ -488,7 +498,7 @@
// 璁剧疆鍏朵粬蹇呰瀛楁鐨勯粯璁ゅ��
staffNo: '', // 鍙互鏍规嵁闇�瑕佷粠personList涓幏鍙�
department: '',
- shiftType: '',
+ shiftType: scheduleForm.shiftType,
workDate: '',
status: '',
remark: ''
diff --git a/src/views/productionManagement/operationScheduling/components/formDia.vue b/src/views/productionManagement/operationScheduling/components/formDia.vue
index baafa46..056c8a2 100644
--- a/src/views/productionManagement/operationScheduling/components/formDia.vue
+++ b/src/views/productionManagement/operationScheduling/components/formDia.vue
@@ -8,11 +8,11 @@
>
<el-button type="primary" @click="addRow" style="margin-bottom: 10px;">鏂板</el-button>
<span style="font-size: 18px;margin-left: 10px">寰呮帓浜ф暟閲忥細{{pendingNum}}</span>
- <div style="margin-bottom: 10px; margin-left: 10px;">
- <el-form-item label="棰嗙敤锛�" style="margin-bottom: 0;">
- <el-input v-model="receive" placeholder="璇疯緭鍏ラ鐢�" style="width: 200px;" />
- </el-form-item>
- </div>
+<!-- <div style="margin-bottom: 10px; margin-left: 10px;">-->
+<!-- <el-form-item label="棰嗙敤锛�" style="margin-bottom: 0;">-->
+<!-- <el-input v-model="receive" placeholder="璇疯緭鍏ラ鐢�" style="width: 200px;" />-->
+<!-- </el-form-item>-->
+<!-- </div>-->
<el-table :data="tableData" border style="width: 100%" :summary-method="summarizeMainTable" show-summary :row-key="row => row.id">
<el-table-column label="搴忓彿" width="60" align="center">
<template #default="scope">
@@ -45,11 +45,6 @@
clearable
style="width: 100%"
/>
- </template>
- </el-table-column>
- <el-table-column label="鎹熻��" prop="loss" width="150">
- <template #default="scope">
- <el-input v-model="scope.row.loss" placeholder="璇疯緭鍏ユ崯鑰�" />
</template>
</el-table-column>
<el-table-column label="宸ユ椂瀹氶" width="200" prop="workHours">
@@ -108,7 +103,7 @@
</template>
<script setup>
-import {ref} from "vue";
+import {ref, getCurrentInstance} from "vue";
import {userListNoPageByTenantId} from "@/api/system/user.js";
import {processScheduling} from "@/api/productionManagement/operationScheduling.js";
const { proxy } = getCurrentInstance()
@@ -117,12 +112,11 @@
const dialogFormVisible = ref(false);
const operationType = ref('')
-const tableData = ref([
- { process: '', schedulingDate: '', schedulingNum: null, schedulingUserId: '', workHours: null, unit: '', remark: '', loss: '', type: '' }
-]);
+const tableData = ref([]);
const unitFromRow = ref('');
const idFromRow = ref('');
-const pendingNum = ref('');
+const specificationModelFromRow = ref('');
+const pendingNum = ref(0);
const userList = ref([])
const receive = ref('')
@@ -133,18 +127,25 @@
userListNoPageByTenantId().then((res) => {
userList.value = res.data;
});
- pendingNum.value = row.pendingNum
- if (row && row.unit !== undefined) {
- unitFromRow.value = row.unit;
- idFromRow.value = row.id;
- tableData.value.forEach(item => {
- item.unit = row.unit;
- item.id = row.id;
- });
- } else {
- unitFromRow.value = '';
- }
+ pendingNum.value = row?.pendingNum ?? 0;
+ unitFromRow.value = row?.unit ?? '';
+ idFromRow.value = row?.id ?? '';
+ specificationModelFromRow.value = row?.specificationModel ?? '';
+ tableData.value = [createRow()];
}
+
+const createRow = () => ({
+ id: idFromRow.value,
+ process: '',
+ schedulingDate: '',
+ schedulingNum: null,
+ schedulingUserId: '',
+ workHours: null,
+ unit: unitFromRow.value,
+ remark: '',
+ type: specificationModelFromRow.value,
+});
+
const submitForm = () => {
// 1. 妫�鏌ユ瘡涓�琛屾槸鍚﹀~鍐欏畬鏁�
for (let i = 0; i < tableData.value.length; i++) {
@@ -169,11 +170,14 @@
proxy.$modal.msgError('鎺掍骇鏁伴噺鍚堣涓嶈兘瓒呰繃寰呮帓浜ф暟閲�');
return;
}
- // 3. 灏� receive 瀛楁娣诲姞鍒版瘡鏉℃暟鎹腑
- const submitData = tableData.value.map(row => ({
- ...row,
- receive: receive.value
- }));
+ // 3. 灏� receive 瀛楁娣诲姞鍒版瘡鏉℃暟鎹腑锛屽苟绉婚櫎 loss 瀛楁
+ const submitData = tableData.value.map(row => {
+ const { loss, ...rest } = row;
+ return {
+ ...rest,
+ receive: receive.value
+ };
+ });
processScheduling(submitData).then((res) => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeDia();
@@ -186,6 +190,11 @@
const closeDia = () => {
dialogFormVisible.value = false;
receive.value = '';
+ tableData.value = [];
+ unitFromRow.value = '';
+ idFromRow.value = '';
+ specificationModelFromRow.value = '';
+ pendingNum.value = 0;
emit('close')
};
defineExpose({
@@ -193,7 +202,7 @@
});
const addRow = () => {
- tableData.value.push({ id: idFromRow.value, process: '', unit: unitFromRow.value, schedulingNum: null, workHours: null, schedulingDate: '', schedulingUserId: '', remark: '', loss: '', type: '' });
+ tableData.value.push(createRow());
};
const removeRow = (index) => {
tableData.value.splice(index, 1);
diff --git a/src/views/productionManagement/productionDispatching/index.vue b/src/views/productionManagement/productionDispatching/index.vue
index 6a61e6e..e976013 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>
@@ -71,7 +81,7 @@
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({
@@ -175,19 +185,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 +211,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 +308,10 @@
// 鏄惁鏈夋煡璇㈡暟鎹�
const hasQueryData = ref(false)
+// 鎹熻�楃巼
+const rate = ref(6)
+// 鎹熻�楃巼ID
+const rateId = ref(null)
// 鑾峰彇鐐掓満姝e湪宸ヤ綔閲忔暟鎹�
const getMachineProductionData = () => {
@@ -310,9 +349,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 +387,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 +468,7 @@
onMounted(() => {
getList();
+ getLossRateData();
});
</script>
@@ -512,8 +569,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>
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index cd36294..83168ba 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -41,7 +41,7 @@
</div>
<el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
:expand-row-keys="expandedRowKeys" :row-key="(row) => row.id" show-summary style="width: 100%"
- :summary-method="summarizeMainTable" @expand-change="expandChange" height="calc(100vh - 18.5em)">
+ :summary-method="summarizeMainTable" @expand-change="expandChange" height="calc(100vh - 21em)">
<el-table-column align="center" type="selection" width="55" />
<el-table-column type="expand">
<template #default="props">
--
Gitblit v1.9.3