<template>
|
<div>
|
<el-form :inline="true" :model="queryParams" class="search-form">
|
<el-form-item label="供应商名称">
|
<el-input v-model="queryParams.searchAll" placeholder="请输入关键词" clearable />
|
</el-form-item>
|
|
<el-form-item>
|
<el-button type="primary" @click="getList">查询</el-button>
|
<el-button @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
<el-card>
|
<!-- 标签页 -->
|
<el-tabs v-model="activeTab" class="info-tabs" @tab-click="handleTabClick">
|
<el-tab-pane v-for="tab in tabs" :key="tab.name" :label="tab.label" :name="tab.name" />
|
</el-tabs>
|
|
<!-- 操作按钮区 -->
|
<el-row :gutter="24" class="table-toolbar">
|
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
|
<el-button type="danger" :icon="Delete" @click="handleDelete">删除</el-button>
|
<el-button type="info" :icon="Download" @click="handleExport">导出</el-button>
|
</el-row>
|
<!-- 表格组件 -->
|
<div>
|
<data-table :loading="loading" :table-data="tableData" :columns="columns"
|
@selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true" />
|
</div> <pagination v-if="total>0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination"
|
:layout="'total, prev, pager, next, jumper'" />
|
<Supplier v-if="tabName === 'supplier'" v-model:supplierDialogFormVisible="dialogFormVisible" :form="form"
|
:title="title" @submit="handleSubmit" @beforeClose="handleBeforeClose"
|
@update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" />
|
<Customer v-if="tabName === 'customer'" v-model:customerDialogFormVisible="dialogFormVisible" :form="form"
|
:title="title" @submit="handleSubmit" :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" />
|
<Coal v-if="tabName === 'coal'" v-model:coalDialogFormVisible="dialogFormVisible" :form="form" :title="title"
|
:addOrEdit="addOrEdit" @submit="handleSubmit" />
|
<coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'"
|
v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" :form="form" :title="title"
|
:addOrEdit="addOrEdit" @submit="handleSubmit" />
|
</el-card>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, reactive, onMounted } from "vue";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
import { Plus, Edit, Delete, Download } from "@element-plus/icons-vue";
|
import DataTable from "@/components/Table/ETable.vue";
|
import Pagination from "@/components/Pagination";
|
import Supplier from "./mould/supplier.vue";
|
import Customer from "./mould/customer.vue";
|
import Coal from "./mould/coal.vue";
|
import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue";
|
const { proxy } = getCurrentInstance()
|
import { getSupply, addOrEditSupply, delSupply } from "@/api/basicInformation/supplier.js";
|
import { getCoalInfo, addOrEditCoalInfo } from "@/api/basicInformation/coal.js";
|
import { getCoalQuality, addOrEditCoalQuality } from "@/api/basicInformation/coalQualityMaintenance.js";
|
// 弹窗
|
const coalQualityMaintenanceDialogFormVisible = ref(false);
|
const customerDialogFormVisible = ref(false);
|
const coalDialogFormVisible = ref(false);
|
const supplierDialogFormVisible = ref(false);
|
const dialogFormVisible = ref(false);
|
const form = ref({});
|
const title = ref("");
|
const copyForm = ref({});
|
// 当前标签
|
const tabName = ref("supplier");
|
// 状态变量
|
const loading = ref(false);
|
const total = ref(0);
|
const pageNum = ref(1);
|
const pageSizes = ref(10);
|
const activeTab = ref("supplier");
|
const selectedRows = ref([]);
|
// 查询参数
|
const queryParams = reactive({
|
searchText: "",
|
supplierName: "",
|
identifyNumber: "",
|
address: "",
|
});
|
onMounted(() => {
|
handleTabClick({ props: { name: "supplier" } });
|
});
|
const columns = ref();
|
// 标签页数据
|
const tabs = reactive([
|
{ name: "supplier", label: "供应商信息" },
|
{ name: "customer", label: "客户信息" },
|
{ name: "coal", label: "煤种信息" },
|
{ name: "coalQualityMaintenance", label: "煤质维护" },
|
]);
|
// 是否编辑
|
const addOrEdit = ref("add");
|
// 表格数据
|
const tableData = ref([]);
|
// 查询方法
|
const handleQuery = () => {
|
|
};
|
// supplier 供应商数据
|
const supplierColumns = ref([
|
{ prop: "supplierName", label: "供应商名称", minWidth: 200 },
|
{ prop: "taxpayerId", label: "统一人识别号", minWidth: 120 },
|
{ prop: "businessAddress", label: "经营地址", minWidth: 150 },
|
{ prop: "bids", label: "详细地址", minWidth: 150 },
|
{ prop: "bankAccount", label: "开户行", minWidth: 120 },
|
{ prop: "bankName", label: "银行账号", minWidth: 150 },
|
{ prop: "contactPerson", label: "联系人", minWidth: 100 },
|
{ prop: "contactAddress", label: "联系地址", minWidth: 150 },
|
{ prop: "maintainer", label: "维护人", minWidth: 100 },
|
{ prop: "createTime", label: "维护日期", minWidth: 100 },
|
]);
|
// customer 客户数据
|
const customerColumns = ref([
|
{ prop: "customerName", label: "客户名称", minWidth: 200 },
|
{ prop: "identifyNumber", label: "统一人识别号", minWidth: 120 },
|
{ prop: "address", label: "经营地址", minWidth: 150 },
|
{ prop: "detailedaddress", label: "详细地址", minWidth: 150 },
|
{ prop: "bank", label: "开户行", minWidth: 120 },
|
{ prop: "bankAccount", label: "银行账号", minWidth: 150 },
|
{ prop: "contacts", label: "联系人", minWidth: 100 },
|
{ prop: "contactAddress", label: "联系地址", minWidth: 150 },
|
{ prop: "maintainer", label: "维护人", minWidth: 100 },
|
{ prop: "maintainDate", label: "维护日期", minWidth: 100 },
|
]);
|
// coal 煤种数据
|
const coalColumns = ref([
|
{ prop: "coalName", label: "煤种名称", minWidth: 200 },
|
{ prop: "maintainerId", label: "维护人", minWidth: 120 },
|
{ prop: "maintenanceDate", label: "维护日期", minWidth: 150 },
|
]);
|
// coalQualityMaintenance 煤质维护数据
|
const coalQualityMaintenanceColumns = ref([
|
{ prop: "supplierName", label: "全水(<)", minWidth: 200 },
|
{ prop: "identifyNumber", label: "水分析(<)", minWidth: 120 },
|
{ prop: "address", label: "灰分", minWidth: 150 },
|
{ prop: "bank", label: "挥发(>)", minWidth: 100 },
|
{ prop: "bankAccount", label: "硫(<)", minWidth: 100 },
|
{ prop: "contacts", label: "固定碳", minWidth: 100 },
|
{ prop: "contactAddress", label: "高位发热量", minWidth: 100 },
|
{ prop: "maintainer", label: "低位发热量", minWidth: 100 },
|
]);
|
// 标签页点击
|
const handleTabClick = (tab) => {
|
form.value = {};
|
addOrEdit.value = "add";
|
loading.value = true;
|
tabName.value = tab.props.name;
|
tableData.value = [];
|
switch (tabName.value) {
|
case "supplier":
|
columns.value = supplierColumns.value;
|
dialogFormVisible.value = supplierDialogFormVisible.value;
|
getList("supplier");
|
break;
|
case "customer":
|
columns.value = customerColumns.value;
|
dialogFormVisible.value = customerDialogFormVisible.value;
|
getList("customer");
|
|
break;
|
case "coal":
|
columns.value = coalColumns.value;
|
dialogFormVisible.value = coalDialogFormVisible.value;
|
getList("coal");
|
break;
|
case "coalQualityMaintenance":
|
columns.value = coalQualityMaintenanceColumns.value;
|
dialogFormVisible.value = coalQualityMaintenanceDialogFormVisible.value;
|
getList("coalQualityMaintenance");
|
break;
|
}
|
};
|
// 重置查询
|
const resetQuery = () => {
|
Object.keys(queryParams).forEach((key) => {
|
if (key !== "pageNum" && key !== "pageSizes") {
|
queryParams[key] = "";
|
}
|
});
|
};
|
// 新增
|
const handleAdd = () => {
|
addOrEdit.value = "add";
|
handleAddEdit(tabName.value);
|
};
|
// 新增编辑
|
const handleAddEdit = (tabName) => {
|
addOrEdit.value == "add" ? title.value = "新增" : title.value = "编辑";
|
if (tabName === "supplier") {
|
dialogFormVisible.value = true;
|
title.value = title.value + "供应商信息";
|
openDialog();
|
} else if (tabName === "customer") {
|
dialogFormVisible.value = true;
|
title.value = title.value + "客户信息";
|
openDialog();
|
} else if (tabName === "coal") {
|
dialogFormVisible.value = true;
|
title.value = title.value + "煤种信息";
|
openDialog();
|
} else if (tabName === "coalQualityMaintenance") {
|
dialogFormVisible.value = true;
|
title.value = title.value + "煤质维护";
|
openDialog();
|
}
|
};
|
// 打开弹窗
|
const openDialog = () => {
|
if (addOrEdit.value === "edit") {
|
copyForm.value = JSON.parse(JSON.stringify(form.value));
|
dialogFormVisible.value = true;
|
return;
|
}
|
form.value = {};
|
dialogFormVisible.value = true;
|
};
|
// 分页
|
const handPagination = (val) => {
|
console.log("分页参数:", val);
|
pageNum.value = val.page;
|
pageSizes.value = val.limit;
|
getList();
|
};
|
// 提交表单
|
const handleSubmit = async (val) => {
|
console.log(val)
|
if (val.code !== 200) {
|
ElMessage.error("操作失败:" + result.msg);
|
return;
|
}
|
ElMessage.success("新增成功:" + result.msg);
|
dialogFormVisible.value = false;
|
};
|
const handleDialogFormVisible = (value) => {
|
dialogFormVisible.value = value;
|
};
|
// 选择行
|
const handleSelectionChange = (selection) => {
|
selectedRows.value = selection;
|
};
|
// 编辑
|
const handleEdit = (row) => {
|
form.value = JSON.parse(JSON.stringify(row));
|
addOrEdit.value = "edit";
|
handleAddEdit(tabName.value);
|
};
|
// 批量删除
|
const handleDelete = () => {
|
if (selectedRows.value.length === 0) {
|
ElMessage.warning("请选择要删除的数据");
|
return;
|
}
|
let arr = reactive([]);
|
selectedRows.value.forEach(element => {
|
return arr.push(element.id);
|
});
|
console.log("选中的数据ID:", arr);
|
ElMessageBox.confirm("确定删除选中的数据吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(async () => {
|
try {
|
let res = await delSupply(arr)
|
console.log(res)
|
selectedRows.value = [];
|
getlist()
|
} catch {
|
ElMessage.error("删除失败,请稍后再试");
|
return;
|
}
|
}).catch(() => {
|
ElMessage.info("已取消删除操作");
|
});
|
}
|
// 关闭弹窗
|
const handleBeforeClose = () => {
|
dialogFormVisible.value = false;
|
form.value = {};
|
};
|
const handleExport = (row) => {
|
proxy.download("system/post/export", {
|
...queryParams.value
|
}, `post_${new Date().getTime()}.xlsx`)
|
ElMessage.success("导出数据:" + row.supplierName);
|
};
|
// 选择接口
|
const selectInterface = () => {
|
if (tabName.value === "supplier") {
|
return getSupply({
|
current: pageNum.value,
|
pageSize: pageSizes.value,
|
searchAll: queryParams.searchAll,
|
});
|
} else if (tabName.value === "customer") {
|
return getSupply({
|
current: pageNum.value,
|
pageSize: pageSizes.value,
|
...queryParams
|
});
|
} else if (tabName.value === "coal") {
|
console.log(addOrEdit.value)
|
return getCoalInfo();
|
} else if (tabName.value === "coalQualityMaintenance") {
|
return getCoalQuality({
|
current: pageNum.value,
|
pageSize: pageSizes.value,
|
...queryParams
|
});
|
}
|
}
|
const getList = async () => {
|
loading.value = true;
|
let { data, code } = await selectInterface()
|
console.log(data)
|
tableData.value = data.records;
|
total.value = data.total;
|
loading.value = false;
|
};
|
</script>
|
|
<style scoped>
|
/* 响应式布局 */
|
@media screen and (min-width: 768px) {
|
.search-form :deep(.el-form-item) {
|
width: 50%;
|
}
|
}
|
|
@media screen and (min-width: 1200px) {
|
.search-form :deep(.el-form-item) {
|
width: 16%;
|
}
|
}
|
|
.table-toolbar {
|
margin-bottom: 20px;
|
display: flex;
|
flex-wrap: wrap;
|
gap: 10px;
|
}
|
|
/* 响应式表格 */
|
@media screen and (max-width: 768px) {
|
.table-toolbar {
|
flex-direction: column;
|
}
|
|
.table-toolbar .el-button {
|
width: 100%;
|
}
|
}
|
|
/* 表格工具栏 */
|
.table-toolbar,
|
.table-toolbar>* {
|
margin: 0 0 0 0 !important;
|
}
|
|
.table-toolbar {
|
margin-bottom: 20px !important;
|
}
|
|
.el-form--inline .el-form-item {
|
margin-right: 25px;
|
}
|
|
.main-container {
|
background: red !important;
|
}
|
</style>
|