Commit 2f40df9c by fukai

提交object加工处理

parent c2174da3
export default class Utils{
static toDepthObject(obj)
{
var target = {};
for(var key in obj)
{
var keyArr = key.split("_"); //以下划线或分割
var tempobj = target;
for(var i=0;i<keyArr.length - 1;i++)
{
if(tempobj[keyArr[i]])
tempobj = tempobj[keyArr[i]];
else
{
tempobj[keyArr[i]] = {};
tempobj = tempobj[keyArr[i]];
}
}
//给叶子元素赋值
tempobj[keyArr[keyArr.length - 1]]=obj[key];
}
return target;
}
static flatObject(obj,target,pkey)
{
target = target||{};
for(var key in obj)
{
var nkey = pkey?pkey+"_"+key:key;
if(!obj[key])
target[nkey] = obj[key];
else if(obj[key] instanceof Array)
target[nkey] = obj[key];
else if(typeof obj[key] == "object")
Utils.flatObject(obj[key],target,nkey); //递归赋值
else
target[nkey] = obj[key];
}
return target;
}
static copyValueFromVO(model,vo)
{
var target = model;
for(var key in vo)
{
var keyArr = key.split("_"); //以下划线或分割
var tempobj = target;
for(var i=0;i<keyArr.length - 1;i++)
{
if(tempobj[keyArr[i]])
tempobj = tempobj[keyArr[i]];
else
{
tempobj = null;
break;
}
}
//给叶子元素赋值
if(tempobj )
{
let leafProp = keyArr[keyArr.length - 1];
if(tempobj.hasOwnProperty(leafProp))
tempobj[leafProp]=obj[key];
}
}
return target;
}
}
\ No newline at end of file
......@@ -9,8 +9,34 @@ export function findCodeLabel(codes,val)
return item.label
}
export function dateFormat (date, format) {
let _format = format || 'yyyy-MM-dd';
const d = date;
const o = {
'M+' : d.getMonth() + 1, // month
'd+' : d.getDate(), // day
'h+' : d.getHours(), // hour
'm+' : d.getMinutes(), // minute
's+' : d.getSeconds(), // second
'q+' : Math.floor((d.getMonth() + 3) / 3), // quarter
'S' : d.getMilliseconds() // millisecond
};
if (/(y+)/.test(_format)) {
_format = _format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (const k in o) {
if (o.hasOwnProperty(k) && new RegExp('(' + k + ')').test(_format)) {
_format = _format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
}
}
return _format;
}
export default {
install(Vue){
Vue.prototype.findCodeLabel = findCodeLabel
Vue.prototype.dateFormat = dateFormat
}
}
<template>
<div class="eContainer">
<c-page title="经办夹">
<el-form :model="model" :rules="rules" ref="modelForm" label-width="100px" size="small">
<el-col :span="24">
<div class="e-table-wrapper">
<el-col :span="12">
<el-form-item label="交易名">
<el-input v-model="model.sptp.frm" maxlength="6" placeholder="请输入交易"></el-input>
</el-form-item>
</el-col>
<!--
<el-col :span="12">
<el-form-item label="对象类型">
<el-input v-model="model.sptp.objtyp" maxlength="6" placeholder="请输入对象类型"></el-input>
</el-form-item>
</el-col>
-->
<el-col :span="12">
<el-form-item label="业务编号">
<el-input v-model="model.sptp.objref" maxlength="20" placeholder="请输入业务编号"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="经办柜员">
<el-input v-model="model.sptp.usr" maxlength="20" placeholder="请输入操作员"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态">
<el-select v-model="model.sptp.sta" style="width:100%" placeholder="请选择类型">
<el-option
v-for="item in codes.sptsta"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12">
<el-form-item label="起始日期">
<el-date-picker type="date" v-model="model.sptp.datsta" style="width:100%" placeholder="请选择起始日期"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="至">
<el-date-picker type="date" v-model="model.sptp.datend" style="width:100%" placeholder="请选择至"></el-date-picker>
</el-form-item>
</el-col>
</el-col>
<el-col :span="24" style="text-align:right;">
<el-button size="small" type="primary" icon="el-icon-search" @click="onSel">
查询
</el-button>
<el-button size="small" type="primary" @click="onReset">
重置
</el-button>
</el-col>
<el-col :span=24>
<el-table
:data="model.sptp.lst"
style="width: 100%"
style="width: 100%;height:400px;"
max-height="500"
>
<el-table-column
prop="frm"
......@@ -18,6 +87,9 @@
label="创建时间"
sortable
width="100">
<template slot-scope="scope">
{{dateFormat(scope.row.credattim)}}
</template>
</el-table-column>
<el-table-column
prop="objtyp"
......@@ -35,7 +107,7 @@
prop="objref"
label="参考号"
sortable
width="100">
width="150">
</el-table-column>
<el-table-column
prop="sta"
......@@ -43,7 +115,7 @@
sortable
width="100">
<template slot-scope="scope">
<span>{{ this.codes.sptsta.find(item=>item.value==scope.row.sta).label }}</span>
<span>{{ findCodeLabel(codes.sptsta,scope.row.sta) }}</span>
</template>
</el-table-column>
<el-table-column
......@@ -71,115 +143,45 @@
width="100">
</el-table-column>
<el-table-column
prop="smhinr"
label=""
sortable
width="100">
prop="op"
label="操作"
width="150">
<template slot-scope="scope">
<div>
<div v-if="scope.row.frm">
<a href="javascript:void(0)" @click="onDeal(scope.row)">处理</a>
<el-divider direction="vertical"></el-divider>
<a href="javascript:void(0)" @click="onSptpDel(scope.row)">删除</a>
<span v-if="scope.row.smhinr">
<el-divider direction="vertical"></el-divider>
<a href="javascript:void(0)" @click="onInc(scope.row)" >显示报文</a>
</span>
</div>
<div v-if="!scope.row.frm">
<a href="javascript:void(0)" @click="onSptpDel(scope.row)">删除</a>
<span v-if="scope.row.smhinr">
<el-divider direction="vertical"></el-divider>
<a href="javascript:void(0)" @click="onInc(scope.row)">显示报文</a>
</span>
</div>
</div>
</template>
</el-table-column>
</el-table>
<el-pagination
layout="prev, pager, next"
:total="pager.sptp_lst.total">
</el-pagination>
</div>
</el-col>
<el-col :span="12">
<el-form-item label="交易">
<el-input v-model="model.sptp.frm" maxlength="6" placeholder="请输入交易"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="对象类型">
<el-input v-model="model.sptp.objtyp" maxlength="6" placeholder="请输入对象类型"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="操作员">
<el-input v-model="model.sptp.usr" maxlength="20" placeholder="请输入操作员"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="类型">
<el-select v-model="model.sptp.sta" style="width:100%" placeholder="请选择类型">
<el-option
v-for="item in codes.sptsta"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起始日期">
<el-date-picker type="date" v-model="model.sptp.datsta" style="width:100%" placeholder="请选择起始日期"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="至">
<el-date-picker type="date" v-model="model.sptp.datend" style="width:100%" placeholder="请选择至"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="业务编号">
<el-input v-model="model.sptp.objref" maxlength="20" placeholder="请输入业务编号"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-button size="small" type="primary" icon="el-icon-search" @click="onSel">
查询
</el-button>
</el-col>
<el-col :span="12">
<el-button size="small" type="primary" @click="onReset">
重置
</el-button>
</el-col>
<el-col :span="12">
<el-button size="small" icon="el-icon-delete" @click="onSptpDel">
删除
</el-button>
</el-col>
<el-col :span="12">
<el-button size="small" type="primary" @click="onInc">
报文显示
</el-button>
</el-col>
<el-col :span="12">
<el-form-item label="NewField">
<el-input v-model="model.mtabut.cortyp" maxlength="3" placeholder="请输入NewField"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="Message Type Optional">
<el-input v-model="model.mtabut.msgtyp" maxlength="100" placeholder="请输入Message Type Optional"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="报文信息">
<el-input type="textarea" v-model="model.mtabut.docinf" maxlength="200" show-word-limit placeholder="请输入报文信息" ></el-input>
</el-form-item>
</el-col>
</el-form>
</div>
</c-page>
</template>
<script>
import Api from "~/service/Api"
import CodeTable from "~/config/CodeTable"
import Utils from "~/utils"
export default {
data(){
......@@ -259,11 +261,13 @@ export default {
this.$refs.modelForm.validate(async valid => {
if(!valid)
return;
let rtnmsg = await Api.post("sptsel/sel",{data:this.model})
if(rtnmsg.retcod == SUCCESS)
let rtnmsg = await Api.post("sptsel/sel",{data:Utils.flatObject(this.model)})
if(rtnmsg.code == SUCCESS)
{
//TODO 处理数据逻辑
//this.
//this.model.sptp.lst = rtnmsg.data.sptp_lst
Utils.copyValueFromVO(this.model,rtnmsg.data)
}
else
{
......@@ -272,27 +276,14 @@ export default {
})
},
onReset(){
this.$refs.modelForm.validate(async valid => {
if(!valid)
return;
let rtnmsg = await Api.post("sptsel/reset",{data:this.model})
if(rtnmsg.retcod == SUCCESS)
{
//TODO 处理数据逻辑
}
else
{
this.$notify.error({title: '错误',message: '服务请求失败!'});
}
})
this.$refs.modelForm.resetFields()
},
onSptpDel(){
onSptpDel(row){
this.$refs.modelForm.validate(async valid => {
if(!valid)
return;
let rtnmsg = await Api.post("sptsel/sptp_del",{data:this.model})
if(rtnmsg.retcod == SUCCESS)
if(rtnmsg.code == SUCCESS)
{
//TODO 处理数据逻辑
......@@ -303,12 +294,12 @@ export default {
}
})
},
onInc(){
onInc(row){
this.$refs.modelForm.validate(async valid => {
if(!valid)
return;
let rtnmsg = await Api.post("sptsel/inc",{data:this.model})
if(rtnmsg.retcod == SUCCESS)
if(rtnmsg.code == SUCCESS)
{
//TODO 处理数据逻辑
......@@ -323,7 +314,7 @@ export default {
created:async function(){
console.log("进入sptsel交易");
let rtnmsg = await Api.post("sptsel/init",{params:{}})
if(rtnmsg.retcod == SUCCESS)
if(rtnmsg.code == SUCCESS)
{
//TODO 处理数据逻辑
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment