|
<template>
|
<div class="page-list-container">
|
<!--数据Table-->
|
<yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
|
<template slot="common-column-slot" slot-scope="{row, col}">
|
<template v-if="col.prop=='statusText'">
|
<template>
|
<el-tag v-if="row[col.prop]=='取消入库'" color="#ff00cc" style="color:white;border:0">
|
{{ row[col.prop] }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop]=='确认入库'" color="#5353ff" style="color:white;border:0">
|
{{ row[col.prop] }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop]=='部分上架'" color="#cc66ff" style="color:white;border:0">
|
{{ row[col.prop] }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop]=='完全上架'" color="#00ccff" style="color:white;border:0">
|
{{ row[col.prop] }}
|
</el-tag>
|
<el-tag v-else color="#ffff99" style="color:#888;">
|
{{ row[col.prop] }}
|
</el-tag>
|
</template>
|
</template>
|
<!--连接字段-->
|
<template v-else-if="col.prop==dataOptions.linkColumn">
|
<el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
|
</template>
|
<template v-else>
|
<template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
|
{{ common.formatDate(row[col.prop], col.formatter) }}
|
</template>
|
<template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
|
{{ common.formatNumber(row[col.prop], col.formatter) }}
|
</template>
|
<template v-else>
|
{{ row[col.prop] }}
|
</template>
|
</template>
|
</template>
|
</yrt-data-list>
|
|
<!--数据编辑器Editor-->
|
<yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :edit-button-click="editButtonClick" :on-save-before="onSaveBefore" @on-change="onChange" @on-detail-change="onDetailChange" @on-row-change="onRowChange">
|
<!--自定义按钮插槽-->
|
<template slot="footer-button-region" slot-scope="{ formData }">
|
<!--自定义审核按钮-->
|
<!-- <el-button type="success" icon="el-icon-yrt-qiyong" @click.native="onConfirm(formData)">审核</el-button> -->
|
</template>
|
</yrt-editor>
|
<!-- class="import-dialog-container" -->
|
<el-dialog v-dialogDrag :visible.sync="dialogImport" width="600px" class="box-card">
|
<el-form>
|
<el-upload ref="upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill">
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitImport()">开始导入</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="primary" plain>
|
<a :href="common.ossDomain+'/node-wms/template/其他入库导入模板.xlsx'" style="color:while;font-size:12px;">下载模板</a>
|
</el-button>
|
<div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
|
</el-upload>
|
</el-form>
|
<el-scrollbar ref="scrollbar" :noresize="false" :native="false" wrap-class="scrollbar-wrap">
|
<ul class="msg-container">
|
<li v-for="(item, index) in msgList" :key="index" class="msg-item" v-html="item">
|
{{ index + 1 }}、{{ item }}
|
</li>
|
</ul>
|
</el-scrollbar>
|
<div ref="loading"></div>
|
</el-dialog>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @on-selected="onSelected"></yrt-selector>
|
<!--其他入库单导入-->
|
<!-- <enter-import ref="enterimport-dialog" :visible.sync="enterimportVisible"></enter-import> -->
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
// import enterImport from "./components/enter-import.vue";
|
export default {
|
name: "storage-operation-enter",
|
components: {
|
yrtSelector
|
// enterImport
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 弹出导入框
|
dialogImport: false,
|
fileList: [],
|
// 消息内容
|
msgList: [],
|
// 导入获得消息interval handle
|
intervalHandler: null,
|
// 文件名
|
fileUrl: null,
|
// 导入key
|
uploadKey: null,
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 导入页面是否显示
|
enterimportVisible: false
|
};
|
},
|
mounted() {
|
this.uploadKey = this.common.getGUID();
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "batchConfirm":
|
// 批量审核
|
this.onConfirm(this.dataListSelections);
|
return false;
|
case "import":
|
// 导入
|
this.import();
|
return false;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "detailAdd":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
return true;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.onConfirm([formData]);
|
return false;
|
}
|
},
|
// 审核
|
onConfirm(formData) {
|
let isok = true;
|
const enter_Ids = formData.map((item, index, Array) => {
|
return item.enter_Id;
|
});
|
const statusTexts = formData.map((item, index, Array) => {
|
return item.statusText;
|
});
|
statusTexts.forEach(rowData => {
|
if (rowData !== "新建") return (isok = false);
|
});
|
if (isok === false) {
|
this.$message.error("只有新建货单,可以审核!");
|
return false;
|
}
|
if (!enter_Ids.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
// var detailRows = formData["Storage_EnterList"].rows;
|
// detailRows.forEach(item => {
|
// if (item.positionName === null) {
|
// isHave = false;
|
// return;
|
// }
|
// });
|
// if (isHave === false) {
|
// this.$message({
|
// message: "明细货位名称不能为空!",
|
// type: "warning"
|
// });
|
// return;
|
// }
|
this.$confirm("确定要进行审核操作吗?", "审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
const url = "/api/storage/enter/singleConfirm";
|
const params = {
|
openNodeApi: true,
|
enter_Ids: enter_Ids
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.editor.config.visible = false;
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
handleRemove(file, fileList) {
|
this.fileUrl = null;
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fileUrl = res.data.url;
|
},
|
// 导入
|
import() {
|
// this.enterimportVisible = true;
|
this.dialogImport = true;
|
this.msg = "";
|
},
|
// 导入
|
submitImport() {
|
if (!this.fileUrl) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
this.msgList = [];
|
const url = "/api/storage/enter/importExcel";
|
const params = {
|
url: this.fileUrl,
|
key: this.uploadKey
|
};
|
var callback = res => {
|
if (res.result) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
this.getMsg();
|
this.fileList = [];
|
this.fileUrl = null;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 获得导入消息
|
getMsg() {
|
// 获得同步消息
|
const url = "/api/common/getUploadMsg";
|
const params = {
|
openNodeApi: true,
|
key: this.uploadKey
|
};
|
// const ref = this.dataList;
|
var callBack = res => {
|
// 自动滚动到最后一行
|
window.setTimeout(() => {
|
const div = this.$refs.scrollbar.$refs.wrap;
|
div.scrollTop = div.scrollHeight + 1000;
|
}, 1500);
|
if (!res.result) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data);
|
}
|
return;
|
}
|
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data.filter(item => item !== "-1"));
|
}
|
if (res.data.indexOf("-1") >= 0) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = null;
|
this.dataList.reload();
|
return;
|
}
|
this.intervalHandler = window.setTimeout(this.getMsg, 1000);
|
};
|
this.common.ajax(url, params, callBack, this.$refs.loading);
|
},
|
// 主表数据改变
|
onChange(ref, val, field, formData) {},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
this.setTotal();
|
},
|
// 保存前事件
|
onSaveBefore(formData) {
|
return this.setTotal();
|
},
|
// 求和
|
setTotal() {
|
let hasQty = true; // 预出库数量
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_EnterList"].rows;
|
var totalQuantity = 0;
|
var totalWeight = 0;
|
var totalMoney = 0;
|
detailRows.forEach(item => {
|
item.purchaseMoney = Math.Round(item.quantity * item.purchasePrice);
|
item.totalWeight = Math.Round(item.quantity * item.weight);
|
if (item.quantity <= 0 || !item.quantity || !item.positionName) {
|
hasQty = false;
|
}
|
if (!item.totalWeight) {
|
item.totalWeight = 0;
|
}
|
totalQuantity += item.quantity;
|
totalWeight += item.totalWeight;
|
totalMoney += item.purchaseMoney;
|
});
|
|
if (!hasQty) {
|
this.$message({
|
message: "明细列表的数量必须大于0,且货位名称不能空!",
|
type: "warning"
|
});
|
return false;
|
}
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("totalWeight", totalWeight);
|
this.editor.changeValue("totalMoney", Math.Round(totalMoney));
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if (statusText === "确认入库") {
|
// 确认入库
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else {
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}
|
},
|
// 表格下拉框字段改变事件
|
onRowChange(ref, val, field) {
|
// 货主和仓库改变
|
if (["consignorName", "storageName"].indexOf(field.options.prop) >= 0) {
|
window.setTimeout(() => {
|
this.getDefaultItems();
|
}, 200);
|
}
|
},
|
// 获取一次性收费项默认值
|
getDefaultItems() {
|
const formData = this.editor.formData;
|
if (formData.feeItem_Ids && this.editorOptions.config.action !== "add") return; // 已经有值了不在设置默认值
|
|
const url = "/api/finance/baseOneCharge/getDefaultItems";
|
const params = {
|
associatedTasks: "出库单",
|
consignor_Id: formData.consignor_Id,
|
storage_Id: formData.storage_Id
|
};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.$set(formData, "feeItem_Ids", res.data);
|
}
|
});
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.box-card {
|
.upload-bill {
|
width: 480px;
|
.el-upload__tip {
|
margin-top: 20px;
|
}
|
}
|
/deep/ .scrollbar-wrap {
|
max-height: 400px !important;
|
margin-top: 10px;
|
font-size: 14px;
|
.msg-container {
|
margin: 0;
|
padding: 0;
|
.msg-item {
|
margin: 0;
|
padding: 5px 0;
|
word-wrap: break-word;
|
}
|
}
|
}
|
}
|
|
.import-dialog-container {
|
.msg-container {
|
margin: 0;
|
padding: 0;
|
.msg-item {
|
margin: 0;
|
padding: 5px 0;
|
word-wrap: break-word;
|
}
|
}
|
}
|
|
.tip {
|
padding: 8px 16px;
|
background-color: #ecf8ff;
|
border-radius: 4px;
|
border-left: 5px solid #50bfff;
|
margin: 5px 0;
|
}
|
.dialog-info {
|
overflow: hidden;
|
width: 100%;
|
}
|
.dialog-left {
|
float: left;
|
width: 45%;
|
}
|
.dialog-right {
|
margin-left: 30px;
|
float: left;
|
width: 45%;
|
}
|
.deleteRule-span {
|
cursor: pointer;
|
}
|
.page-list-container {
|
min-height: calc(100vh - 110px);
|
overflow: hidden;
|
position: relative;
|
}
|
|
@media screen and (max-height: 900px) {
|
.page-list-container {
|
min-height: 600px;
|
}
|
}
|
</style>
|