<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 == 'goodsText'">
|
<template>
|
<el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])" class="cursor-pointer">
|
{{ row[col.prop] }}
|
</el-tag>
|
</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" :use-detail-slot="['sortingStatus', 'lackStorage']" :on-save-before="onSaveBefore" @on-detail-change="onDetailChange">
|
</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: "outbound-require-goods",
|
components: {
|
yrtSelector
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 预到货状态值
|
statusValueList: [
|
{
|
status: "审核成功",
|
bgColor: "#00ff99",
|
color: "black"
|
},
|
{
|
status: "新建",
|
bgColor: "#ffff66",
|
color: "#000"
|
},
|
{
|
status: "生成调拨单",
|
bgColor: "#0066ff",
|
color: "#fff"
|
}
|
],
|
// 选择器配置参数
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
}
|
};
|
},
|
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 = "#000000";
|
if (colorItem) color = colorItem.color;
|
|
return {
|
border: 0,
|
color: color
|
};
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "createAllocation":
|
// 生成调拨单
|
this.createAllocation(this.dataListSelections);
|
break;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "detailAdd":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
return true;
|
}
|
},
|
// 将明细选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
rows.forEach(element => {
|
// element.sortingStatus = 1;
|
// element.quantityOrder = 1;
|
element.productPrice = element.salePrice;
|
// element.totalWeight = Math.Round((element.weight || 0) * element.quantityOrder, 2);
|
// element.ratePrice = Math.Round((element.salePrice || 0) * (1 + (element.rate || 0)), 2);
|
// element.rateMoney = Math.Round(element.ratePrice * element.quantityOrder, 2);
|
// element.discountRate = 1;
|
// element.salePriceDiscount = element.salePrice;
|
// element.subTotal = element.rowTotal;
|
});
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 明细字段改变
|
onDetailChange(ref, val, row, field) {
|
this.setTotal();
|
},
|
// 求和
|
setTotal() {
|
var totalQuantity = 0; // 合计数量
|
var productMoney = 0; // 物料金额
|
var formData = this.editor.formData;
|
var detailRows = formData["Require_GoodsList"].rows;
|
detailRows.forEach(item => {
|
item.productTotal = (item.goodsQuantity || 0) * (item.productPrice || 0);
|
totalQuantity += item.goodsQuantity;
|
productMoney += item.productTotal;
|
});
|
this.editor.changeValue("totalQuantity", totalQuantity);
|
this.editor.changeValue("productMoney", productMoney);
|
},
|
// 生成调拨单
|
createAllocation(dataList) {
|
const the = this;
|
this.$confirm("确定要生成调拨单操作吗?", "生成调拨单", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
const selectIDs = dataList
|
.map((item, index, Array) => {
|
return item.goods_Id;
|
})
|
.join(",");
|
if (selectIDs === "") {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
}
|
const url = "/api/outbound/goods/toAllocation";
|
const params = {
|
openNodeApi: true,
|
goods_Id: 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) {
|
var detailRows = formData["Require_GoodsList"].rows;
|
for (const item of detailRows) {
|
if (item.goodsQuantity <= 0) {
|
this.$message.error(`明细【${item.productName}】要货数量必须大于0!`);
|
return false;
|
}
|
}
|
this.setTotal();
|
}
|
}
|
};
|
</script>
|