<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" :action-field="actionField" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
|
<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" :btn-read-only="btnReadOnly" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-edit-load-after="onEditLoadAfter">
|
<!--自定义按钮插槽-->
|
<template slot="footer-button-region" slot-scope="{ formData, details }">
|
<!--打印条码按钮-->
|
<el-button :disabled="btnReadOnly.createProfitLoss" type="success" icon="el-icon-yrt-pan" @click.native="createProfitLoss(formData, details)">生成复盘单</el-button>
|
<el-button :disabled="btnReadOnly.changeAdjust" type="success" icon="el-icon-yrt-pan" @click.native="adjustsubmit(formData, details)">调整库存</el-button>
|
</template>
|
</yrt-editor>
|
<!-- 生成复盘单 -->
|
<el-dialog :visible.sync="dialogFormVisible" width="20%" title="生成复盘单">
|
<el-form :model="form">
|
<el-form-item :label-width="formLabelWidth" label="是否盲盘">
|
<el-checkbox v-model="form.checked"></el-checkbox>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="dialogFormVisible=false">取 消</el-button>
|
<el-button type="primary" @click="confirmsubmit">确 定</el-button>
|
</div>
|
</el-dialog>
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @onSelected="onSelected"></yrt-selector>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
export default {
|
name: "storage-check-profit-loss",
|
components: {
|
yrtSelector
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
actionField: {},
|
dialogFormVisible: false, // 生成复盘单
|
form: {
|
checked: false
|
},
|
formLabelWidth: "120px",
|
msgList: [], // 返回信息集合
|
intervalHandler: null,
|
storageAdjustSwitch: false, // 复盘开关
|
tipsMsg: null, // 库存调整提示语
|
btnAdjustsubmit: false,
|
// 盘点盈亏单
|
statusValueList: [
|
{
|
status: "已复盘",
|
bgColor: "#00ff99",
|
color: "black"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
|
{
|
status: "已调整",
|
bgColor: "#00ffff",
|
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
|
};
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
break;
|
case "exportPositionName":
|
// 导出货位
|
this.exportPositionName();
|
break;
|
case "exportList":
|
// 导出明细
|
this.exportList();
|
break;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 复制
|
copySaleOrder(formData) {
|
const return_Id = formData.return_Id;
|
const url = "/api/purchase/return/copySaleOrder";
|
const params = {
|
return_Id: return_Id
|
};
|
const ref = this.dataList;
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
},
|
ref
|
);
|
},
|
// 生成复盘单
|
createProfitLoss() {
|
this.dialogFormVisible = true;
|
},
|
// 调整库存,开始盘点
|
adjustsubmit() {
|
var the = this;
|
const ref = this.dataList;
|
var editorRef = this.editor;
|
var url = "/api/storage/check/startSorting";
|
var params = {
|
selectIDs: editorRef.formData.profitLoss_Id
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
the.common.showMsg(res);
|
if (res.msg) {
|
this.dialogOrderMerge = false;
|
this.editorOptions.config.visible = false;
|
ref.loadData();
|
}
|
},
|
ref
|
);
|
},
|
// 获取信息
|
getMsg() {
|
var url = "/api/storage/check/getThreadMsg";
|
var params = {};
|
this.common.ajax(url, params, res => {
|
this.msgList.push(res.state);
|
if (res.statusCode === 2) {
|
window.clearInterval(this.intervalHandler);
|
this.intervalHandler = null;
|
return;
|
}
|
this.intervalHandler = window.setTimeout(this.getMsg, 10000);
|
});
|
},
|
// (生成复盘单)提交
|
confirmsubmit() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.profitLoss_Id) {
|
this.$message({
|
message: "Id不能为空",
|
type: "warning"
|
});
|
}
|
var subTableView = this.editor.detailFields[0].subTableView;
|
var rows = this.editor.formData[subTableView].rows;
|
var idList = "";
|
rows.forEach(item => {
|
if (idList) idList += ",";
|
idList += item.product_Id;
|
});
|
if (!idList) {
|
this.$message({
|
type: "error",
|
message: "请选择要复盘的数据"
|
});
|
}
|
var isBlind = this.form.checked === true ? 1 : 0;
|
var url = "/api/storage/check/reCheck";
|
var params = {
|
profitLoss_Id: editorRef.formData.profitLoss_Id,
|
product_Ids: idList,
|
isBlind: isBlind
|
};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.$message({
|
type: "success",
|
message: res.msg
|
});
|
this.dialogFormVisible = false;
|
}
|
});
|
},
|
// 数据加载后的事件
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if (statusText === "新建") {
|
this.$set(this.btnReadOnly, "createProfitLoss", false);
|
this.$set(this.btnReadOnly, "changeAdjust", false);
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (statusText === "已复盘") {
|
this.$set(this.btnReadOnly, "createProfitLoss", true);
|
this.$set(this.btnReadOnly, "changeAdjust", false);
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (statusText === "已调整") {
|
this.$set(this.btnReadOnly, "createProfitLoss", true);
|
this.$set(this.btnReadOnly, "changeAdjust", true);
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
}
|
},
|
// 获取复盘开关状态
|
getStorageAdjustConfig() {
|
var url = "/api/storage/check/getStorageAdjustConfig";
|
var params = {};
|
var editorRef = this.editor;
|
this.common.ajax(url, params, res => {
|
if (res.result) {
|
this.storageAdjustSwitch = res.msg;
|
if (this.storageAdjustSwitch !== "False") {
|
if (editorRef.formData.statusText === "已复盘") {
|
this.tipsMsg = "点击分拣开始分拣调整库存!";
|
} else {
|
this.tipsMsg = "需要先进行复盘,才允许调整库存!";
|
this.$message.error("需要先进行复盘,才允许调整库存!");
|
this.btnAdjustsubmit = true;
|
}
|
} else {
|
this.tipsMsg = "点击确定开始分拣调整库存!";
|
}
|
}
|
});
|
},
|
// 明细导出
|
exportList() {
|
var formData = this.editor.formData;
|
var url = "/api/storage/check/exportlossList";
|
const params = {
|
ids: formData.profitLoss_Id
|
};
|
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);
|
},
|
// 货位导出
|
exportPositionName() {
|
var formData = this.editor.formData;
|
var url = "/api/storage/check/exportPositionName";
|
const params = {
|
ids: formData.profitLoss_Id
|
};
|
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);
|
}
|
}
|
};
|
</script>
|