<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'">
|
<state-flow :load-options="stateLoadOptions" :where="{return_Id: row[dataOptions.idField]}">
|
<template slot="content">
|
<el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])">
|
{{ row[col.prop] }}
|
</el-tag>
|
</template>
|
</state-flow>
|
</template>
|
<template v-else-if="col.prop==dataOptions.linkColumn">
|
<el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">
|
<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>
|
</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" :btn-read-only="btnReadOnly" :use-detail-slot="['sortingStatus']" :on-save-before="onSaveBefore" :edit-button-click="editButtonClick" @on-blur="onBlur" @on-detail-change="onDetailChange">
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
|
</div>
|
</template>
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
import stateFlow from "@/components/common/components/stateflow.vue";
|
export default {
|
name: "service-return",
|
components: {
|
baseLayout,
|
yrtSelector,
|
stateFlow
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 状态流加载参数
|
stateLoadOptions: {
|
folder: "outbound/order",
|
projectName: "ERP.Outbound",
|
tableView: "Sale_Return_StatusHistory",
|
idField: "history_Id",
|
sortName: "history_Id DESC",
|
pageIndex: 1,
|
pageSize: 100,
|
menu_Id: -1,
|
noUserProduct_Id: true // 不需要账套ID
|
},
|
// 自动加载预到货单字段
|
jiazaiorder: [
|
"storage_Id",
|
"storageName",
|
"consignor_Id",
|
"consignorName",
|
"consignorCode",
|
"clientShortName",
|
"client_Id",
|
"clientCode",
|
"consignorName",
|
"totalPaid",
|
"storeOrderCode"
|
],
|
// 预到货状态值
|
statusValueList: [
|
{
|
status: "审核成功",
|
bgColor: "#33cc33",
|
color: "#ffffff"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000000"
|
},
|
{
|
status: "部分退货",
|
bgColor: "#99cc66",
|
color: "#ffffff"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#ffffff"
|
},
|
{
|
status: "在途中",
|
bgColor: "#00ffff",
|
color: "#000000"
|
},
|
{
|
status: "部分收货",
|
bgColor: "#cc66ff",
|
color: "#ffffff"
|
},
|
{
|
status: "全部收货",
|
bgColor: "#33cc00",
|
color: "#ffffff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#ffffff"
|
},
|
{
|
status: "强制完成",
|
bgColor: "#00ccff",
|
color: "#ffffff"
|
},
|
{
|
status: "待审核",
|
bgColor: "#ffff33",
|
color: "#000000"
|
},
|
{
|
status: "等待配货",
|
bgColor: "#00bcd4",
|
color: "#ffffff"
|
},
|
{
|
status: "已转预到货",
|
bgColor: "#00bcd4",
|
color: "#ffffff"
|
}
|
]
|
};
|
},
|
methods: {
|
// 状态背景颜色
|
setStatusBgColor(status) {
|
var colorItem = this.statusValueList.find(item => {
|
return item.status === status;
|
});
|
var bgColor = "#eeeeee";
|
if (colorItem) bgColor = colorItem.bgColor;
|
|
return bgColor;
|
},
|
// 状态字体颜色
|
setStatusColor(status) {
|
var colorItem = this.statusValueList.find(item => {
|
return item.status === status;
|
});
|
var color = "#000000";
|
if (colorItem) color = colorItem.color;
|
|
return {
|
border: 0,
|
color: color
|
};
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
var isok = true;
|
var statusText = this.dataListSelections.map((item, index, array) => {
|
return item.statusText;
|
});
|
statusText.forEach(rowData => {
|
if (rowData !== "新建") return (isok = false);
|
});
|
if (isok === false) {
|
this.$message.error("只有新建货单,可以审核!");
|
return false;
|
}
|
var return_Ids = this.dataListSelections.map((item, index, array) => {
|
return item.return_Id;
|
});
|
this.onConfirm(return_Ids);
|
return false;
|
case "toPurchase":
|
// 转到出库单
|
this.toPurchase();
|
return false;
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case "auditing":
|
// 批量审核
|
this.onConfirm([formData.return_Id]);
|
return false;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.openSelected();
|
return true;
|
}
|
},
|
openSelected() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.consignorName) {
|
this.$message({
|
message: "请选择货主!",
|
type: "warning"
|
});
|
return;
|
}
|
const selector = this.$refs["selector-dialog"];
|
selector.setSearchValue("consignor_Id", [editorRef.formData.consignor_Id]);
|
selector.setReadOnly("consignor_Id", true); // 设为只读
|
|
selector.loadData();
|
this.selectorConfig.visible = true;
|
},
|
// 将明细选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
rows.forEach(element => {
|
element.sortingStatus = 1;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 输入出库订单号失去焦点加载主表信息
|
onBlur(ref, val, row, field) {
|
if (field.label === "出库单号" && val) {
|
const url = "/api/outbound/return/getByCode";
|
const params = {
|
orderCode: val
|
};
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.jiazaiorder.forEach(field => {
|
this.$set(this.editor.formData, field, res.data[field]);
|
});
|
if (res.data.saleOrderList) {
|
// 默认为第一个明细表名称
|
var subTableView = this.editor.detailFields[0].subTableView;
|
|
res.data.saleOrderList.forEach(item => {
|
item.quantityRefunded = item.quantityOrder;
|
});
|
|
this.editor.formData[subTableView].rows = []; // 清空数据
|
this.editor.addDetailDataRow(res.data.saleOrderList);
|
}
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
}
|
},
|
// 审核
|
onConfirm(return_Ids) {
|
if (!return_Ids.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
this.$confirm("确认后将无法进行修改,确实要进行确认操作吗?", "确认审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/outbound/return/singleAuditing";
|
const params = {
|
return_Ids: return_Ids
|
};
|
const ref = this.dataList;
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 转到预到货单
|
toPurchase() {
|
let isok = true;
|
let return_Id = this.dataListSelections.map((item, index, array) => {
|
return item.return_Id;
|
});
|
const statusText = this.dataListSelections.map((item, index, array) => {
|
return item.statusText;
|
});
|
statusText.forEach(rowData => {
|
if (rowData !== "审核成功") return (isok = false);
|
});
|
if (isok === false) {
|
this.$message.error("只有审核成功后,才可以转到出库单!");
|
return false;
|
}
|
if (!return_Id.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
this.$confirm("确认转到预到货单?", "转到预到货单", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
return_Id = return_Id[0];
|
const url = "/api/outbound/return/toPurchase";
|
const params = {
|
return_Id: return_Id
|
};
|
const ref = this.dataList;
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
onSaveBefore(formData) {
|
let quantityRefunded = 0; // 退货数量
|
var detailRows = formData["Sale_ReturnList"].rows;
|
detailRows.forEach(item => {
|
quantityRefunded = item.quantityRefunded;
|
});
|
if (!quantityRefunded) {
|
this.$message({
|
message: "明细列表的退货数量必须大于0!",
|
type: "warning"
|
});
|
return false;
|
}
|
this.setTotal();
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
this.setTotal();
|
},
|
// 求和
|
setTotal() {
|
var totalWeight = 0.0;
|
var returnMoney = 0.0;
|
var totalQuantity = 0;
|
var returnQuantity = 0;
|
var formData = this.editor.formData;
|
var detailRows = formData["Sale_ReturnList"].rows;
|
detailRows.forEach(item => {
|
item.totalWeight = Math.Round((item.quantityRefunded || 0) * (item.weight || 0));
|
item.amountRefunded = Math.Round((item.quantityRefunded || 0) * (item.salePrice || 0));
|
totalWeight += item.totalWeight || 0;
|
returnMoney += item.amountRefunded || 0;
|
totalQuantity += item.quantityOrder || 0;
|
returnQuantity += item.quantityRefunded || 0;
|
});
|
this.editor.changeValue("totalWeight", Math.Round(totalWeight, 2));
|
this.editor.changeValue("returnMoney", Math.Round(returnMoney, 2));
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("returnQuantity", returnQuantity);
|
}
|
}
|
};
|
</script>
|