guoyujia 1 jaar geleden
bovenliggende
commit
46de58109e

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

@@ -34,3 +34,11 @@ export function getOrderDetailProcess(data) {
 		data:data
 	})
 }
+//查询上一道序的合格数
+export function getLastProcessQualifitedNum(data) {
+	return request({
+		url: baseUrl + '/business/outsourceDetailProcess/getLastProcessQualifitedNum',
+		method: 'post',
+		data:data
+	})
+}

+ 10 - 0
src/api/business/returnReceipt.js

@@ -30,6 +30,16 @@ export function printReturnReceipt(data) {
     `外协收回单_${new Date().getTime()}.pdf`
   )
 }
+// 导出
+export function exportReturn(data) {
+	download(
+	  baseUrl+"/business/returnReceipt/export",
+	  {
+		...data,
+	  },
+	  `外协收回单_${new Date().getTime()}.xlsx`
+	)
+  }
 
 
 

+ 1 - 1
src/router/index.js

@@ -100,7 +100,7 @@ export const constantRoutes = [
 				component: () => import('@/views/business/outsourcedOrderDetails/index'),
 				name: 'OutsourcedOrderDetails',
 				meta: {
-					title: '外协订单明细',
+					title: '外协报工',
 					icon: 'list'
 				}
 			}

+ 110 - 23
src/views/business/outsourcedOrderDetails/index.vue

@@ -42,6 +42,25 @@
 					style="width: 130px"
 				/>
 			</el-form-item>
+			<el-form-item label="箱号:">
+				<el-input
+					placeholder="请输入箱号"
+					v-model.trim="queryParams.newCarrierName"
+					@keydown.enter.prevent
+					clearable
+					style="width: 130px"
+				/>
+			</el-form-item>
+			<el-form-item label="报工状态:">
+					<el-select v-model="queryParams.status" clearable placeholder="请选择报工状态" style="width: 145px">
+						<el-option v-for="dict in is_report" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+					</el-select>
+				</el-form-item>
+				<el-form-item label="收回状态:">
+					<el-select v-model="queryParams.returnStatus" clearable placeholder="请选择收回状态" style="width: 145px">
+						<el-option v-for="dict in is_return" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+					</el-select>
+				</el-form-item>
 			<el-form-item style="margin-left: 0">
 				<el-button type="info" icon="Search" @click="getList">搜索 </el-button>
 			</el-form-item>
@@ -61,9 +80,19 @@
 					<el-table-column label="外协日期" align="center" prop="formDate" width="120" />
 					<el-table-column label="批次号" align="center" prop="lotCode" width="120" />
 					<el-table-column label="产品描述" align="center" prop="productDescription" />
+					<el-table-column label="箱号" align="center" prop="newCarrierName" />
+					<el-table-column label="收回状态" align="center" prop="returnStatus" width="80" >
+						<template #default="scope">
+							<dict-tag :options="is_return" :value="scope.row.returnStatus" />
+						</template>
+					</el-table-column>
 					<el-table-column label="外协数量" align="center" prop="productNum" width="80" />
 					<el-table-column label="工序名称" align="center" prop="processAlias" width="80" />
-					<!-- <el-table-column label="工序序号" align="center" prop="processStepNumber" width="80" /> -->
+					<el-table-column label="报工状态" align="center" prop="status" width="80" >
+						<template #default="scope">
+							<dict-tag :options="is_report" :value="scope.row.status" />
+						</template>
+					</el-table-column>
 					<el-table-column label="投产数" align="center" prop="productionNum" width="120">
 						<template #default="scope">
 							<el-input-number
@@ -125,9 +154,11 @@
 </template>
 
 <script setup>
-import { listProcess,editOutsourcedOrderDetailProcess } from '@/api/business/outsourcedOrderDetailProcess.js'
+import { listProcess,editOutsourcedOrderDetailProcess,getLastProcessQualifitedNum } from '@/api/business/outsourcedOrderDetailProcess.js'
 const { proxy } = getCurrentInstance()
-
+/** 字典数组区 */
+const { is_report } = proxy.useDict('is_report')
+const { is_return } = proxy.useDict('is_return')
 /** 生产批次 */
 const dataList = ref([])
 const dataTable = ref(null)
@@ -143,12 +174,19 @@ const queryParams = ref({
 	formEndDate: null,
 	lotCode: '',
 	productDescription: '',
+	status:null,
+	returnStatus:null,
 	pageNum: 1,
 	pageSize: 10
 })
 
 /***********************  工段相关事件  ****************************/
-const getList = () => {
+const getTime =()=>{
+	getNowDate();
+  	getPassDate();
+	  getList()
+}
+const getList = () => {	
 	loading.value = true
 	listProcess(queryParams.value).then((res) => {
 		dataList.value = res.rows
@@ -164,10 +202,51 @@ const getList = () => {
 		}
 	})
 }
+//获取当前时间
+function getNowDate() {
+  var nowDate = new Date();
+  var date = {
+    year: nowDate.getFullYear(),
+    month: nowDate.getMonth() + 1,
+    day: nowDate.getDate(),
+  };
+  const dayDate =
+    date.year +
+    "-" +
+    (date.month >= 10 ? date.month : "0" + date.month) +
+    "-" +
+    (date.day >= 10 ? date.day : "0" + date.day);
+  console.log(dayDate);
+  queryParams.value.endTime = dayDate;
+}
+//获取30天前时间
+function getPassDate() {
+  var myDate = new Date();
+  myDate.setDate(myDate.getDate() - 29);
+  var dateTemp;
+  var day;
+  for (var i = 0; i < 30; i++) {
+    if (myDate.getDate() < 10) {
+      day = "0" + myDate.getDate().toString();
+    } else {
+      day = myDate.getDate().toString();
+    }
+  }
+  var month = myDate.getMonth() + 1;
+  dateTemp =
+    myDate.getFullYear() +
+    "-" +
+    (month < 10 ? "0" + month : "" + month) +
+    "-" +
+    day;
+  queryParams.value.startTime = dateTemp;
+}
+//计算损耗率
 const handleChangeloss = (row) => {
 	let percent = (row.productionNum - row.qualifiedNum)/row.productionNum * 100; 
         row.loss = Math.ceil(percent * 100) / 100; 
 }
+//报工确认
 const handleSaveRow = (row) => {
 	var flag = true
 	if(row.qualifiedNum == 0) {
@@ -218,25 +297,33 @@ const handleCancelRow = (row) => {
 	getList()
 }
 const handleStartReport = (row) => {
-	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
-			if(!row.productionNum) {
-				row.productionNum = row.productNum
-			}
+	// 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
+	// 		if(!row.productionNum) {
+	// 			row.productionNum = row.productNum
+	// 		}
 			
+	// 	}
+	//获得上一道序报工的合格数
+	getLastProcessQualifitedNum(row).then(res =>{
+		if(res.code == 200) {
+			row.editStatus = true
+			row.productionNum = res.data
+			row.qualifiedNum = res.data
 		}
+	})
 }
 let rowSpansMap = new Map(); //存需要开始合并的行号,向下合并多少行
 
@@ -271,7 +358,7 @@ const spanPropGroup = (data) => {
  
 const rowSpanMethod =({ row, column, rowIndex, columnIndex }) => {
   //采样值5-9列所对应的行不需要合并
-  if (columnIndex != 5 && columnIndex != 6 && columnIndex != 7 && columnIndex != 8 && columnIndex != 9 ) {
+  if (columnIndex != 11 && columnIndex != 7 && columnIndex != 8 && columnIndex != 9 && columnIndex != 10&& columnIndex != 12 ) {
     //根据当前行号从map中获取开始合并的行根据当前行号从map中获取开始合并的行号,向下合并多少行
     const span = rowSpansMap.get(rowIndex);
     if (span != null) {
@@ -348,7 +435,7 @@ const rowSpanMethod =({ row, column, rowIndex, columnIndex }) => {
 // }
 
 onMounted(() => {
-	getList()
+	getTime()
 })
 </script>
 <style scoped>

+ 13 - 8
src/views/business/returnReceipt/DialogOutsourceDetails.vue

@@ -15,7 +15,18 @@
 					type="text"
 					@keydown.enter.prevent
 					style="width: 160px"
-					placeholder="请输入关键字"
+					placeholder="请输入产品描述"
+					:clearable="true"
+					@keyup.enter="handleSearch"
+				/>
+			</el-form-item>
+			<el-form-item label="箱号:" prop="newCarrier" label-width="104">
+				<el-input
+					v-model.trim="queryParams.newCarrier"
+					type="text"
+					@keydown.enter.prevent
+					style="width: 160px"
+					placeholder="请输入箱号"
 					:clearable="true"
 					@keyup.enter="handleSearch"
 				/>
@@ -37,14 +48,8 @@
 			<el-table-column type="selection" width="40" align="center" />
 			<el-table-column type="index" label="行号" width="50" align="center" />
 			<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">
-				<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 label="箱号" align="center" prop="newCarrier" width="220">
 			</el-table-column>
 		</el-table>
 		<!-- 分页 -->

+ 394 - 194
src/views/business/returnReceipt/form.vue

@@ -1,223 +1,423 @@
 <template>
-	<el-drawer title="外协单信息" :with-header="false" v-model="visible" direction="rtl" size="100%">
-		<div class="form-container column-container">
-			<div class="form-btns-container">
-				<span class="title-label">
-					<el-icon><Document /></el-icon>
-					<span>收回单信息</span>
-				</span>
-				<el-button-group>
-					<el-button v-if="editStatus" type="primary" icon="Finished" :loading="isSubmitting" @click="submitForm"> 保存 </el-button>
-					<el-button v-else type="primary" icon="Finished" @click="cancel"> 确定 </el-button>
-				</el-button-group>
+  <el-drawer
+    title="外协单信息"
+    :with-header="false"
+    v-model="visible"
+    direction="rtl"
+    size="100%"
+  >
+    <div class="form-container column-container">
+      <div class="form-btns-container">
+        <span class="title-label">
+          <el-icon><Document /></el-icon>
+          <span>收回单信息</span>
+        </span>
+        <el-button-group>
+          <el-button v-if="editStatus&& submitStatus" type="success" @click="saveForm">
+            保存
+          </el-button>
+          <el-button
+            v-if="editStatus && submitStatus"
+            type="primary"
+            @click="submitForm"
+          >
+            提交
+          </el-button>
+          <el-button
+            v-if="editStatus && !submitStatus"
+            type="primary"
+            @click="handleCancelSubmit"
+          >
+            取消提交
+          </el-button>
+          <el-button
+            v-if="!editStatus"
+            type="primary"
+            icon="Finished"
+            @click="cancel"
+          >
+            确定
+          </el-button>
+        </el-button-group>
 
-				<div class="close-btn" @click="cancel">
-					<i class="fa fa-times" aria-hidden="true" />
-					<!-- <span>关闭</span> -->
-				</div>
-			</div>
-			<el-form ref="formRef" class="master-container" :model="form" v-loading="loading" label-width="120px">
-				<el-row :gutter="20">
-					<el-col :span="6">
-						<el-form-item label="单据号" prop="formCode">
-							<el-input v-model="form.formCode" readonly />
-						</el-form-item>
-					</el-col>
-					<el-col :span="6">
-						<el-form-item label="表单日期" prop="formDate">
-							<el-date-picker
-							    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" 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" v-if="editStatus" @click="handleShowDialogOutSourceDetails"> 添加收回明细 </el-button>
-			</div>
-			<div class="el-table-container">
-				<div class="el-table-inner-container">
-					<el-table v-loading="loading" :data="form.details" size="small" border height="100%">
-						<el-table-column label="行号" type="index" align="center" width="48" />
-						<el-table-column label="批次号" align="center" prop="lotCode" width="104" />
-						<el-table-column label="产品描述" align="center" prop="productDescription" width="320" />
-						<el-table-column label="产品数量" align="center" prop="productNum" width="96" />
-						<el-table-column
-							label ='原箱号'
-							align="center"
-							prop="originalCarrier"
-							width="320"
-						/>
-						<el-table-column
-							label="新箱号"
-							align="center"
-							prop="newCarrier"
-							width="320"
-						/>
-						<el-table-column label="外协工序" align="center" prop="processAlias" width="320" />
-						<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" v-if="editStatus" />
-								<el-input v-model="scope.row.remark" v-else readonly />
-							</template>
-						</el-table-column>
-					</el-table>
-				</div>
-			</div>
-		</div>
+        <div class="close-btn" @click="cancel">
+          <i class="fa fa-times" aria-hidden="true" />
+          <!-- <span>关闭</span> -->
+        </div>
+      </div>
+      <el-form
+        ref="formRef"
+        class="master-container"
+        :model="form"
+        v-loading="loading"
+        label-width="120px"
+      >
+        <el-row :gutter="20">
+          <el-col :span="6">
+            <el-form-item label="单据号" prop="formCode">
+              <el-input v-model="form.formCode" readonly />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="表单日期" prop="formDate">
+              <el-date-picker
+                v-if="editStatus && submitStatus"
+                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.trim="form.remark" v-if="editStatus&& submitStatus" />
+              <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"
+          v-if="editStatus && submitStatus"
+          @click="handleShowDialogOutSourceDetails"
+        >
+          添加收回明细
+        </el-button>
+      </div>
+      <div class="el-table-container">
+        <div class="el-table-inner-container">
+          <el-table
+            v-loading="loading"
+            :data="form.details"
+            size="small"
+            border
+            height="100%"
+          >
+            <el-table-column
+              label="行号"
+              type="index"
+              align="center"
+              width="48"
+            />
+            <el-table-column
+              label="批次号"
+              align="center"
+              prop="lotCode"
+              width="104"
+            />
+            <el-table-column
+              label="产品描述"
+              align="center"
+              prop="productDescription"
+              width="320"
+            />
+            <el-table-column
+              label="产品数量"
+              align="center"
+              prop="productNum"
+              width="96"
+            />
+            <el-table-column
+              label="箱号"
+              align="center"
+              prop="newCarrier"
+              width="320"
+            />
+            <el-table-column
+              label="外协工序"
+              align="center"
+              prop="processAlias"
+              width="320"
+            />
+            <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.trim="scope.row.remark" v-if="editStatus&& submitStatus" />
+                <el-input v-model="scope.row.remark" v-else readonly />
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="操作"
+              align="center"
+              class-name="small-padding fixed-width"
+              width="64"
+            >
+              <template #default="scope">
+                <el-button
+                  v-if="editStatus && submitStatus"
+                  link
+                  type="danger"
+                  icon="Delete"
+                  @click="handleDeletedDetails(scope.row)"
+                >
+                  删除
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      </div>
+    </div>
 
-		<!-- 外协商选择 -->
-		<dialog-outsource-details
-			ref="dialogOutsourceDetailsRef"
-			:multiple-selected="handleMultipleSelectedOutsourceDetails"
-		/>
-	</el-drawer>
+    <!-- 外协商选择 -->
+    <dialog-outsource-details
+      ref="dialogOutsourceDetailsRef"
+      :multiple-selected="handleMultipleSelectedOutsourceDetails"
+    />
+  </el-drawer>
 </template>
 <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()
+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(true)
-const isSubmitting = ref(false)
-const webHost = import.meta.env.VITE_APP_BASE_API
-const form = ref({})
+const loading = ref(false);
+const visible = ref(false);
+const editStatus = ref(true);
+const submitStatus = ref(true);
+const webHost = import.meta.env.VITE_APP_BASE_API;
+const form = ref({});
 
 /****************************  方法区  ****************************/
 /** 打开抽屉 */
 const open = (row) => {
-	reset()
-	visible.value = true
-	if (row) {
-		editStatus.value = row.editStatus == false?row.editStatus:true
-		loading.value = true
-		getReceipt(row.id).then((response) => {
-			form.value = response.data
-			loading.value = false
-		})
-	} else {
-		form.value.supplierName = getTenant().tenantName
-	}
-}
+  reset();
+  visible.value = true;
+  if (row) {
+    editStatus.value = row.editStatus == false ? row.editStatus : true;
+    submitStatus.value = row.isSubmit == 0 ? true : false;
+    loading.value = true;
+    getReceipt(row.id).then((response) => {
+      form.value = response.data;
+      loading.value = false;
+    });
+  } else {
+    form.value.supplierName = getTenant().tenantName;
+  }
+};
 
 /** 取消按钮 */
 const cancel = () => {
-	visible.value = false
-	reset()
-}
+  visible.value = false;
+  reset();
+};
 
 /** 表单重置 */
 const reset = () => {
-	form.value = {
-		id: null,
-		formCode: '',
-		formDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
-		supplierId: '0',
-		supplierName: '',
-		remark: '',
-		details: []
-	}
-	proxy.resetForm('formRef')
-}
+  form.value = {
+    id: null,
+    formCode: "",
+    formDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
+    supplierId: "0",
+    supplierName: "",
+    remark: "",
+    details: [],
+    detailInfo: [],
+  };
+  proxy.resetForm("formRef");
+};
 /***************************** 外协明细对话框相关 *****************************/
 // 打开外协明细选择对话框
 const handleShowDialogOutSourceDetails = () => {
-	const outsourceDetailIds =(form.value.details && form.value.details.length>0)? form.value.details.map((item) => item.outsourceDetailId):[]
-	proxy.$refs.dialogOutsourceDetailsRef.open(outsourceDetailIds)
-}
+  const outsourceDetailIds =
+    form.value.details && form.value.details.length > 0
+      ? form.value.details.map((item) => item.outsourceDetailId)
+      : [];
+  proxy.$refs.dialogOutsourceDetailsRef.open(outsourceDetailIds);
+};
 // 外协明细选择带回
 const handleMultipleSelectedOutsourceDetails = (selection) => {
-	for(let i = 0;i<selection.length;i++) {
-		for(let j = 0;j<selection[i].outsourcedOrderDetailProcessList.length;j++) {
-			const newDetail = {
-			outsourceDetailId: selection[i].id,
-			productDescription: selection[i].productDescription,
-			lotCode:selection[i].lotCode,
-			lotId:selection[i].lotId,
-			dayworkId:selection[i].dayworkId,
-			productId:selection[i].productId,
-			productNum: selection[i].productNum,
-			receiptNum: selection[i].outsourcedOrderDetailProcessList[j].qualifiedNum,
-			originalCarrier:selection[i].originalCarrier,
-			originalCarrierCount:selection[i].originalCarrierCount,
-			newCarrier:selection[i].newCarrier,
-			newCarrierCount:selection[i].newCarrierCount,
-			processNames: selection[i].processNames,
-			remark: '',
-			technologicalProcessId:selection[i].outsourcedOrderDetailProcessList[j].technologicalProcessId,
-			technologyVersion:selection[i].outsourcedOrderDetailProcessList[j].technologyVersion,
-			technologicalProcessDetailId:selection[i].outsourcedOrderDetailProcessList[j].technologicalProcessDetailId,
-			processId:selection[i].outsourcedOrderDetailProcessList[j].processId,
-			processAlias:selection[i].outsourcedOrderDetailProcessList[j].processAlias,
-			processCode:selection[i].outsourcedOrderDetailProcessList[j].processCode,
-			processStepNumber:selection[i].outsourcedOrderDetailProcessList[j].processStepNumber
-			}
-		    form.value.details.push(newDetail)
-		}
-		}
-	}
+  for (let i = 0; i < selection.length; i++) {
+    for (
+      let j = 0;
+      j < selection[i].outsourcedOrderDetailProcessList.length;
+      j++
+    ) {
+      //存进数据库的内容
+      const newDetail = {
+        outsourceDetailId: selection[i].id,
+        productDescription: selection[i].productDescription,
+        lotCode: selection[i].lotCode,
+        lotId: selection[i].lotId,
+        dayworkId: selection[i].dayworkId,
+        productId: selection[i].productId,
+        productNum: selection[i].productNum,
+        receiptNum:
+          selection[i].outsourcedOrderDetailProcessList[j].qualifiedNum,
+        originalCarrier: selection[i].originalCarrier,
+        originalCarrierCount: selection[i].originalCarrierCount,
+        newCarrier: selection[i].newCarrier,
+        newCarrierCount: selection[i].newCarrierCount,
+        processNames: selection[i].processNames,
+        remark: "",
+        technologicalProcessId:
+          selection[i].outsourcedOrderDetailProcessList[j]
+            .technologicalProcessId,
+        technologyVersion:
+          selection[i].outsourcedOrderDetailProcessList[j].technologyVersion,
+        technologicalProcessDetailId:
+          selection[i].outsourcedOrderDetailProcessList[j]
+            .technologicalProcessDetailId,
+        processId: selection[i].outsourcedOrderDetailProcessList[j].processId,
+        processAlias:
+          selection[i].outsourcedOrderDetailProcessList[j].processAlias,
+        processCode:
+          selection[i].outsourcedOrderDetailProcessList[j].processCode,
+        processStepNumber:
+          selection[i].outsourcedOrderDetailProcessList[j].processStepNumber,
+      };
+      form.value.detailInfo.push(newDetail);
+    }
+    //页面显示内容,一个批次一行
+    const detail = {
+      outsourceDetailId: selection[i].id,
+      productDescription: selection[i].productDescription,
+      lotCode: selection[i].lotCode,
+      productNum: selection[i].productNum,
+      receiptNum:
+        selection[i].outsourcedOrderDetailProcessList[
+          selection[i].outsourcedOrderDetailProcessList.length - 1
+        ].qualifiedNum,
+      newCarrier: selection[i].newCarrier,
+      remark: "",
+      processAlias: selection[i].processNames,
+    };
+    form.value.details.push(detail);
+  }
+};
 
 /** 提交按钮 */
 function submitForm() {
-	proxy.$refs['formRef'].validate((valid) => {
-		if (valid) {
-			if(isSubmitting.value) {
-				return
-			}
-			isSubmitting.value = true
-			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('修改成功')
-					isSubmitting.value = false;
-					visible.value = false
-					emit('handleSaveSuccess')
-				})
-			} else {
-				addReceipt(form.value).then((response) => {
-					proxy.$modal.msgSuccess('新增成功')
-					isSubmitting.value = false;
-					visible.value = false
-					emit('handleSaveSuccess')
-				})
-			}
-			}
-		}
-	})
+  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) {
+        form.value.isSubmit = 1;
+        handleChangeRemark();
+        if (form.value.id != null) {
+          updateReceipt(form.value).then((response) => {
+            proxy.$modal.msgSuccess("修改成功");
+            visible.value = false;
+            emit("handleSaveSuccess");
+          });
+        } else {
+          addReceipt(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            emit("handleSaveSuccess");
+          });
+        }
+      }
+    }
+  });
+}
+/** 保存按钮 */
+function saveForm() {
+  proxy.$refs["formRef"].validate((valid) => {
+    if (valid) {
+      var flag = true;
+      if (form.value.details.length == 0) {
+        flag = false;
+        proxy.$modal.msgError("收回明细不能为空");
+      }
+      if (flag) {
+        form.value.isSubmit = 0;
+        handleChangeRemark();
+        if (form.value.id != null) {
+          updateReceipt(form.value).then((response) => {
+            proxy.$modal.msgSuccess("修改成功");
+            visible.value = false;
+            emit("handleSaveSuccess");
+          });
+        } else {
+          addReceipt(form.value).then((response) => {
+            proxy.$modal.msgSuccess("保存成功");
+            visible.value = false;
+            emit("handleSaveSuccess");
+          });
+        }
+      }
+    }
+  });
+}
+//添加备注
+function handleChangeRemark() {
+  for (let i = 0; i < form.value.details.length; i++) {
+    form.value.detailInfo.forEach((element) => {
+      if (form.value.details[i].lotCode == element.lotCode) {
+        element.remark = form.value.details[i].remark;
+      }
+    });
+  }
+}
+//取消提交
+function handleCancelSubmit() {
+	proxy.$refs["formRef"].validate((valid) => {
+    if (valid) {
+      var flag = true;
+      if (form.value.details.length == 0) {
+        flag = false;
+        proxy.$modal.msgError("收回明细不能为空");
+      }
+      if (flag) {
+        form.value.isSubmit = 0;
+        handleChangeRemark();
+        if (form.value.id != null) {
+          updateReceipt(form.value).then((response) => {
+            proxy.$modal.msgSuccess("修改成功");
+            visible.value = false;
+            emit("handleSaveSuccess");
+          });
+        }
+      }
+    }
+  });
+}
+//删除收回明细
+function handleDeletedDetails(row) {
+	//前端同时操作form.value的两个集合
+	form.value.details.splice(form.value.details.indexOf(row), 1);
+	var index = []
+	for(let i = 0;i<form.value.detailInfo.length;i++) {
+		if(form.value.detailInfo[i].lotCode == row.lotCode){
+			index.push(i)
+		}	
+	}
+	for (let i = index.length - 1; i >= 0; i--) {
+  form.value.detailInfo.splice(index[i], 1);
+}
 }
 
 /** 暴露给父组件的方法 */
 defineExpose({
-	open
-})
+  open,
+});
 </script>

+ 44 - 13
src/views/business/returnReceipt/index.vue

@@ -65,6 +65,14 @@
       >
         打印
       </el-button>
+      <el-button
+        type="warning"
+        icon="Download"
+        :disabled="ids.length != 1"
+        @click="handleExport"
+      >
+        导出
+      </el-button>
     </div>
     <!-- 渲染数据区 -->
     <div class="el-table-container">
@@ -103,7 +111,7 @@
           >
             <template #default="scope">
               <el-button
-                v-if="scope.row"
+                v-if="scope.row.isAudit == 1"
                 link
                 type="primary"
                 icon="View"
@@ -145,13 +153,13 @@ import {
   listReceipt,
   delReceipt,
   printReturnReceipt,
+  exportReturn
 } from "@/api/business/returnReceipt";
 import receiptForm from "./form";
 const { proxy } = getCurrentInstance();
 
 const dataList = ref([]);
 const loading = ref(true);
-const multiple = ref(false);
 const ids = ref([]);
 const total = ref(0);
 /** 查询对象 */
@@ -201,14 +209,34 @@ function handleSelectionChange(selection) {
 }
 /** 修改按钮操作 */
 function handleShowFormDialog(row) {
-  if (row && row.status == 1) {
+  if (row !=null &&row.isAudit == 1) {
     row.editStatus = false;
   }
   proxy.$refs.receiptRef.open(row ? row : null);
 }
+/** 导出按钮操作 */
+function handleExport() {
+  exportReturn({ id: ids.value[0] });
+}
 /** 删除按钮操作 */
 function handleDelete() {
   const _ids = ids.value;
+  let tempList = []
+  let flag = true;
+  for(let i = 0;i<ids.value.length;i++) {
+    for(let j =0;j<dataList.value.length;j++) {
+      if(dataList.value[j].id == ids.value[i]) {
+        tempList.push(dataList.value[j])
+      }
+    }
+  }
+  tempList.forEach(item => {
+    if(item.isAudit == 1) {
+      flag = false;
+    }
+  })
+  console.log(tempList)
+  if(flag) {
   proxy.$modal
     .confirm("是否确认删除选中的数据项?")
     .then(function () {
@@ -219,6 +247,9 @@ function handleDelete() {
       proxy.$modal.msgSuccess("删除成功!");
     })
     .catch(() => {});
+}else{
+  proxy.$modal.msgError("所选的数据项包含已确认的收回单,不能删除!");
+}
 }
 
 /** 打印按钮操作 */
@@ -226,15 +257,15 @@ function handlePrint() {
   printReturnReceipt({ id: ids.value[0] });
 }
 
-/** 导出按钮操作 */
-function handleExport() {
-  proxy.download(
-    "business/returnReceipt/export",
-    {
-      ...queryParams.value,
-    },
-    `order_${new Date().getTime()}.xlsx`
-  );
-}
+// /** 导出按钮操作 */
+// function handleExport() {
+//   proxy.download(
+//     "business/returnReceipt/export",
+//     {
+//       ...queryParams.value,
+//     },
+//     `order_${new Date().getTime()}.xlsx`
+//   );
+// }
 getList();
 </script>