<template>
|
<div class="app-container">
|
<div class="search_form">
|
<el-form :model="searchForm" :inline="true">
|
<el-form-item label="流水号:">
|
<el-input v-model="searchForm.serialNo" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" />
|
</el-form-item>
|
<el-form-item label="车号:">
|
<el-input v-model="searchForm.carNo" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" />
|
</el-form-item>
|
<el-form-item label="货名:">
|
<el-input v-model="searchForm.goodsName" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" />
|
</el-form-item>
|
<el-form-item label="收货单位:">
|
<el-input v-model="searchForm.receiveUnit" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" />
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="handleQuery">搜索</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
|
<div class="table_list">
|
<div class="actions">
|
<div />
|
<div>
|
<el-button type="primary" plain @click="openImportDialog">导入</el-button>
|
<el-button type="danger" plain @click="handleDelete">删除</el-button>
|
</div>
|
</div>
|
|
<el-table
|
:data="tableData"
|
border
|
v-loading="tableLoading"
|
@selection-change="handleSelectionChange"
|
:row-key="(row) => row.id"
|
style="width: 100%"
|
height="calc(100vh - 21.5em)"
|
>
|
<el-table-column align="center" type="selection" width="55" />
|
<el-table-column label="流水号" prop="serialNo" show-overflow-tooltip min-width="120" />
|
<el-table-column label="车号" prop="carNo" show-overflow-tooltip min-width="120" />
|
<el-table-column label="发货单位" prop="shipUnit" show-overflow-tooltip min-width="140" />
|
<el-table-column label="收货单位" prop="receiveUnit" show-overflow-tooltip min-width="140" />
|
<el-table-column label="货名" prop="goodsName" show-overflow-tooltip min-width="120" />
|
<el-table-column label="规格" prop="specification" show-overflow-tooltip min-width="120" />
|
<el-table-column label="毛重" prop="grossWeight" show-overflow-tooltip min-width="100" />
|
<el-table-column label="皮重" prop="tareWeight" show-overflow-tooltip min-width="100" />
|
<el-table-column label="净重" prop="netWeight" show-overflow-tooltip min-width="100" />
|
<el-table-column label="一次过磅时间" prop="firstWeighTime" show-overflow-tooltip min-width="180" />
|
<el-table-column label="二次过磅时间" prop="secondWeighTime" show-overflow-tooltip min-width="180" />
|
<el-table-column label="原发" prop="originalSender" show-overflow-tooltip min-width="100" />
|
<el-table-column label="更新人" prop="updateBy" show-overflow-tooltip min-width="120" />
|
</el-table>
|
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
layout="total, sizes, prev, pager, next, jumper"
|
:page="page.current"
|
:limit="page.size"
|
@pagination="paginationChange"
|
/>
|
</div>
|
|
<el-dialog v-model="importUpload.open" :title="importUpload.title" width="500px" append-to-body>
|
<el-upload
|
ref="importUploadRef"
|
drag
|
:limit="1"
|
:action="importUpload.url"
|
:headers="importUpload.headers"
|
:before-upload="importUpload.beforeUpload"
|
:on-success="importUpload.onSuccess"
|
:on-error="importUpload.onError"
|
:auto-upload="false"
|
accept=".xlsx,.xls"
|
>
|
<i class="el-icon-upload"></i>
|
<div class="el-upload__text">
|
将文件拖到此处,或<em>点击上传</em>
|
</div>
|
<template #tip>
|
<div class="el-upload__tip">仅支持 xlsx/xls 文件</div>
|
</template>
|
</el-upload>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button type="primary" :loading="importUpload.isUploading" @click="submitImport">确定</el-button>
|
<el-button @click="importUpload.open = false">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import pagination from "@/components/PIMTable/Pagination.vue";
|
import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
|
import { getToken } from "@/utils/auth";
|
import { weighbridgeLedgerListPage, delWeighbridgeLedger } from "@/api/salesManagement/deliveryLedger.js";
|
|
const { proxy } = getCurrentInstance();
|
|
const tableData = ref([]);
|
const selectedRows = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: 1,
|
size: 100,
|
});
|
const total = ref(0);
|
|
const data = reactive({
|
searchForm: {
|
serialNo: "",
|
carNo: "",
|
goodsName: "",
|
receiveUnit: "",
|
},
|
});
|
const { searchForm } = toRefs(data);
|
|
const importUploadRef = ref(null);
|
const importUpload = reactive({
|
title: "导入台账",
|
open: false,
|
isUploading: false,
|
url: import.meta.env.VITE_APP_BASE_API + "/sales/weighbridgeLedger/import",
|
headers: { Authorization: "Bearer " + getToken() },
|
beforeUpload: (file) => {
|
const isExcel = file.name.endsWith(".xlsx") || file.name.endsWith(".xls");
|
if (!isExcel) {
|
proxy.$modal.msgError("上传文件只能是 xlsx/xls 格式");
|
return false;
|
}
|
return true;
|
},
|
onSuccess: (res) => {
|
importUpload.isUploading = false;
|
if (res?.code === 200) {
|
proxy.$modal.msgSuccess("导入成功");
|
importUpload.open = false;
|
importUploadRef.value?.clearFiles();
|
getList();
|
return;
|
}
|
proxy.$modal.msgError(res?.msg || "导入失败");
|
},
|
onError: () => {
|
importUpload.isUploading = false;
|
proxy.$modal.msgError("导入失败,请重试");
|
},
|
});
|
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
|
const paginationChange = (obj) => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
|
const getList = () => {
|
tableLoading.value = true;
|
weighbridgeLedgerListPage({ ...searchForm.value, ...page })
|
.then((res) => {
|
tableData.value = res?.data?.records || res?.records || [];
|
total.value = res?.data?.total || res?.total || 0;
|
})
|
.finally(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
const handleSelectionChange = (selection) => {
|
selectedRows.value = selection;
|
};
|
|
const handleDelete = () => {
|
if (!selectedRows.value.length) {
|
proxy.$modal.msgWarning("请选择数据");
|
return;
|
}
|
const ids = selectedRows.value.map((item) => item.id);
|
proxy.$modal
|
.confirm("选中的内容将被删除,是否确认?")
|
.then(() => delWeighbridgeLedger(ids))
|
.then(() => {
|
proxy.$modal.msgSuccess("删除成功");
|
getList();
|
})
|
.catch(() => {});
|
};
|
|
const openImportDialog = () => {
|
importUpload.open = true;
|
importUploadRef.value?.clearFiles();
|
};
|
|
const submitImport = () => {
|
if (!importUploadRef.value) return;
|
importUpload.isUploading = true;
|
importUploadRef.value.submit();
|
};
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.table_list {
|
margin-top: unset;
|
}
|
|
.actions {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 10px;
|
}
|
</style>
|