<!DOCTYPE html>
|
<html lang="en">
|
|
<head>
|
<meta charset="utf-8">
|
<title></title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../static/evn/index.css">
|
<style>
|
.text-center {
|
text-align: center;
|
}
|
.text-gray-500 {
|
width: 100%;
|
color: #6b7280;
|
}
|
</style>
|
</head>
|
|
<body>
|
<div id="app">
|
<el-card>
|
<el-form :inline="true" label-width="auto">
|
<el-form-item label="开工日期">
|
|
<div>
|
<el-date-picker
|
v-model="tableSearchParam.dateStart"
|
type="date"
|
placeholder="开始日期"
|
style="width: 150px;"
|
:default-time="defaultTime"
|
/>
|
</div>
|
<div style="margin-left: 5px;margin-right: 5px">
|
<span >-</span>
|
</div>
|
<div>
|
<el-date-picker
|
v-model="tableSearchParam.dateEnd"
|
type="date"
|
placeholder="结束日期"
|
style="width: 150px;"
|
:default-time="defaultTime"
|
/>
|
</div>
|
</el-form-item>
|
|
|
<el-form-item label="供应商">
|
<el-select v-model="tableSearchParam.venId" placeholder="选择供应商" style="width: 150px" >
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="">
|
<el-button type="primary" @click="page" circle >
|
<el-icon><Search /></el-icon>
|
</el-button>
|
</el-form-item>
|
</el-form>
|
<el-form :inline="true">
|
<el-form-item label="">
|
<el-button type="primary" @click="export1">导出</el-button>
|
</el-form-item>
|
<el-form-item label="">
|
<el-button type="primary" @click="export2">导出1</el-button>
|
</el-form-item>
|
|
|
</el-form>
|
<el-table :data="tableData" border style="width: 100%" row-key="id" @selection-change="handleSelectionChange" max-height="300">
|
<el-table-column type="selection" >
|
</el-table-column>
|
<el-table-column type="index" width="50" >
|
</el-table-column>
|
<el-table-column prop="venCode" label="加工商编码" >
|
</el-table-column>
|
<el-table-column prop="invCode" label="加工商名称">
|
</el-table-column>
|
<el-table-column prop="invCode" label="产品编码" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invName" label="产品名称" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invStd" label="产品规格" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invUnit" label="单位" width="90">
|
</el-table-column>
|
<el-table-column prop="fqty" label="数量">
|
</el-table-column>
|
<el-table-column prop="fdate" label="入库日期">
|
</el-table-column>
|
<el-table-column prop="tranType" label="类型">
|
</el-table-column>
|
<el-table-column prop="orderCode" label="生产单号">
|
</el-table-column>
|
<el-table-column prop="gramWeight" label="克重">
|
</el-table-column>
|
<el-table-column prop="totalWeight" label="重量">
|
</el-table-column>
|
</el-table>
|
|
<div style="margin-top: 10px"></div>
|
<el-table :data="otherData" border style="width: 100%" row-key="id" @selection-change="handleSelectionChange" max-height="300" show-summary :summary-method="getSummaries">
|
<el-table-column type="selection" >
|
</el-table-column>
|
<el-table-column type="index" width="50" >
|
</el-table-column>
|
<el-table-column prop="venCode" label="加工商编码" >
|
</el-table-column>
|
<el-table-column prop="invCode" label="加工商名称">
|
</el-table-column>
|
<el-table-column prop="invCode" label="产品编码" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invName" label="产品名称" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invStd" label="产品规格" :show-overflow-tooltip="true">
|
</el-table-column>
|
<el-table-column prop="invUnit" label="单位" width="90">
|
</el-table-column>
|
<el-table-column prop="qqty" label="期初数量">
|
</el-table-column>
|
<el-table-column prop="fqty" label="发出数量">
|
</el-table-column>
|
<el-table-column prop="hqty" label="理论数量">
|
</el-table-column>
|
<el-table-column prop="jqty" label="结存数量">
|
</el-table-column>
|
</el-table>
|
|
</el-card>
|
</div>
|
|
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
|
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
|
<script src="../../static/evn/vue.global.js"></script>
|
<script src="../../static/evn/element-plus.js"></script>
|
<script src="../../static/evn/icons-vue.js"></script>
|
<script src='../../static/js/erp/LodopFuncs.js'></script>
|
<script type="module">
|
// 导入中文语言包
|
import zhCn from '../../static/js/erp/zh-cn.js';
|
|
const { createApp, ref, onMounted, onBeforeMount ,watchEffect} = Vue;
|
|
|
const app = createApp({
|
setup() {
|
const currentPage = ref(1)
|
const pageSizes = ref([15,20, 30, 50, 100, 200])
|
const pageSize = ref(15)
|
const pageTotal = ref(0)
|
const tableSearchParam = ref({
|
izJb:"否",
|
dateStart:new Date(),
|
dateEnd: new Date(),
|
venId:null,
|
izJs:"否"
|
})
|
const tableSearchParamDialog = ref({
|
dateStart:new Date(),
|
dateEnd: new Date(),
|
izSync: null
|
})
|
const tableData = ref([])
|
const otherData = ref([])
|
const tableDataDialog = ref([])
|
const defaultTime = ref(new Date())
|
const fullscreenLoading = ref(false)
|
|
const selectData = ref([
|
])
|
|
const depName = ref('')
|
|
const options = ref([])
|
|
const dialogVisible = ref(false)
|
|
watchEffect(() =>{
|
options.value.map(item =>{
|
if (item.value === tableSearchParam.value.venId){
|
depName.value = item.label
|
}
|
})
|
|
})
|
|
const printOptions = [
|
{
|
value: '否',
|
label: '否'
|
},
|
{
|
value: '是',
|
label: '是'
|
},
|
|
]
|
|
const selectList = ref([])
|
|
function page(){
|
let data = JSON.parse(JSON.stringify(tableSearchParam.value))
|
data.curr = currentPage.value
|
data.limit = pageSize.value
|
if (tableSearchParam.value.datetime != null) {
|
data.datetime = null
|
data.create_time = tableSearchParam.value.datetime[0] + " - " + tableSearchParam.value.datetime[1]
|
}
|
const loading = ElementPlus.ElLoading.service({
|
lock: true,
|
text: 'Loading',
|
background: 'rgba(0, 0, 0, 0.7)',
|
})
|
$.ajax({
|
url: "http://127.0.0.1:9090/mo/wwreport/getList",
|
data: data,
|
dataType: 'json',
|
contentType: 'application/json;charset=UTF-8',
|
method: 'GET',
|
success: function(res) {
|
loading.close()
|
if (res.code == 200) {
|
tableData.value = res.data
|
otherData.value = res.other
|
ElementPlus.ElMessage({
|
message: "拉取数据完成",
|
type: 'success'
|
});
|
} else if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
} else {
|
ElementPlus.ElMessage({
|
message: res.msg,
|
type: 'error'
|
});
|
}
|
}
|
});
|
}
|
|
function export1(){
|
ElementPlus.ElMessageBox.confirm('确定导出吗?')
|
.then(() => {
|
const loading = ElementPlus.ElLoading.service({
|
lock: true,
|
text: 'Loading',
|
background: 'rgba(0, 0, 0, 0.7)',
|
})
|
$.ajax({
|
url: "http://127.0.0.1:9090/mo/wwreport/export",
|
data: JSON.stringify({
|
data: JSON.stringify(tableData.value),
|
datas: JSON.stringify(otherData.value)
|
}),
|
contentType: 'application/json;charset=UTF-8',
|
method: 'POST',
|
xhrFields: {
|
responseType: 'blob' // 重要:指定响应类型
|
},
|
success: function(data, status, xhr) {
|
// 获取文件名
|
let fileName = '委外加工材料对账表.xls';
|
const contentDisposition = xhr.getResponseHeader('Content-Disposition');
|
if (contentDisposition) {
|
const fileNameMatch = contentDisposition.match(/filename="?(.+)"?/);
|
if (fileNameMatch && fileNameMatch[1]) {
|
fileName = fileNameMatch[1];
|
}
|
}
|
|
// 创建 Blob 对象并下载
|
const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
|
const url = window.URL.createObjectURL(blob);
|
const link = document.createElement('a');
|
link.href = url;
|
link.download = fileName;
|
document.body.appendChild(link);
|
link.click();
|
document.body.removeChild(link);
|
window.URL.revokeObjectURL(url);
|
|
ElementPlus.ElMessage({
|
message: "导出成功",
|
type: 'success'
|
});
|
},
|
error: function(xhr, status, error) {
|
console.error('导出失败:', error);
|
ElementPlus.ElMessage({
|
message: "导出失败",
|
type: 'error'
|
});
|
},
|
complete: function (xhr, status){
|
loading.close()
|
}
|
});
|
})
|
.catch(() => {
|
// catch error
|
})
|
|
|
}
|
|
function export2(){
|
if (tableSearchParam.value.venId == "" || tableSearchParam.value.venId == null){
|
ElementPlus.ElMessage({
|
message: "请选择供应商",
|
type: 'warning'
|
});
|
return ;
|
}
|
let data = JSON.parse(JSON.stringify(tableSearchParam.value))
|
ElementPlus.ElMessageBox.confirm('确定导出吗?')
|
.then(() => {
|
const loading = ElementPlus.ElLoading.service({
|
lock: true,
|
text: 'Loading',
|
background: 'rgba(0, 0, 0, 0.7)',
|
})
|
$.ajax({
|
url: "http://127.0.0.1:9090/mo/wwreport/export1",
|
data: data,
|
contentType: 'application/json;charset=UTF-8',
|
method: 'GET',
|
xhrFields: {
|
responseType: 'blob' // 重要:指定响应类型
|
},
|
success: function(data, status, xhr) {
|
// 获取文件名
|
let fileName = '委外加工材料对账表.xls';
|
const contentDisposition = xhr.getResponseHeader('Content-Disposition');
|
if (contentDisposition) {
|
const fileNameMatch = contentDisposition.match(/filename="?(.+)"?/);
|
if (fileNameMatch && fileNameMatch[1]) {
|
fileName = fileNameMatch[1];
|
}
|
}
|
|
// 创建 Blob 对象并下载
|
const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
|
const url = window.URL.createObjectURL(blob);
|
const link = document.createElement('a');
|
link.href = url;
|
link.download = fileName;
|
document.body.appendChild(link);
|
link.click();
|
document.body.removeChild(link);
|
window.URL.revokeObjectURL(url);
|
|
ElementPlus.ElMessage({
|
message: "导出成功",
|
type: 'success'
|
});
|
},
|
error: function(xhr, status, error) {
|
console.error('导出失败:', error);
|
ElementPlus.ElMessage({
|
message: "导出失败",
|
type: 'error'
|
});
|
},
|
complete: function (xhr, status){
|
loading.close()
|
}
|
});
|
})
|
.catch(() => {
|
// catch error
|
})
|
|
|
|
}
|
|
function getSummaries({ columns, data }) {
|
const sumFields = ['qqty', 'fqty', 'hqty', 'jqty'];
|
const sums = new Array(columns.length).fill('');
|
|
// 将“合计”文本放到第一个非汇总且有 property 的列,避免选择/序号列
|
const labelIndex = columns.findIndex(
|
(col) => col.property && !sumFields.includes(col.property)
|
);
|
if (labelIndex !== -1) {
|
sums[labelIndex] = '合计';
|
}
|
|
columns.forEach((column, index) => {
|
const prop = column.property;
|
if (prop && sumFields.includes(prop)) {
|
const total = data.reduce((acc, row) => {
|
const n = Number(row[prop]);
|
return acc + (isNaN(n) ? 0 : n);
|
}, 0);
|
sums[index] = total;
|
}
|
});
|
|
return sums;
|
}
|
|
|
|
function handleSizeChange(val) {
|
pageSize.value = val
|
currentPage.value = 1 // 重置到第一页
|
page()
|
}
|
|
function handleCurrentChange(val) {
|
currentPage.value = val
|
page()
|
}
|
function handleSelectionChange(val) {
|
selectList.value = val
|
}
|
function handleSelectionChangeDialog(val) {
|
selectList.value = val
|
}
|
function getVendor(){
|
$.ajax({
|
url: "http://127.0.0.1:9090/basicinfo/vendor/getlistfordropdown",
|
contentType: 'application/json;charset=UTF-8',
|
method: 'GET',
|
success: function(res) {
|
if (res.code == 200) {
|
res.data.map(item => {
|
options.value.push({
|
value: item.venId, label: item.venName
|
})
|
})
|
} else {
|
ElementPlus.ElMessage({
|
message: res.msg,
|
type: 'error'
|
});
|
}
|
}
|
});
|
}
|
|
onMounted(() => {
|
page()
|
})
|
|
onBeforeMount(() => {
|
getVendor()
|
|
})
|
|
return {
|
tableData,
|
tableDataDialog,
|
currentPage,
|
pageSizes,
|
pageSize,
|
pageTotal,
|
tableSearchParam,
|
tableSearchParamDialog,
|
defaultTime,
|
selectData,
|
options,
|
printOptions,
|
dialogVisible,
|
otherData,
|
page,
|
export1,
|
export2,
|
getSummaries,
|
handleSizeChange,
|
handleCurrentChange,
|
handleSelectionChange,
|
handleSelectionChangeDialog
|
|
}
|
}
|
});
|
|
app.use(ElementPlus, {
|
locale: zhCn.default || zhCn
|
});
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
app.component(key, component)
|
}
|
app.mount('#app');
|
</script>
|
|
</body>
|
|
</html>
|