<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'">
|
<el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])">
|
{{ row[col.prop] }}
|
</el-tag>
|
</template>
|
<!--审核字段-->
|
<template v-else-if="col.prop=='auditing'">
|
<template>
|
<el-tag v-if="row[col.prop]==0" 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]==1" color="#ff0033" style="color:white;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="#33cc33" 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 == '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-save-before="onSaveBefore" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange">
|
|
<template slot="footer-button-region" slot-scope="{formData}">
|
<!--自定义审核按钮-->
|
<!-- 分拣 -->
|
<el-button :disabled="btnReadOnly.btnSorting" type="success" icon="el-icon-yrt-gouxuan1" @click.native="sorting(formData)">分拣</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-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @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";
|
|
export default {
|
name: "storage-allocate-apply",
|
components: { yrtSelector },
|
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"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建",
|
auditing: 0,
|
sortingStatus: 1
|
},
|
// 弹出导入框
|
dialogLandingTime: false,
|
fileList: [],
|
// 导入消息
|
importMsg: null,
|
// 预到货状态值
|
statusValueList: [
|
{
|
status: "审核成功",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "部分退货",
|
bgColor: "#99cc66",
|
color: "#fff"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#fff"
|
},
|
{
|
status: "完全入库",
|
bgColor: "#00ffff",
|
color: "#000"
|
},
|
{
|
status: "确认调拨",
|
bgColor: "#cc66ff",
|
color: "#fff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#fff"
|
},
|
{
|
status: "强制完成",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "完全退货",
|
bgColor: "#E052FB",
|
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 = "#ffffff";
|
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) {},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
break;
|
case "detailAddPisition":
|
this.openPositionSelected();
|
break;
|
case "exportList":
|
this.exportList();
|
break;
|
case "importList":
|
this.importList();
|
break;
|
}
|
},
|
// 打开库存选择器
|
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;
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.auditing();
|
return false;
|
case "open":
|
this.open();
|
return false;
|
case "stop":
|
this.stop();
|
return false;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
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;
|
},
|
auditing() {
|
var the = this;
|
var formData = the.editor.formData;
|
if (formData.sortingStatus !== 2 || formData.statusText !== "新建") {
|
this.$message.error("申请状态为新建且分拣状态为已分配的才能审核!");
|
return false;
|
}
|
this.$confirm("审核后将无法进行修改, 是否继续?", "审核操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
_auditing();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "取消审核"
|
});
|
});
|
function _auditing() {
|
var formData = the.editor.formData;
|
var dbServer = "Sys";
|
var idField = the.dataOptions.idField;
|
var allocateApply_Id = formData.allocateApply_Id;
|
var tableName = the.dataOptions.tableView;
|
|
const ref = the.dataList;
|
var url = "/api/storage/allocateApply/auditing";
|
the.initLoading = true;
|
var params = {
|
dbServer: dbServer,
|
idField: idField,
|
allocateApply_Id: allocateApply_Id,
|
tableName: tableName,
|
auditing: 2
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
the.$message.success(res.msg);
|
ref.loadData();
|
} else {
|
the.$message({
|
showClose: true,
|
duration: 6000,
|
message: res.msg,
|
type: "error"
|
});
|
}
|
the.initLoading = false;
|
},
|
true
|
);
|
}
|
},
|
open() {
|
var the = this;
|
var formData = the.editor.formData;
|
if (formData.statusText !== "终止") {
|
the.$message({
|
type: "error",
|
message: "只有终止的调拨单才能开启!"
|
});
|
return false;
|
}
|
the
|
.$confirm("确定要进行开启操作吗, 是否继续?", "开启操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
the._open();
|
})
|
.catch(() => {
|
the.$message({
|
type: "info",
|
message: "已取消开启"
|
});
|
});
|
},
|
_open() {
|
var the = this;
|
var formData = the.editor.formData;
|
var idField = the.dataOptions.idField;
|
var idValue = formData[the.dataOptions.idField];
|
var tableName = the.dataOptions.tableView;
|
|
const ref = the.dataList;
|
var url = "/api/storage/allocateApply/open";
|
the.initLoading = true;
|
var params = {
|
idField: idField,
|
idValue: idValue,
|
tableName: tableName
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
the.$message.success(res.msg);
|
ref.loadData();
|
this.editor.reload();
|
} else {
|
the.$message({
|
showClose: true,
|
duration: 6000,
|
message: res.msg,
|
type: "error"
|
});
|
}
|
the.initLoading = false;
|
},
|
true
|
);
|
},
|
stop() {
|
var the = this;
|
var formData = the.editor.formData;
|
if (formData.statusText !== "新建" || formData.sortingStatus !== 2) {
|
the.$message({
|
type: "error",
|
message: "只有申请单状态为新建,分拣状态为已分配才能终止!"
|
});
|
return false;
|
}
|
this.$confirm("确定要进行终止操作吗, 是否继续?", "终止操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this._stop();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消终止"
|
});
|
});
|
},
|
// 在内部定义 加function 无法刷新编辑页面
|
_stop() {
|
var the = this;
|
var formData = the.editor.formData;
|
var idField = the.dataOptions.idField;
|
var idValue = formData[the.dataOptions.idField];
|
var tableName = the.dataOptions.tableView;
|
const ref = the.dataList;
|
var url = "/api/storage/allocateApply/stop";
|
the.initLoading = true;
|
var params = {
|
idField: idField,
|
idValue: idValue,
|
tableName: tableName
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
the.$message.success(res.msg);
|
ref.loadData();
|
this.editor.reload();
|
} else {
|
the.$message({
|
showClose: true,
|
duration: 6000,
|
message: res.msg,
|
type: "error"
|
});
|
}
|
the.initLoading = false;
|
},
|
true
|
);
|
},
|
// 分拣
|
sorting(formData) {
|
this.$confirm("将进行分拣操作, 是否继续?", "分拣操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
var formData = this.editor.formData;
|
var id = formData[this.dataOptions.idField];
|
const url = "/api/storage/allocateApply/startSorting";
|
const ref = this.dataList;
|
const params = {
|
selectIDs: id
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
this.editorOptions.config.visible = false;
|
} else {
|
ref.loadData();
|
this.editorOptions.config.visible = false;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "取消分拣"
|
});
|
});
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
// 只有申请单状态为新建,分拣状态为已分配才能审核
|
if (formData.sortingStatus === 2 && formData.statusText === "新建") {
|
this.$set(this.btnReadOnly, "stop", false);
|
this.$set(this.btnReadOnly, "auditing", false);
|
this.$set(this.btnReadOnly, "btnSorting", true);
|
this.$set(this.btnReadOnly, "open", true);
|
} else {
|
this.$set(this.btnReadOnly, "stop", true);
|
this.$set(this.btnReadOnly, "auditing", true);
|
this.$set(this.btnReadOnly, "btnSorting", false);
|
}
|
// 只有终止的调拨单才能开启!
|
if (formData.statusText === "终止" && formData.statusID === 5) {
|
this.$set(this.btnReadOnly, "open", false);
|
this.$set(this.btnReadOnly, "auditing", true);
|
this.$set(this.btnReadOnly, "stop", true);
|
this.$set(this.btnReadOnly, "btnSorting", true);
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else {
|
this.$set(this.btnReadOnly, "open", true);
|
}
|
},
|
// 主表数据改变
|
onChange(ref, val, field, formData) {
|
switch (field.options.prop) {
|
case "providerShortName":
|
this.$refs["selector-dialog"].setSearchValue("provider_Id", [val]);
|
this.$refs["selector-dialog"].loadData();
|
break;
|
case "storageName":
|
this.$refs["selector-position-dialog"].setSearchValue("storageName", formData.storageName);
|
this.$refs["selector-position-dialog"].loadData();
|
break;
|
case "consignorName":
|
this.$refs["selector-position-dialog"].setSearchValue("consignorName", formData.consignorName);
|
this.$refs["selector-position-dialog"].loadData();
|
break;
|
}
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 明细数据改变时触发
|
onDetailChange() {
|
// 合计数量求和
|
let totalQuantity = 0;
|
let totalMoney = 0.0;
|
var formData = this.editor.formData;
|
var detailRows = formData["storage_AllocateApplyList"].rows;
|
detailRows.forEach(item => {
|
totalQuantity += item.quantity || 0;
|
item.purchaseMoney = (item.quantity || 0) * (item.purchasePrice || 0);
|
totalMoney += item.purchaseMoney;
|
});
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("totalMoney", totalMoney);
|
},
|
// 明细导出
|
exportList() {
|
const ids = [];
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_AllocateApplyList"].rows;
|
detailRows.map((item, index, array) => {
|
ids.push(item.allocateApplyList_Id);
|
});
|
var url = "/api/storage/allocateApply/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/allocateApply/importExel";
|
const ref = this.dataList;
|
const params = {
|
url: this.fullFileRote,
|
allocateApply_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);
|
},
|
// 求和
|
setTotal() {
|
// 合计数量求和
|
let totalQuantity = 0;
|
let totalMoney = 0.0;
|
let totalWeight = 0.0;
|
this.detailRows.forEach(item => {
|
// 明细金额 = 数量 * 单价;
|
// item.purchaseMoney = Math.Round((item.quantity || 0) * (item.purchasePrice || 0), 2);
|
// 行重量
|
// item.totalWeight = Math.Round((item.quantity || 0) * (item.weight || 0), 2);
|
|
totalQuantity += item.quantity || 0;
|
totalMoney += item.purchaseMoney || 0;
|
totalWeight += item.totalWeight || 0;
|
});
|
|
this.editor.changeValue("totalQuantity", parseFloat(totalQuantity.toFixed(4)));
|
this.editor.changeValue("totalMoney", parseFloat(totalMoney).toFixed(2));
|
this.editor.changeValue("totalWeight", totalWeight);
|
},
|
// 保存前事件
|
onSaveBefore() {
|
this.setTotal();
|
}
|
}
|
};
|
</script>
|