<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>调货出库单编辑</title>
|
<script src="../../../../js/vue/vue.js"></script>
|
<script src="../../../../js/vue/element-ui/lib/index.js"></script>
|
<script src="../../../../js/myelement.js"></script>
|
<script src="../../../../js/vue/page.js"></script>
|
|
<link href="../../../../js/vue/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
|
<link href="../../../../css/myelement.css" rel="stylesheet">
|
<link href="../../../../css/iconfont.css" rel="stylesheet">
|
<link href="../../../../css/page.css" rel="stylesheet">
|
<link href="//at.alicdn.com/t/font_2374495_mkoo966o0uo.css" rel="stylesheet">
|
</head>
|
|
<body>
|
<div id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="width: 1000px;">
|
<div class="el-dialog__header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{formAttr.title}} </span>
|
</div>
|
</div>
|
<div class="el-dialog__body">
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
>
|
</h-form>
|
<el-button-group v-if="notdisabled" style="float: right;">
|
<el-button @click="addTableData">新增数据</el-button>
|
</el-button-group>
|
<h-table
|
v-if="isRefresh"
|
ref="table2"
|
:table-fields="tableFields"
|
:table-data="tableData2"
|
:is-within-edit-table-data= "isWithinEditTableData"
|
:is-edit-table-data="isEditTableData"
|
:pagesize="pagesize"
|
:pagenum="pagenum"
|
:total="total"
|
:table-height="tableHeight2"
|
:is-pagination="false"
|
:is-show-index="true"
|
|
v-on:edit-data="editData"
|
v-on:del-data="delData"
|
v-on:cell-input-change="cellInputChange"
|
v-on:cell-select-change="cellSelectChange"
|
v-on:cell-click="cellClick"
|
v-on:visible-change="cellVisibleChange"
|
>
|
</h-table>
|
</div>
|
|
<div class="el-dialog__footer">
|
<el-button type="default" @click="closeDialog">取 消</el-button>
|
<el-button v-if="notdisabled" type="primary" @click="saveRowTable">保 存</el-button>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 100vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</div>
|
|
<script type="text/javascript">
|
new Vue({
|
el: "#vbody",
|
data: {
|
notdisabled: true,
|
form_dataname: "exwarehouse",
|
dataname: "exwarehousedetail",
|
formAttr: {
|
istitle: false,
|
title: "调货出库单",
|
columnnumber: 2,
|
labelwidth: "110px",
|
labelposition: "right",
|
size: "medium",
|
border: "0px solid #c6c6c600"
|
},
|
newRowDefault: {
|
id: uuid_short(),
|
code: createCode("H"),
|
producer: window.top.userinfo.user.name,
|
},
|
tableDataChange: {},
|
formFields: [],
|
tableFields: [],
|
tableData2: [],
|
tableData: [],
|
selectrow: {},
|
|
tableHeight2: 300,
|
isEditTableData:true,
|
isWithinEditTableData:false,
|
formData: {},
|
isRefresh: true,
|
},
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
},
|
|
mounted() {
|
this.initData();
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "browse") {
|
this.formAttr.disabled = true;
|
this.isWithinEditTableData = false;
|
this.notdisabled = false;
|
}
|
else if (this.popupParames.sceneCode == "add") {
|
if (this.newRowDefault) {
|
let formData_ = clone(this.formData);
|
|
for (var k in this.newRowDefault) {
|
formData_[k] = this.newRowDefault[k];
|
}
|
this.formData = formData_;
|
}
|
}
|
}
|
|
this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
|
document.getElementById('page_root').style.display = "block";
|
document.getElementById('page_loading').style.display = "none";
|
|
//重新设置弹窗宽高
|
this.$nextTick(function(){
|
let w_ = this.$refs.popup_body.offsetWidth + "px";
|
let h_ = this.$refs.popup_body.offsetHeight + "px";
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
},
|
|
methods:{
|
closeDialog() {
|
Root.hidePopup();
|
},
|
initData() {
|
let me = this
|
let filter_table = "";
|
let filter_form = "";
|
me.tableFields = dataRootFields.tableFields.exWarehouseOrder_;
|
me.formFields = dataRootFields.formFields.exWarehouse_
|
|
if (this.popupParames.data) {
|
filter_table = "parentid = '" + this.popupParames.data.id + "'";
|
filter_form = "stock_exwarehouse.id = '" + this.popupParames.data.id + "'";
|
}
|
|
let param_table = {
|
isClientMode: false,
|
dataname: this.dataname,
|
filter: filter_table,
|
}
|
|
Server.call("root/data/getEntitySet", param_table, function(result) {
|
if (result && result.data) {
|
me.tableData2= result.data.entityset;
|
}
|
});
|
|
let param_form = {
|
isClientMode: false,
|
dataname: this.form_dataname,//"sorder",
|
filter: filter_form,
|
}
|
|
Server.call("root/data/getEntitySet", param_form, function(result) {
|
if (result && result.data) {
|
me.formData= result.data.entityset[0];
|
}
|
});
|
},
|
|
saveRowTable() {
|
var array_ = [];
|
|
for (var id in this.tableDataChange) {
|
array_.push(id);
|
}
|
|
this.doSave(array_);
|
},
|
doSave(array){
|
var me = this;
|
if (array.length) {//存在需处理的明细数据
|
var id = array[0];
|
var row_ = this.tableDataChange[id];
|
var type = row_.type;
|
var row = row_.data;
|
|
var param = {};
|
let event = "";
|
|
if (type == "add") {
|
param = row;
|
param.isClientMode = false;
|
|
event = "insertEntity";
|
}
|
else if (type == "up") {
|
param = row;
|
param.isClientMode = false;
|
|
event = "updateEntity";
|
}
|
else if (type == "del") {
|
param = {
|
id: row.id,
|
isClientMode: false
|
}
|
event = "deleteEntity";
|
}
|
|
Server.call("root/data/" + event + "/" + this.dataname, param, function(result) {
|
array.remove(id);
|
me.doSave(array);
|
});
|
|
}
|
else {
|
//1保存form数据
|
let param = this.formData;
|
param.isClientMode = false;
|
let event = "updateEntity";
|
if(this.popupParames.sceneCode == "add") {
|
event = "insertEntity"
|
}
|
|
Server.call("root/data/" + event + "/" + this.form_dataname, param, function(result) {
|
//2回调
|
if(me.popupParames.callback) {
|
let obj = {
|
row: me.formData
|
}
|
me.popupParames.callback(obj, function() {
|
Root.hidePopup();
|
});
|
}
|
else {
|
alert("该按键事件缺失!")
|
}
|
});
|
}
|
},
|
rowChange(row, type) {
|
//tc
|
var id_ = row.id;
|
if (this.tableDataChange[id_]) {
|
this.tableDataChange[id_].data = row;
|
}
|
else {
|
var changeRow_ = {
|
type: type,
|
data: row
|
};
|
this.tableDataChange[id_] = changeRow_;
|
}
|
|
//t2
|
if (type == "add") {
|
this.tableData2.unshift(row);
|
}
|
else if (type == "del") {
|
this.tableData2.remove(row);
|
}
|
|
var sum_noRate_ = 0 ;
|
var formData_ = clone(this.formData);
|
this.tableData2.map(e=>{
|
sum_noRate_ += (e.price_final ? e.price_final : 0 ) * 1;
|
})
|
|
this.formData = formData_;
|
this.$refs.form1.refresh();
|
},
|
|
addTableData() {
|
if (this.selectrow != {}) {
|
this.selectrow.isWithinEdit = false;
|
}
|
|
var id_ = uuid_short();
|
var row_ = {
|
isWithinEdit: true,
|
id: id_
|
};
|
|
for (var i = 0; i < this.tableFields.length; i++) {
|
let field_ = this.tableFields[i].field;
|
|
if (field_ == "parentid") {
|
row_[field_] = this.formData.id;
|
}
|
else {
|
row_[field_]="";
|
}
|
}
|
|
this.selectrow = row_;
|
this.rowChange(row_, "add");
|
},
|
|
editData(scope) {
|
if (this.selectrow != {}) {
|
this.selectrow.isWithinEdit = false;
|
}
|
this.selectrow = scope.row;
|
scope.row.isWithinEdit = scope.row.isWithinEdit ? false : true;
|
this.isRefresh = false;
|
this.$nextTick(function(){
|
this.isRefresh = true;
|
})
|
},
|
|
cellVisibleChange(obj) {
|
let options_ = [];
|
let param_ = {
|
isClientMode: false,
|
}
|
|
if (obj.field == "productcode") {
|
Server.call("root/data/getEntitySet/batch", param_, function(result){
|
options_ = result.data.entityset;
|
obj.options = options_;
|
});
|
}
|
},
|
|
cellSelectChange(scope) {
|
let me = this;
|
let row = scope.row;
|
let field = scope.column.property;
|
if(field == "productcode") {
|
let val = row[field];
|
let param_ = {
|
isClientMode: false,
|
dataname: "batch",
|
filter: "md_batch.code = " + "'" + val + "'",
|
}
|
Server.call("root/data/getEntitySet", param_, function(result){
|
var productDetail = result.data.entityset[0];
|
row.productcode = productDetail.code;
|
row.productname = productDetail.name + productDetail.spec;
|
row.batchnumber = productDetail.batchnumber;
|
row.expirationdate = productDetail.expirationdate;
|
row.productid = productDetail.id;
|
me.rowChange(row, "up");
|
});
|
}
|
this.$refs.form1.refresh();
|
},
|
|
cellInputChange(scope) {
|
let row = scope.row;
|
let field = scope.column.property;
|
},
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
|
Root.confirm('确定删除-' + row.productname + '-吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.rowChange(row, "del");
|
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}).catch(() => {
|
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
}
|
});
|
</script>
|
|
<style>
|
.el-input__inner{
|
padding: 0 2px;
|
}
|
.el-dialog {
|
width: 80%;
|
}
|
</style>
|
|
</body>
|
</html>
|