<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">
|
<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=='auditing'">
|
<template>
|
<el-tag v-if="row[col.prop]==1" color="#ffcc66" style="color:black;border:0">
|
审核失败
|
</el-tag>
|
<el-tag v-else-if="row[col.prop]==2" color="#33ccff" style="color:black;border:0">
|
通过审核
|
</el-tag>
|
<el-tag v-else-if="row[col.prop]==0" color="#ffff33" style="color:black;border:0">
|
待审核
|
</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-if="col.dropdown_Id>0">
|
{{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
|
</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" :btn-read-only="btnReadOnly" :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-edit-load-after="onEditLoadAfter" @on-add-load-after="onEditLoadAfter" @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>
|
<!--物料库存选择器-->
|
<yrt-selector ref="selector-position-dialog" :config="selectorPositionConfig" :visible.sync="selectorPositionConfig.visible" :url="selectorPositionConfig.url" :set-search-default="setSearchDefault" @on-selected="onPositionSelected"></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: "inbound-purchase-return",
|
components: {
|
yrtSelector,
|
stateFlow
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
selectorPositionConfig: {
|
title: "库存选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/x-product-selector",
|
url: "/api/common/GroupDataList"
|
},
|
// 状态流加载参数
|
stateLoadOptions: {
|
folder: "inbound/purchase",
|
projectName: "ERP.Inbound",
|
tableView: "Purchase_Return_StatusHistory",
|
idField: "history_Id",
|
sortName: "history_Id DESC",
|
pageIndex: 1,
|
pageSize: 100,
|
menu_Id: -1,
|
noUserProduct_Id: true
|
},
|
// 自动加载预到货单字段
|
jiazaiorder: [
|
"consignorName",
|
"consignor_Id",
|
"consignorCode",
|
"storageName",
|
"dept_Id",
|
"deptName",
|
"applyDate",
|
"provider_Id",
|
"providerCode",
|
"providerShortName",
|
"shippingName",
|
"shippingAddress",
|
"mobile",
|
"storage_Id"
|
],
|
// 预到货状态值
|
statusValueList: [
|
{
|
status: "审核成功",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "已转出库单",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#fff"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#fff"
|
}
|
]
|
};
|
},
|
activated() {
|
// SaaS模块权限
|
this.common.hasSaaSAuth("到货退货单", this.$refs.container);
|
},
|
methods: {
|
// 状态背景颜色
|
setStatusBgColor(status) {
|
var colorItem = this.statusValueList.find(item => {
|
return item.status === status;
|
});
|
var bgColor = "#fffff";
|
if (colorItem) bgColor = colorItem.bgColor;
|
|
return bgColor;
|
},
|
// 状态字体颜色
|
setStatusColor(status) {
|
var colorItem = this.statusValueList.find(item => {
|
return item.status === status;
|
});
|
var color = "#fffff";
|
if (colorItem) color = colorItem.color;
|
|
return {
|
border: 0,
|
color: color,
|
cursor: "pointer"
|
};
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.batchAuditing(this.dataListSelections);
|
return false;
|
case "toSaleOrder":
|
// 转到出库单
|
this.toSaleOrder();
|
break;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
return true;
|
case "detailAddPisition":
|
// 明细添加
|
this.openPositionSelected();
|
return true;
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.batchAuditing([formData]);
|
return false;
|
}
|
},
|
// 打开库存选择器
|
openPositionSelected() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.consignorName) {
|
this.$message({
|
message: "请选择货主!",
|
type: "warning"
|
});
|
return;
|
}
|
if (editorRef.formData.positionType) {
|
this.$refs["selector-position-dialog"].setSearchValue("positionType", [editorRef.formData.positionType]);
|
}
|
this.selectorPositionConfig.visible = true;
|
const selector = this.$refs["selector-position-dialog"];
|
selector.setSearchValue("storage_Id", [editorRef.formData.storage_Id]);
|
selector.setSearchValue("consignor_Id", [editorRef.formData.consignor_Id]);
|
selector.setReadOnly("storage_Id", true); // 设为只读
|
selector.setReadOnly("consignor_Id", true); // 设为只读
|
selector.loadData();
|
},
|
// 将物料选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
rows.forEach(item => {
|
item.quantity = 0;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 将库存选择器选择中的数据填充到明细表中
|
onPositionSelected(rows) {
|
rows.forEach(element => {
|
element.quantity = element.productStorage;
|
});
|
|
this.editor.addDetailDataRow(rows);
|
this.selectorPositionConfig.visible = false;
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 审核
|
batchAuditing(dataListSelections) {
|
let isok = true;
|
const return_Ids = dataListSelections.map((item, index, Array) => {
|
return item.return_Id;
|
});
|
const statusTexts = dataListSelections.map((item, index, Array) => {
|
return item.statusText;
|
});
|
statusTexts.forEach(rowData => {
|
if (rowData !== "新建") return (isok = false);
|
});
|
if (isok === false) {
|
this.$message.error("只有新建货单,可以审核!");
|
return false;
|
}
|
if (!return_Ids.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
this.$confirm("确认后将无法进行修改,确实要进行确认操作吗?", "确认审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/inbound/return/auditingReturn";
|
const params = {
|
openNodeApi: true,
|
return_Ids: return_Ids
|
};
|
const ref = this.dataList;
|
const 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: "已取消"
|
});
|
});
|
},
|
// 复制
|
copyOrder(formData) {
|
const return_Id = formData.return_Id;
|
if (!return_Id) {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/inbound/return/copySaleOrder";
|
const params = {
|
openNodeApi: true,
|
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);
|
},
|
// 转到出货单
|
toSaleOrder() {
|
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/inbound/return/toSaleOrder";
|
const params = {
|
openNodeApi: true,
|
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: "已取消"
|
});
|
});
|
},
|
// 输入预到货单失去焦点加载主表信息
|
onBlur(ref, val, row, field) {
|
if (field.label === "预到货单号") {
|
// debugger;
|
const orderCode = val;
|
const url = "/api/inbound/order/getByCode";
|
const params = {
|
orderCode: orderCode
|
};
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.jiazaiorder.forEach(fieldName => {
|
this.$set(this.editor.formData, fieldName, res.data[fieldName]);
|
});
|
if (res.data.purchaseOrderList) {
|
// 默认为第一个明细表名称
|
var rows = this.editor.formData["Purchase_ReturnList"].rows;
|
|
res.data.purchaseOrderList.forEach(item => {
|
item.quantityRefunded = item.quantity;
|
item.amountRefunded = item.purchaseMoney;
|
var isExist = false;
|
rows.forEach(temp => {
|
if (item.orderList_Id === temp.orderList_Id) {
|
isExist = true;
|
}
|
});
|
if (!isExist) {
|
this.editor.addDetailDataRow([item]);
|
}
|
});
|
}
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
}
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if ("审核成功".indexOf(statusText) >= 0) {
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.InTransit = false;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
}
|
if (statusText === "终止") {
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = false;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.InTransit = true;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
}
|
if (statusText === "新建") {
|
this.btnReadOnly.auditing = false;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = false;
|
this.btnReadOnly.InTransit = false;
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}
|
if (statusText === "已转出库单") {
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.InTransit = false;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
}
|
},
|
// 保存前事件
|
onSaveBefore() {
|
this.setTotal();
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
// var formData = this.editor.formData;
|
// var detailRows = formData["Purchase_ReturnList"].rows;
|
if (["purchasePrice", "quantity", "totalWeight", "quantityRefunded"].indexOf(field.prop) >= 0) {
|
this.setTotal();
|
}
|
},
|
// 求和
|
setTotal() {
|
var formData = this.editor.formData;
|
var detailRows = formData["Purchase_ReturnList"].rows;
|
// 合计数量求和
|
let totalQuantity = 0;
|
let returnQuantity = 0;
|
let totalMoney = 0.0;
|
let returnMoney = 0.0;
|
let totalWeight = 0.0;
|
detailRows.forEach(item => {
|
item.amountRefunded = Math.Round((item.quantityRefunded || 0) * (item.purchasePrice || 0), 2);
|
// 行重量
|
item.totalWeight = Math.Round((item.quantityRefunded || 0) * (item.weight || 0), 2);
|
|
totalQuantity += item.quantity || 0;
|
returnQuantity += item.quantityRefunded || 0;
|
totalMoney += item.purchaseMoney || 0;
|
returnMoney += item.amountRefunded || 0;
|
totalWeight += item.totalWeight || 0;
|
});
|
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("returnQuantity", returnQuantity);
|
this.editor.changeValue("totalMoney", parseFloat(totalMoney).toFixed(2));
|
this.editor.changeValue("returnMoney", parseFloat(returnMoney).toFixed(2));
|
this.editor.changeValue("totalWeight", totalWeight);
|
}
|
}
|
};
|
</script>
|