<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" :on-stop-before="onStopBefore">
|
<template slot="common-column-slot" slot-scope="{ row, col }">
|
<template v-if="col.prop == 'statusText'">
|
<el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])" class="cursor-pointer">
|
{{ row[col.prop] }}
|
</el-tag>
|
</template>
|
<!--分拣状态字段-->
|
<template v-else-if="col.prop == 'sortingStatus'">
|
<template>
|
<el-tag v-if="row[col.prop] == 1" color="#ffff33" style="color:black;border:0">
|
{{ $refs[dataListRef].translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop] == 2" color="#00ff99" style="color:black;border:0">
|
{{ $refs[dataListRef].translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop] == 3" color="#ff0000" style="color:black;border:0;color:#fff;">
|
{{ $refs[dataListRef].translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
|
</el-tag>
|
<el-tag v-else-if="row[col.prop] == 5" color="#6699FF" style="color:black;border:0;color:#fff;">
|
{{ $refs[dataListRef].translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
|
</el-tag>
|
<span v-else>
|
{{ row[col.prop] }}
|
</span>
|
</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" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :btn-read-only="btnReadOnly" :default-value="defaultValue" :edit-button-click="editButtonClick" :on-stop-before="onStopBefore" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange" @on-change="onChange">
|
|
<!--自定义按钮插槽-->
|
<template slot="footer-button-region" slot-scope="{ formData, details }">
|
<!--自定义审核按钮-->
|
<!-- <el-button type="success" icon="el-icon-yrt-gouxuan1" @click.native="singleAuditing(formData)">审核</el-button> -->
|
<!--打印条码按钮-->
|
<el-button type="success" icon="el-icon-yrt-saomiao8" @click.native="printBarcode(formData, details)">打印条码</el-button>
|
</template>
|
</yrt-editor>
|
<el-dialog :visible.sync="dialogLandingTime">
|
<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>
|
<div class="margin-10" v-html="importMsg">{{ importMsg }}</div>
|
<div slot="footer" class="dialog-footer">
|
<!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
|
</div>
|
</el-dialog>
|
<!--物料库存选择器-->
|
<yrt-selector ref="selector-position-dialog" :config="selectorPositionConfig" :visible.sync="selectorPositionConfig.visible" :url="selectorPositionConfig.url" :set-search-default="setSearchDefault" @on-selected="onPositionSelected"></yrt-selector>
|
|
<position-transfer-barcode ref="position-transfer-barcode-dialog" :visible.sync="barcodeVisible"></position-transfer-barcode>
|
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
import positionTransferBarcode from "./components/position-transfer-barcode.vue";
|
|
export default {
|
name: "position-transfer",
|
components: {
|
yrtSelector,
|
positionTransferBarcode
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorPositionConfig: {
|
title: "物料库存选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/x-product-selector",
|
url: "/api/common/groupDataList"
|
},
|
// 弹出导入框
|
dialogLandingTime: false,
|
fileList: [],
|
// 导入消息
|
importMsg: null,
|
// 条码对话框是否显示
|
barcodeVisible: false,
|
// 表单默认值,新建时用
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建",
|
sortingStatus: 1,
|
auditing: 0
|
},
|
// 预到货状态值
|
statusValueList: [
|
{
|
status: "审核成功",
|
bgColor: "#00ff99",
|
color: "black"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#fff"
|
},
|
{
|
status: "在途中",
|
bgColor: "#00ffff",
|
color: "#000"
|
},
|
{
|
status: "部分交货",
|
bgColor: "#cc66ff",
|
color: "#fff"
|
},
|
{
|
status: "完全交货",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#fff"
|
},
|
{
|
status: "强制完成",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "待审核",
|
bgColor: "#ffff33",
|
color: "#000"
|
},
|
{
|
status: "波次完成",
|
bgColor: "#ffcc33",
|
color: "#fff"
|
},
|
{
|
status: "打包中",
|
bgColor: "#66cccc",
|
color: "#000"
|
},
|
{
|
status: "部分打包",
|
bgColor: "#66cccc",
|
color: "#fff"
|
},
|
{
|
status: "打包完成",
|
bgColor: "#66cccc",
|
color: "#fff"
|
},
|
{
|
status: "发运完成",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "已发货",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "部分退货",
|
bgColor: "#ff9999",
|
color: "#fff"
|
},
|
{
|
status: "完全退货",
|
bgColor: "#ff9999",
|
color: "#fff"
|
},
|
{
|
status: "已完成",
|
bgColor: "#99ffff",
|
color: "#fff"
|
},
|
{
|
status: "拣货中",
|
bgColor: "#33ffff",
|
color: "#fff"
|
},
|
{
|
status: "配货中",
|
bgColor: "#ccff66",
|
color: "#fff"
|
},
|
{
|
status: "等待配货",
|
bgColor: "#ccff66",
|
color: "#000"
|
},
|
{
|
status: "等待打包",
|
bgColor: "#cccc33",
|
color: "#000"
|
},
|
{
|
status: "用户取消",
|
bgColor: "#c53e3a",
|
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
|
};
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.openPositionSelected();
|
break;
|
case "exportList":
|
this.exportList();
|
break;
|
case "importList":
|
this.importList();
|
break;
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.editauditing([formData]);
|
return false;
|
}
|
},
|
// 打开库存选择器
|
openPositionSelected() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.consignorName) {
|
this.$message({
|
message: "请选择货主!",
|
type: "warning"
|
});
|
return;
|
}
|
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();
|
this.selectorPositionConfig.visible = true;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onPositionSelected(rows) {
|
rows.forEach(element => {
|
element.quantity = element.productStorage;
|
});
|
|
this.editor.addDetailDataRow(rows);
|
this.selectorPositionConfig.visible = false;
|
},
|
// 终止前事件
|
onStopBefore(rows) {
|
const statusList = ["新建"];
|
for (const row of rows) {
|
const statusText = row.statusText;
|
|
if (statusList.indexOf(statusText) < 0) {
|
this.$message.error(`只有["新建"]状态时才可以做终止动作!`);
|
return false;
|
}
|
return true;
|
}
|
},
|
// 审核
|
editauditing(dataListSelections) {
|
var formData = this.editor.formData;
|
var isOK = true;
|
const transfer_Ids = dataListSelections.map((item, index, Array) => {
|
return item.transfer_Id;
|
});
|
var detailRows = formData["Storage_PositionTransferList"].rows;
|
detailRows.map((item, index, array) => {
|
if (item.transferQuantity === null || item.transferQuantity <= 0) {
|
isOK = false;
|
}
|
});
|
if (isOK === false) {
|
this.$message.error("明细的转移数量不能为空!");
|
return false;
|
}
|
this.$confirm("提示:确认后将无法进行修改", "确认审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/storage/positionTransfer/auditing";
|
const params = {
|
openNodeApi: true,
|
transfer_Id: transfer_Ids.join(",")
|
};
|
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, true);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 打印条码
|
printBarcode(formData, details) {
|
// 得到,明细选中项
|
const detailSelections = details[0].options.detailSelections;
|
if (!detailSelections.length) {
|
this.$message.error("至少选择一项!");
|
return;
|
}
|
this.barcodeVisible = true;
|
|
var rows = JSON.parse(JSON.stringify(detailSelections));
|
this.$refs["position-transfer-barcode-dialog"].showData(rows);
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if (statusText === "审核成功") {
|
// 审核成功
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.auditing = true;
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else if (statusText === "终止") {
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = false;
|
this.btnReadOnly.auditing = true;
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else {
|
this.btnReadOnly.save = false;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.auditing = false;
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}
|
},
|
// 主表数据改变
|
onChange(ref, val, field, formData) {
|
// switch (field.options.prop) {
|
// case "storageName":
|
// this.$refs["selector-position-dialog"].setSearchValue("storage_Id", formData.storage_Id);
|
// this.$refs["selector-position-dialog"].loadData();
|
// break;
|
// case "consignorName":
|
// this.$refs["selector-position-dialog"].setSearchValue("consignor_Id", formData.consignor_Id);
|
// this.$refs["selector-position-dialog"].loadData();
|
// break;
|
// }
|
},
|
// 明细数据改变时触发
|
onDetailChange() {
|
// 合计数量求和
|
let totalQuantity = 0;
|
let totalMoney = 0.0;
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_PositionTransferList"].rows;
|
detailRows.forEach(item => {
|
totalQuantity += item.transferQuantity || 0;
|
totalMoney += (item.transferQuantity || 0) * (item.purchasePrice || 0);
|
});
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("totalMoney", totalMoney);
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 明细导出
|
exportList() {
|
const ids = [];
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_PositionTransferList"].rows;
|
detailRows.map((item, index, Array) => {
|
ids.push(item.transferList_Id);
|
});
|
var url = "/api/storage/positionTransfer/exportList";
|
const params = {
|
ids: ids.join(",")
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
const url = this.common.domain + "/api/common/download?url=" + res.data.url;
|
window.open(url);
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 明细导入
|
importList() {
|
this.dialogLandingTime = true;
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
handleRemove(file, fileList) {
|
this.fullFileRote = null;
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
// return domain + "/api/TMS_WayBillOther/UploadImport";
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fullFileRote = res.data.url;
|
},
|
// 导入
|
submitImport() {
|
var the = this;
|
var formData = the.editor.formData;
|
var idValue = formData[the.dataOptions.idField];
|
this.importMsg = null;
|
|
if (!this.fullFileRote) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
const url = "api/storage/positionTransfer/importExel";
|
const ref = this.dataList;
|
const params = {
|
url: this.fullFileRote,
|
transfer_Id: idValue
|
// StorageName: StorageName
|
};
|
var callback = res => {
|
if (res.result) {
|
this.fullFileRote = null;
|
this.fileList = [];
|
this.importMsg = res.msg;
|
ref.loadData();
|
} else {
|
this.importMsg = "<font color='red'>" + res.msg + "</font>";
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
}
|
}
|
};
|
</script>
|