浏览代码

收回单前端

ezhizao 1 年之前
父节点
当前提交
4c6bcd5996

+ 3 - 3
src/api/business/outsourcedOrderDetail.js

@@ -20,10 +20,10 @@ export function getDetail(id) {
 }
 
 // 获取已完成的外协单从表
-export function listDetailForReceipt(data) {
+export function listDetailForReceipt(query) {
 	return request({
 		url: baseUrl + '/business/outsourceDetail/listDetailForReceipt',
-		method: 'post',
-		data: data
+		method: 'get',
+		params: query
 	})
 }

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

@@ -2,7 +2,7 @@ import request from '@/utils/request'
 
 const baseUrl = import.meta.env.VITE_APP_BASE_API
 
-// 查询外协
+// 查询收回
 export function listReceipt(query) {
 	return request({
 		url: baseUrl + '/business/returnReceipt/list',
@@ -11,10 +11,36 @@ export function listReceipt(query) {
 	})
 }
 
-// 查询外协
+// 查询收回
 export function getReceipt(id) {
 	return request({
 		url: baseUrl + '/business/returnReceipt/' + id,
 		method: 'get'
 	})
 }
+
+// 新增收回单
+export function addReceipt(data) {
+	return request({
+		url: baseUrl + '/business/outsource',
+		method: 'post',
+		data: data
+	})
+}
+
+// 修改收回单
+export function updateReceipt(data) {
+	return request({
+		url: baseUrl + '/business/outsource',
+		method: 'put',
+		data: data
+	})
+}
+
+// 删除收回单
+export function delReceipt(id) {
+	return request({
+		url: baseUrl + '/business/returnReceipt/' + id,
+		method: 'delete'
+	})
+}

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

@@ -1,6 +1,6 @@
 <template>
 	<el-dialog
-		title="添加外协明细"
+		title="添加收回明细"
 		v-model="visible"
 		width="800px"
 		height="400px"
@@ -20,19 +20,6 @@
 					@keyup.enter="handleSearch"
 				/>
 			</el-form-item>
-			<el-form-item
-				v-if="supplierId !== '' && supplierId !== '0'"
-				label="只看外协商配置的产品:"
-				prop="isSupplierProducts"
-			>
-				<el-switch
-					v-model="queryParams.isSupplierProducts"
-					active-text="是"
-					:active-value="1"
-					inactive-text="否"
-					:inactive-value="0"
-				/>
-			</el-form-item>
 			<el-form-item label-width="20px">
 				<el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
 			</el-form-item>
@@ -40,7 +27,7 @@
 
 		<el-table
 			ref="dialogTable"
-			:data="productList"
+			:data="dataList"
 			size="small"
 			v-loading="loading"
 			border
@@ -84,15 +71,11 @@ const props = defineProps({
 })
 
 const { multipleSelected } = toRefs(props)
-const productList = ref([])
+const dataList = ref([])
 const visible = ref(false)
 const loading = ref(false)
 const queryParams = ref({
-	existingDayworkIds: [],
-	deptCode: '170000',
-	// 是否看所有产品【0:看全部产品,1:只看该外协商配置的产品】
-	isSupplierProducts: 0,
-	supplierId: '',
+	existingOutsourceDetailIds: [],
 	productDescription: '',
 	pageNum: 1,
 	pageSize: 10
@@ -102,9 +85,9 @@ const selections = ref([])
 /**
  * 对话框打开 事件
  */
-function open(existingDayworkIds) {
+function open(existingOutsourceDetailIds) {
 	visible.value = true
-	queryParams.value.existingDayworkIds = existingDayworkIds
+	queryParams.value.existingOutsourceDetailIds = existingOutsourceDetailIds
 	getList()
 }
 
@@ -123,9 +106,8 @@ function close() {
  */
 function getList() {
 	loading.value = true
-	queryParams.value.supplierId = props.supplierId
-	listForOutsource(queryParams.value).then((res) => {
-		productList.value = res.rows
+	listDetailForReceipt(queryParams.value).then((res) => {
+		dataList.value = res.rows
 		total.value = res.total
 		loading.value = false
 	})

+ 64 - 28
src/views/business/returnReceipt/form.vue

@@ -6,6 +6,17 @@
 					<el-icon><Document /></el-icon>
 					<span>收回单信息</span>
 				</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-group>
+
 				<div class="close-btn" @click="cancel">
 					<i class="fa fa-times" aria-hidden="true" />
 					<!-- <span>关闭</span> -->
@@ -39,14 +50,7 @@
 			</el-form>
 			<!-- 渲染数据区 -->
 			<div class="form-details-btns-container">
-				<el-button
-					type="primary"
-					icon="Plus"
-					@click="handleShowDialogOutSourceDetails"
-					v-hasPermi="['business:outsource:add']"
-				>
-					添加收回明细
-				</el-button>
+				<el-button type="primary" icon="Plus" @click="handleShowDialogOutSourceDetails"> 添加收回明细 </el-button>
 			</div>
 			<div class="el-table-container">
 				<div class="el-table-inner-container">
@@ -54,6 +58,7 @@
 						<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="form.packagingMethod === '0' ? '箱号' : '原箱号'"
 							align="center"
@@ -64,16 +69,25 @@
 							v-if="form.packagingMethod === '1'"
 							label="新箱号"
 							align="center"
-							prop="new_carrier"
+							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 v-model="scope.row.receiptNum" controls-position="right" />
+								<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="remark">
+							<template #default="scope">
+								<el-input v-model="scope.row.remark" />
 							</template>
 						</el-table-column>
-						<el-table-column label="备注" align="center" prop="remark" />
 					</el-table>
 				</div>
 			</div>
@@ -87,25 +101,30 @@
 	</el-drawer>
 </template>
 <script setup>
-import { getReceipt } from '@/api/business/returnReceipt'
+import { getReceipt, addReceipt, updateReceipt } from '@/api/business/returnReceipt'
 import dialogOutsourceDetails from './DialogOutsourceDetails'
 const { proxy } = getCurrentInstance()
 /** 表单抽屉 页变量 */
 const loading = ref(false)
 const visible = ref(false)
+const editStatus = ref(false)
 const webHost = import.meta.env.VITE_APP_BASE_API
 const form = ref({})
 
-/***********************  方法区  ****************************/
+/****************************  方法区  ****************************/
 /** 打开抽屉 */
 const open = (id) => {
 	reset()
-	loading.value = true
 	visible.value = true
-	getReceipt(id).then((response) => {
-		form.value = response.data
-		loading.value = false
-	})
+	if (id) {
+		loading.value = true
+		getReceipt(id).then((response) => {
+			form.value = response.data
+			loading.value = false
+		})
+	} else {
+		editStatus.value = true
+	}
 }
 
 /** 取消按钮 */
@@ -118,7 +137,6 @@ const cancel = () => {
 const reset = () => {
 	form.value = {
 		id: null,
-		tenantId: '0',
 		formCode: '',
 		formDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
 		supplierId: '0',
@@ -131,27 +149,45 @@ const reset = () => {
 /***************************** 外协明细对话框相关 *****************************/
 // 打开外协明细选择对话框
 const handleShowDialogOutSourceDetails = () => {
-	const dayworkIds = form.value.details.map((item) => item.dayworkId)
-	proxy.$refs.dialogProductsRef.open(dayworkIds)
+	const outsourceDetailIds = form.value.details.map((item) => item.outsourceDetailId)
+	proxy.$refs.dialogOutsourceDetailsRef.open(outsourceDetailIds)
 }
 // 外协明细选择带回
 const handleMultipleSelectedOutsourceDetails = (selection) => {
 	selection.forEach((item) => {
 		const newDetail = {
-			lotId: item.lotId,
-			lotCode: item.lotCode,
-			dayworkId: item.id,
-			productId: item.productId,
+			outsourceDetailId: item.id,
 			productDescription: item.productDescription,
-			productNum: 0,
+			productNum: item.productNum,
 			receiptNum: 0,
-			processNames: '',
-			remark: item.remark
+			processNames: item.processNames,
+			remark: ''
 		}
 		form.value.details.push(newDetail)
 	})
 }
 
+/** 提交按钮 */
+function submitForm() {
+	proxy.$refs['formRef'].validate((valid) => {
+		if (valid) {
+			if (form.value.id != null) {
+				updateReceipt(form.value).then((response) => {
+					proxy.$modal.msgSuccess('修改成功')
+					visible.value = false
+					getList.value()
+				})
+			} else {
+				addReceipt(form.value).then((response) => {
+					proxy.$modal.msgSuccess('新增成功')
+					visible.value = false
+					getList.value()
+				})
+			}
+		}
+	})
+}
+
 /** 暴露给父组件的方法 */
 defineExpose({
 	open

+ 21 - 1
src/views/business/returnReceipt/index.vue

@@ -36,6 +36,11 @@
 			</el-form-item>
 		</el-form>
 
+		<!-- 功能按钮区 -->
+		<div class="list-btns-container">
+			<el-button type="primary" icon="Plus" @click="handleShowFormDialog(null)"> 新增 </el-button>
+			<el-button type="danger" icon="Delete" :disabled="multiple" @click="handleDelete"> 删除 </el-button>
+		</div>
 		<!-- 渲染数据区 -->
 		<div class="el-table-container">
 			<div class="el-table-inner-container">
@@ -78,6 +83,7 @@ const { proxy } = getCurrentInstance()
 
 const dataList = ref([])
 const loading = ref(true)
+const multiple = ref(false)
 const ids = ref([])
 const total = ref(0)
 /** 查询对象 */
@@ -115,7 +121,21 @@ function resetQuery() {
 
 /** 修改按钮操作 */
 function handleShowFormDialog(row) {
-	proxy.$refs.receiptRef.open(row.id)
+	proxy.$refs.receiptRef.open(row ? row.id : null)
+}
+/** 删除按钮操作 */
+function handleDelete(row) {
+	const _ids = row.id || ids.value
+	proxy.$modal
+		.confirm('是否确认删除选中的数据项?')
+		.then(function () {
+			return delOrder(_ids)
+		})
+		.then(() => {
+			getList()
+			proxy.$modal.msgSuccess('删除成功!')
+		})
+		.catch(() => {})
 }
 
 /** 导出按钮操作 */