<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">
|
|
</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.sorting" type="success" icon="el-icon-yrt-gouxuan1" @click.native="sorting(formData)">分拣</el-button>
|
<!-- 确认过户 -->
|
<el-button :disabled="btnReadOnly.transferConfirm" type="success" icon="el-icon-yrt-gouxuan1" @click.native="transferConfirm(formData)">确认过户</el-button>
|
</template>
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @on-selected="onSelected"></yrt-selector>
|
<!--明细导入-->
|
<batch-import ref="batchimport-dialog" :visible.sync="batchimportVisible"></batch-import>
|
<!--物料库存选择器-->
|
<yrt-selector ref="selector-position-dialog" :config="selectorPositionConfig" :visible.sync="selectorPositionConfig.visible" :url="selectorPositionConfig.url" :set-search-default="setSearchDefault" :get-custom-where="getCustomWhere" @on-selected="onPositionSelected">
|
<template slot="search-form-item">
|
<el-select v-model="operationType" splaceholder="账面库存量" class="w-150">
|
<el-option label="库存大于0" value=">0">
|
</el-option>
|
<el-option label="库存大于等于0" value=">=0">
|
</el-option>
|
<el-option label="库存等于0" value="=0">
|
</el-option>
|
<el-option label="全部" value="">
|
</el-option>
|
</el-select>
|
</template>
|
</yrt-selector>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
import batchImport from "./components/batch-import.vue";
|
|
export default {
|
name: "storage-transfer-consignor-transfer",
|
components: {
|
yrtSelector,
|
batchImport
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorConfig: {
|
title: "资产选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 批量拆分导入是否显示
|
batchimportVisible: false,
|
selectorPositionConfig: {
|
title: "物料库存选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/x-product-selector",
|
url: "/api/common/GroupDataList"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {
|
StatusID: 1,
|
StatusText: "新建",
|
auditing: 0,
|
SortingStatus: 1
|
},
|
operationType: null
|
};
|
},
|
activated() {
|
// SaaS模块权限
|
this.common.hasSaaSAuth("货主过户", this.$refs.container);
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "batchConfirm":
|
// 批量审核
|
this.auditing(this.dataListSelections);
|
return false;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
break;
|
case "batchImport":
|
// 明细导入
|
this.batchImport();
|
break;
|
case "batchexport":
|
// 明细导入
|
this.batchexport();
|
break;
|
case "detailAddPisition":
|
this.openPositionSelected();
|
break;
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.auditing([formData]);
|
return false;
|
}
|
},
|
// 打开库存选择器
|
openPositionSelected() {
|
var editorRef = this.editor;
|
|
this.$refs["selector-position-dialog"].setSearchValue("storage_Id", [editorRef.formData.storage_Id]);
|
this.$refs["selector-position-dialog"].setReadOnly("storage_Id", true); // 设为只读
|
this.$refs["selector-position-dialog"].loadData();
|
|
this.selectorPositionConfig.visible = true;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onPositionSelected(rows) {
|
rows.forEach(element => {
|
element.Quantity = element.ProductStorage;
|
this.$set(element, "PositionName_In", element.PositionName);
|
this.$set(element, "transferQuantity", element.ProductStorage);
|
});
|
|
this.editor.addDetailDataRow(rows);
|
this.selectorPositionConfig.visible = false;
|
}, // 查询条件改变
|
getCustomWhere(val) {
|
var where = {};
|
if (this.operationType === ">0") {
|
where.productStorage = {
|
operator: ">",
|
value: 0
|
};
|
} else if (this.operationType === ">=0") {
|
where.productStorage = {
|
operator: ">=",
|
value: 0
|
};
|
} else if (this.operationType === "=0") {
|
where.productStorage = {
|
operator: "=",
|
value: 0
|
};
|
}
|
return where;
|
},
|
// 审核
|
auditing(dataListSelections) {
|
const consignorTransfer_Ids = dataListSelections.map((item, index, Array) => {
|
return item.consignorTransfer_Id;
|
});
|
if (!consignorTransfer_Ids.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
this.$confirm("提示:确认后将无法进行修改", "确认审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/Storage/storageConsignorTransfer/auditing";
|
const params = {
|
openNodeApi: true,
|
idValue: consignorTransfer_Ids,
|
auditing: 2
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.editorOptions.config.visible = false;
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
// 保存前
|
onSaveBefore(formData) {
|
this.setTotal();
|
var flag = true;
|
let isPositionName = true;
|
let productModel = "";
|
var detailRows = formData["Storage_ConsignorTransferList"].rows;
|
detailRows.forEach(item => {
|
productModel = item.productModel;
|
if (item.transferQuantity === 0) {
|
flag = false;
|
}
|
if (!item.positionName_In || !item.positionName) {
|
isPositionName = false;
|
}
|
});
|
if (!flag) {
|
this.$message({
|
type: "error",
|
message: productModel + "条码:明细中转移数量不能为0"
|
});
|
return false;
|
}
|
if (!isPositionName) {
|
this.$message({
|
type: "error",
|
message: productModel + "条码:原货位与目标货位不能为空"
|
});
|
return false;
|
}
|
},
|
// 分拣
|
sorting(formData) {
|
var the = this;
|
this.$confirm("将进行分拣操作, 是否继续?", "分拣操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
_sorting();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "取消分拣"
|
});
|
});
|
function _sorting() {
|
var formData = the.editor.formData;
|
var id = formData[the.dataOptions.idField];
|
|
const ref = the.dataList;
|
const url = "/api/Storage/storageConsignorTransfer/startSorting";
|
the.initLoading = true;
|
var params = {
|
id: id
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
}
|
the.initLoading = false;
|
},
|
true
|
);
|
}
|
},
|
// 过户确认
|
transferConfirm(formData) {
|
var the = this;
|
if (formData.SortingStatus === 3) {
|
this.$message.error("缺货中,不允许过户!");
|
return false;
|
}
|
const ref = the.dataList;
|
the
|
.$confirm("将进行过户操作, 是否继续?", "过户操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const id = formData.consignorTransfer_Id;
|
const url = "/api/Storage/storageConsignorTransfer/transferConfirm";
|
const params = {
|
id: id
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
the.common.showMsg(res);
|
if (res.result) {
|
this.editorOptions.config.visible = false;
|
ref.loadData();
|
}
|
},
|
true
|
);
|
})
|
.catch(res => {
|
the.$message({
|
type: "info",
|
message: "取消过户"
|
});
|
});
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText; // 过户状态
|
if (statusText === "新建") {
|
this.$set(this.btnReadOnly, "auditing", false);
|
this.$set(this.btnReadOnly, "sorting", true);
|
this.$set(this.btnReadOnly, "transferConfirm", true);
|
this.$set(this.btnReadOnly, "save", false);
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (statusText === "过户完成") {
|
this.$set(this.btnReadOnly, "auditing", true);
|
this.$set(this.btnReadOnly, "sorting", true);
|
this.$set(this.btnReadOnly, "transferConfirm", true);
|
this.$set(this.btnReadOnly, "save", true);
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else if (statusText === "审核成功") {
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.sorting = false;
|
this.btnReadOnly.transferConfirm = false;
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
}
|
},
|
// 明细数据改变时触发
|
onDetailChange() {
|
this.setTotal();
|
},
|
// 明细求和
|
setTotal() {
|
// 合计数量求和
|
let totalQuantity = 0; // 合计数量
|
let totalMoney = 0.0; // 合计金额
|
// let totalWeight = 0; // 毛重合计
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_ConsignorTransferList"].rows;
|
detailRows.forEach(item => {
|
totalQuantity += item.transferQuantity || 0;
|
item.subTotalMoney = (item.purchasePrice || 0) * totalQuantity;
|
totalMoney = item.subTotalMoney;
|
// totalWeight = item.totalWeight;
|
item.totalWeight = item.transferQuantity * item.weight;
|
});
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("totalMoney", totalMoney);
|
// this.editor.changeValue("totalWeight", totalWeight);
|
},
|
// 明细导入
|
batchImport() {
|
const rows = [];
|
this.batchimportVisible = true;
|
this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
|
rows.push(rowData);
|
});
|
this.$refs["batchimport-dialog"].showData(rows);
|
},
|
// 批量导出
|
batchexport() {
|
var the = this;
|
if (this.editor.detailFields[0].options.detailSelections.length < 1) {
|
this.$message.error("至少选中一行明细数据!");
|
return false;
|
}
|
const ConsignorTransferCode = this.editor.formData.ConsignorTransferCode;
|
|
const idValues = [];
|
this.dataListSelections.forEach(rowData => {
|
idValues.push(rowData[this.dataOptions.idField]);
|
});
|
var where = "ConsignorTransferCode = '" + ConsignorTransferCode + "'";
|
var url = "/api/common/exportData";
|
var tableName = the.dataOptions.tableName || the.dataOptions.tableView;
|
var params = Object.assign({}, the.dataOptions, {
|
tableName: tableName,
|
idValues: idValues.join(","),
|
where: where
|
});
|
this.initLoading = true;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
window.open(the.common.domain + res.data);
|
}
|
this.initLoading = false;
|
};
|
the.common.ajax(url, params, callback, false);
|
},
|
// 主表数据改变
|
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) {}
|
}
|
};
|
</script>
|