<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">
|
|
</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-change="onChange" @on-edit-load-after="onEditLoadAfter" @on-add-load-after="onEditLoadAfter">
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @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: "storage-allocate-enter",
|
components: { yrtSelector },
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorConfig: {
|
title: "资产选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建",
|
sortingStatus: "未分配",
|
auditing: 0
|
},
|
// 自动加载预到货单字段
|
editorData: [
|
"consignor_Id",
|
"storageName",
|
"DeptName",
|
"ApplyDate",
|
"providerShortName",
|
"ShippingName",
|
"ShippingAddress",
|
"Mobile",
|
"storage_Id"
|
]
|
};
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
break;
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.auditing();
|
return false;
|
}
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
auditing(formData) {
|
var the = this;
|
this.$confirm("审核后将无法进行修改, 是否继续?", "审核操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
_auditing();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "取消审核"
|
});
|
});
|
function _auditing() {
|
var formData = the.editor.formData;
|
var dbServer = "Sys";
|
var idField = the.dataOptions.idField;
|
var idValue = formData[the.dataOptions.idField];
|
var tableName = the.dataOptions.tableView;
|
|
const ref = the.dataList;
|
var url = "/api/storage/allocateEnter/auditing";
|
the.initLoading = true;
|
var params = {
|
dbServer: dbServer,
|
idField: idField,
|
idValue: idValue,
|
tableName: tableName,
|
auditing: 2
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
the.$message.success(res.msg);
|
ref.loadData();
|
the.editorOptions.config.visible = false;
|
} else {
|
the.$message({
|
showClose: true,
|
duration: 6000,
|
message: res.msg,
|
type: "error"
|
});
|
}
|
the.initLoading = false;
|
},
|
true
|
);
|
}
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var auditing = formData.auditing;
|
if (auditing === 2) {
|
// 审核成功
|
this.btnReadOnly.save = true;
|
this.btnReadOnly.stop = true;
|
this.btnReadOnly.open = false;
|
this.btnReadOnly.auditing = true;
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else {
|
this.btnReadOnly.save = false;
|
this.btnReadOnly.stop = false;
|
this.btnReadOnly.open = false;
|
this.btnReadOnly.auditing = false;
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
}
|
this.editor.reLoadDropDown();
|
},
|
// 主表数据改变
|
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;
|
}
|
if (field.label === "调拨申请单号") {
|
const url = "/api/storage/allocateEnter/getByCode";
|
const ref = this.dataList;
|
const params = {
|
code: formData.allocateApplyCode,
|
consignor_Id: formData.consignor_Id
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res) {
|
this.editorData.forEach(rows => {
|
this.$set(this.editor.formData, rows, res.rows);
|
});
|
this.$set(formData, "consignor_Id", res.data.consignor_Id);
|
this.$set(formData, "consignorCode", res.data.consignorCode);
|
this.$set(formData, "consignorName", res.data.consignorName);
|
this.$set(formData, "storage_Id", res.data.storage_Id);
|
this.$set(formData, "storageName", res.data.storageName);
|
this.$set(formData, "storage_Id_In", res.data.storage_Id_In);
|
this.$set(formData, "storageName_In", res.data.storageName_In);
|
if (res.data.storage_AllocateApplyList) {
|
// 默认为第一个明细表名称
|
var subTableView = this.editor.detailFields[0].subTableView;
|
var rows = this.editor.formData[subTableView].rows;
|
if (rows.length) {
|
rows = this.editor.formData[subTableView].rows = [];
|
}
|
for (var i = 0; i < res.data.storage_AllocateApplyList.length; i++) {
|
var item = res.data.storage_AllocateApplyList[i];
|
if (rows.length) {
|
rows.forEach(temp => {
|
if (item.allocateApplyList_Id !== temp.allocateApplyList_Id) {
|
this.editor.addDetailDataRow(item);
|
}
|
});
|
} else {
|
this.editor.addDetailDataRow(res.data.storage_AllocateApplyList);
|
break;
|
}
|
}
|
}
|
}
|
},
|
ref
|
);
|
}
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 求和
|
setTotal() {
|
// 合计数量求和
|
let totalQuantity = 0;
|
let totalMoney = 0.0;
|
let totalWeight = 0.0;
|
this.detailRows.forEach(item => {
|
// 明细金额 = 数量 * 单价;
|
// item.purchaseMoney = Math.Round((item.quantity || 0) * (item.purchasePrice || 0), 2);
|
// 行重量
|
// item.totalWeight = Math.Round((item.quantity || 0) * (item.weight || 0), 2);
|
|
totalQuantity += item.quantity || 0;
|
totalMoney += item.purchaseMoney || 0;
|
totalWeight += item.totalWeight || 0;
|
});
|
|
this.editor.changeValue("totalQuantity", parseFloat(totalQuantity.toFixed(4)));
|
this.editor.changeValue("totalMoney", parseFloat(totalMoney).toFixed(2));
|
this.editor.changeValue("totalWeight", totalWeight);
|
},
|
// 保存前事件
|
onSaveBefore() {
|
this.setTotal();
|
}
|
}
|
};
|
</script>
|