<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" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
|
<template slot="common-column-slot" slot-scope="{row, col}">
|
<template v-if="col.prop=='quotationStatus'">
|
<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==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" :btn-read-only="btnReadOnly" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :default-value="defaultValue" :on-save-before="onSaveBefore" @on-detail-change="onDetailChange" @on-edit-load-after="onEditLoadAfter" @on-add-load-after="onEditLoadAfter" @on-load-dropdown-after="onLoadDropdownAfter">
|
<!--自定义按钮插槽-->
|
<!-- <template slot="footer-button-region" slot-scope="{ formData, details }"> -->
|
<!--转到预到货单按钮-->
|
<!-- <el-button v-if="authNodes.toPurchaseOrder" :disabled="btnReadOnly.toPurchaseOrder" type="success" icon="el-icon-yrt-saomiao8" @click.native="toPurchaseOrderVisible(formData, details)">转到预到货单</el-button>
|
</template> -->
|
</yrt-editor>
|
<!-- 主表批量导入 -->
|
<import-dialog :visible.sync="orderImportConfig.isShowDialog" :import-config="orderImportConfig" @on-close="onImportClose">
|
</import-dialog>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
|
|
<!--转到预到货单窗口-->
|
<el-dialog :visible.sync="providerDialogVisible" title="选择供应商" width="400px">
|
<el-select v-model="provider_Id" placeholder="请选择">
|
<el-option v-for="item in providerList" :key="item.provider_Id" :label="item.providerShortName" :value="item.provider_Id">
|
</el-option>
|
</el-select>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="providerDialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="toPurchaseOrder">确 定</el-button>
|
</span>
|
</el-dialog>
|
|
<!-- 入库计划单批量导入 -->
|
<el-dialog v-dialogDrag :visible.sync="dialogLandingTime" title="出库单批量导入">
|
<el-form :model="form">
|
<el-form-item label="货主名称">
|
<el-select v-model="form.consignor_Id" placeholder="请选择">
|
<el-option v-for="item in consignorNames" :key="item.consignor_Id" :label="item.consignorName" :value="item.consignor_Id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<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>
|
|
<el-scrollbar :noresize="false" :native="false" wrap-class="scrollbar-wrap">
|
<ul class="msg-container">
|
<li v-for="(item, index) in msgList" :key="index" class="msg-item" v-html="item">
|
{{ index + 1 }}、{{ item }}
|
</li>
|
</ul>
|
</el-scrollbar>
|
<div ref="loading"></div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
import ImportDialog from "@/components/common/components/import-common-dialog";
|
var moment = require("moment");
|
|
export default {
|
name: "inbound-purchase-quotation",
|
components: {
|
yrtSelector,
|
ImportDialog
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 配置参数
|
config: {
|
in_autoGenerateBatchCode: false,
|
in_autoSingleSignCode: false
|
},
|
// 出库单导入对话框参数
|
orderImportConfig: {
|
// 显示导入对话框
|
isShowDialog: false,
|
title: "冲压生产计划导入",
|
// 导入地址
|
url: "/api/inbound/quotation/import",
|
// 模板地址
|
templateUrl: "/upload/template/冲压计划导入模板.xlsx"
|
},
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 状态值
|
statusValueList: [
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#fff"
|
},
|
{
|
status: "已审核",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "完全交货",
|
bgColor: "#009999",
|
color: "#fff"
|
},
|
{
|
status: "已转预到货单",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#fff"
|
}
|
],
|
// 供应商信息
|
providerList: [],
|
provider_Id: "",
|
providerShortName: "",
|
// 显示供应商窗口
|
providerDialogVisible: false,
|
form: {
|
consignor_Id: null
|
},
|
consignorNames: [],
|
// 导出框
|
dialogLandingTime: false,
|
// 文件名
|
fileUrl: null,
|
fileList: [],
|
// 消息内容
|
msgList: [],
|
// 导入获得消息interval handle
|
intervalHandler: null,
|
// 导入key
|
uploadKey: null,
|
// 编辑新建时表单默认值
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建"
|
}
|
};
|
},
|
mounted() {
|
this.getProvider();
|
this.getConsignorList();
|
},
|
methods: {
|
// 获得供应商信息
|
getProvider() {
|
const url = "/api/basicInfo/base/provider/getList";
|
const params = {};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.providerList = res.data;
|
}
|
});
|
},
|
// 获取货主名称下拉框
|
getConsignorList() {
|
const url = "/api/basicInfo/base/consignor/getList";
|
const params = {
|
openNodeApi: true
|
};
|
var callback = res => {
|
if (res.result) {
|
this.consignorNames = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 导入窗口关闭时事件
|
onImportClose() {
|
this.dataList.reload();
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 批量审核
|
this.multiAuditing();
|
return false;
|
case "importall":
|
// 入库导入
|
this.orderImportConfig.isShowDialog = true;
|
return true;
|
}
|
},
|
// 状态背景颜色
|
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
|
};
|
},
|
// 明细添加
|
detailAdd() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.consignor_Id) {
|
this.$message.error("请选择货主!");
|
return false;
|
}
|
this.selectorConfig.visible = true;
|
const selector = this.$refs["selector-dialog"];
|
// selector.setSearchValue("provider_Id", [editorRef.formData.provider_Id]);
|
selector.setSearchValue("consignor_Id", [editorRef.formData.consignor_Id]);
|
// selector.setReadOnly("provider_Id", true); // 设为只读
|
selector.setReadOnly("consignor_Id", true); // 设为只读
|
selector.loadData();
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
// 设置默认值
|
rows.forEach(element => {
|
element.quantity = 1;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.detailAdd();
|
return true;
|
}
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
// debugger;
|
// 合计数量求和
|
let totalQuantityOrder = 0;
|
let totalWeight = 0;
|
let grandTotal = 0;
|
var formData = this.editor.formData;
|
var detailRows = formData["TMS_QuotationList"].rows;
|
// 合计
|
detailRows.forEach(item => {
|
if (item.quantityOrder) {
|
totalQuantityOrder += item.quantityOrder;
|
}
|
if (!item.quantityOrder) {
|
item.rowTotal = 0;
|
} else {
|
item.rowTotal = item.quantityOrder * item.purchasePrice;
|
}
|
if (item.rowTotal) {
|
grandTotal += item.rowTotal;
|
}
|
// 行小计重量
|
if (field) {
|
// debugger;
|
// weight 单位毛重 / totalWeight 小计毛重 quantityOrder 数量
|
if (field.prop === "quantityOrder" || field.prop === "weight") {
|
// 小计 = 数量 * 单位毛重
|
const totalWeight = Math.Round((item.quantityOrder || 0) * (item.weight || 0), 4);
|
// 数量 复制 总件数
|
this.$set(item, "totalPackageQty", item.quantityOrder);
|
this.$set(item, "totalWeight", totalWeight);
|
} else if (field && field.prop === "totalWeight") {
|
// 修改合计重量,计算出单位重量
|
if (item.quantityOrder) {
|
const weight = Math.Round((item.totalWeight || 0) / (item.quantityOrder || 0), 4);
|
this.$set(item, "weight", weight);
|
} else {
|
this.$set(item, "weight", 0);
|
}
|
}
|
}
|
// 建议拍数 = 总件数 / 打包配置
|
item.paiQty = item.unitPackage ? Math.ceil(item.totalPackageQty / item.unitPackage) : 0;
|
// 同步主表合计重量
|
if (item.totalWeight) {
|
totalWeight += item.totalWeight;
|
}
|
if (item.unitPackageType === "按数量") {
|
item.totalPackageQty = item.quantityOrder;
|
} else if (item.unitPackageType === "按毛重") {
|
item.totalPackageQty = item.totalWeight;
|
}
|
// else if (item.unitPackageType === "按大单位数量") {
|
// item.totalPackageQty = item.bigUnitRounding;
|
// }
|
});
|
this.editor.changeValue("totalQuantityOrder", totalQuantityOrder);
|
this.editor.changeValue("grandTotal", Math.Round(grandTotal, 4));
|
this.editor.changeValue("totalWeight", Math.Round(totalWeight, 4));
|
},
|
// 显示转到预到货单窗口
|
toPurchaseOrderVisible(formData, details) {
|
this.providerDialogVisible = true;
|
},
|
// 转到预到货单
|
toPurchaseOrder() {
|
if (!this.provider_Id) {
|
this.$message.error("请选择供应商");
|
return;
|
}
|
const formData = this.editor.formData;
|
const quotation_Id = formData.quotation_Id;
|
const url = "/api/inbound/quotation/changePurchaseOrder";
|
const params = {
|
quotation_Id: quotation_Id,
|
provider_Id: this.provider_Id
|
};
|
const ref = this.dataList;
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
this.editorOptions.config.visible = false;
|
this.providerDialogVisible = false;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 数据加载后,设置是否可编辑
|
onEditLoadAfter(formData) {
|
// 设置工厂名称第一条,只有新建时设置默认第一条
|
const consignorDropdown = this.editor.getDropdownData(797);
|
if (consignorDropdown && consignorDropdown.length && !this.masterData.quotation_Id) {
|
const conInfo = consignorDropdown[0];
|
this.editor.changeValue("consignor_Id", conInfo.consignor_Id);
|
this.editor.changeValue("consignorCode", conInfo.consignorCode);
|
this.editor.changeValue("consignorName", conInfo.consignorName);
|
}
|
var quotationStatus = formData.quotationStatus;
|
if (quotationStatus === "新建") {
|
// 新建
|
this.btnReadOnly.auditing = false;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.copy = true;
|
this.btnReadOnly.save = false;
|
this.btnReadOnly.toPurchaseOrder = false;
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (quotationStatus === "已审核") {
|
// 审核成功
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.toPurchaseOrder = false;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
this.btnReadOnly.copy = false;
|
} else if (quotationStatus === "已转预到货单") {
|
// 已转预到货单
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.toPurchaseOrder = true;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
this.btnReadOnly.copy = false;
|
}
|
// else if (quotationStatus === "终止") {
|
// // 9-终止
|
// this.btnReadOnly.auditing = true;
|
// this.btnReadOnly.stop = true;
|
// this.btnReadOnly.open = false;
|
// this.btnReadOnly.save = true;
|
// this.btnReadOnly.toPurchaseOrder = true;
|
// this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
// this.btnReadOnly.copy = false;
|
// } else {
|
// this.btnReadOnly.auditing = true;
|
// this.btnReadOnly.stop = true;
|
// this.btnReadOnly.open = true;
|
// this.btnReadOnly.save = true;
|
// this.btnReadOnly.toPurchaseOrder = true;
|
// this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
// this.btnReadOnly.copy = false;
|
// }
|
},
|
// 批量审核
|
multiAuditing() {
|
const the = this;
|
// 获得已选中的ID
|
var IsStatusText = true;
|
const selectIDs = the.dataListSelections
|
.map((item, index, Array) => {
|
if (item.quotationStatus !== "新建") {
|
IsStatusText = false;
|
}
|
return item.quotation_Id;
|
})
|
.join(",");
|
if (!selectIDs) {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
if (!IsStatusText) {
|
this.$message({
|
message: "只允许审核新建状态的计划单!",
|
type: "warning"
|
});
|
return;
|
}
|
this.$confirm("确定要批量进行审核操作吗?", "批量审核", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/inbound/quotation/multiConfirm";
|
const params = {
|
openNodeApi: true,
|
selectIDs: 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: "已取消"
|
});
|
});
|
},
|
// 保存前事件
|
onSaveBefore(formData) {
|
// 生成数据
|
this.detailRows.forEach((row, index) => {
|
debugger;
|
const currentDate = moment(new Date());
|
if (!row.batchNumber) {
|
row.batchNumber = currentDate.format("YYYYMMDD") + "-" + (index + 1);
|
row.__ischange__ = true;
|
}
|
});
|
// var isQuantity = true;
|
var datarows = formData["TMS_QuotationList"].rows;
|
if (!datarows.length) {
|
this.$message.error("明细不能为空!");
|
return false;
|
}
|
// datarows.forEach(item => {
|
// if (!item.storageName) {
|
// isQuantity = false;
|
// }
|
// });
|
// if (!isQuantity) {
|
// this.$message.error("明细列表仓库不能为空!");
|
// return false;
|
// }
|
|
// 验证是否存在提示
|
const url = "/api/inbound/quotation/getExistContainNo";
|
const params = {
|
quotation_Id: formData.quotation_Id,
|
containerNo: formData.containerNo
|
};
|
this.common.ajax(url, params, res => {
|
if (res.result) {
|
this.$confirm("当前库存中已存在该集装箱号,是否确定?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 点击确认按钮后执行保存操作
|
this.editor.save();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消保存"
|
});
|
});
|
} else {
|
// 没有重复的,直接执行保存,不提示
|
this.editor.save();
|
}
|
});
|
|
return false; // 返回false,不执行底层默认保存
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
handleRemove(file, fileList) {
|
this.fileUrl = null;
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fileUrl = res.data.url;
|
},
|
// importall() {
|
// // window.location.href = "#/inbound/purchase/inbound/import/quotation";
|
// this.$router.push("/inbound/import/quotation");
|
// },
|
submitImport() {
|
if (!this.fileUrl) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
if (!this.form.consignor_Id) {
|
this.$message.error("请选择货主!");
|
return;
|
}
|
this.msgList = [];
|
let consignorName = null;
|
for (var index in this.consignorNames) {
|
if (this.consignorNames[index].consignor_Id === this.form.consignor_Id) {
|
consignorName = this.storageNames[index].consignorName;
|
}
|
}
|
const url = "/api/outbound/order/importExcel";
|
const params = {
|
key: this.uploadKey,
|
url: this.fileUrl,
|
consignorName: consignorName
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
this.getMsg();
|
this.fileList = [];
|
}
|
};
|
this.common.ajax(url, params, callback, this.$refs.loading);
|
}, // 获得导入消息
|
getMsg() {
|
// 获得同步消息
|
var url = "/api/common/getUploadMsg";
|
const params = {
|
key: this.uploadKey
|
};
|
var callBack = res => {
|
if (!res.result) {
|
window.clearInterval(this.intervalHandler);
|
this.intervalHandler = false;
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data);
|
}
|
return;
|
}
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data.filter(item => item !== "-1"));
|
}
|
if (res.data.indexOf("-1") >= 0) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = null;
|
this.dataList.reload();
|
return;
|
}
|
this.intervalHandler = window.setTimeout(this.getMsg, 1000);
|
};
|
this.common.ajax(url, params, callBack, this.$refs.loading);
|
},
|
// 选择供应商
|
onChang(item) {},
|
// 新建设置默认值,编辑页面下拉框加载完毕后
|
onLoadDropdownAfter() {
|
// 设置工厂名称第一条,只有新建时设置默认第一条
|
const consignorDropdown = this.editor.getDropdownData(797);
|
if (consignorDropdown && consignorDropdown.length && !this.masterData.quotation_Id) {
|
const conInfo = consignorDropdown[0];
|
this.editor.changeValue("consignor_Id", conInfo.consignor_Id);
|
this.editor.changeValue("consignorCode", conInfo.consignorCode);
|
this.editor.changeValue("consignorName", conInfo.consignorName);
|
}
|
}
|
}
|
};
|
</script>
|