<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-add-load-after="onEditLoadAfter">
|
|
<template slot="footer-button-region" slot-scope="{formData}">
|
<!--自定义审核按钮-->
|
<!-- 确认调整 -->
|
<el-button :disabled="btnReadOnly.confirm" type="success" icon="el-icon-yrt-gouxuan1" @click.native="confirm(formData)">调整</el-button>
|
</template>
|
</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>
|
|
<el-dialog v-dialogDrag :visible.sync="dialogLandingTime">
|
<el-form>
|
<el-upload ref="upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill">
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitImport()">开始导入</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="primary" plain>
|
<a :href="common.ossDomain + '/node-wms/template/效期信息调整明细数据.xlsx'" style="color:while;font-size:12px;">下载模板</a>
|
</el-button>
|
<div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
|
</el-upload>
|
</el-form>
|
<div class="margin-10" v-html="importMsg">{{ importMsg }}</div>
|
<div slot="footer" class="dialog-footer">
|
<!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
|
</div>
|
</el-dialog>
|
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
import yrtSelector from "@/components/common/yrtSelector.vue";
|
|
export default {
|
name: "storage-operation-valid-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,
|
// 弹出导入框
|
dialogLandingTime: false,
|
fileList: [],
|
// 导入消息
|
importMsg: null
|
};
|
},
|
activated() {
|
// SaaS模块权限
|
this.common.hasSaaSAuth("效期调整", this.$refs.container);
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case "add":
|
// 明细添加
|
this.selectorConfig.visible = true;
|
return true;
|
case "detailAddPisition":
|
this.openPositionSelected();
|
return true;
|
case "detailExport":
|
this.exportList();
|
return true;
|
case "detailImport":
|
this.detailImport();
|
return true;
|
}
|
},
|
// 打开库存选择器
|
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) {},
|
// 将选择器选择中的数据填充到明细表中
|
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;
|
}, // 查询条件改变
|
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;
|
},
|
// 确认修改
|
confirm(formData) {
|
var the = this;
|
if (the.editor.formData.statusText === "修改完成") {
|
this.$message.error("修改完成的不允许调整");
|
return false;
|
}
|
this.$confirm("将进行确认修改操作, 是否继续?", "确认修改操作", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
_sorting();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "取消确认修改"
|
});
|
});
|
function _sorting() {
|
const formData = the.editor.formData;
|
const id = formData[the.dataOptions.idField];
|
|
const url = "/api/storage/storageValidAdjust/confirmAdjust";
|
the.initLoading = true;
|
const params = {
|
id: id
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
the.$message.success(res.msg);
|
the.dataList.reload();
|
the.editor.reload();
|
} else {
|
the.$message({
|
showClose: true,
|
duration: 6000,
|
message: res.msg,
|
type: "error"
|
});
|
}
|
the.initLoading = false;
|
},
|
false
|
);
|
}
|
},
|
// 数据加载后
|
onEditLoadAfter(formData) {
|
var statusText = formData.statusText;
|
if (statusText === "新建") {
|
this.$set(this.btnReadOnly, "save", false);
|
this.$set(this.btnReadOnly, "confirm", true);
|
this.$set(this.btnReadOnly, "auditing", false);
|
this.editorOptions.config.disabled = false; // 整个对话框可编辑
|
} else if (statusText === "审核成功") {
|
this.$set(this.btnReadOnly, "auditing", true);
|
this.$set(this.btnReadOnly, "confirm", false);
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
} else if (statusText === "修改完成") {
|
this.$set(this.btnReadOnly, "auditing", true);
|
this.$set(this.btnReadOnly, "confirm", true);
|
this.editorOptions.config.disabled = true; // 整个对话框不可编辑
|
}
|
},
|
// 主表数据改变
|
onChange(ref, val, field, formData) {
|
var StorageList = [];
|
var ConsignorList = [];
|
StorageList.push(formData.storage_Id);
|
ConsignorList.push(formData.consignor_Id);
|
switch (field.options.prop) {
|
case "storageName":
|
this.$refs["selector-position-dialog"].setSearchValue("storage_Id", StorageList);
|
this.$refs["selector-position-dialog"].loadData();
|
break;
|
case "consignorName":
|
this.$refs["selector-position-dialog"].setSearchValue("consignor_Id", ConsignorList);
|
this.$refs["selector-position-dialog"].loadData();
|
break;
|
}
|
},
|
// 对选择器默认值操作
|
setSearchDefault(searchData) {},
|
// 明细导出
|
exportList() {
|
const ids = [];
|
var formData = this.editor.formData;
|
var detailRows = formData["Storage_ValidAdjustList"].rows;
|
detailRows.map((item, index, array) => {
|
ids.push(item.validAdjustList_Id);
|
});
|
var url = "/api/storage/storageValidAdjust/exportList";
|
const params = {
|
ids: ids.join(",")
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
const url = this.common.domain + "/api/common/download?url=" + res.data.url;
|
window.open(url);
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 明细导入
|
detailImport() {
|
this.dialogLandingTime = true;
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
handleRemove(file, fileList) {
|
this.fullFileRote = null;
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fullFileRote = res.data.url;
|
},
|
// 导入
|
submitImport() {
|
var the = this;
|
var formData = the.editor.formData;
|
var idValue = formData[the.dataOptions.idField];
|
this.importMsg = null;
|
if (!this.fullFileRote) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
const url = "api/storage/storageValidAdjust/importExel";
|
const ref = this.dataList;
|
const params = {
|
url: this.fullFileRote,
|
validAdjust_Id: idValue
|
};
|
var callback = res => {
|
if (res.result) {
|
this.fullFileRote = null;
|
this.fileList = [];
|
this.importMsg = res.msg;
|
this.editorOptions.config.visible = false;
|
ref.loadData();
|
} else {
|
this.importMsg = "<font color='red'>" + res.msg + "</font>";
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
}
|
}
|
};
|
</script>
|