<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==dataOptions.linkColumn">
|
<el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
|
</template>
|
<template v-else>
|
{{ row[col.prop] }}
|
</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" :default-value="defaultValue">
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @onSelected="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-enter",
|
components: {
|
yrtSelector
|
},
|
mixins: [baseLayout],
|
// 自定义处理权限函数
|
doAuth(the) {
|
// 判断当前版本是否拥有导入权限
|
var authList = [{ name: "入库撤销", auth: "cancelEnter" }, { name: "打印入库单", auth: "print" }];
|
const names = authList.map(item => {
|
return item.name;
|
});
|
the.common.isSaaSAuth(names, res => {
|
authList.forEach(node => {
|
let hasAuth = res.result;
|
if (hasAuth) {
|
hasAuth = res.data.some(item => {
|
return item.moduleName === node.name;
|
});
|
}
|
the.authNodes[node.auth] = hasAuth;
|
});
|
});
|
},
|
data() {
|
return {
|
selectorConfig: {
|
title: "物料选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建"
|
},
|
// 入库记录状态值
|
statusValueList: [
|
{
|
status: "取消入库",
|
bgColor: "#ff00cc",
|
color: "#fff"
|
},
|
{
|
status: "确认入库",
|
bgColor: "#5353ff",
|
color: "#fff"
|
},
|
{
|
status: "部分上架",
|
bgColor: "#cc66ff",
|
color: "#fff"
|
},
|
{
|
status: "完全上架",
|
bgColor: "#00ccff",
|
color: "#fff"
|
}
|
]
|
};
|
},
|
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
|
};
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 批量审核
|
this.multiAuditing();
|
return true;
|
case "cancelEnter":
|
// 撤销入库
|
this.cancelEnter();
|
return true;
|
case "getFeeItem":
|
// 生成一次性费用
|
this.getFeeItem(this.dataListSelections);
|
break;
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
return true;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 撤销入库
|
cancelEnter() {
|
let isok = true;
|
const statusText = this.dataListSelections.map((item, index, Array) => {
|
return item.statusText;
|
});
|
const enter_Id = this.dataListSelections.map((item, index, Array) => {
|
return item.enter_Id;
|
});
|
if (!enter_Id.length) {
|
this.$message.error("请至少选择一行数据!");
|
return false;
|
}
|
const statusList = ["确认入库", "完全上架"];
|
statusText.forEach(rowData => {
|
if (statusList.indexOf(rowData) < 0) return (isok = false);
|
});
|
if (isok === false) {
|
this.$message.error(`只有【${statusList.join(",")}】的单据才可以执行取消操作!`);
|
return false;
|
}
|
this.$confirm("确定将选中的数据撤销入库吗?", "撤销入库", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
const url = "/api/inbound/enter/cancelEnter";
|
const params = {
|
enter_Ids: enter_Id.join(","),
|
isFullPlate: 1
|
};
|
const ref = this.dataList;
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
ref.reload();
|
}
|
};
|
this.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
},
|
|
// 生成一次性费用
|
getFeeItem() {
|
// 获得已选中的ID
|
const ids = this.dataListSelections.map((item, index, Array) => {
|
return item.enter_Id;
|
});
|
if (!ids.length) {
|
this.$message({
|
message: "至少选中一行!",
|
type: "warning"
|
});
|
return;
|
} else {
|
this.$confirm("是否要生成一次性费用", "一次性费用", {
|
distinguishCancelAndClose: true,
|
confirmButtonText: "确认"
|
}).then(() => {
|
const url = "/api/inbound/enter/getFeeItem";
|
const params = {
|
ids: ids
|
};
|
const callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.dataList.reload();
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
});
|
}
|
}
|
}
|
};
|
</script>
|