<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" :on-delete-before="onDeleteBefore" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
|
<template slot="action-column-slot" slot-scope="{row, col}">
|
<template>
|
<!-- <el-button type="text" size="mini" @click="editData(row.wayBill_Id)">轨迹</el-button> -->
|
<state-flow :load-options="stateflowLoadOptions" :where="{clientDesc:{operator:'not', value:null}, wayBillCode:row.wayBillCode}">
|
<template slot="content">
|
<el-button type="text" size="mini">轨迹</el-button>
|
</template>
|
</state-flow>
|
|
<waybill-history :load-options="stateLoadOptions" :where="{wayBill_Id: row[dataOptions.idField]}">
|
<template slot="content">
|
<el-button type="text" size="mini">运单记录</el-button>
|
</template>
|
</waybill-history>
|
</template>
|
</template>
|
|
<template slot="button-tool2-slot">
|
<el-dropdown>
|
<el-button type="primary">
|
运单打印
|
<i class="el-icon-arrow-down el-icon--right"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item v-for="(item, index) in printTemplateList" :key="index" class="w-200" @click.native="detailPrint(item)">{{ item.templateName }}</el-dropdown-item>
|
<el-dropdown-item v-if="printTemplateList.length === 0" disabled>暂时没有模板</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
</template>
|
</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" :auth-nodes="authNodes" @on-change="onChange" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter" @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 waybillHistory from "./components/waybillhistory.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
import stateFlow from "./components/stateflow.vue";
|
export default {
|
name: "user-way-bill",
|
components: {
|
waybillHistory,
|
yrtSelector,
|
stateFlow
|
},
|
mixins: [baseLayout],
|
// 自定义JSON路由地址
|
custoJsonmRoute: "/user/way/bill",
|
data() {
|
return {
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 运单记录加载参数
|
stateLoadOptions: {
|
folder: "express/tms",
|
projectName: "Interface.Express",
|
tableView: "TMS_WayBill",
|
idField: "wayBill_Id",
|
sortName: { wayBill_Id: "DESC" },
|
pageIndex: 1,
|
pageSize: 100,
|
menu_Id: -1
|
},
|
// 状态流加载参数
|
stateflowLoadOptions: {
|
folder: "express/tms",
|
projectName: "Interface.Express",
|
tableView: "TMS_WayBillTracking",
|
idField: "wayBillTracking_Id",
|
sortName: { wayBillTracking_Id: "DESC" },
|
pageIndex: 1,
|
pageSize: 100,
|
menu_Id: -1
|
},
|
// 客户端权限点需要在这里增加,否则无法显示按钮
|
authNodes: {
|
add: true,
|
delete: true,
|
export: true,
|
save: true,
|
batchAuditing: true,
|
returnGoods: true,
|
batchOpen: true,
|
batchStop: true
|
},
|
// 打印模板列表
|
printTemplateList: []
|
};
|
},
|
mounted() {
|
var addListString = localStorage.getItem("addList");
|
if (addListString) {
|
var the = this;
|
var addList = JSON.parse(addListString);
|
window.setTimeout(function() {
|
the.dataList.addSearchFields(addList);
|
the.dataList.loadData();
|
}, 1000);
|
localStorage.removeItem("addList");
|
}
|
this.getPrintTemplate();
|
},
|
methods: {
|
// 编辑框弹出
|
// editData(id) {
|
// var ref = this.editor;
|
// ref.editData(id);
|
// },
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "batchAuditing":
|
// 批量提交
|
this.batchAuditing();
|
return true;
|
case "returnGoods":
|
// 批量退货
|
this.returnGoods();
|
break;
|
case "batchOpen":
|
// 批量开启
|
this.multiBatchOpen();
|
return true;
|
case "batchStop":
|
// 批量终止
|
this.multiBatchStop();
|
return true;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.detailAdd();
|
return true;
|
}
|
},
|
// 批量提交操作
|
batchAuditing() {
|
const the = this;
|
this.$confirm("确定要批量进行提交操作吗?", "批量提交", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
var isOrderStatus = true; // 可操作状态
|
const selectIDs = the.dataListSelections.map((item, index, Array) => {
|
if (item.orderStatus !== "新建") {
|
isOrderStatus = false;
|
}
|
return item.wayBill_Id;
|
});
|
if (!selectIDs.length) {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isOrderStatus === false) {
|
this.$message({
|
message: "所选单据存在不可操作提交状态!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/tms/waybill/batchAuditing";
|
const params = {
|
ids: selectIDs
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
the.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 批量退货操作
|
returnGoods() {
|
const the = this;
|
this.$confirm("确定要批量进行退货操作吗?", "批量退货", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
var isOrderType = ""; // 运单类型=仓配,=直邮
|
var isOrderStatus = ""; // 可操作状态
|
const selectIDs = the.dataListSelections.map((item, index, Array) => {
|
isOrderType = item.orderType;
|
isOrderStatus = item.orderStatus;
|
return item.wayBill_Id;
|
});
|
if (selectIDs === "") {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isOrderType === "仓配") {
|
if (isOrderStatus === "审核成功" || isOrderStatus === "已提交") {
|
this.updateOrderStatus(selectIDs);
|
} else {
|
this.$message({
|
message: "提交的数据订单状态不符合仓配退货条件!",
|
type: "warning"
|
});
|
return;
|
}
|
} else if (isOrderType === "直邮") {
|
if (isOrderStatus === "新建" || isOrderStatus === "已提交" || isOrderStatus === "面单已录入" || isOrderStatus === "审核成功") {
|
this.updateOrderStatus(selectIDs);
|
} else {
|
this.$message({
|
message: "提交的数据订单状态不符合直邮退货条件!",
|
type: "warning"
|
});
|
return;
|
}
|
}
|
})
|
.catch(() => {
|
the.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 修改满足条件数据的退货状态
|
updateOrderStatus(selectIDs) {
|
const url = "/api/tms/wayBill/billReturnGoods";
|
const params = {
|
ids: selectIDs,
|
abnormalReason: "客户端操作退货"
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
},
|
// 获得运单打印模板
|
getPrintTemplate() {
|
const url = "/api/sys/printTemplate/getTemplateList";
|
const params = {
|
templateName: "客户端运单面单"
|
};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.printTemplateList = res.data;
|
}
|
});
|
},
|
// 打印运单
|
detailPrint(templateInfo) {
|
var ids = [];
|
this.dataListSelections.forEach(item => {
|
ids.push(item[this.dataOptions.idField]);
|
});
|
if (!ids.length) {
|
this.$message.error("至少选择一项!");
|
return;
|
}
|
this.printRecord(ids);
|
window.open(`/user.html#/print/base/${templateInfo.menu_Id}/${ids}`);
|
},
|
printRecord(ids) {
|
var url = "/api/tms/userSys/bill/changePrintStatus";
|
var params = {
|
wayBill_Ids: ids
|
};
|
this.common.ajax(url, params, res => {});
|
},
|
// 删除前事件
|
onDeleteBefore(row) {
|
let StatusText = true;
|
this.dataListSelections.forEach(rowData => {
|
StatusText = rowData.orderStatus;
|
if (StatusText !== "新建") {
|
StatusText = false;
|
}
|
});
|
if (StatusText === false) {
|
this.$message.error("仅可删除新建运单!");
|
return false;
|
}
|
return true;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
setTimeout(() => {
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}, 800);
|
},
|
// 明细添加
|
detailAdd() {
|
this.selectorConfig.visible = true;
|
this.$refs["selector-dialog"].setSearchValue("provider_Id", []);
|
this.$refs["selector-dialog"].loadData();
|
},
|
// 批量开启操作
|
multiBatchOpen() {
|
const the = this;
|
this.$confirm("确定要批量进行开启操作吗?", "批量开启", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
var isOrderStatus = true;
|
const selectIDs = the.dataListSelections.map((item, index, Array) => {
|
if (item.orderStatus !== "终止") {
|
isOrderStatus = false;
|
}
|
return item.wayBill_Id;
|
});
|
if (!selectIDs.length) {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isOrderStatus !== true) {
|
this.$message({
|
message: "只有终止的运单才可以开启!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/tms/waybill/multiBatchOpen";
|
const params = {
|
ids: 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: "已取消"
|
});
|
});
|
},
|
// 批量终止操作
|
multiBatchStop() {
|
const the = this;
|
this.$confirm("确定要批量进行终止操作吗?", "批量终止", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
var isOrderStatus = true;
|
var isCollectStatus = true;
|
const selectIDs = the.dataListSelections.map((item, index, Array) => {
|
if (item.orderStatus !== "新建" && item.orderStatus !== "已提交") {
|
isOrderStatus = false;
|
}
|
if (item.CollectStatus === "已揽收") {
|
isCollectStatus = false;
|
}
|
return item.wayBill_Id;
|
});
|
if (selectIDs === "") {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isOrderStatus !== true) {
|
this.$message({
|
message: "只有新建或已提交的运单才可以终止!",
|
type: "warning"
|
});
|
return;
|
}
|
if (isCollectStatus === false) {
|
this.$message({
|
message: "已揽收的运单不允许操作终止!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/tms/waybill/multiBatchStop";
|
const params = {
|
ids: 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: "已取消"
|
});
|
});
|
},
|
// 级联改变数据
|
onChange(ref, val, field, formData) {
|
// 所有状态都可以编辑
|
// this.editorOptions.config.disabled = false;
|
|
var editor = this.editor;
|
if (field.options.prop === "portName") {
|
var url = "/api/tms/wayBill/getGoodsRegion";
|
var parsms = {
|
portName: formData.portName
|
};
|
this.common.ajax(url, parsms, res => {
|
if (res.result) {
|
editor.formData.planDropOffPort = res.data.RegionName; // 落口名称
|
}
|
});
|
}
|
},
|
// 数据加载后事件
|
onEditLoadAfter(formData) {
|
if (formData.orderStatus === "终止") {
|
// 不可以编辑
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else {
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
// 合计数量求和
|
let totalQuantityOrder = 0;
|
let grandTotal = 0.0;
|
|
var formData = this.editor.formData;
|
var detailRows = formData["TMS_WayBillList"].rows;
|
detailRows.forEach(item => {
|
if (item.quantityOrder !== null || item.salePrice !== null) {
|
// 行金额
|
item.rowTotal = Math.Round(item.quantityOrder * item.salePrice, 2);
|
}
|
|
// totalQuantityOrder += item.Quantity;
|
totalQuantityOrder += item.quantityOrder;
|
grandTotal += item.rowTotal;
|
});
|
|
this.editor.changeValue("totalQuantityOrder", parseInt(totalQuantityOrder));
|
this.editor.changeValue("grandTotal", Math.Round(grandTotal, 2));
|
}
|
}
|
};
|
</script>
|