<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">
|
</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-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange">
|
</yrt-editor>
|
|
<!--明细选择器-->
|
<yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @on-selected="onSelected"></yrt-selector>
|
|
<!--物料库存选择器-->
|
<yrt-selector ref="selector-position-dialog" :config="selectorPositionConfig" :visible.sync="selectorPositionConfig.visible" :url="selectorPositionConfig.url" :set-search-default="setSearchDefault" :get-custom-where="getCustomWhere" @on-selected="onPositionSelected">
|
<template slot="search-form-item">
|
<el-select v-model="operationType" splaceholder="账面库存量" class="w-150">
|
<el-option label="库存大于0" value=">0">
|
</el-option>
|
<el-option label="库存大于等于0" value=">=0">
|
</el-option>
|
<el-option label="库存等于0" value="=0">
|
</el-option>
|
<el-option label="全部" value="">
|
</el-option>
|
</el-select>
|
</template>
|
</yrt-selector>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
|
export default {
|
name: "storage-operation-purchase-price-adjust",
|
components: {
|
yrtSelector
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
selectorConfig: {
|
title: "资产选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/s-product-selector"
|
},
|
selectorPositionConfig: {
|
title: "物料库存选择器",
|
width: "1000px",
|
visible: false,
|
// 配置路由
|
router: "/selector/x-product-selector",
|
url: "/api/common/GroupDataList"
|
},
|
// 表单默认值,新建时用
|
defaultValue: {
|
statusID: 1,
|
statusText: "新建",
|
auditing: 0
|
},
|
operationType: null
|
};
|
},
|
activated() {
|
// SaaS模块权限
|
this.common.hasSaaSAuth("库存成本调整", this.$refs.container);
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
break;
|
case "detailAddPisition":
|
this.openPositionSelected();
|
break;
|
}
|
},
|
// 打开库存选择器
|
openPositionSelected() {
|
var editorRef = this.editor;
|
if (!editorRef.formData.consignorName) {
|
this.$message({
|
message: "请选择货主!",
|
type: "warning"
|
});
|
return;
|
}
|
this.$refs["selector-position-dialog"].setSearchValue("consignor_Id", [editorRef.formData.consignor_Id]);
|
this.$refs["selector-position-dialog"].setSearchValue("storage_Id", [editorRef.formData.storage_Id]);
|
this.$refs["selector-position-dialog"].loadData();
|
this.selectorPositionConfig.visible = true;
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode) {
|
switch (authNode) {
|
case "auditing":
|
// 审核
|
this.auditing();
|
return false;
|
}
|
},
|
// 查询条件改变
|
getCustomWhere(val) {
|
var where = {};
|
if (this.operationType === ">0") {
|
where.productStorage = {
|
operator: ">",
|
value: 0
|
};
|
} else if (this.operationType === ">=0") {
|
where.productStorage = {
|
operator: ">=",
|
value: 0
|
};
|
} else if (this.operationType === "=0") {
|
where.productStorage = {
|
operator: "=",
|
value: 0
|
};
|
}
|
return where;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
this.editor.addDetailDataRow(rows);
|
this.selectorConfig.visible = false;
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onPositionSelected(rows) {
|
rows.forEach(element => {
|
element.Quantity = element.productStorage;
|
});
|
|
this.editor.addDetailDataRow(rows);
|
this.selectorPositionConfig.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 idField = the.dataOptions.idField;
|
var idValue = formData[the.dataOptions.idField];
|
var menu_Id = the.dataOptions.menu_Id;
|
const ref = the.dataList;
|
var url = "/api/storage/purchasePriceAdjust/auditing";
|
var params = {
|
idField: idField,
|
idValue: idValue,
|
menu_Id: menu_Id
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
the.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
the.editorOptions.config.visible = 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; // 整个对话框可编辑
|
}
|
},
|
// 明细数据改变时触发
|
onDetailChange() {
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_PurchasePriceAdjustList"].rows;
|
detailRows.forEach(item => {
|
item.diffPrice = item.adjustPrice - (item.purchasePrice || 0);
|
});
|
},
|
// 主表数据改变
|
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;
|
}
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {}
|
}
|
};
|
</script>
|