<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-batch-auditing-before="onBatchAuditingBefore">
|
<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==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" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :default-value="defaultValue" :btn-read-only="btnReadOnly" :on-save-before="onSaveBefore" @on-detail-change="onDetailChange" @on-edit-load-after="onEditLoadAfter" @on-add-load-after="onEditLoadAfter">
|
<!--自定义按钮插槽-->
|
<template slot="footer-button-region" slot-scope="{ formData, details }">
|
<!--打印条码按钮-->
|
<el-button :disabled="btnReadOnly.ToPurchaseOrder" type="success" icon="el-icon-yrt-zhuanyiwenti" @click.native="toPurchaseOrder(formData, details)">转到预到货单</el-button>
|
</template>
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected">
|
</yrt-selector>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
|
export default {
|
name: "inbound-purchase-damaged-order",
|
components: {
|
yrtSelector
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {},
|
// 状态值
|
statusValueList: [
|
{
|
status: "已审核",
|
bgColor: "#33cc33",
|
color: "#fff"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "审核失败",
|
bgColor: "#ffcc66",
|
color: "#fff"
|
},
|
{
|
status: "已转预到货单",
|
bgColor: "#00ccff",
|
color: "#fff"
|
},
|
{
|
status: "终止",
|
bgColor: "#ff6600",
|
color: "#fff"
|
}
|
]
|
};
|
},
|
created() {
|
var userInfo = this.common.getUserInfo();
|
this.defaultValue = {
|
user_Id: userInfo.user_Id,
|
userTrueName: userInfo.userTrueName,
|
dept_Id: userInfo.dept_Id,
|
deptName: userInfo.deptName
|
};
|
},
|
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.detailAdd();
|
return true;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
rows.forEach(row => {
|
row.DamagedData = new Date();
|
row.quantity = 1;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 明细添加
|
detailAdd() {
|
var editorRef = this.editor;
|
const provider_Id = this.editor.formData["provider_Id"];
|
if (!provider_Id) {
|
this.$message.error("请先选择供应商!");
|
return false;
|
} else {
|
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();
|
|
// this.selectorConfig.visible = true;
|
// this.$refs["selector-dialog"].setSearchValue("provider_Id", [provider_Id]);
|
// this.$refs["selector-dialog"].loadData();
|
// this.$refs["selector-dialog"].setReadOnly("consignor_Id", true);
|
}
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
this.setTotal();
|
},
|
// 求和
|
setTotal() {
|
var formData = this.editor.formData;
|
var detailRows = formData["Purchase_DamagedOrderList"].rows;
|
// 合计数量求和
|
let totalQuantity = 0;
|
let totalMoney = 0.0;
|
detailRows.forEach(item => {
|
if (item.Quantity !== null || item.PurchasePrice !== null) {
|
// 金额 = 数量 * 单价;
|
item.PurchaseMoney = parseFloat(((item.Quantity || 0) * (item.PurchasePrice || 0)).toFixed(2));
|
}
|
item.purchaseMoney = item.quantity * item.purchasePrice;
|
totalQuantity += item.quantity || 0;
|
totalMoney += item.purchaseMoney || 0;
|
});
|
|
this.editor.changeValue("totalQuantity", parseFloat(totalQuantity.toFixed(4)));
|
this.editor.changeValue("totalMoney", parseFloat(totalMoney).toFixed(2));
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if (statusText === "新建") {
|
// 新建
|
this.btnReadOnly.auditing = false;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = false;
|
this.btnReadOnly.ToPurchaseOrder = true;
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (statusText === "审核成功") {
|
// 审核成功
|
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; // 整个对话框可编辑
|
} else if (statusText === "已转预到货单") {
|
// 已转预到货单
|
this.btnReadOnly.auditing = true;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = true;
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.ToPurchaseOrder = true;
|
this.editorOptions.config.disabled = true; // 整个对话框可编辑
|
} else if (statusText === "终止") {
|
// 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; // 整个对话框可编辑
|
} 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; // 整个对话框可编辑
|
}
|
},
|
// 保存前事件
|
onSaveBefore(formData) {
|
let isQuantity = true; // 验证数量
|
var detailRows = formData["Purchase_DamagedOrderList"].rows;
|
if (!detailRows.length) {
|
this.$message.error("明细不能为空!");
|
return false;
|
}
|
detailRows.forEach(item => {
|
if (item.quantity <= 0 || !item.quantity) {
|
isQuantity = false;
|
}
|
});
|
if (!isQuantity) {
|
this.$message.error("明细列表数量必须大于0!");
|
return false;
|
}
|
this.setTotal();
|
},
|
// 批量审核前事件
|
onBatchAuditingBefore(rows) {
|
let isOK = true;
|
rows.forEach(row => {
|
if (row.statusText !== "新建") {
|
isOK = false;
|
}
|
});
|
if (!isOK) {
|
this.$message.error("只有新建状态的单子才允许审核!");
|
return false;
|
}
|
return true;
|
},
|
// 转到预到货单
|
toPurchaseOrder(formData, details) {
|
if (formData.statusText !== "审核成功") {
|
this.$message.error("不是审核成功的单子不允许转移到预到货单!");
|
return;
|
}
|
const url = "/api/inbound/damagedOrder/toPurchaseOrder";
|
const params = {
|
openNodeApi: true,
|
damagedOrder_Id: formData.damagedOrder_Id
|
};
|
const ref = this.dataList;
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.editor.config.visible = false;
|
ref.loadData();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
}
|
}
|
};
|
</script>
|