| | |
| | | :show-selection="true" |
| | | :border="true" |
| | | :maxHeight="440" |
| | | /> |
| | | <pagination |
| | | /> <pagination |
| | | v-if="total>0" |
| | | :page-num="pageNum" |
| | | :page-size="pageSize" |
| | | :page="pageNum" |
| | | :limit="pageSize" |
| | | :total="total" |
| | | @pagination="handleQuery" |
| | | @pagination="handlePagination" |
| | | :layout="'total, prev, pager, next, jumper'" |
| | | /> |
| | | </el-card> |
| | | <ProductionDialog |
| | | v-if="total>0" |
| | | </el-card> <ProductionDialog |
| | | v-model:dialogFormVisible="dialogFormVisible" |
| | | :form="form" |
| | | :title="title" |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, onMounted } from "vue"; |
| | | import { ref, reactive, onMounted, getCurrentInstance } 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 ProductionDialog from "./components/ProductionDialog.vue"; |
| | | import ProductionDialog from './components/ProductionDialog.vue'; |
| | | import { purchaseRegistration } from "@/api/procureMent"; |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const form = ref({}); |
| | | const title = ref(""); |
| | |
| | | supplierName: "", |
| | | identifyNumber: "", |
| | | address: "", |
| | | |
| | | pageNum: 1, |
| | | pageSize: 10 |
| | | }); |
| | | // 是否编辑 |
| | | const addOrEdit = ref("add"); |
| | |
| | | const handleQuery = () => { |
| | | loading.value = true; |
| | | // 这里添加实际的查询逻辑 |
| | | setTimeout(() => { |
| | | loading.value = false; |
| | | }, 500); |
| | | getList(); |
| | | }; |
| | | |
| | | // 分页处理 |
| | | const handlePagination = (val) => { |
| | | console.log("分页参数:", val); |
| | | pageNum.value = val.page; |
| | | pageSize.value = val.limit; |
| | | queryParams.pageNum = val.page; |
| | | queryParams.pageSize = val.limit; |
| | | getList(); |
| | | }; |
| | | |
| | | // supplier 供应商数据 |
| | | const columns = ref([ |
| | | { prop: "supplierName", label: "供应商名称", minWidth: 200 }, |
| | | { prop: "category", label: "煤种", minWidth: 120 }, |
| | | { prop: "unit", label: "单位", minWidth: 150 }, |
| | | { prop: "purchaseAmount", label: "采购数量", minWidth: 120 }, |
| | | { prop: "priceBeforeTax", label: "单价(税前)", minWidth: 150 }, |
| | | { prop: "totalBeforeTax", label: "总价(税前)", minWidth: 100 }, |
| | | { prop: "calorificValue", label: "热值", minWidth: 150 }, |
| | | { prop: "registrant", label: "登记人", minWidth: 100 }, |
| | | { prop: "coal", label: "煤种类型", minWidth: 120 }, |
| | | { prop: "purchaseQuantity", label: "采购数量", minWidth: 100 }, |
| | | { prop: "priceIncludingTax", label: "单价(含税)", minWidth: 150 }, |
| | | { prop: "totalPriceIncludingTax", label: "总价(含税)", minWidth: 100 }, |
| | | { prop: "taxRate", label: "税率", minWidth: 100 }, |
| | | { prop: "priceExcludingTax", label: "不含税单价", minWidth: 100 }, |
| | | { prop: "registrantId", label: "登记人", minWidth: 100 }, |
| | | { prop: "registrationDate", label: "登记日期", minWidth: 100 }, |
| | | ]); |
| | | |
| | |
| | | }; |
| | | // 新增 |
| | | const handleAdd = () => { |
| | | console.log("点击新增按钮"); |
| | | addOrEdit.value = "add"; |
| | | handleAddEdit(); |
| | | }; |
| | |
| | | // 打开弹窗 |
| | | const openDialog = () => { |
| | | if (addOrEdit.value === "edit") { |
| | | // 确保复制一份数据,避免直接引用 |
| | | form.value = JSON.parse(JSON.stringify(form.value)); |
| | | dialogFormVisible.value = true; |
| | | return; |
| | | } |
| | | form.value = {}; |
| | | dialogFormVisible.value = true; |
| | | // 新建时初始化表单 |
| | | form.value = { |
| | | supplierName: "", |
| | | category: "", |
| | | unit: "", |
| | | purchaseAmount: "", |
| | | priceBeforeTax: "", |
| | | totalBeforeTax: "", |
| | | calorificValue: "", |
| | | registrant: "", |
| | | registrationDate: new Date().toISOString().split('T')[0] |
| | | }; dialogFormVisible.value = true; |
| | | console.log("openDialog 设置 dialogFormVisible =", dialogFormVisible.value); |
| | | }; |
| | | |
| | | // 提交表单 |
| | |
| | | total.value = tableData.value.length; |
| | | ElMessage.success("操作成功"); |
| | | }; |
| | | const getList = () => { |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | setTimeout(() => { |
| | | tableData.value = [ |
| | | { |
| | | supplierName: "中国石油化工股份有限公司", |
| | | category: "煤", |
| | | unit: "吨", |
| | | purchaseAmount: "1000", |
| | | priceBeforeTax: "100", |
| | | totalBeforeTax: "100000", |
| | | calorificValue: "5000", |
| | | registrant: "张三", |
| | | registrationDate: "2025-01-01", |
| | | }, |
| | | { |
| | | supplierName: "中国中石化", |
| | | category: "精品煤", |
| | | unit: "千克", |
| | | purchaseAmount: "1000", |
| | | priceBeforeTax: "100", |
| | | totalBeforeTax: "100000", |
| | | calorificValue: "5000", |
| | | registrant: "李四", |
| | | registrationDate: "2025-01-01", |
| | | } |
| | | ] |
| | | total.value = tableData.value.length; |
| | | try { |
| | | // 传递分页参数 |
| | | let res = await purchaseRegistration({ |
| | | pageNum: pageNum.value, |
| | | pageSize: pageSize.value, |
| | | ...queryParams |
| | | }); |
| | | console.log("API返回数据:", res); |
| | | if (res && res.data) { |
| | | tableData.value = res.data.records || []; |
| | | total.value = res.data.total || 0; |
| | | } |
| | | } catch (error) { |
| | | console.error("获取数据失败:", error); |
| | | ElMessage.error("获取数据失败"); |
| | | } finally { |
| | | loading.value = false; |
| | | }, 500); |
| | | } |
| | | }; |
| | | getList(); |
| | | </script> |