<template>
|
<view>
|
<up-popup
|
v-model:show="dialogFormVisible"
|
mode="center"
|
border-radius="20"
|
:closeable="true"
|
@close="closeDia"
|
>
|
<view class="popup-content">
|
<view class="popup-header">
|
<text class="popup-title">自动派工</text>
|
</view>
|
|
<view class="popup-body">
|
<view class="section-title">派工列表</view>
|
|
<view class="card-list">
|
<view
|
v-for="(item, index) in dispatchList"
|
:key="index"
|
class="dispatch-card"
|
:class="{ 'even-card': index % 2 === 1 }"
|
>
|
<view class="card-header">
|
<text class="card-index">{{ index + 1 }}</text>
|
<text class="card-project">{{ item.projectName }}</text>
|
</view>
|
|
<view class="card-content">
|
<view class="info-row">
|
<text class="info-label">合同号:</text>
|
<text class="info-value">{{ item.salesContractNo }}</text>
|
</view>
|
|
<view class="info-row">
|
<text class="info-label">客户名称:</text>
|
<text class="info-value">{{ item.customerName }}</text>
|
</view>
|
|
<view class="info-row">
|
<text class="info-label">产品大类:</text>
|
<text class="info-value">{{ item.productCategory }}</text>
|
</view>
|
|
<view class="info-row">
|
<text class="info-label">规格型号:</text>
|
<text class="info-value">{{ item.specificationModel }}</text>
|
</view>
|
|
<view class="info-row">
|
<text class="info-label">绑定机器:</text>
|
<text class="info-value">{{ item.speculativeTradingName }}</text>
|
</view>
|
|
<view class="quantity-row">
|
<view class="quantity-item">
|
<text class="quantity-label">总数量:</text>
|
<text class="quantity-value">{{ item.quantity }}</text>
|
</view>
|
|
<view class="quantity-item">
|
<text class="quantity-label">已排产:</text>
|
<text class="quantity-value">{{ item.schedulingNum }}</text>
|
</view>
|
|
<view class="quantity-item">
|
<text class="quantity-label">待排产:</text>
|
<text class="quantity-value">{{ item.pendingQuantity }}</text>
|
</view>
|
</view>
|
|
<view class="scheduling-row">
|
<text class="scheduling-label">本次排产:</text>
|
<up-number-box
|
v-model="item.schedulingNum"
|
:min="0"
|
:max="item.pendingQuantity"
|
:step="1"
|
:precision="0"
|
size="mini"
|
@change="(value) => changeCurrentNum(value, item)"
|
class="scheduling-input"
|
/>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view v-if="dispatchList.length === 0" class="empty-state">
|
<text class="empty-text">暂无派工数据</text>
|
</view>
|
</view>
|
|
<view class="popup-footer">
|
<up-button type="primary" @click="submitForm" class="confirm-btn">确认派工</up-button>
|
<up-button @click="closeDia" class="cancel-btn">取消</up-button>
|
</view>
|
</view>
|
</up-popup>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive, toRefs } from "vue";
|
import { productionDispatchList } from "@/api/productionManagement/productionOrder.js";
|
|
const emit = defineEmits(['close'])
|
|
const dialogFormVisible = ref(false);
|
const operationType = ref('')
|
|
const data = reactive({
|
form: {},
|
dispatchList: [], // 派工列表数据
|
});
|
|
const { form, dispatchList } = toRefs(data);
|
|
// 表格行样式
|
const tableRowClassName = ({ rowIndex }) => {
|
if (rowIndex % 2 === 1) {
|
return 'even-row'
|
}
|
return ''
|
}
|
|
// 修改本次排产数量
|
const changeCurrentNum = (value, row) => {
|
if (value > row.pendingQuantity) {
|
row.schedulingNum = row.pendingQuantity
|
uni.$u.toast('排产数量不可大于待排产数量')
|
}
|
}
|
|
// 打开弹框
|
const openDialog = (rows) => {
|
dialogFormVisible.value = true;
|
|
console.log('接收到传入的数据:', rows);
|
console.log('传入数据数量:', rows.length);
|
|
// 处理传入的数据
|
dispatchList.value = rows.map((row, index) => ({
|
...row,
|
schedulingNum: 0, // 初始化本次排产数量为0
|
pendingQuantity: (Number(row.quantity) || 0) - (Number(row.schedulingNum) || 0) // 计算待排产数量
|
}))
|
|
console.log('处理后的派工列表:', dispatchList.value);
|
console.log('派工列表数量:', dispatchList.value.length);
|
}
|
|
// 提交表单
|
const submitForm = () => {
|
// 检查是否有排产数据
|
const hasSchedulingData = dispatchList.value.some(item => item.schedulingNum > 0)
|
if (!hasSchedulingData) {
|
uni.$u.toast('请至少为一条记录设置排产数量')
|
return
|
}
|
|
// 构造提交数据 - 直接传递数组,不过滤
|
const submitData = dispatchList.value
|
|
console.log('提交自动派工数据:', submitData)
|
|
// 调用API(这里需要根据实际接口调整)
|
productionDispatchList(submitData).then(res => {
|
uni.$u.toast(res.msg || '派工成功');
|
closeDia();
|
}).catch(err => {
|
uni.$u.toast('派工失败');
|
console.error('派工失败:', err);
|
})
|
}
|
|
// 关闭弹框
|
const closeDia = () => {
|
dialogFormVisible.value = false;
|
dispatchList.value = []
|
emit('close')
|
};
|
|
defineExpose({
|
openDialog,
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.popup-content {
|
width: 90vw;
|
max-width: 1200px;
|
background: #fff;
|
border-radius: 20rpx;
|
overflow: hidden;
|
}
|
|
.popup-header {
|
padding: 30rpx;
|
border-bottom: 1rpx solid #f0f0f0;
|
text-align: center;
|
}
|
|
.popup-title {
|
font-size: 36rpx;
|
font-weight: bold;
|
color: #333;
|
}
|
|
.popup-body {
|
padding: 30rpx;
|
height: 60vh;
|
overflow-y: auto;
|
overflow-x: hidden;
|
-webkit-overflow-scrolling: touch;
|
max-height: 60vh;
|
}
|
|
.section-title {
|
font-size: 32rpx;
|
font-weight: bold;
|
color: #333;
|
margin-bottom: 20rpx;
|
flex-shrink: 0;
|
}
|
|
.card-list {
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx;
|
min-height: 0;
|
overflow-y: auto;
|
max-height: 60vh;
|
}
|
|
.dispatch-card {
|
background: #f8f9fa;
|
border-radius: 12rpx;
|
padding: 24rpx;
|
border: 1rpx solid #e9ecef;
|
transition: all 0.3s ease;
|
flex-shrink: 0;
|
}
|
|
.dispatch-card:hover {
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
|
transform: translateY(-2rpx);
|
}
|
|
.even-card {
|
background: #ffffff;
|
}
|
|
.card-header {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20rpx;
|
padding-bottom: 16rpx;
|
border-bottom: 1rpx solid #e9ecef;
|
}
|
|
.card-index {
|
background: #1890ff;
|
color: white;
|
width: 40rpx;
|
height: 40rpx;
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 24rpx;
|
font-weight: bold;
|
margin-right: 16rpx;
|
}
|
|
.card-project {
|
font-size: 28rpx;
|
font-weight: bold;
|
color: #333;
|
flex: 1;
|
}
|
|
.card-content {
|
display: flex;
|
flex-direction: column;
|
gap: 12rpx;
|
}
|
|
.info-row {
|
display: flex;
|
align-items: center;
|
}
|
|
.info-label {
|
font-size: 26rpx;
|
color: #666;
|
width: 140rpx;
|
flex-shrink: 0;
|
}
|
|
.info-value {
|
font-size: 26rpx;
|
color: #333;
|
flex: 1;
|
}
|
|
.quantity-row {
|
display: flex;
|
gap: 20rpx;
|
margin: 8rpx 0;
|
}
|
|
.quantity-item {
|
display: flex;
|
align-items: center;
|
background: #f8f9fa;
|
padding: 8rpx 16rpx;
|
border-radius: 6rpx;
|
border: 1rpx solid #e9ecef;
|
}
|
|
.quantity-label {
|
font-size: 24rpx;
|
color: #666;
|
margin-right: 8rpx;
|
}
|
|
.quantity-value {
|
font-size: 24rpx;
|
color: #1890ff;
|
font-weight: bold;
|
}
|
|
.scheduling-row {
|
display: flex;
|
align-items: center;
|
margin-top: 12rpx;
|
padding-top: 12rpx;
|
border-top: 1rpx dashed #e9ecef;
|
}
|
|
.scheduling-label {
|
font-size: 26rpx;
|
color: #333;
|
font-weight: bold;
|
margin-right: 16rpx;
|
width: 140rpx;
|
flex-shrink: 0;
|
}
|
|
.scheduling-input {
|
flex: 1;
|
}
|
|
.empty-state {
|
text-align: center;
|
padding: 60rpx 30rpx;
|
color: #999;
|
}
|
|
.empty-text {
|
font-size: 28rpx;
|
}
|
|
.popup-footer {
|
padding: 30rpx;
|
border-top: 1rpx solid #f0f0f0;
|
display: flex;
|
justify-content: center;
|
gap: 20rpx;
|
}
|
|
.confirm-btn {
|
width: 200rpx;
|
}
|
|
.cancel-btn {
|
width: 200rpx;
|
}
|
</style>
|