<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form-item label="产品名称" prop="productName">
|
<el-input
|
v-model="queryParams.productName"
|
placeholder="请输入产品名称"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="批次号" prop="batchNumber">
|
<el-input
|
v-model="queryParams.batchNumber"
|
placeholder="请输入批次号"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="退回日期" prop="returnDate">
|
<el-date-picker
|
clearable
|
v-model="queryParams.returnDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择退回日期">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="Plus"
|
@click="handleAdd"
|
>新增</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="Edit"
|
:disabled="single"
|
@click="handleUpdate"
|
>修改</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="Delete"
|
:disabled="multiple"
|
@click="handleDelete"
|
>删除</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="Download"
|
@click="handleExport"
|
>导出</el-button>
|
</el-col>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table v-loading="loading" :data="nearExpiryReturnList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column label="序号" type="index" width="50" align="center" />
|
<el-table-column label="产品名称" prop="productName" />
|
<el-table-column label="产品规格" prop="productSpec" />
|
<el-table-column label="批次号" prop="batchNumber" />
|
<el-table-column label="生产日期" prop="productionDate" align="center">
|
<template #default="scope">
|
<span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d}') }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="到期日期" prop="expiryDate" align="center">
|
<template #default="scope">
|
<span>{{ parseTime(scope.row.expiryDate, '{y}-{m}-{d}') }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="退回数量" prop="returnQuantity" />
|
<el-table-column label="退回原因" prop="returnReason" />
|
<el-table-column label="退回日期" prop="returnDate" align="center">
|
<template #default="scope">
|
<span>{{ parseTime(scope.row.returnDate, '{y}-{m}-{d}') }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="处理状态" prop="status" align="center">
|
<template #default="scope">
|
<dict-tag :options="statusOptions" :value="scope.row.status"/>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template #default="scope">
|
<el-button size="mini" type="text" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
|
<el-button size="mini" type="text" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total>0"
|
:total="total"
|
v-model:page="queryParams.pageNum"
|
v-model:limit="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
|
<!-- 添加或修改临期退回台账对话框 -->
|
<el-dialog :title="title" v-model="open" width="800px" append-to-body>
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="产品名称" prop="productName">
|
<el-input v-model="form.productName" placeholder="请输入产品名称" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="产品规格" prop="productSpec">
|
<el-input v-model="form.productSpec" placeholder="请输入产品规格" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="批次号" prop="batchNumber">
|
<el-input v-model="form.batchNumber" placeholder="请输入批次号" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="退回数量" prop="returnQuantity">
|
<el-input-number v-model="form.returnQuantity" controls-position="right" :min="1" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="生产日期" prop="productionDate">
|
<el-date-picker
|
clearable
|
v-model="form.productionDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择生产日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="到期日期" prop="expiryDate">
|
<el-date-picker
|
clearable
|
v-model="form.expiryDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择到期日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="退回日期" prop="returnDate">
|
<el-date-picker
|
clearable
|
v-model="form.returnDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择退回日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="处理状态" prop="status">
|
<el-select v-model="form.status" placeholder="请选择处理状态">
|
<el-option
|
v-for="dict in statusOptions"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="退回原因" prop="returnReason">
|
<el-input v-model="form.returnReason" type="textarea" placeholder="请输入退回原因" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup name="NearExpiryReturn">
|
import { ref, reactive, onMounted } from "vue";
|
import { ElMessageBox } from "element-plus";
|
// API接口已移除,不再调用后端接口
|
|
const { proxy } = getCurrentInstance();
|
const { parseTime } = proxy;
|
|
const nearExpiryReturnList = ref([]);
|
const open = ref(false);
|
const loading = ref(true);
|
const showSearch = ref(true);
|
const ids = ref([]);
|
const single = ref(true);
|
const multiple = ref(true);
|
const total = ref(0);
|
const title = ref("");
|
|
// 状态字典
|
const statusOptions = ref([
|
{ label: "待处理", value: "0" },
|
{ label: "处理中", value: "1" },
|
{ label: "已完成", value: "2" }
|
]);
|
|
const data = reactive({
|
form: {},
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
productName: null,
|
batchNumber: null,
|
returnDate: null
|
},
|
rules: {
|
productName: [
|
{ required: true, message: "产品名称不能为空", trigger: "blur" }
|
],
|
productSpec: [
|
{ required: true, message: "产品规格不能为空", trigger: "blur" }
|
],
|
batchNumber: [
|
{ required: true, message: "批次号不能为空", trigger: "blur" }
|
],
|
returnQuantity: [
|
{ required: true, message: "退回数量不能为空", trigger: "blur" }
|
],
|
productionDate: [
|
{ required: true, message: "生产日期不能为空", trigger: "blur" }
|
],
|
expiryDate: [
|
{ required: true, message: "到期日期不能为空", trigger: "blur" }
|
],
|
returnDate: [
|
{ required: true, message: "退回日期不能为空", trigger: "blur" }
|
],
|
returnReason: [
|
{ required: true, message: "退回原因不能为空", trigger: "blur" }
|
],
|
status: [
|
{ required: true, message: "处理状态不能为空", trigger: "change" }
|
]
|
}
|
});
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
/** 查询临期退回台账列表 */
|
function getList() {
|
loading.value = true;
|
// 不调用接口,返回空数据
|
nearExpiryReturnList.value = [];
|
total.value = 0;
|
loading.value = false;
|
}
|
|
// 取消按钮
|
function cancel() {
|
open.value = false;
|
reset();
|
}
|
|
// 表单重置
|
function reset() {
|
form.value = {
|
id: null,
|
productName: null,
|
productSpec: null,
|
batchNumber: null,
|
productionDate: null,
|
expiryDate: null,
|
returnQuantity: null,
|
returnReason: null,
|
returnDate: null,
|
status: null,
|
remark: null
|
};
|
proxy.resetForm("formRef");
|
}
|
|
/** 搜索按钮操作 */
|
function handleQuery() {
|
queryParams.value.pageNum = 1;
|
getList();
|
}
|
|
/** 重置按钮操作 */
|
function resetQuery() {
|
proxy.resetForm("queryForm");
|
handleQuery();
|
}
|
|
// 多选框选中数据
|
function handleSelectionChange(selection) {
|
ids.value = selection.map(item => item.id);
|
single.value = selection.length !== 1;
|
multiple.value = !selection.length;
|
}
|
|
/** 新增按钮操作 */
|
function handleAdd() {
|
reset();
|
open.value = true;
|
title.value = "添加临期退回台账";
|
}
|
|
/** 修改按钮操作 */
|
function handleUpdate(row) {
|
reset();
|
// 不调用接口,直接使用传入的数据
|
if (row) {
|
form.value = { ...row };
|
open.value = true;
|
title.value = "修改临期退回台账";
|
}
|
}
|
|
/** 提交按钮 */
|
function submitForm() {
|
proxy.$refs["formRef"].validate(valid => {
|
if (valid) {
|
// 不调用接口,只显示成功提示
|
if (form.value.id != null) {
|
proxy.$modal.msgSuccess("修改成功");
|
} else {
|
proxy.$modal.msgSuccess("新增成功");
|
}
|
open.value = false;
|
getList();
|
}
|
});
|
}
|
|
/** 删除按钮操作 */
|
function handleDelete(row) {
|
const deleteIds = row.id || ids.value;
|
ElMessageBox.confirm('是否确认删除临期退回台账编号为"' + deleteIds + '"的数据项?', "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
}).then(function() {
|
// 不调用接口,只显示成功提示
|
proxy.$modal.msgSuccess("删除成功");
|
getList();
|
}).catch(() => {});
|
}
|
|
/** 导出按钮操作 */
|
function handleExport() {
|
// 不调用接口,只显示提示
|
proxy.$modal.msgSuccess("导出功能暂未实现");
|
}
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|