<template>
|
<div ref="container" 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">
|
</yrt-data-list>
|
|
<!--数据编辑器Editor-->
|
<yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :btn-read-only="btnReadOnly" :auth-nodes="authNodes" :use-detail-slot="['lackStorage']" @on-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange" @on-add-load-after="onEditLoadAfter">
|
<!--自定义按钮插槽-->
|
<template slot="footer-button-region" slot-scope="{ formData, details }">
|
<!--审核按钮-->
|
<el-button :disabled="btnReadOnly.auditingBtn" type="success" icon="el-icon-yrt-pan" @click.native="auditingReplenishment(formData, details)">审核</el-button>
|
<!--分拣按钮-->
|
<el-button :disabled="btnReadOnly.sortingBtn" type="success" icon="el-icon-yrt-pan" @click.native="sortingReplenishment(formData, details)">分拣</el-button>
|
</template>
|
<!--自定义字段插槽-->
|
<template slot="detail-column-slot" slot-scope="{ row, col }">
|
<template v-if="col.prop == 'lackStorage'">
|
<div v-if="row[col.prop]||row[col.prop]==0">{{ row[col.prop] }}</div>
|
<div v-else>
|
<el-button size="mini" round @click="setSortingRule(row)">设置规则</el-button>
|
</div>
|
</template>
|
</template>
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
|
|
<el-dialog :visible.sync="winSortingRuleVisible" title="设置订单明细分拣规则">
|
<div class="dialog-info">
|
<div class="dialog-left">
|
<el-form :model="sortingRuleForm" label-width="150px">
|
<el-form-item label="物料编号">
|
<el-input v-model="sortingRuleForm.productCode" :readonly="true" type="text" placeholder="请输入物料编号"></el-input>
|
</el-form-item>
|
<el-form-item label="拣货货位">
|
<el-input v-model="sortingRuleForm.positionName" type="text" placeholder="请输入出库货位名称"></el-input>
|
</el-form-item>
|
<el-form-item label="批次号">
|
<el-input v-model="sortingRuleForm.batchNumber" type="text" placeholder="请输入批次号"></el-input>
|
</el-form-item>
|
<el-form-item label="生产日期">
|
<el-date-picker v-model="sortingRuleForm.produceDate" type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker>
|
</el-form-item>
|
<el-form-item label="拍号">
|
<el-input v-model="sortingRuleForm.plateCode" type="text" placeholder="请输入拍号"></el-input>
|
</el-form-item>
|
<el-form-item label="唯一码">
|
<el-input v-model="sortingRuleForm.singleSignCode" type="text" placeholder="请输入唯一码"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="submitSortingRuleData()">添加</el-button>
|
<!-- <detail-roleflow :load-options="productPositionDetail" :where="'productCode=' + sortingRuleForm.helpProductCode">
|
<template slot="content">
|
<el-button type="primary">查看库存</el-button>
|
</template>
|
</detail-roleflow> -->
|
</el-form-item>
|
</el-form>
|
</div>
|
<div class="dialog-right">
|
<div v-if="sortingRuleList.length==0" class="tip">
|
<p>[暂无规则]</p>
|
</div>
|
<div v-for="item in sortingRuleList" :key="item.rule_Id" class="tip">
|
<p>物料编号:{{ item.productCode }}
|
<span class="deleteRule-span" style="float:right" @click="deleteRule(item.rule_Id)">[关闭]
|
</span>
|
</p>
|
<p v-if="item.positionName">拣货货位:{{ item.positionName }}</p>
|
<p v-if="item.batchNumber">批次号:{{ item.batchNumber }}</p>
|
<p v-if="item.produceDate">生产日期:{{ item.produceDate }}</p>
|
<p v-if="item.plateCode">拍号:{{ item.plateCode }}</p>
|
<p v-if="item.positionName">唯一码:{{ item.singleSignCode }}</p>
|
</div>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="winSortingRuleVisible = false">关闭</el-button>
|
|
</div>
|
</el-dialog>
|
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
var moment = require("moment");
|
|
export default {
|
name: "storage-replenishment",
|
components: { yrtSelector },
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
sortingRuleForm: {
|
productCode: "",
|
positionName: "",
|
batchNumber: "",
|
produceDate: "",
|
plateCode: "",
|
singleSignCode: ""
|
},
|
winSortingRuleVisible: false,
|
sortingRuleList: [],
|
selectRuleRow: null
|
};
|
},
|
methods: {
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.detailAdd();
|
break;
|
}
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "auditingSorting":
|
// 审核分拣
|
this.auditingSorting();
|
break;
|
}
|
},
|
// 明细添加
|
detailAdd() {
|
this.selectorConfig.visible = true;
|
this.$refs["selector-dialog"].loadData();
|
}, // 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
rows = rows.map(v => {
|
v.outQuantity = 0;
|
v.sortingStatus = 1;
|
return v;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var auditing = formData.auditing;
|
var billStatus = formData.billStatus;
|
var sortingStatus = formData.sortingStatus;
|
if (auditing === 2) {
|
// 审核成功
|
this.$set(this.btnReadOnly, "auditingBtn", true);
|
this.$set(this.btnReadOnly, "sortingBtn", false);
|
this.btnReadOnly.stop = false; // 可编辑
|
this.btnReadOnly.open = true; // 不可编辑
|
}
|
// else {
|
// this.$set(this.btnReadOnly, "auditingBtn", false);
|
// this.$set(this.btnReadOnly, "sortingBtn", true);
|
// this.btnReadOnly.stop = true; // 不可编辑
|
// }
|
if (billStatus === "完全补货") {
|
this.$set(this.btnReadOnly, "auditingBtn", true);
|
this.$set(this.btnReadOnly, "sortingBtn", true);
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.stop = true;
|
}
|
if (sortingStatus === 2) {
|
this.$set(this.btnReadOnly, "auditingBtn", true);
|
this.$set(this.btnReadOnly, "sortingBtn", true);
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.stop = true;
|
// this.btnReadOnly.auditingBtn = true;
|
// this.btnReadOnly.sortingBtn = true;
|
}
|
if (billStatus === "终止") {
|
this.$set(this.btnReadOnly, "auditingBtn", true);
|
this.$set(this.btnReadOnly, "sortingBtn", true);
|
this.btnReadOnly.open = false;
|
this.btnReadOnly.stop = true;
|
}
|
if (billStatus === "新建") {
|
this.$set(this.btnReadOnly, "auditingBtn", false);
|
this.$set(this.btnReadOnly, "sortingBtn", true);
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.stop = false;
|
}
|
},
|
// 审核
|
auditingReplenishment(formData, details) {
|
var auditing = formData.auditing;
|
var replenishment_Id = formData.replenishment_Id;
|
if (auditing === 2) {
|
this.$message.error("已经通过审核!");
|
return;
|
}
|
const url = "/api/storage/replenishment/confirm";
|
const params = {
|
replenishment_Id: replenishment_Id,
|
auditing: 2,
|
remark: ""
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
this.editorOptions.config.visible = false;
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
},
|
// 分拣
|
sortingReplenishment(formData, details) {
|
var auditing = formData.auditing;
|
var replenishment_Id = formData.replenishment_Id;
|
var billStatus = formData.billStatus;
|
if (billStatus === "完全补货") {
|
this.$message.error("完全补货不能进行分拣!");
|
return;
|
}
|
if (auditing !== 2) {
|
this.$message.error("当前数据没有通过审核!");
|
return;
|
}
|
const url = "/api/storage/replenishment/startSorting";
|
const params = {
|
replenishment_Id: replenishment_Id
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
ref.loadData();
|
this.editor.reload();
|
};
|
this.common.ajax(url, params, callback, ref);
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
// 合计数量求和
|
let transferQuantity = 0;
|
let subTotalMoney = 0.0;
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_ReplenishmentList"].rows;
|
detailRows.forEach(item => {
|
if (item.transferQuantity && item.purchasePrice) {
|
item.subTotalMoney = parseFloat((item.transferQuantity * item.purchasePrice).toFixed(4));
|
}
|
if (item.transferQuantity) {
|
transferQuantity += item.transferQuantity;
|
}
|
if (item.subTotalMoney) {
|
subTotalMoney += item.subTotalMoney;
|
}
|
});
|
this.editor.changeValue("totalQuantity", parseFloat(transferQuantity.toFixed(4)));
|
this.editor.changeValue("totalMoney", parseFloat(subTotalMoney).toFixed(4));
|
},
|
// 设置分拣规则
|
setSortingRule(row) {
|
this.winSortingRuleVisible = true;
|
this.selectRuleRow = row;
|
this.sortingRuleForm.productCode = this.selectRuleRow["productCode"];
|
this.sortingRuleForm.helpProductCode = "'" + this.selectRuleRow["productCode"] + "'";
|
this.getSortingRuleList();
|
},
|
// 获取分拣列表
|
getSortingRuleList() {
|
const url = "/api/storage/replenishment/replenishmentGetSortingRule";
|
var replenishmentList_Id = this.selectRuleRow["replenishmentList_Id"];
|
const params = { replenishmentList_Id: replenishmentList_Id };
|
var callback = res => {
|
if (res.result) {
|
var dataList = [];
|
res.data.forEach(element => {
|
element.produceDate = element.produceDate ? moment(element.produceDate).format("YYYY-MM-DD") : null;
|
dataList.push(element);
|
});
|
this.sortingRuleList = dataList;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 提交分拣规则
|
submitSortingRuleData() {
|
var consignor_Id = this.editor.formData["consignor_Id"];
|
var consignorCode = this.editor.formData["consignorCode"];
|
var consignorName = this.editor.formData["consignorName"];
|
var storage_Id = this.editor.formData["storage_Id"];
|
var storageName = this.editor.formData["storageName"];
|
|
var replenishment_Id = this.editor.formData["replenishment_Id"];
|
var replenishmentCode = this.editor.formData["replenishmentCode"];
|
var positionName = this.sortingRuleForm.positionName;
|
var batchNumber = this.sortingRuleForm.batchNumber;
|
var produceDate = this.sortingRuleForm.produceDate;
|
var plateCode = this.sortingRuleForm.plateCode;
|
var singleSignCode = this.sortingRuleForm.singleSignCode;
|
var product_Id = this.selectRuleRow["product_Id"];
|
var productCode = this.selectRuleRow["productCode"];
|
var ProductName = this.selectRuleRow["ProductName"];
|
var replenishmentList_Id = this.selectRuleRow["replenishmentList_Id"];
|
|
const url = "/api/storage/replenishment/sortingRule";
|
const params = {
|
consignor_Id: consignor_Id,
|
consignorCode: consignorCode,
|
consignorName: consignorName,
|
storage_Id: storage_Id,
|
storageName: storageName,
|
|
replenishmentList_Id: replenishmentList_Id,
|
replenishment_Id: replenishment_Id,
|
replenishmentCode: replenishmentCode,
|
|
positionName: positionName,
|
batchNumber: batchNumber,
|
produceDate: produceDate,
|
plateCode: plateCode,
|
singleSignCode: singleSignCode,
|
|
product_Id: product_Id,
|
productCode: productCode,
|
ProductName: ProductName
|
};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.getSortingRuleList();
|
this.sortingRuleForm.positionName = "";
|
this.sortingRuleForm.batchNumber = "";
|
this.sortingRuleForm.produceDate = "";
|
this.sortingRuleForm.plateCode = "";
|
this.sortingRuleForm.singleSignCode = "";
|
}
|
});
|
},
|
// 关闭分拣规则
|
deleteRule(rule_Id) {
|
this.$confirm("确实要关闭当前规则吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/storage/replenishment/deleteSortingRule";
|
const params = { rule_Id: rule_Id };
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.getSortingRuleList();
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 审核分拣
|
auditingSorting() {
|
const the = this;
|
this.$confirm("确定要批量进行审核分拣操作吗?", "批量审核分拣", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
var isStatusText = true;
|
const selectIDs = the.dataListSelections
|
.map((item, index, array) => {
|
if (item.billStatus !== "新建") {
|
isStatusText = false;
|
}
|
return item.replenishment_Id;
|
})
|
.join(",");
|
if (selectIDs === "") {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isStatusText !== true) {
|
this.$message({
|
message: "选中项含有不是新建状态的订单!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/storage/replenishment/confirmSorting";
|
const params = {
|
selectIDs: selectIDs
|
};
|
const ref = the.dataList;
|
var callback = res => {
|
the.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
};
|
the.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
the.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
}
|
}
|
};
|
</script>
|
|
<style rel="stylesheet/scss" scoped>
|
.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>
|