<template>
|
<!-- 面包屑导航区 -->
|
<div class="indexs">
|
<el-card>
|
<!-- 搜索与添加 clearable "toggleSelection([tableData[1], tableData[2]])" -->
|
<el-row>
|
<el-button type="success" plain @click="exportExcel" >导出Excel</el-button>
|
<el-button type="info" plain @click="addMaterial" >新建物料</el-button>
|
<el-input v-model="searchParam" placeholder="物料名称/物料编号" class="searchParamClass"></el-input>
|
<el-button type="success" plain @click="find" >查询</el-button>
|
<el-button type="info" plain @click="reset" >重置</el-button>
|
</el-row>
|
<!-- 显示人员列表 -->
|
<el-table ref= "table" :data="TakeStocklist" border stripe show-summary :summary-method="getSummaries" >
|
<el-table-column :reserve-selection="true" type="selection" width="55"> </el-table-column>
|
<el-table-column label="序号" type="index" width="50" > </el-table-column>
|
<el-table-column label="物料id" prop="Product_Id" width="100" v-if="false"></el-table-column>
|
<el-table-column label="物料编号" prop="ProductCode" width="200"></el-table-column>
|
<el-table-column label="物料名称" prop="ProductName" width="450"></el-table-column>
|
<el-table-column label="库存单位" prop="SmallUnit" width="100"></el-table-column>
|
<el-table-column label=" PO单位" prop="BigUnit" width="100"></el-table-column>
|
<el-table-column label="库存预警量" prop="Brand_Id" width="100"></el-table-column>
|
<el-table-column label="创建人" prop="Creator" width="110" ></el-table-column>
|
<el-table-column label="创建时间" prop="CreateDate" width="180" ></el-table-column>
|
<el-table-column label="修改时间" prop="ModifyDate" width="180" ></el-table-column>
|
|
<el-table-column label="操作">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
@click="updataStock(scope.$index, scope.row)">编辑</el-button>
|
<el-button
|
size="mini"
|
type="danger"
|
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination
|
:current-page="queryInfo.pagenum"
|
:page-sizes="[5,10, 15, 20,50,100,1000,5000]"
|
:page-size="queryInfo.pagesize"
|
:total="total"
|
layout="total, sizes, prev, pager, next, jumper"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange">
|
</el-pagination>
|
</el-card>
|
<el-dialog :visible.sync="dialogFormVisible" :title="titleName" width="30%">
|
<el-form :label-width="formLabelWidth" :model="taskForm" :rules="mustRules" ref="taskForm">
|
<el-form-item label="物料编号:" prop="ProductCode">
|
<el-col :span="18">
|
<el-input v-model="taskForm.ProductCode" ></el-input>
|
</el-col>
|
</el-form-item>
|
<el-form-item label="物料名称:" prop="ProductName">
|
<el-col :span="18">
|
<el-input v-model="taskForm.ProductName" ></el-input>
|
</el-col>
|
</el-form-item>
|
<el-form-item label="库存单位:" prop="SmallUnit">
|
<el-col :span="18">
|
<el-input v-model="taskForm.SmallUnit" ></el-input>
|
</el-col>
|
</el-form-item>
|
<el-form-item label=" PO单位:" >
|
<el-col :span="18">
|
<el-input v-model="taskForm.BigUnit"></el-input>
|
</el-col>
|
</el-form-item>
|
<el-form-item label=" 库存预警量:">
|
<el-col :span="18">
|
<el-input v-model="taskForm.Brand_Id" type="number" ></el-input>
|
</el-col>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
<el-button type="primary" @click="updateProductPosition('taskForm')">确 定</el-button>
|
</div>
|
|
</el-dialog>
|
|
</div>
|
</template>
|
<script>
|
import { parseTime } from "@/utils";
|
import Cookies from "js-cookie";
|
import { userInfoCookie, menuListCookie } from "@/utils/auth";
|
import { getDate } from "@/utils/dateTime";
|
export default {
|
data() {
|
return {
|
queryInfo: {
|
// 当前页
|
pagenum: 1,
|
// 每页显示多少条信息s
|
pagesize: 5
|
},
|
titleName: "",
|
TakeStocklist: [],
|
TakeStocklistAll: [],
|
total: 0,
|
MaterialOperationValue: 0,
|
OperationValue: 0,
|
dialogFormVisible: false,
|
productList: [],
|
updateDate: null,
|
searchParam: null,
|
taskForm: {
|
Product_Id: null,
|
ProductCode: null,
|
ProductName: null,
|
SmallUnit: null,
|
BigUnit: null,
|
Brand_Id: null,
|
Creator: null
|
},
|
mustRules: {
|
ProductCode: [{ required: true, message: "产品编号不能为空", trigger: "blur" }],
|
ProductName: [{ required: true, message: "产品名称不能为空", trigger: "blur" }],
|
SmallUnit: [{ required: true, message: "库存单位不能为空", trigger: "blur" }]
|
}
|
};
|
},
|
created() {},
|
mounted() {
|
this.find();
|
},
|
methods: {
|
// 监听 pagesize 改变
|
handleSizeChange(newSizd) {
|
this.queryInfo.pagesize = newSizd;
|
this.queryInfo.pagenum = 1;
|
this.find();
|
},
|
// 监听 页码值改变
|
handleCurrentChange(newpage) {
|
this.queryInfo.pagenum = newpage;
|
this.find();
|
},
|
//excel 导出数据
|
exportExcel() {
|
// import("@/vendor/Export2Excel")
|
this.downloadLoading = true;
|
import("@/vendor/Export2Excel").then(excel => {
|
const tHeader = ["物料id", "物料编号", "物料名称", "库存单位", "PO单位", "库存预警量", "创建人", "创建时间", "修改时间"];
|
const filterVal = ["Product_Id", "ProductCode", "ProductName", "SmallUnit", "Brand_Id", "BigUnit", "Creator", "CreateDate", "ModifyDate"];
|
debugger;
|
const data = this.formatJson(filterVal, this.TakeStocklistAll);
|
excel.export_json_to_excel({
|
header: tHeader,
|
data,
|
filename: "物料明细"
|
});
|
this.downloadLoading = false;
|
});
|
},
|
formatJson(filterVal, jsonData) {
|
return jsonData.map(v =>
|
filterVal.map(j => {
|
if (j === "timestamp") {
|
return parseTime(v[j]);
|
} else {
|
return v[j];
|
}
|
})
|
);
|
},
|
find() {
|
const url = "/api/task/findMaterial";
|
const params = {
|
searchParam: this.searchParam,
|
queryInfo: this.queryInfo
|
};
|
//MaterialOperation
|
var callback = res => {
|
debugger;
|
if (res.result === true) {
|
res.data.forEach(item => {
|
item.CreateDate = getDate(item.CreateDate);
|
item.ModifyDate = getDate(item.ModifyDate);
|
});
|
|
this.TakeStocklist = res.data;
|
this.TakeStocklistAll = res.data;
|
this.total = res.countPrint;
|
} else {
|
this.TakeStocklist = [];
|
this.TakeStocklistAll = [];
|
this.total = 0;
|
if (res.msg == "服务端错误:undefined") {
|
return this.$message.error("请打开后台服务");
|
} else {
|
return this.$message.success("当前条件 查不到数据!");
|
}
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
//表格增加汇总数量
|
getSummaries(param) {
|
const { columns, data } = param;
|
const sums = [];
|
columns.forEach((column, index) => {
|
if (index === 0) {
|
sums[index] = "合计";
|
return;
|
}
|
if (index != 11) {
|
sums[index] = "";
|
return;
|
}
|
const values = data.map(item => Number(item[column.property]));
|
if (!values.every(value => isNaN(value))) {
|
sums[index] = values.reduce((prev, curr) => {
|
const value = Number(curr);
|
if (!isNaN(value)) {
|
return prev + curr;
|
} else {
|
return prev;
|
}
|
}, 0);
|
sums[index] += " ";
|
} else {
|
sums[index] = "N/A";
|
}
|
});
|
|
return sums;
|
},
|
|
//删除库存
|
handleDelete(index, row) {
|
debugger;
|
const url = "/api/task/MaterialOperation";
|
this.taskForm.Creator = userInfoCookie.getUserInfo().userTrueName;
|
const params = {
|
taskForm: row,
|
OperationValue: 3
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
if (res.result) {
|
this.find();
|
return this.$message.success(res.msg);
|
} else {
|
this.find();
|
return this.$message.error(res.msg);
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
},
|
//向修改页面内赋值
|
updataStock(index, row) {
|
this.taskForm = row;
|
this.titleName = "修改物料";
|
this.MaterialOperationValue = 2;
|
this.dialogFormVisible = true;
|
},
|
//向修改页面内赋值
|
addMaterial() {
|
this.titleName = "新建物料";
|
this.MaterialOperationValue = 1;
|
this.dialogFormVisible = true;
|
},
|
//复位
|
reset() {
|
this.searchParam = "";
|
this.MaterialOperationValue = 0;
|
this.find();
|
},
|
|
// 物料新增修改删除操作
|
updateProductPosition(formName) {
|
this.$refs[formName].validate(valid => {
|
debugger;
|
if (valid) {
|
const url = "/api/task/MaterialOperation";
|
if (this.MaterialOperationValue === 1) {
|
this.taskForm.Creator = userInfoCookie.getUserInfo().userTrueName;
|
}
|
const params = {
|
taskForm: this.taskForm,
|
OperationValue: this.MaterialOperationValue
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
if (res.result) {
|
this.dialogFormVisible = false;
|
this.find();
|
return this.$message.success(res.msg);
|
} else {
|
this.dialogFormVisible = false;
|
this.find();
|
return this.$message.error(res.msg);
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
} else {
|
console.log("error submit!!");
|
return false;
|
}
|
});
|
}
|
}
|
};
|
</script>
|
<style lang="postcss" scoped>
|
.el-table .el-pagination {
|
margin-top: 10px;
|
line-height: 30px;
|
margin-bottom: 0%;
|
}
|
.el-row {
|
text-align: left;
|
}
|
.searchParamClass {
|
width: 380px;
|
}
|
.positionTypevalue {
|
width: 150px;
|
}
|
.el-card {
|
padding: 0%;
|
margin-bottom: 0%;
|
}
|
thead .el-table-column--selection .cell {
|
display: none;
|
}
|
.displayneed {
|
//display: none;
|
|
display: inline-block;
|
width: 180px;
|
}
|
</style>
|