guoyujia 1 gadu atpakaļ
vecāks
revīzija
c5d2cb3c8d

+ 8 - 0
src/api/business/outsourcedOrderDetailProcess.js

@@ -18,3 +18,11 @@ export function getProcess(id) {
 		method: 'get'
 	})
 }
+// 修改外协单从对应的外协工序的从列表
+export function editOutsourcedOrderDetailProcess(data) {
+	return request({
+		url: baseUrl + '/business/outsourceDetailProcess/editOutsourcedOrderDetailProcess',
+		method: 'post',
+		data: data
+	})
+}

+ 2 - 2
src/api/business/returnReceipt.js

@@ -22,7 +22,7 @@ export function getReceipt(id) {
 // 新增收回单
 export function addReceipt(data) {
 	return request({
-		url: baseUrl + '/business/outsource',
+		url: baseUrl + '/business/returnReceipt',
 		method: 'post',
 		data: data
 	})
@@ -31,7 +31,7 @@ export function addReceipt(data) {
 // 修改收回单
 export function updateReceipt(data) {
 	return request({
-		url: baseUrl + '/business/outsource',
+		url: baseUrl + '/business/returnReceipt',
 		method: 'put',
 		data: data
 	})

+ 1 - 1
src/views/business/outsourcedOrder/index.vue

@@ -80,7 +80,7 @@
 					<el-table-column label="备注" align="center" prop="remark" />
 					<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="64">
 						<template #default="scope">
-							<el-button link type="warning" icon="View" @click="handleShowFormDialog(scope.row)"> 查看 </el-button>
+							<el-button link type="primary" icon="View" @click="handleShowFormDialog(scope.row)"> 查看 </el-button>
 						</template>
 					</el-table-column>
 				</el-table>

+ 172 - 59
src/views/business/outsourcedOrderDetails/index.vue

@@ -84,17 +84,24 @@
 								:min="1"
 								controls-position="right"
 								style="width: 100%"
+								@change="handleChangeloss(scope.row)"
 							/>
 							<span v-else>{{ scope.row.qualifiedNum }}</span>
 						</template>
 					</el-table-column>
+					<el-table-column label="料损率" align="center" prop="loss" width="120">
+						<template #default="scope">
+							<span v-if="scope.row.loss > scope.row.lossLimit" style="color: red">{{ scope.row.loss }}</span>
+							<span v-else>{{ scope.row.loss }}</span>
+						</template>
+					</el-table-column>
 					<el-table-column label="操作" align="center" width="104">
 						<template #default="scope">
 							<template v-if="scope.row.editStatus">
 								<el-button type="success" icon="Finished" circle @click="handleSaveRow(scope.row)" />
-								<el-button type="danger" icon="Close" circle @click="scope.row.editStatus = false" />
+								<el-button type="danger" icon="Close" circle @click="handleCancelRow(scope.row)" />
 							</template>
-							<el-button v-else type="primary" icon="Bell" @click="scope.row.editStatus = true">报工</el-button>
+							<el-button v-else type="primary" icon="Bell" @click="handleStartReport(scope.row)">报工</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
@@ -112,13 +119,14 @@
 </template>
 
 <script setup>
-import { listProcess } from '@/api/business/outsourcedOrderDetailProcess.js'
+import { listProcess,editOutsourcedOrderDetailProcess } from '@/api/business/outsourcedOrderDetailProcess.js'
 const { proxy } = getCurrentInstance()
 
 /** 生产批次 */
 const dataList = ref([])
 const dataTable = ref(null)
 const currentDaywork = ref({})
+const spanProps = ref([])
 const loading = ref(false)
 const total = ref(0)
 // 用于计算合并行的计数器
@@ -143,77 +151,182 @@ const getList = () => {
 		total.value = res.total
 		loading.value = false
 		if (dataList.value.length > 0) {
-			getSpanArr(dataList.value, 'formCode')
-			getSpanArr(dataList.value, 'formDate')
-			getSpanArr(dataList.value, 'lotCode')
-			getSpanArr(dataList.value, 'productDescription')
+			// getSpanArr(dataList.value, 'formCode')
+			// getSpanArr(dataList.value, 'formDate')
+			// getSpanArr(dataList.value, 'lotCode')
+			// getSpanArr(dataList.value, 'productDescription')
+			spanProps.value = ['formCode', 'formDate','lotCode','productDescription'];
+			spanPropGroup(dataList.value)
 		}
 	})
 }
-
+const handleChangeloss = (row) => {
+	let percent = (row.productionNum - row.qualifiedNum)/row.productionNum * 100; 
+        row.loss = Math.ceil(percent * 100) / 100; 
+}
 const handleSaveRow = (row) => {
-	row.editStatus = true
+	var flag = true
+	if(row.productionNum < row.qualifiedNum) {
+		flag = false
+		proxy.$modal.msgError('合格数不能大于投产数')
+	}else {
+		var tempList = dataList.value.filter(item => {
+			return item.detailId ==row.detailId
+		})
+		var index = tempList.indexOf(row)
+			if(index>0 && row.productionNum > tempList[index-1].qualifiedNum) {
+				flag = false
+				proxy.$modal.msgError('投产数不能大于上一道序合格数')
+		}
+	}
+	if(flag) {
+		editOutsourcedOrderDetailProcess(row).then((res) => {
+		if(res.code == 200) {
+			row.editStatus = false
+			proxy.$modal.msgSuccess('报工成功')
+			getList()		
+		}
+	})
+	}
 }
-
-const rowSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
-	if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2 || columnIndex === 3 || columnIndex === 4) {
-		const _row = spanArr.value[rowIndex]
-		const _col = _row > 0 ? 1 : 0
-		return {
-			rowspan: _row,
-			colspan: _col
+const handleCancelRow = (row) => {
+	row.editStatus = false
+	getList()
+}
+const handleStartReport = (row) => {
+	//如果收回单已经被审核,则不能让他报工
+	if(row.status == 1) {
+		proxy.$modal.msgError('该外协单已被审核,不能再报工')
+	}else{
+	let tempList = dataList.value.filter(item => {
+			return item.detailId ==row.detailId
+		})
+	let index = tempList.indexOf(row)
+		if(index > 0) {
+			//判断如果上一道序没有报工,不允许报此道序
+			if(tempList[index-1].productionNum == 0) {
+				proxy.$modal.msgError('上一道序未报工,不允许报此道序')
+			}else {
+				row.editStatus = true
+				row.productionNum = tempList[index-1].qualifiedNum
+			}		 	
+		}else {
+			row.editStatus = true
+			row.productionNum = row.productNum
 		}
 	}
+		
 }
 
-// groupBy 数组
-const groupBy = (data, params) => {
-	const groups = {}
-	data.forEach((v) => {
-		const group = JSON.stringify(v[params])
-		groups[group] = groups[group] || []
-		groups[group].push(v)
-	})
-	return Object.values(groups)
-}
+ 
+let rowSpansMap = new Map(); //存需要开始合并的行号,向下合并多少行
 
-// 计算 数据合并 索引
-const getSpanArr = (data, params) => {
-	// 接收重构数组
-	let arr = []
+const spanPropGroup = (data) => {
+  let oldRow = null; //需要合并的行
+  rowSpansMap = new Map(); //重置Map
+  oldRow = data[0]; //默认第0行为需要合并的行
+  rowSpansMap.set(0, 1); //第0行,向下合并一行(其实就是自己单独一行)
+  let spanRow = 0; //记录需要开始合并的行号
+  for (let i = 1; i < data.length; i++) {
+    const item = data[i];
+    let isSame = true;
+    //遍历需要判断的属性判断对应值是否全部相等
+    for (let j = 0; j < spanProps.value.length; j++) {
+      const prop = spanProps.value[j];
+      //只要有一个属性值不相等则记录新的需要合并的行号
+      if (item[prop] != oldRow[prop]) {
+        oldRow = item;
+        rowSpansMap.set(i, 1);
+        spanRow = i;
+        isSame = false;
+        break;
+      }
+    }
+    //如果所有属性值相同则所需要合并的行数+1
+    if (isSame) {
+      let span = rowSpansMap.get(spanRow);
+      rowSpansMap.set(spanRow, span + 1);
+    }
+  }
+};
+ 
+const rowSpanMethod =({ row, column, rowIndex, columnIndex }) => {
+  //采样值5-9列所对应的行不需要合并
+  if (columnIndex != 5 && columnIndex != 6 && columnIndex != 7 && columnIndex != 8 && columnIndex != 9 && columnIndex != 10) {
+    //根据当前行号从map中获取开始合并的行根据当前行号从map中获取开始合并的行号,向下合并多少行
+    const span = rowSpansMap.get(rowIndex);
+    if (span != null) {
+      return {
+        rowspan: span, //向下合并span行
+        colspan: 1,
+      };
+    } else {
+      return {
+        rowspan: 0,
+        colspan: 0,
+      };
+    }
+  }
+};
+// const rowSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
+// 	if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2 || columnIndex === 3 || columnIndex === 4) {
+// 		const _row = spanArr.value[rowIndex]
+// 		const _col = _row > 0 ? 1 : 0
+// 		return {
+// 			rowspan: _row,
+// 			colspan: _col
+// 		}
+// 	}
+// }
 
-	// 设置索引
-	let pos = 0
+// // groupBy 数组
+// const groupBy = (data, params) => {
+// 	const groups = {}
+// 	data.forEach((v) => {
+// 		const group = JSON.stringify(v[params])
+// 		groups[group] = groups[group] || []
+// 		groups[group].push(v)
+// 	})
+// 	return Object.values(groups)
+// }
 
-	// 控制合并的数组
-	spanArr.value = []
+// // 计算 数据合并 索引
+// const getSpanArr = (data, params) => {
+// 	// 接收重构数组
+// 	let arr = []
 
-	// arr 处理
-	groupBy(data, params).map((v) => (arr = arr.concat(v)))
+// 	// 设置索引
+// 	let pos = 0
 
-	arr.map((res) => {
-		data.shift()
-		data.push(res)
-	})
+// 	// 控制合并的数组
+// 	spanArr.value = []
 
-	// spanArr 处理
-	const redata = arr.map((v) => v[params])
-	redata.reduce((old, cur, i) => {
-		if (i === 0) {
-			spanArr.value.push(1)
-			pos = 0
-		} else {
-			if (cur === old) {
-				spanArr.value[pos] += 1
-				spanArr.value.push(0)
-			} else {
-				spanArr.value.push(1)
-				pos = i
-			}
-		}
-		return cur
-	}, {})
-}
+// 	// arr 处理
+// 	groupBy(data, params).map((v) => (arr = arr.concat(v)))
+
+// 	arr.map((res) => {
+// 		data.shift()
+// 		data.push(res)
+// 	})
+
+// 	// spanArr 处理
+// 	const redata = arr.map((v) => v[params])
+// 	redata.reduce((old, cur, i) => {
+// 		if (i === 0) {
+// 			spanArr.value.push(1)
+// 			pos = 0
+// 		} else {
+// 			if (cur === old) {
+// 				spanArr.value[pos] += 1
+// 				spanArr.value.push(0)
+// 			} else {
+// 				spanArr.value.push(1)
+// 				pos = i
+// 			}
+// 		}
+// 		return cur
+// 	}, {})
+// }
 
 onMounted(() => {
 	getList()

+ 7 - 1
src/views/business/returnReceipt/DialogOutsourceDetails.vue

@@ -39,7 +39,13 @@
 			<el-table-column label="批次号" align="center" prop="lotCode" width="96" />
 			<el-table-column label="料号" align="center" prop="productCode" width="96" />
 			<el-table-column label="产品描述" align="center" prop="productDescription" />
-			<el-table-column label="箱号" align="center" prop="originalCarrier" width="220" />
+			<el-table-column label="箱号" align="center" prop="originalCarrier" width="220">
+				<template #default="scope">
+        <!-- 检查 scope.row.newCarrier 是否有值 -->
+        <span v-if="scope.row.newCarrier">{{ scope.row.newCarrier }}</span>
+        <span v-else>{{ scope.row.originalCarrier }}</span>
+      </template>
+			</el-table-column>
 		</el-table>
 		<!-- 分页 -->
 		<pagination

+ 43 - 31
src/views/business/returnReceipt/form.vue

@@ -8,13 +8,7 @@
 				</span>
 				<el-button-group>
 					<el-button v-if="editStatus" type="primary" icon="Finished" @click="submitForm"> 保存 </el-button>
-					<el-button v-else type="warning" icon="Edit" @click="editStatus = true">编辑</el-button>
-					<el-button v-if="form.id && editStatus" type="info" icon="Close" @click="editStatus = false">
-						取消编辑
-					</el-button>
-					<el-button v-if="form.id" type="success" @click="getForm">
-						<i class="fa fa-refresh" aria-hidden="true" /> 刷新
-					</el-button>
+					<el-button v-else type="primary" icon="Finished" @click="cancel"> 确定 </el-button>
 				</el-button-group>
 
 				<div class="close-btn" @click="cancel">
@@ -32,25 +26,27 @@
 					<el-col :span="6">
 						<el-form-item label="表单日期" prop="formDate">
 							<el-date-picker
-								readonly
+							    v-if="editStatus"
 								v-model="form.formDate"
 								type="date"
 								value-format="YYYY-MM-DD"
 								style="width: 100%"
 							>
 							</el-date-picker>
+							<el-input v-model="form.formDate" v-else readonly />
 						</el-form-item>
 					</el-col>
 					<el-col :span="12">
 						<el-form-item label="备注" prop="remark">
-							<el-input v-model="form.remark" readonly />
+							<el-input v-model="form.remark" v-if ="editStatus" />
+							<el-input v-model="form.remark" v-else readonly />
 						</el-form-item>
 					</el-col>
 				</el-row>
 			</el-form>
 			<!-- 渲染数据区 -->
 			<div class="form-details-btns-container">
-				<el-button type="primary" icon="Plus" @click="handleShowDialogOutSourceDetails"> 添加收回明细 </el-button>
+				<el-button type="primary" icon="Plus" v-if="editStatus" @click="handleShowDialogOutSourceDetails"> 添加收回明细 </el-button>
 			</div>
 			<div class="el-table-container">
 				<div class="el-table-inner-container">
@@ -60,32 +56,23 @@
 						<el-table-column label="产品描述" align="center" prop="productDescription" width="320" />
 						<el-table-column label="产品数量" align="center" prop="productNum" width="96" />
 						<el-table-column
-							:label="form.packagingMethod === '0' ? '箱号' : '原箱号'"
+							label ='原箱号'
 							align="center"
 							prop="originalCarrier"
 							width="320"
 						/>
 						<el-table-column
-							v-if="form.packagingMethod === '1'"
 							label="新箱号"
 							align="center"
 							prop="newCarrier"
 							width="320"
 						/>
 						<el-table-column label="外协工序" align="center" prop="processNames" width="320" />
-						<el-table-column label="收回数量" align="center" prop="receiptNum" width="104">
-							<template #default="scope">
-								<el-input-number
-									v-model="scope.row.receiptNum"
-									:min="0"
-									controls-position="right"
-									style="text-align: center"
-								/>
-							</template>
-						</el-table-column>
+						<el-table-column label="收回数量" align="center" prop="receiptNum" width="104"/>
 						<el-table-column label="备注" align="center" prop="remark">
 							<template #default="scope">
-								<el-input v-model="scope.row.remark" />
+								<el-input v-model="scope.row.remark" v-if="editStatus" />
+								<el-input v-model="scope.row.remark" v-else readonly />
 							</template>
 						</el-table-column>
 					</el-table>
@@ -103,27 +90,30 @@
 <script setup>
 import { getReceipt, addReceipt, updateReceipt } from '@/api/business/returnReceipt'
 import dialogOutsourceDetails from './DialogOutsourceDetails'
+import { getTenant } from '@/utils/auth'
+const emit = defineEmits(['handleSaveSuccess'])
 const { proxy } = getCurrentInstance()
 /** 表单抽屉 页变量 */
 const loading = ref(false)
 const visible = ref(false)
-const editStatus = ref(false)
+const editStatus = ref(true)
 const webHost = import.meta.env.VITE_APP_BASE_API
 const form = ref({})
 
 /****************************  方法区  ****************************/
 /** 打开抽屉 */
-const open = (id) => {
+const open = (row) => {
 	reset()
 	visible.value = true
-	if (id) {
+	if (row) {
+		editStatus.value = row.editStatus == false?row.editStatus:true
 		loading.value = true
-		getReceipt(id).then((response) => {
+		getReceipt(row.id).then((response) => {
 			form.value = response.data
 			loading.value = false
 		})
 	} else {
-		editStatus.value = true
+		form.value.supplierName = getTenant().tenantName
 	}
 }
 
@@ -158,8 +148,16 @@ const handleMultipleSelectedOutsourceDetails = (selection) => {
 		const newDetail = {
 			outsourceDetailId: item.id,
 			productDescription: item.productDescription,
+			lotCode:item.lotCode,
+			lotId:item.lotId,
+			dayworkId:item.dayworkId,
+			productId:item.productId,
 			productNum: item.productNum,
-			receiptNum: 0,
+			receiptNum: item.receiptNum,
+			originalCarrier:item.originalCarrier,
+			originalCarrierCount:item.originalCarrierCount,
+			newCarrier:item.newCarrier,
+			newCarrierCount:item.newCarrierCount,
 			processNames: item.processNames,
 			remark: ''
 		}
@@ -171,19 +169,33 @@ const handleMultipleSelectedOutsourceDetails = (selection) => {
 function submitForm() {
 	proxy.$refs['formRef'].validate((valid) => {
 		if (valid) {
+			var flag = true;
+			if(form.value.details.length==0) {
+				flag = false
+				proxy.$modal.msgError('收回明细不能为空')
+			}
+		for (let i = 0; i < form.value.details.length; i++) {
+       		if (form.value.details[i].receiptNum <= 0) {
+				flag = false;
+				proxy.$modal.msgError("第" + (i + 1) + "行收回数量应大于0");
+				return;
+       		}
+			}
+			if(flag) {
 			if (form.value.id != null) {
 				updateReceipt(form.value).then((response) => {
 					proxy.$modal.msgSuccess('修改成功')
 					visible.value = false
-					getList.value()
+					emit('handleSaveSuccess')
 				})
 			} else {
 				addReceipt(form.value).then((response) => {
 					proxy.$modal.msgSuccess('新增成功')
 					visible.value = false
-					getList.value()
+					emit('handleSaveSuccess')
 				})
 			}
+			}
 		}
 	})
 }

+ 16 - 9
src/views/business/returnReceipt/index.vue

@@ -44,7 +44,7 @@
 		<!-- 渲染数据区 -->
 		<div class="el-table-container">
 			<div class="el-table-inner-container">
-				<el-table v-loading="loading" :data="dataList" size="small" border height="100%">
+				<el-table v-loading="loading" :data="dataList" size="small" border height="100%"  @selection-change="handleSelectionChange">
 					<el-table-column type="selection" width="48" align="center" />
 					<el-table-column label="收回单号" align="center" prop="formCode" width="120" />
 					<el-table-column label="收回日期" align="center" prop="formDate" width="120">
@@ -55,7 +55,8 @@
 					<el-table-column label="备注" align="center" prop="remark" />
 					<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="64">
 						<template #default="scope">
-							<el-button link type="warning" icon="View" @click="handleShowFormDialog(scope.row)"> 查看 </el-button>
+							<el-button v-if="scope.row.status == 1" link type="primary" icon="View" @click="handleShowFormDialog(scope.row)"> 查看 </el-button>
+							<el-button v-else link type="warning" icon="Edit" @click="handleShowFormDialog(scope.row)"> 编辑 </el-button>
 						</template>
 					</el-table-column>
 				</el-table>
@@ -72,12 +73,12 @@
 		/>
 
 		<!-- 表单 -->
-		<receipt-form ref="receiptRef" />
+		<receipt-form ref="receiptRef" @handleSaveSuccess="getList" />
 	</div>
 </template>
 
 <script setup name="Receipt">
-import { listReceipt } from '@/api/business/returnReceipt'
+import { listReceipt,delReceipt } from '@/api/business/returnReceipt'
 import receiptForm from './form'
 const { proxy } = getCurrentInstance()
 
@@ -118,18 +119,24 @@ function resetQuery() {
 	proxy.resetForm('queryRef')
 	handleQuery()
 }
-
+/**复选框选中数据 */
+function handleSelectionChange(selection) {
+	ids.value = selection.map((item) => item.id)
+}
 /** 修改按钮操作 */
 function handleShowFormDialog(row) {
-	proxy.$refs.receiptRef.open(row ? row.id : null)
+	if(row && row.status == 1) {
+		row.editStatus = false
+	}
+	proxy.$refs.receiptRef.open(row?row:null)
 }
 /** 删除按钮操作 */
-function handleDelete(row) {
-	const _ids = row.id || ids.value
+function handleDelete() {
+	const _ids =ids.value
 	proxy.$modal
 		.confirm('是否确认删除选中的数据项?')
 		.then(function () {
-			return delOrder(_ids)
+			return delReceipt(_ids)
 		})
 		.then(() => {
 			getList()