<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
|
<title>库存调整修改</title>
|
|
<script type="text/javascript">
|
var pageVue = null;
|
function loadJsCss(callback) {
|
var jscss_urls = [];
|
window.top.initJsCss(document, jscss_urls, callback);
|
};
|
|
function initVue() {
|
new FormVue({
|
el: "#vbody",
|
data: {
|
dataname: "wm_alter",
|
table_dataname: "wm_alter_detail",
|
title: "库存调整修改",
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 2,
|
labelwidth: "120px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "5px solid #c6c6c600"
|
},
|
formFields: [],
|
|
newformData: {},
|
formData: {},
|
dataRequest: [
|
{
|
name: "wm_warehouse",
|
dataname: "wm_warehouse",
|
// filter: "org_id='"+window.top.vue.userinfo.org_id+"'", // 标识
|
isnotoption: false, //true:不是选项
|
code:"code",//是下拉选项时设置
|
label:"name",//是下拉选项时设置
|
},
|
],
|
tablebuttonClick:[],
|
options_wm_warehouse: [],
|
isRefresh: true,
|
|
tableFields: [],
|
newTableData: {
|
create_time: createDatetime(),
|
creator_name: window.top.vue.userinfo.name,
|
},
|
tableData: [],
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
|
iscommit: false,//提交标记
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
operate: "",
|
dheight: 0,
|
|
//审批相关变量
|
loading_save: false,
|
loading_pass: false,
|
reasonvisible:false,//审批通过或拒绝填写原因
|
approveremark: "",//填写理由
|
passOrRefuse:false,
|
iscustomer:false,
|
},
|
created() {
|
this.iscustomer = window.top.vue.isCustomer
|
if (this.iscustomer) { // 是经销商账号
|
this.newformData = {
|
code: createCode("TZ"),
|
doc_date: createDate(),
|
state_code: "Input",
|
state_name: "草稿",
|
account_id:window.top.vue.userinfo.currentactor.target_id,
|
company_id:window.top.vue.userinfo.currentactor.company_id,
|
bu_id:window.top.vue.userinfo.currentactor.bu_id,
|
bu_name:window.top.vue.userinfo.currentactor.bu_name,
|
org_id:window.top.vue.userinfo.org.id,
|
org_code:window.top.vue.userinfo.org.code,
|
org_name:window.top.vue.userinfo.org.name,
|
}
|
}
|
|
this.dheight = document.documentElement.clientHeight - 92;
|
|
this.popupParames = clone(Root.popupParames);
|
this.operate = this.popupParames.sceneCode;
|
this.title = this.popupParames.title || this.popupParames.text
|
if (this.popupParames.data) {
|
this.formData = clone(this.popupParames.data);
|
}
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "add") {//新增
|
//动态获取默认数据
|
var newEntity_ = {
|
name: "newEntity",
|
url: "root/data/newEntity",
|
paramsobj: {dataname: this.dataname},
|
isnotoption: true, //true:不是选项
|
}
|
this.dataRequest.push(newEntity_);
|
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "browse") {//只读
|
this.formAttr.disabled = true;
|
this.isedit = false;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "approval") {//审批
|
this.formAttr.disabled = true;
|
this.isapproval = true;
|
}
|
else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
|
this.isrefuseedit = true;
|
}
|
}
|
},
|
|
mounted() {
|
var me = this;
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
//预加载数据后给哪些字段设置options或formatterjson
|
if(me.dataRequestObj.wm_warehouse) {
|
me.options_wm_warehouse = me.dataRequestObj.wm_warehouse
|
}
|
|
if (me.dataRequestObj.newEntity) {
|
var formData = clone(me.dataRequestObj.newEntity.data[me.dataname]);
|
if (me.newformData) {
|
let formData_ = clone(formData);
|
|
for (var k in me.newformData) {
|
if (!formData_[k]) {
|
formData_[k] = me.newformData[k];
|
}
|
}
|
|
if (!formData_.doc_date) {
|
formData_.doc_date = formData_.create_time
|
}
|
|
me.formData = formData_;
|
}
|
}
|
me.initData();
|
|
});
|
}
|
else {
|
this.initData();
|
}
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
this.$nextTick(() => {
|
hideLoading();
|
|
//重新设置弹窗宽高
|
this.$nextTick(function(){
|
//let w_ = this.$refs.popup_body.offsetWidth + "px";
|
let w_ = "900px";
|
let h_ = this.$refs.popup_body.offsetHeight + "px";
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
},
|
|
methods:{
|
//关闭弹窗
|
closeDialog() {
|
var me = this;
|
if (me.popupParames.totab){
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, false);
|
}
|
else {
|
Root.hidePopup();
|
}
|
},
|
//关闭前调回调
|
saveAfter() {
|
var me = this;
|
if(this.popupParames.callback) {
|
let obj = {
|
//row: this.formData
|
}
|
this.popupParames.callback(obj, function() {
|
me.closeDialog();
|
});
|
}
|
else {
|
me.closeDialog();
|
}
|
},
|
|
initData() {
|
let me = this
|
var id_ = null;
|
|
if (this.formData.id) {
|
id_ = this.formData.id;
|
}
|
me.tableButtonClick();
|
this.getRowDataById(id_, function(result) {//查询后的回调,用于获取字段的
|
if (result.meta && result.meta[me.dataname] && result.meta[me.dataname].fields) {
|
var metas = clone(result.meta[me.dataname].fields);
|
var table_dataname_ = "";
|
for (var dataname_ in result.meta) {
|
if (dataname_ != me.dataname && !table_dataname_) {
|
table_dataname_ = dataname_;
|
}
|
}
|
var table_metas = [];
|
if (table_dataname_) {
|
me.table_dataname = table_dataname_;
|
table_metas = clone(result.meta[table_dataname_].fields);
|
|
}
|
|
var formFields_ = [];
|
var tableFields_ = [];
|
metas.map(f=>{
|
f.isshow = "T";
|
|
if(f.field == "org_name"){
|
if(me.iscustomer){
|
f.isshow = "F";
|
}
|
}
|
if(f.field == "warehouse_name") {
|
f.options = me.options_wm_warehouse
|
}
|
|
formFields_.push(clone(f));
|
})
|
table_metas.map(f=>{
|
f.isshow = "T";
|
if(f.field == "create_time") {
|
f.isshow = "F";
|
}
|
if (f.field == "actual_qty") {
|
f.inputkeys = "number";//按键正整数
|
}
|
if (f.field == "stock_qty" || f.field == "actual_qty" || f.field == "diff_qty") {
|
f.istablesum = true
|
}
|
tableFields_.push(clone(f));
|
})
|
|
if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
|
me.formFields = clone(formFields_);
|
me.tableFields = clone(tableFields_);
|
|
|
}
|
}
|
|
if (me.rowData[me.dataname]) {
|
me.formData = me.rowData[me.dataname];
|
}
|
else {
|
var formData_ = getDataByFields(me.formData, me.formFields);
|
me.formData = clone(formData_);
|
}
|
|
if(me.operate == "add"){
|
|
}else {
|
if (me.rowData[me.table_dataname]) {
|
me.rowData[me.table_dataname].map(row=>{
|
if (!row.stock_qty) {
|
row.stock_qty = 0;
|
}
|
if (row.book_detail_id) {
|
row.rowEditField = {};
|
}
|
else {
|
row.rowEditField = {
|
"batch_no": {type: "input"},
|
"batch_sn": {type: "input"},
|
"actual_qty": {type: "input"},
|
"valid_from": {type: "date"},
|
"valid_to": {type: "date"}
|
};
|
}
|
})
|
|
me.tableData = me.rowData[me.table_dataname];
|
}
|
}
|
|
})
|
|
|
//字段数组转字段obj,目的为了筛选时获取字段属性
|
me.fieldsToFieldsObj();
|
|
//设置字段事件
|
me.tableFieldClick();
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
this.formfieldClick = {
|
warehouse_name: {
|
visible: {
|
onchange: function(obj) {
|
// me.formData.from_warehouse_name//这是出仓项
|
var formFields_ = [];
|
var options_ = []
|
formFields_ = clone(me.formFields)
|
me.options_wm_warehouse.map(f=>{
|
if(f.org_id == me.formData.org_id && f.account_id == me.formData.account_id) { //仓库项根据对应公司和户头过滤
|
options_.push(clone(f))
|
}
|
// if(f.name != me.formData.to_warehouse_name) {//出入仓项互斥
|
// options_.push(clone(f))
|
// }
|
})
|
formFields_.map(f=>{
|
if(f.field == "warehouse_name") { //仓库项赋值
|
f.options = clone(options_)
|
}
|
})
|
me.formFields = clone(formFields_)
|
if(me.formData.warehouse_name) {
|
Root.confirm('更换移出仓库将会重置明细,是否继续?', '更换提示', { //下拉提示
|
confirmButtonText: '确定',
|
// cancelButtonText: '取消',
|
showCancelButton:false,
|
type: 'warning'
|
}).then(() => {
|
return
|
}).catch(() => {
|
return
|
});
|
}
|
|
}
|
},
|
select: {
|
onchange: function(obj) {
|
// obj.data.warehouse_name = obj.selectoption.name//将选中项赋值
|
me.tableData = []
|
|
obj.data.warehouse_id = obj.selectoption.id
|
obj.data.warehouse_code = obj.selectoption.code
|
obj.data.warehouse_name = obj.selectoption.value
|
obj.data.warehouse_type_name = obj.selectoption.type_name//仓库选项更改后,仓库类型字段也要改变
|
obj.data.warehouse_type_code = obj.selectoption.type_code
|
obj.data.bu_id = obj.selectoption.bu_id;
|
}
|
}
|
|
},
|
org_name: {
|
popup: {
|
onclick: function(obj) {
|
me.openAccount("add", obj, function(popupobj){
|
let formData_ = clone(me.formData);
|
|
formData_.account_id = popupobj.row.id;
|
formData_.company_id = popupobj.row.company_id;
|
formData_.bu_id = popupobj.row.bu_id;
|
formData_.bu_name = popupobj.row.bu_name;
|
formData_.org_id = popupobj.row.org_id;
|
formData_.org_code = popupobj.row.md_org__code;
|
formData_.org_name = popupobj.row.account_name;
|
|
me.formData = clone(formData_);
|
});
|
// me.tablePopup_customerList()
|
}
|
},
|
},
|
// warehouse_name: {
|
// popup: {
|
// onclick: function(obj) {
|
// if(obj.val==''){
|
// me.tablePopup_warehouseList(obj)
|
// }else {
|
// if(me.tableData.length == 0){
|
// me.tablePopup_warehouseList(obj)
|
// }else {
|
// Root.confirm('切换仓库会清除所有明细数据,确定切换吗?', '提示', {
|
// confirmButtonText: '确定',
|
// cancelButtonText: '取消',
|
// type: 'warning'
|
// }).then(() => {
|
// me.tablePopup_warehouseList(obj)
|
// }).catch(() => {
|
// Root.message({
|
// type: 'info',
|
// message: '已取消'
|
// });
|
// });
|
// }
|
// }
|
// }
|
// },
|
// },
|
|
};
|
|
//表格字段事件设置
|
this.tablefieldClick = {
|
batch_no: {
|
cssname: function(row, callback) {
|
var classname_ = "" // 默认状态
|
// if (row.source_type == "wm_detail") { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
if (row.book_detail_id) { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
classname_ = "h_cell_readonly";
|
}
|
callback(classname_)
|
},
|
},
|
// batch_no: {
|
// val:{
|
// // 当满足以下条件时,单元格不可编辑
|
// readonly_bindfield:{field: "is_modifiable", value: false}
|
// },
|
// },
|
|
batch_sn: {
|
cssname: function(row, callback) {
|
var classname_ = "" // 默认状态
|
// if (row.source_type == "wm_detail") { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
if (row.book_detail_id) { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
classname_ = "h_cell_readonly";
|
}
|
callback(classname_)
|
},
|
},
|
valid_from: {
|
cssname: function(row, callback) {
|
var classname_ = "" // 默认状态
|
// if (row.source_type == "wm_detail") { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
if (row.book_detail_id) { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
classname_ = "h_cell_readonly";
|
}
|
callback(classname_)
|
},
|
},
|
valid_to: {
|
cssname: function(row, callback) {
|
var classname_ = "" // 默认状态
|
// if (row.source_type == "wm_detail") { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
if (row.book_detail_id) { // 判断是新增还是库存明细调整,如果是调整明细则只读
|
classname_ = "h_cell_readonly";
|
}
|
callback(classname_)
|
},
|
},
|
actual_qty: {
|
input: {
|
onchange: function(obj) {//输入更改事件
|
// if (obj.row.batch_sn) {//有序列号
|
// //不能大于1且不能小于0
|
// if (obj.row.actual_qty > 1) {
|
// Root.message({
|
// type: 'warning',
|
// message: '存在序列号的数量不可大于1'
|
// });
|
// me.$set(obj.row, "actual_qty", 1);
|
// }
|
// else if (obj.row.actual_qty < 0) {
|
// Root.message({
|
// type: 'warning',
|
// message: '存在序列号的数量不可小于0'
|
// });
|
// me.$set(obj.row, "actual_qty", 0);
|
// }
|
// }
|
// else if (!obj.row.book_detail_id) {
|
// if (obj.row.actual_qty < 0) {
|
// Root.message({
|
// type: 'warning',
|
// message: '新增产品的数量不可小于0'
|
// });
|
// me.$set(obj.row, "actual_qty", 0);
|
// }
|
// }
|
|
|
//将类似‘00099’之类的数字,前面的0都删掉
|
// if (obj.row.actual_qty && obj.row.actual_qty.length > 1) {
|
// var p = 0;
|
// for (q = 0; q <= (obj.row.actual_qty.length + p); q++) {
|
// if (obj.row.actual_qty[0]*1 == 0) {
|
// obj.row.actual_qty = obj.row.actual_qty.substring(1);
|
// p ++;
|
// } else {
|
// break;
|
// }
|
// }
|
// }
|
if (obj.row.stock_qty) {
|
me.$set(obj.row, "diff_qty", obj.row.actual_qty - obj.row.stock_qty);
|
}
|
else {
|
me.$set(obj.row, "diff_qty", obj.row.actual_qty - 0);
|
}
|
}
|
},
|
},
|
|
|
// batch_sn: {
|
// input: {
|
// onchange: function(obj) {
|
// if(obj.row.actual_qty > 1 && obj.row.batch_sn){
|
// Root.message({
|
// type: 'warning',
|
// message: '存在序列号的数量不可大于1'
|
// });
|
// me.$set(obj.row, "actual_qty", 1);
|
|
// me.$set(obj.row, "diff_qty", obj.row.actual_qty - obj.row.stock_qty);
|
// }
|
// }
|
// },
|
// },
|
|
};
|
},
|
// 设置表格工具栏按键事件
|
tableButtonClick() {
|
var me = this;
|
var tablebuttonclick = [];
|
tablebuttonclick = [
|
{
|
name:"新增明细",
|
isbuttonshow: me.isedit, type: "primary",
|
code: "addDetail", isselected: false, classname:"",
|
|
onclick: function(obj) {
|
console.log(obj)
|
if(!me.formData.warehouse_code){
|
Root.message({
|
type: 'warning',
|
message: '请先选择仓库'
|
});
|
return;
|
}
|
me.tablepopup_productlist("add", obj, function(popupobj){
|
// let row_ = clone(me.formData)
|
var tableData_ = clone(me.tableData);
|
if (popupobj.rowlist && popupobj.rowlist.length) {
|
popupobj.rowlist.map(row=>{
|
var newrow = {
|
// book_detail_id: popupobj.row.book_detail_id,
|
product_id: row.product_id,
|
product_code: row.product_code,
|
product_name: row.product_name,
|
// material_code: row.material_code,
|
// material_name: row.material_name,
|
spec: row.spec,
|
|
unit: row.unit,
|
batch_no: row.batch_no,
|
batch_sn: row.batch_sn,
|
// batch_no_flag: row.batch_no_flag,
|
// batch_sn_flag: row.batch_sn_flag,
|
valid_from: row.valid_from,
|
valid_to: row.valid_to,
|
// stock_type: row.stock_type_name,
|
stock_qty: row.qty_available,//标识二,待调整
|
actual_qty: row.qty_available,
|
diff_qty: 0,
|
book_detail_id: row.book_detail_id,
|
source_type: popupobj.type, // 调整来源,wm_detail库存明细、product产品新增
|
// qty: 1,//标识二,待调整
|
}
|
tableData_.unshift(clone(newrow));
|
})
|
}
|
|
|
|
me.tableData = clone(tableData_)
|
})
|
}
|
},
|
{
|
isbuttonshow: me.isedit, type: "danger",
|
code: "delete", isselected: true, classname:"",
|
disabled: function(selectRowList) {
|
var bo_ = true ;
|
if (selectRowList[0]) {
|
bo_ = false
|
}
|
return bo_;
|
},
|
onclick: function(obj) {
|
var row = obj.selectedList[0];
|
var txt = clone(row.product_name);
|
me.deleteDataById(row.id, "wm_alter_detail", "【" + txt + "】", function(){
|
me.tableData.splice(obj.selectRowIndex, 1);
|
})
|
}
|
}
|
]
|
me.tablebuttonClick = tablebuttonclick
|
|
},
|
|
tablepopup_productlist_v1(sceneCode, obj , callback) {
|
var me = this;
|
var data_ = {};
|
console.log(obj);
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "明细选择",
|
id: "popup_book_detail",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/inventory/page/popup/popup_book_detail.html",
|
data: data_,
|
delta: {},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
// filter: "parent_id='" + me.formData.id +"'" , //此处id是否已经存在
|
filter: "warehouse_name='" + me.formData.warehouse_name +"'" ,
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
tablepopup_productlist(sceneCode, obj, callback) {
|
var me = this;
|
var data_ = clone(this.formData);
|
var delta_ = {};
|
|
//排除已选物料
|
me.tableData.map(row=>{
|
if (row.batch_sn) {
|
var key_ = row.product_code + "_" + row.batch_no + "_" + row.batch_sn
|
delta_[key_] = true
|
}
|
else if (row.product_code) {
|
var key_ = row.product_code + "_" + row.batch_no
|
delta_[key_] = true
|
}
|
})
|
console.log(obj);
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "明细选择",
|
id: "popup_book_detail",//totab: true时需设置,用于判断是否已打开此页面
|
// url: "module/inventory/page/popup/popup_book_detail.html",
|
url: "module/inventory/page/popup/popup_tab_wm_detail.html",
|
data: data_,
|
delta: delta_,
|
filter: "wm_book_detail.account_id='" + me.formData.account_id + "' and warehouse_code='" + me.formData.warehouse_code + "'",
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
// filter: "parent_id='" + me.formData.id +"'" , //此处id是否已经存在
|
// filter: "warehouse_name='" + me.formData.warehouse_name +"'" ,
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
|
deleteDataById(id, dataname, confirm_txt, callback){
|
var me = this;
|
var formData_ = clone(me.formData);
|
Root.confirm('确定删除该' + confirm_txt + '吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
if (id) {
|
let param = {
|
dataname: dataname,
|
id: id
|
}
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
callback();
|
}
|
});
|
}
|
else {
|
callback();
|
}
|
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
|
},
|
|
clearDetail(callback) {
|
var me = this;
|
if (me.tableData.length) {
|
var row = me.tableData[0];
|
if (row.id) {
|
let param = {
|
dataname: me.table_dataname,
|
id: row.id
|
}
|
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
me.tableData.remove(row);
|
me.clearDetail(callback)
|
}
|
});
|
}
|
else {
|
me.tableData.remove(row);
|
me.clearDetail(callback)
|
}
|
}
|
else {
|
if (callback) {
|
callback();
|
}
|
}
|
},
|
|
openAccount(sceneCode, obj, callback) {
|
var me = this;
|
var data_ = {};
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "经销商选择",
|
id: "popup_account",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_account.html",
|
data: data_,
|
delta: {},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
filter: "md_org_account.state_code='Open'",
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
tablePopupProduct(obj) {
|
var me = this;
|
var delta_ = {};
|
|
//排除已选物料
|
me.tableData.map(row=>{
|
if (row.batch_sn) {
|
var key_ = row.product_code + "_" + row.batch_no + "_" + row.batch_sn
|
delta_[key_] = true
|
}
|
else if (row.product_code) {
|
var key_ = row.product_code + "_" + row.batch_no
|
delta_[key_] = true
|
}
|
})
|
let index = obj.$index;
|
Root.showPopup({
|
url: "module/inventory/page/popup/popup_tab_wm_detail.html",
|
width: 800,
|
height: 550,
|
text: "产品选择",
|
sceneCode: "add",
|
data: this.formData,
|
filter: "org_id='" + me.formData.org_id + "' and warehouse_code='" + me.formData.warehouse_code + "'",
|
delta: delta_,
|
callback: function(obj, callback) {
|
console.log(obj);
|
if (obj.type == "wm_detail") {
|
for (var i = 0; i < obj.rowlist.length; i++) {
|
var obj_row = obj.rowlist[i];
|
if (i == 0) {
|
me.$set(me.tableData[index], "rowEditField", {});
|
me.$set(me.tableData[index], "book_detail_id", obj_row.id);
|
me.$set(me.tableData[index], "product_id", obj_row.product_id);
|
me.$set(me.tableData[index], "product_code", obj_row.product_code);
|
me.$set(me.tableData[index], "product_name", obj_row.product_name);
|
me.$set(me.tableData[index], "material_code", obj_row.material_code);
|
me.$set(me.tableData[index], "material_name", obj_row.material_name);
|
me.$set(me.tableData[index], "spec", obj_row.spec);
|
me.$set(me.tableData[index], "batch_no", obj_row.batch_no);
|
// me.$set(me.tableData[index], "expiry_date", obj.row.expiry_date);
|
me.$set(me.tableData[index], "stock_qty", obj_row.qty_available);//可用量
|
me.$set(me.tableData[index], "actual_qty", obj_row.qty_available);
|
me.$set(me.tableData[index], "diff_qty", 0);
|
me.$set(me.tableData[index], "valid_from", obj_row.valid_from);
|
me.$set(me.tableData[index], "valid_to", obj_row.valid_to);
|
me.$set(me.tableData[index], "batch_sn", obj_row.batch_sn);
|
}
|
else {
|
//新增其余行
|
var table_row = clone(me.newTableData);
|
|
table_row.rowEditField = {};
|
table_row.book_detail_id = obj_row.id;
|
table_row.product_id = obj_row.product_id;
|
table_row.product_code = obj_row.product_code;
|
table_row.product_name = obj_row.product_name;
|
table_row.material_code = obj_row.material_code;
|
table_row.material_name = obj_row.material_name;
|
table_row.spec = obj_row.spec;
|
table_row.batch_no = obj_row.batch_no;
|
table_row.stock_qty = obj_row.qty_available;
|
table_row.actual_qty = obj_row.qty_available;
|
table_row.diff_qty = 0;
|
table_row.valid_from = obj_row.valid_from;
|
table_row.valid_to = obj_row.valid_to;
|
table_row.batch_sn = obj_row.batch_sn;
|
|
me.tableData.unshift(table_row);
|
}
|
}
|
}
|
else if (obj.type == "product") {
|
for (var i = 0; i < obj.rowlist.length; i++) {
|
var obj_row = obj.rowlist[i];
|
if (i == 0) {
|
me.$set(me.tableData[index], "rowEditField",
|
{
|
"batch_no": {type: "input"},
|
"batch_sn": {type: "input"},
|
"actual_qty": {type: "input"},
|
"valid_from": {type: "date"},
|
"valid_to": {type: "date"}
|
},
|
);
|
|
me.$set(me.tableData[index], "book_detail_id", "");
|
me.$set(me.tableData[index], "product_id", obj_row.id);
|
me.$set(me.tableData[index], "product_code", obj_row.code);
|
me.$set(me.tableData[index], "product_name", obj_row.name);
|
me.$set(me.tableData[index], "material_code", obj_row.material_code);
|
me.$set(me.tableData[index], "material_name", obj_row.material_name);
|
me.$set(me.tableData[index], "batch_no_flag", obj_row.batch_no_flag);
|
me.$set(me.tableData[index], "batch_sn_flag", obj_row.batch_sn_flag);
|
me.$set(me.tableData[index], "spec", obj_row.spec);
|
|
me.$set(me.tableData[index], "batch_no", "");
|
me.$set(me.tableData[index], "batch_sn", "");
|
me.$set(me.tableData[index], "valid_from", "");
|
me.$set(me.tableData[index], "valid_to", "");
|
me.$set(me.tableData[index], "actual_qty", 0);
|
me.$set(me.tableData[index], "stock_qty", 0);//可用量
|
me.$set(me.tableData[index], "diff_qty", 0);
|
}
|
else {
|
//新增其余行
|
var table_row = clone(me.newTableData);
|
|
table_row.rowEditField = {
|
"batch_no": {type: "input"},
|
"batch_sn": {type: "input"},
|
"actual_qty": {type: "input"},
|
"valid_from": {type: "date"},
|
"valid_to": {type: "date"}
|
};
|
table_row.book_detail_id = obj_row.id;
|
table_row.product_id = obj_row.id;
|
table_row.product_code = obj_row.code;
|
table_row.product_name = obj_row.name;
|
table_row.material_code = obj_row.material_code;
|
table_row.material_name = obj_row.material_name;
|
table_row.batch_no_flag = obj_row.batch_no_flag;
|
table_row.batch_sn_flag = obj_row.batch_sn_flag;
|
table_row.spec = obj_row.spec;
|
table_row.batch_no = obj_row.batch_no;
|
table_row.batch_sn = obj_row.batch_sn;
|
table_row.stock_qty = 0;
|
table_row.actual_qty = 0;
|
table_row.diff_qty = 0;
|
table_row.valid_from = obj_row.valid_from;
|
table_row.valid_to = obj_row.valid_to;
|
|
me.tableData.unshift(table_row);
|
}
|
}
|
}
|
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
},
|
|
// tablePopupProduct(obj) {
|
// var me = this;
|
// var delta_ = {};
|
|
// //排除已选物料
|
// me.tableData.map(row=>{
|
// if (row.batch_sn) {
|
// var key_ = row.product_code + "_" + row.batch_no + "_" + row.batch_sn
|
// delta_[key_] = true
|
// }
|
// else if (row.product_code) {
|
// var key_ = row.product_code + "_" + row.batch_no
|
// delta_[key_] = true
|
// }
|
// })
|
// let index = obj.$index;
|
// Root.showPopup({
|
// url: "module/order/page/popup/wm_book_detail.html",
|
// width: 800,
|
// height: 550,
|
// sceneCode: "add",
|
// filter: "org_id='" + me.formData.org_id + "' and warehouse_name='" + me.formData.warehouse_name + "'",
|
// delta: delta_,
|
// callback: function(obj, callback) {
|
// me.$set(me.tableData[index], "product_id", obj.row.product_id);
|
// me.$set(me.tableData[index], "product_code", obj.row.product_code);
|
// me.$set(me.tableData[index], "product_name", obj.row.product_name);
|
// me.$set(me.tableData[index], "material_code", obj.row.material_code);
|
// me.$set(me.tableData[index], "material_name", obj.row.material_name);
|
// me.$set(me.tableData[index], "batch_no", obj.row.batch_no);
|
// me.$set(me.tableData[index], "expiry_date", obj.row.expiry_date);
|
// me.$set(me.tableData[index], "stock_qty", obj.row.qty_available);//可用量
|
// me.$set(me.tableData[index], "actual_qty", obj.row.qty_available);
|
// me.$set(me.tableData[index], "diff_qty", 0);
|
// me.$set(me.tableData[index], "valid_from", obj.row.valid_from);
|
// me.$set(me.tableData[index], "valid_to", obj.row.valid_to);
|
// me.$set(me.tableData[index], "batch_sn", obj.row.batch_sn);
|
|
// if (callback) {
|
// callback();
|
// }
|
// }
|
// });
|
// },
|
|
addTableData() {
|
if (!this.formData.warehouse_name) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择仓库'
|
});
|
}
|
else {
|
var table_row = clone(this.newTableData);
|
this.rowChange(table_row, "add", this.table_dataname);
|
}
|
},
|
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
Root.confirm('确定删除数据' + (row.material_name ? JSON.stringify(row.material_name) : "") + '吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.rowChange(row, "del", me.table_dataname);
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
rowChange(row, type, tablename) {
|
var me = this;
|
if (type == "add") {
|
this.tableData.unshift(row);
|
}
|
else if (type == "del") {
|
if (row.id) {
|
let param = {
|
dataname: tablename,
|
id: row.id
|
}
|
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
me.tableData.remove(row);
|
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}
|
});
|
}
|
else {
|
this.tableData.remove(row);
|
}
|
}
|
else {
|
|
}
|
},
|
|
//提交
|
submitRowTable() {
|
var me = this;
|
var bo_ = true;
|
var batch_no_ = true;
|
var no_flag_ = true;
|
var sn_flag_ = true;
|
//必填项校验
|
var bo1 = this.$refs.form1.checkForm();
|
if(!bo1){
|
Root.message({
|
type: 'error',
|
message: '请填写必填项'
|
});
|
return;
|
}
|
|
if (me.tableData.length == 0) {
|
bo_ = false;
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
return
|
}
|
|
me.tableData.map(r=>{
|
if (r.actual_qty == null || r.actual_qty === "" || isNaN(r.actual_qty)) {
|
bo_ = false;
|
}
|
if (r.batch_no == null || r.batch_no === "") {
|
batch_no_ = false;
|
r.batch_no = "N/A";
|
}
|
if(r.batch_no_flag == "Y"){
|
if (r.batch_no == null || r.batch_no === "") {
|
no_flag_ = false;
|
}
|
}
|
if(r.batch_sn_flag == "Y"){
|
if (r.batch_sn == null || r.batch_sn === "") {
|
sn_flag_ = false;
|
}
|
}
|
})
|
if (!bo_) {
|
Root.message({
|
type: 'error',
|
message: '明细中存在数量为空的数据'
|
});
|
return
|
}
|
|
// if (!batch_no_) {
|
// Root.message({
|
// type: 'error',
|
// message: '明细中存在批号为空的数据'
|
// });
|
// return
|
// }
|
|
if (!no_flag_) {
|
Root.message({
|
type: 'error',
|
message: '明细中存在批号为空的数据'
|
});
|
return
|
}
|
|
if (!sn_flag_) {
|
Root.message({
|
type: 'error',
|
message: '明细中存在序列号为空的数据'
|
});
|
return
|
}
|
|
this.iscommit = true;
|
this.saveRowTable();
|
},
|
|
//保存
|
saveRowTable() {
|
var me = this;
|
var operator_ = "saveEntity";//保存
|
if(me.iscommit) {
|
operator_ = "commit";//提交
|
}
|
|
var entity_ = clone(this.formData);
|
var entity = {};
|
for (var r in entity_) {
|
if (entity_[r] || entity_[r] == 0 || entity_[r] == false || entity_[r] == "") {
|
entity[r] = entity_[r];
|
}
|
}
|
|
var tableData_ = [];
|
this.tableData.map(r=>{
|
var row_ = {};
|
for (var k in r) {
|
if (r[k] || r[k] == 0 || r[k] == false || r[k] == "") {
|
row_[k] = r[k];
|
}
|
}
|
tableData_.push(row_);
|
})
|
|
if (tableData_.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
return
|
}
|
|
let param = {
|
dataname: this.dataname,
|
data: {},
|
}
|
param.data[this.dataname] = entity;
|
param.data[this.table_dataname] = tableData_;
|
if (this.formData.id) {
|
param.id = this.formData.id
|
}
|
// if(me.iscommit) {
|
// param.book_command = "Adjust.NoApproval.open"
|
// // "id": "1001A2100000000KC6B6"
|
// }
|
|
Server.call("root/data/" + operator_, param, function(result) {
|
console.log(result);
|
if (result.success) {
|
if(me.iscommit){
|
me.iscommit = false;
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.saveAfter();
|
}
|
else {
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.saveAfter();
|
}
|
}
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
me.iscommit = false;
|
if (errorresult.messages.list) {
|
var config = {
|
totab: false,
|
// width: "1200px",
|
// height: 800,
|
icon: "icon-product",
|
text: "错误信息",
|
url: "module/tool/page/popup_error_messages.html",
|
data: {},
|
delta: errorresult.messages.list,
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
}
|
}
|
else {
|
if (me.iscommit) {
|
Root.message({
|
type: 'error',
|
message: '提交失败'
|
});
|
me.iscommit = false;
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '保存失败'
|
});
|
}
|
|
}
|
});
|
},
|
|
// 通过或拒绝
|
onShowApproval(passOrRefuse) {
|
this.approveremark = "";
|
this.reasonvisible = true;//审批备注填写弹窗
|
this.passOrRefuse = passOrRefuse;// commit下一个状态;approve通过;gohome;//拒绝 goback;//回退
|
},
|
saveReason() {
|
this.loading_pass = true;
|
if(this.passOrRefuse == "commit" || this.passOrRefuse == "approve"){
|
this.doApproval();
|
}
|
else{
|
if(this.approveremark != ""){
|
this.doApproval();
|
}
|
else{
|
Root.message({
|
type: 'warning',
|
message: '请填写原因'
|
});
|
this.loading_pass = false;
|
}
|
}
|
},
|
doApproval(bo) {
|
var me = this;
|
this.getMachine(function(next_step, up_step) { //
|
me.doRunApproval(next_step, up_step);
|
});
|
},
|
|
getMachine(callback) {
|
var me = this;
|
let param = {
|
dataname: me.dataname,
|
}
|
Server.call("root/state/getMachine", param, function(result) {
|
var next_step = {}; // 向下流程
|
var up_step = {}; // 向上流程
|
|
if (result && result.machine && result.machine.detail) {
|
result.machine.detail.map(md=>{
|
next_step[md.from_code] = md.to_code;
|
up_step[md.to_code] = md.from_code;
|
})
|
|
callback(next_step, up_step);
|
}
|
})
|
},
|
|
doRunApproval(next_step, up_step) {
|
var me = this;
|
this.passOrRefuse;//首次开户-通过
|
// commit // 下一个状态
|
// approve // 通过
|
// gohome // 拒绝
|
// goback // 回退
|
|
var to_state_ = "";
|
if (this.passOrRefuse == "commit") {
|
to_state_ = next_step[this.formData.state_code];
|
}
|
else if (this.passOrRefuse == "approve") {
|
|
}
|
else if (this.passOrRefuse == "gohome") {
|
// to_state_ = up_step[this.formData.state_code];
|
}
|
else if (this.passOrRefuse == "goback") {
|
to_state_ = up_step[this.formData.state_code];
|
}
|
|
let param = {
|
dataname: me.dataname,
|
id: me.formData.id,
|
to_state: to_state_,
|
remark: this.approveremark
|
}
|
//
|
// return
|
Server.call("root/data/" + this.passOrRefuse, param, function(result) {
|
me.loading_pass = false;
|
console.log(result);
|
if (me.passOrRefuse == "commit" || me.passOrRefuse == "approve") {
|
Root.message({
|
type: 'success',
|
message: '审批成功'
|
});
|
}
|
else if (me.passOrRefuse == "goback") {
|
Root.message({
|
type: 'success',
|
message: '已退回'
|
});
|
}
|
else if (me.passOrRefuse == "gohome") {
|
Root.message({
|
type: 'success',
|
message: '已拒绝'
|
});
|
}
|
me.saveAfter();
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
me.loading_pass = false;
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
if (errorresult.messages.list) {
|
var config = {
|
totab: false,
|
// width: "1200px",
|
// height: 800,
|
icon: "icon-product",
|
text: "错误信息",
|
url: "module/tool/page/popup_error_messages.html",
|
data: {},
|
delta: errorresult.messages.list,
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
|
}
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '审批失败'
|
});
|
}
|
});
|
},
|
|
|
|
}
|
});
|
};
|
|
loadJsCss(function () {
|
initVue();
|
});
|
</script>
|
<style>
|
/* 在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
|
[v-cloak] {
|
display: none !important;
|
}
|
.h_cell_readonly .el-input__inner {
|
pointer-events: none;
|
border: 1px solid #DDD;
|
background-color: #F5F5F5;
|
color: #ACA899;
|
}
|
</style>
|
|
</head>
|
|
<body style="margin: 0px;">
|
<div v-cloak id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding: 0 20px;">
|
<div class="el-dialog__header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{title}}</span>
|
</div>
|
</div>
|
<div :style="{height: dheight + 'px', 'overflow-y': 'auto'}">
|
<div class="el-dialog__body">
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
|
<div class="h_dialog__body">
|
<div v-if="isedit || isrefuseedit" style=" text-align: right; margin-top: 20px;">
|
<!-- 工具栏 -->
|
<!-- <div v-if="tableFields.length" style=" display: inline-block; width: 90px;">
|
<el-button-group style="display: flex;justify-content: center;"> -->
|
<!-- <el-button @click="addTableData">新增明细</el-button> -->
|
<!-- </el-button-group>
|
</div> -->
|
</div>
|
<h-table
|
v-if="isRefresh && tableFields.length"
|
ref="table1"
|
:table-fields="tableFields"
|
:table-data="tableData"
|
:is-pagination="false"
|
:is-selection="false"
|
:isfilterfield="false"
|
:is-within-edit-table-data="isedit || isrefuseedit"
|
:table-field-click="tablefieldClick"
|
:table-buttons-click="tablebuttonClick"
|
:show-summary="true"
|
:is-highlight-row="true"
|
:isdraggableorder="false"
|
:isbasicfilterfields="false"
|
:istablebuttons="false"
|
|
v-on:get-data="getData"
|
v-on:del-data="delData"
|
>
|
</h-table>
|
</div>
|
|
<el-dialog title="填写原因" :visible.sync="reasonvisible" height="50%">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 2, maxRows: 10}"
|
placeholder="请输入原因"
|
v-model="approveremark">
|
</el-input>
|
|
<div slot="footer" class="dialog-footer" >
|
<el-button type="default" @click="reasonvisible = false">取 消</el-button>
|
<el-button type="primary" :loading="loading_pass" @click="saveReason">确 定</el-button>
|
</div>
|
</el-dialog>
|
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<el-button-group style="margin-right: 80px;" >
|
<el-button size="small" v-if="isapproval" type="warning" plain @click="onShowApproval('gohome')">退回到申请人</el-button>
|
<el-button size="small" v-if="isapproval" type="danger" plain @click="onShowApproval('goback')">退回到上一步</el-button>
|
</el-button-group>
|
|
<el-button size="small" type="default" @click="closeDialog">取 消</el-button>
|
<el-button size="small" v-if="isedit || isrefuseedit" type="primary" @click="saveRowTable":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
|
<el-button size="small" v-if="isedit" type="success" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('approve')">通 过</el-button>
|
<!-- <el-button size="small" v-if="isrefuseedit" type="success" @click="">再次提交</el-button> -->
|
<!-- <el-button size="small" v-if="isapproval" type="danger" @click="onRefuseApproval">拒 绝</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="onPassApproval">通 过</el-button> -->
|
<!-- <el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="">退 回</el-button> -->
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</body>
|
</html>
|