add
This commit is contained in:
@ -4,6 +4,16 @@
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<!-- 新增:搜索表单字段(可选,支持按新字段搜索) -->
|
||||
<el-form-item label="供应商名称" prop="supplierName">
|
||||
<el-input v-model="queryParams.supplierName" placeholder="请输入供应商名称" maxlength="50" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商负责人" prop="supplierPerson">
|
||||
<el-input v-model="queryParams.supplierPerson" placeholder="请输入负责人" maxlength="20" />
|
||||
</el-form-item>
|
||||
<el-form-item label="负责人电话" prop="personPhone">
|
||||
<el-input v-model="queryParams.personPhone" placeholder="请输入负责人电话" maxlength="11" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
@ -42,11 +52,26 @@
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<!-- 表格:新增3个字段列 -->
|
||||
<el-table v-loading="loading" :data="supplierInputList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="供应商类型" align="center" prop="supplierType" />
|
||||
<el-table-column label="入库资料" align="center" prop="inputFile" />
|
||||
|
||||
<el-table-column label="供应商名称" align="center" prop="supplierName" width="180" />
|
||||
<el-table-column label="供应商负责人" align="center" prop="supplierPerson" width="150" />
|
||||
<el-table-column label="负责人电话" align="center" prop="personPhone" width="150" />
|
||||
<el-table-column label="供应商类型" align="center" prop="supplierType" width="150" />
|
||||
<el-table-column label="状态" align="center" prop="state" width="150">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="wf_business_status" :value="scope.row.state"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="入库资料" align="center" prop="inputFile" width="200">
|
||||
<template #default="scope">
|
||||
<el-link :href="scope.row.inputFile" :underline="false" target="_blank" v-if="scope.row.inputFile">
|
||||
<el-button size="mini" class="el-icon-document">查看文件</el-button>
|
||||
</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
@ -73,10 +98,19 @@
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改供应商入库对话框 -->
|
||||
|
||||
<!-- 新增/修改对话框:添加3个字段表单 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="supplierInputFormRef" :model="form" :rules="rules" label-width="100px">
|
||||
<!-- 新增的供应商类型下拉框 -->
|
||||
<el-form-item label="供应商名称" prop="supplierName">
|
||||
<el-input v-model="form.supplierName" placeholder="请输入供应商名称" maxlength="50" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商负责人" prop="supplierPerson">
|
||||
<el-input v-model="form.supplierPerson" placeholder="请输入供应商负责人" maxlength="20" />
|
||||
</el-form-item>
|
||||
<el-form-item label="负责人电话" prop="personPhone">
|
||||
<el-input v-model="form.personPhone" placeholder="请输入负责人电话" maxlength="11" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商类型" prop="supplierType">
|
||||
<el-select v-model="form.supplierType" placeholder="请选择供应商类型">
|
||||
<el-option label="劳务" value="劳务"></el-option>
|
||||
@ -84,15 +118,20 @@
|
||||
<el-option label="物资设备" value="物资设备"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="入库资料" prop="inputFile" l>
|
||||
<el-form-item label="入库资料" prop="inputFile">
|
||||
<file-upload
|
||||
v-model="form.inputFile"
|
||||
:fileType="['doc', 'docx', 'pdf']"
|
||||
:fileType="['pdf']"
|
||||
:autoUpload="false"
|
||||
ref="fileUploadRef"
|
||||
:method="form.id ? 'put' : 'post'"
|
||||
:data="{ supplierType: form.supplierType }"
|
||||
:data="{
|
||||
supplierType: form.supplierType,
|
||||
supplierName: form.supplierName,
|
||||
supplierPerson: form.supplierPerson,
|
||||
personPhone: form.personPhone,
|
||||
id: form.id
|
||||
}"
|
||||
uploadUrl="/supplierInput/supplierInput"
|
||||
:limit="1"
|
||||
:onUploadSuccess="handleUploadSuccess"
|
||||
@ -132,6 +171,17 @@
|
||||
import { listSupplierInput, getSupplierInput, delSupplierInput, addSupplierInput, updateSupplierInput } from '@/api/supplierInput/supplierInput';
|
||||
import { SupplierInputVO, SupplierInputQuery, SupplierInputForm } from '@/api/supplierInput/supplierInput/types';
|
||||
|
||||
// 补充类型定义(若types.ts未同步更新,需先在types.ts中添加以下字段)
|
||||
interface DialogOption {
|
||||
visible: boolean;
|
||||
title: string;
|
||||
}
|
||||
interface PageData<F, Q> {
|
||||
form: F;
|
||||
queryParams: Q;
|
||||
rules: Record<string, any[]>;
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const fileUploadRef = ref(null);
|
||||
const supplierInputList = ref<SupplierInputVO[]>([]);
|
||||
@ -150,9 +200,13 @@ const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const { wf_business_status } = toRefs(proxy.useDict('wf_business_status'));
|
||||
// 初始化表单:添加3个新字段
|
||||
const initFormData: SupplierInputForm = {
|
||||
id: undefined,
|
||||
supplierName: undefined, // 新增
|
||||
supplierPerson: undefined, // 新增
|
||||
personPhone: undefined, // 新增
|
||||
supplierType: undefined,
|
||||
inputFile: undefined
|
||||
};
|
||||
@ -162,12 +216,21 @@ const data = reactive<PageData<SupplierInputForm, SupplierInputQuery>>({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
supplierName: undefined, // 新增:搜索参数
|
||||
supplierPerson: undefined, // 新增:搜索参数
|
||||
personPhone: undefined, // 新增:搜索参数
|
||||
supplierType: undefined,
|
||||
inputFile: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
// 添加供应商类型的验证规则
|
||||
// 新增:3个字段的验证规则
|
||||
supplierName: [{ required: true, message: '请输入供应商名称', trigger: 'blur' }],
|
||||
supplierPerson: [{ required: true, message: '请输入供应商负责人', trigger: 'blur' }],
|
||||
personPhone: [
|
||||
{ required: true, message: '请输入负责人电话', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式', trigger: 'blur' }
|
||||
],
|
||||
supplierType: [{ required: true, message: '请选择供应商类型', trigger: 'change' }],
|
||||
id: [{ required: true, message: '不能为空', trigger: 'blur' }]
|
||||
}
|
||||
@ -208,6 +271,8 @@ const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 文件上传成功回调 */
|
||||
const handleUploadSuccess = () => {
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
@ -215,14 +280,16 @@ const handleUploadSuccess = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 文件选择变更回调 */
|
||||
const change = (fileList) => {
|
||||
fileUrl.value = '';
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: SupplierInputVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
single.value = selection.length !== 1;
|
||||
multiple.value = selection.length === 0;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
@ -232,32 +299,42 @@ const handleAdd = () => {
|
||||
dialog.title = '添加供应商入库';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
/** 修改按钮操作:回显3个新字段数据 */
|
||||
const handleUpdate = async (row?: SupplierInputVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getSupplierInput(_id);
|
||||
// Object.assign(form.value, res.data);
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data,
|
||||
inputFile: ''
|
||||
inputFile: '' // 清空文件上传绑定值(保持原有逻辑)
|
||||
};
|
||||
fileUrl.value = res.data.inputFile;
|
||||
// 确保新字段回显(若接口返回字段名一致,可省略此步;若不一致需手动映射)
|
||||
form.value.supplierName = res.data.supplierName;
|
||||
form.value.supplierPerson = res.data.supplierPerson;
|
||||
form.value.personPhone = res.data.personPhone;
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改供应商入库';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
/** 提交按钮:文件上传携带新字段参数 */
|
||||
const submitForm = () => {
|
||||
supplierInputFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
fileUploadRef.value.submitUpload().then(() => {
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
getList();
|
||||
});
|
||||
// 提交文件时携带所有表单参数(含新字段)
|
||||
fileUploadRef.value
|
||||
.submitUpload()
|
||||
.then(() => {
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
buttonLoading.value = false;
|
||||
getList();
|
||||
})
|
||||
.catch(() => {
|
||||
buttonLoading.value = false; // 上传失败重置加载状态
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -265,27 +342,29 @@ const submitForm = () => {
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: SupplierInputVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除供应商入库编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delSupplierInput(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
try {
|
||||
await proxy?.$modal.confirm(`是否确认删除供应商入库编号为"${_ids}"的数据项?`);
|
||||
await delSupplierInput(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
} catch (error) {
|
||||
// 取消删除不处理
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
/** 导出按钮操作:携带新字段搜索参数 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'supplierInput/supplierInput/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`supplierInput_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
proxy?.download('supplierInput/supplierInput/export', { ...queryParams.value }, `supplierInput_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
/** 页面挂载时加载列表 */
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pdf {
|
||||
display: flex;
|
||||
@ -324,6 +403,7 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.Shadow {
|
||||
align-items: center;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
@ -345,6 +425,7 @@ onMounted(() => {
|
||||
.ele-upload-list__item-content-action .el-link {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.el-icon.avatar-uploader-icon {
|
||||
border: 1px dashed #cdd0d6;
|
||||
border-radius: 6px;
|
||||
|
Reference in New Issue
Block a user