Browse Source

优化

master
陈裕财 3 years ago
parent
commit
23d9b9bef0
  1. 45
      src/api/xm/core/xmRptData.js
  2. 177
      src/views/xm/core/xmRptData/XmRptDataEdit.vue
  3. 327
      src/views/xm/core/xmRptData/XmRptDataMng.vue
  4. 23
      src/views/xm/rpt/CompsCard.vue

45
src/api/xm/core/xmRptData.js

@ -0,0 +1,45 @@
import axios from '@/utils/request'
import { getDicts,initSimpleDicts,initComplexDicts } from '@/api/mdp/meta/item';//字典表
import config from '@/common/config'
let base = config.getCoreBasePath();
/**-------------------------与后端通讯接口------------------请写在下面-------------------------------------------- */
/**
* xm_rpt_data
*1 默认只开放普通查询所有查询只要上传 分页参数 {pageNum:当前页码从1开始,pageSize:每页记录数,total:总记录数如果是0后台会自动计算总记录数非0不会自动计算}后台都会自动按分页查询 其它 api用到再打开没用到的api请注释掉
*2 查询新增修改的参数格式 params={id:'报表主键 主键',cfgId:'报表配置主键',rptName:'报表名称',rptData:'报表数据json对象,比rptCfg.cfg多了rawDatas',cuserid:'创建人编号',cbranchId:'创建人机构号',cusername:'创建人名称',ctime:'创建日期',bizDate:'归属业务日期yyyy-MM-dd型',bizType:'业务类型,同rpt_config.biz_type'}
**/
//普通查询 条件之间and关系
export const listXmRptData = params => { return axios.get(`${base}/xm/core/xmRptData/list`, { params: params }); };
//删除一条xm_rpt_data params={id:'报表主键 主键'}
export const delXmRptData = params => { return axios.post(`${base}/xm/core/xmRptData/del`,params); };
//批量删除xm_rpt_data params=[{id:'报表主键 主键'}]
export const batchDelXmRptData = params => { return axios.post(`${base}/xm/core/xmRptData/batchDel`, params); };
//修改一条xm_rpt_data记录
export const editXmRptData = params => { return axios.post(`${base}/xm/core/xmRptData/edit`, params); };
//新增一条xm_rpt_data
export const addXmRptData = params => { return axios.post(`${base}/xm/core/xmRptData/add`, params); };
//批量修改某些字段
export const editSomeFieldsXmRptData = params => { return axios.post(`${base}/xm/core/xmRptData/editSomeFields`, params); };
/**-------------------------前端mng|add|edit界面公共函数---------------请写在下面----------------------------------------------- */
//初始化页面上的字典
export const initDicts = (that) => {
var itemCodes=[];//在此添加要加载的字典 如['sex','grade','lvl']
if(itemCodes.length>0){
initSimpleDicts('all',itemCodes).then(res=>{
Object.assign(that.dicts,res.data.data)
});
}
};

177
src/views/xm/core/xmRptData/XmRptDataEdit.vue

@ -0,0 +1,177 @@
<template>
<section class="page-container padding">
<el-row class="page-header">
</el-row>
<el-row class="page-main" :style="{overflowX:'auto',height:maxTableHeight+'px'}" ref="table">
<!--编辑界面 XmRptData xm_rpt_data-->
<el-form :model="editForm" label-width="120px" :rules="editFormRules" ref="editFormRef">
<el-form-item label="报表配置主键" prop="cfgId">
<el-input v-model="editForm.cfgId" placeholder="报表配置主键" :maxlength="50" @change="editSomeFields(editForm,'cfgId',$event)"></el-input>
</el-form-item>
<el-form-item label="报表主键" prop="id">
<el-input v-model="editForm.id" placeholder="报表主键" :maxlength="50" @change="editSomeFields(editForm,'id',$event)"></el-input>
</el-form-item>
<el-form-item label="报表名称" prop="rptName">
<el-input v-model="editForm.rptName" placeholder="报表名称" :maxlength="255" @change="editSomeFields(editForm,'rptName',$event)"></el-input>
</el-form-item>
<el-form-item label="报表数据json对象,比rptCfg.cfg多了rawDatas" prop="rptData">
<el-input v-model="editForm.rptData" placeholder="报表数据json对象,比rptCfg.cfg多了rawDatas" :maxlength="2147483647" @change="editSomeFields(editForm,'rptData',$event)"></el-input>
</el-form-item>
<el-form-item label="创建人编号" prop="cuserid">
<el-input v-model="editForm.cuserid" placeholder="创建人编号" :maxlength="50" @change="editSomeFields(editForm,'cuserid',$event)"></el-input>
</el-form-item>
<el-form-item label="创建人机构号" prop="cbranchId">
<el-input v-model="editForm.cbranchId" placeholder="创建人机构号" :maxlength="50" @change="editSomeFields(editForm,'cbranchId',$event)"></el-input>
</el-form-item>
<el-form-item label="创建人名称" prop="cusername">
<el-input v-model="editForm.cusername" placeholder="创建人名称" :maxlength="255" @change="editSomeFields(editForm,'cusername',$event)"></el-input>
</el-form-item>
<el-form-item label="创建日期" prop="ctime">
<el-date-picker type="date" placeholder="选择日期" v-model="editForm.ctime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
<el-form-item label="归属业务日期yyyy-MM-dd型" prop="bizDate">
<el-input v-model="editForm.bizDate" placeholder="归属业务日期yyyy-MM-dd型" :maxlength="10" @change="editSomeFields(editForm,'bizDate',$event)"></el-input>
</el-form-item>
<el-form-item label="业务类型,同rpt_config.biz_type" prop="bizType">
<el-input v-model="editForm.bizType" placeholder="业务类型,同rpt_config.biz_type" :maxlength="1" @change="editSomeFields(editForm,'bizType',$event)"></el-input>
</el-form-item>
</el-form>
</el-row>
<el-row v-if="opType=='add'" class="page-bottom bottom-fixed">
<el-button @click.native="handleCancel">取消</el-button>
<el-button v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="load.edit==true">提交</el-button>
</el-row>
</section>
</template>
<script>
import util from '@/common/js/util';//
import config from "@/common/config"; //import
import { initDicts, addXmRptData,editXmRptData,editSomeFieldsXmRptData } from '@/api/xm/core/xmRptData';
import { mapGetters } from 'vuex'
export default {
name:'xmRptDataEdit',
components: {
},
computed: {
...mapGetters([ 'userInfo' ]),
},
props:['xmRptData','visible','opType'],
watch: {
'xmRptData':function( xmRptData ) {
if(xmRptData){
this.editForm = {...xmRptData};
}
},
'visible':function(visible) {
if(visible==true){
this.initData()
}
}
},
data() {
return {
currOpType:'add',//add/edit
load:{ list: false, edit: false, del: false, add: false },//...
dicts:{},// params={categoryId:'all',itemCodes:['sex']} {sex: [{id:'1',name:''},{id:'2',name:''}]}
editFormRules: {
id: [
//{ required: true, message: '', trigger: 'blur' }
]
},
editForm: {
cfgId:'',id:'',rptName:'',rptData:'',cuserid:'',cbranchId:'',cusername:'',ctime:'',bizDate:'',bizType:''
},
maxTableHeight:300,
}//end return
},//end data
methods: {
...util,
// @cancel="editFormVisible=false"
handleCancel:function(){
this.$refs['editFormRef'].resetFields();
this.$emit('cancel');
},
//XmRptData xm_rpt_data@submit="afterEditSubmit"
saveSubmit: function () {
this.$refs.editFormRef.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
this.load.edit=true
let params = Object.assign({}, this.editForm);
var func=addXmRptData
if(this.currOpType=='edit'){
func=editXmRptData
}
func(params).then((res) => {
this.load.edit=false
var tips=res.data.tips;
if(tips.isOk){
this.editForm=res.data.data
this.initData()
this.currOpType="edit";
this.$emit('submit');// @submit="afterAddSubmit"
}
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err =>this.load.edit=false);
});
}else{
this.$notify({ showClose:true, message: "表单验证不通过,请修改表单数据再提交", type: 'error' });
}
});
},
initData: function(){
this.currOpType=this.opType
if(this.xmRptData){
this.editForm = Object.assign({},this.xmRptData);
}
if(this.opType=='edit'){
}else{
}
this.editFormBak={...this.editForm}
},
editSomeFields(row,fieldName,$event){
if(this.opType=='add'){
return;
}
let params={};
params['ids']=[row].map(i=>i.id)
params[fieldName]=$event
var func = editSomeFieldsXmRptData
func(params).then(res=>{
let tips = res.data.tips;
if(tips.isOk){
this.editFormBak=[...this.editForm]
}else{
Object.assign(this.editForm,this.editFormBak)
this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'})
}
}).catch((e)=>Object.assign(this.editForm,this.editFormBak))
},
},//end method
mounted() {
this.$nextTick(() => {
initDicts(this);
this.initData()
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.table.$el)
});
}
}
</script>
<style scoped>
</style>

327
src/views/xm/core/xmRptData/XmRptDataMng.vue

@ -0,0 +1,327 @@
<template>
<section class="page-container border padding">
<el-row>
<el-input v-model="filters.key" style="width: 20%;" placeholder="模糊查询"></el-input>
<el-button v-loading="load.list" :disabled="load.list==true" @click="searchXmRptDatas" icon="el-icon-search">查询</el-button>
<span style="float:right;">
<el-button type="primary" @click="showAdd" icon="el-icon-plus" plain> </el-button>
<el-button type="danger" v-loading="load.del" @click="batchDel" :disabled="this.sels.length===0 || load.del==true" icon="el-icon-delete" plain></el-button>
</span>
</el-row>
<el-row class="padding-top">
<!--列表 XmRptData xm_rpt_data-->
<el-table ref="xmRptDataTable" :data="xmRptDatas" :height="maxTableHeight" @sort-change="sortChange" highlight-current-row v-loading="load.list" border @selection-change="selsChange" @row-click="rowClick" style="width: 100%;">
<el-table-column type="selection" width="55" show-overflow-tooltip fixed="left"></el-table-column>
<el-table-column sortable type="index" width="55" show-overflow-tooltip fixed="left"></el-table-column>
<!--
<el-table-column sortable prop="username" width="55" show-overflow-tooltip fixed="left">
<span class="cell-text"> {{scope.row.username}}} </span>
<span class="cell-bar"><el-input style="display:inline;" v-model="scope.row.username" placeholder="" @change="editSomeFields(scope.row,'username',$event)" :maxlength="22"></el-input></span>
</el-table-column>
-->
<el-table-column prop="id" label="报表主键" min-width="120" show-overflow-tooltip fixed="left"></el-table-column>
<el-table-column prop="cfgId" label="报表配置主键" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cfgId}} </span>
</template>
</el-table-column>
<el-table-column prop="rptName" label="报表名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.rptName}} </span>
</template>
</el-table-column>
<el-table-column prop="rptData" label="报表数据json对象,比rptCfg.cfg多了rawDatas" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.rptData}} </span>
</template>
</el-table-column>
<el-table-column prop="cuserid" label="创建人编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cuserid}} </span>
</template>
</el-table-column>
<el-table-column prop="cbranchId" label="创建人机构号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cbranchId}} </span>
</template>
</el-table-column>
<el-table-column prop="cusername" label="创建人名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cusername}} </span>
</template>
</el-table-column>
<el-table-column prop="ctime" label="创建日期" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.ctime}} </span>
</template>
</el-table-column>
<el-table-column prop="bizDate" label="归属业务日期yyyy-MM-dd型" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.bizDate}} </span>
</template>
</el-table-column>
<el-table-column prop="bizType" label="业务类型,同rpt_config.biz_type" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.bizType}} </span>
</template>
</el-table-column>
<el-table-column label="操作" width="180" fixed="right">
<template scope="scope">
<el-button type="primary" @click="showEdit( scope.row,scope.$index)" icon="el-icon-edit" plain></el-button>
<el-button type="danger" @click="handleDel(scope.row,scope.$index)" icon="el-icon-delete" plain></el-button>
</template>
</el-table-column>
</el-table>
<el-pagination layout="total, sizes, prev, pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;"></el-pagination>
</el-row>
<el-row>
<!--编辑 XmRptData xm_rpt_data界面-->
<el-drawer title="编辑xm_rpt_data" :visible.sync="editFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-rpt-data-edit op-type="edit" :xm-rpt-data="editForm" :visible="editFormVisible" @cancel="editFormVisible=false" @submit="afterEditSubmit"></xm-rpt-data-edit>
</el-drawer>
<!--新增 XmRptData xm_rpt_data界面-->
<el-drawer title="新增xm_rpt_data" :visible.sync="addFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-rpt-data-edit op-type="add" :visible="addFormVisible" @cancel="addFormVisible=false" @submit="afterAddSubmit"></xm-rpt-data-edit>
</el-drawer>
</el-row>
</section>
</template>
<script>
import util from '@/common/js/util';//
import config from '@/common/config';//
import { initDicts,listXmRptData, delXmRptData, batchDelXmRptData,editSomeFieldsXmRptData } from '@/api/xm/core/xmRptData';
import XmRptDataEdit from './XmRptDataEdit';//
import { mapGetters } from 'vuex'
export default {
name:'xmRptDataMng',
components: {
XmRptDataEdit,
},
props:['visible'],
computed: {
...mapGetters(['userInfo']),
},
watch:{
visible(val){
if(val==true){
this.initData();
this.searchXmRptDatas()
}
}
},
data() {
return {
filters: {
key: ''
},
xmRptDatas: [],//
pageInfo:{//
total:0,//0>0
pageSize:10,//
count:false,//
pageNum:1,//1
orderFields:[],// ['sex','student_id']
orderDirs:[]// asc,desc ['asc','desc']
},
load:{ list: false, edit: false, del: false, add: false },//...
sels: [],//
dicts:{
//sex: [{id:'1',name:''},{id:'2',name:''}]
},// params={categoryId:'all',itemCodes:['sex']} {sex: [{id:'1',name:''},{id:'2',name:''}]}
addFormVisible: false,//xmRptData
addForm: {
cfgId:'',id:'',rptName:'',rptData:'',cuserid:'',cbranchId:'',cusername:'',ctime:'',bizDate:'',bizType:''
},
editFormVisible: false,//
editForm: {
cfgId:'',id:'',rptName:'',rptData:'',cuserid:'',cbranchId:'',cusername:'',ctime:'',bizDate:'',bizType:''
},
maxTableHeight:300,
}
},//end data
methods: {
...util,
handleSizeChange(pageSize) {
this.pageInfo.pageSize=pageSize;
this.getXmRptDatas();
},
handleCurrentChange(pageNum) {
this.pageInfo.pageNum = pageNum;
this.getXmRptDatas();
},
// obj.order=ascending/descending, asc/desc ; obj.prop=,
sortChange( obj ){
if(obj.order==null){
this.pageInfo.orderFields=[];
this.pageInfo.orderDirs=[];
}else{
var dir='asc';
if(obj.order=='ascending'){
dir='asc'
}else{
dir='desc';
}
this.pageInfo.orderFields=[util.toLine(obj.prop)];
this.pageInfo.orderDirs=[dir];
}
this.getXmRptDatas();
},
searchXmRptDatas(){
this.pageInfo.count=true;
this.getXmRptDatas();
},
// XmRptData xm_rpt_data
getXmRptDatas() {
let params = {
pageSize: this.pageInfo.pageSize,
pageNum: this.pageInfo.pageNum,
total: this.pageInfo.total,
count:this.pageInfo.count
};
if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
let orderBys=[];
for(var i=0;i<this.pageInfo.orderFields.length;i++){
orderBys.push(this.pageInfo.orderFields[i]+" "+this.pageInfo.orderDirs[i])
}
params.orderBy= orderBys.join(",")
}
if(this.filters.key){
params.key=this.filters.key
}
this.load.list = true;
listXmRptData(params).then((res) => {
var tips=res.data.tips;
if(tips.isOk){
this.pageInfo.total = res.data.total;
this.pageInfo.count=false;
this.xmRptDatas = res.data.data;
}else{
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: 'error' });
}
this.load.list = false;
}).catch( err => this.load.list = false );
},
// XmRptData xm_rpt_data
showEdit: function ( row,index ) {
this.editFormVisible = true;
this.editForm = Object.assign({}, row);
},
// XmRptData xm_rpt_data
showAdd: function () {
this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm);
},
afterAddSubmit(){
this.addFormVisible=false;
this.pageInfo.count=true;
this.getXmRptDatas();
},
afterEditSubmit(){
this.editFormVisible=false;
},
//xmRptData
selsChange: function (sels) {
this.sels = sels;
},
//xmRptData
handleDel: function (row,index) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.load.del=true;
let params = { id:row.id };
delXmRptData(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if(tips.isOk){
this.searchXmRptDatas();
}
this.$notify({ position:'bottom-left', showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.del=false );
});
},
//xmRptData
batchDel: function () {
if(this.sels.length<=0){
return;
}
var params=this.sels.map(i=>{
return { id:i.id}
})
this.$confirm('确认删除选中记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.load.del=true;
batchDelXmRptData(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if( tips.isOk ){
this.searchXmRptDatas();
}
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error'});
}).catch( err => this.load.del=false );
});
},
editSomeFields(row,fieldName,$event){
let params={};
if(this.sels.length>0){
if(!this.sels.some(k=> k.id==row.id)){
this.$notify({position:'bottom-left',showClose:true,message:'请编辑选中的行',type:'warning'})
Object.assign(this.editForm,this.editFormBak)
return;
}
params['ids']=this.sels.map(i=>i.id)
}else{
params['ids']=[row].map(i=>i.id)
}
params[fieldName]=$event
var func = editSomeFieldsXmRptData
func(params).then(res=>{
let tips = res.data.tips;
if(tips.isOk){
if(this.sels.length>0){
this.searchXmRptDatas();
}
this.editFormBak=[...this.editForm]
}else{
Object.assign(this.editForm,this.editFormBak)
this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'})
}
}).catch((e)=>Object.assign(this.editForm,this.editFormBak))
},
rowClick: function(row, event, column){
this.editForm=row
this.editFormBak={...row};
this.$emit('row-click',row, event, column);// @row-click="rowClick"
},
initData: function(){
},
},//end methods
mounted() {
this.$nextTick(() => {
initDicts(this);
this.initData()
this.searchXmRptDatas();
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.xmRptDataTable.$el)
});
}
}
</script>
<style scoped>
</style>

23
src/views/xm/rpt/CompsCard.vue

@ -218,6 +218,29 @@ export default {
this.$message.error("还没制作报告,请先制作报告") this.$message.error("还没制作报告,请先制作报告")
return; return;
} }
var rptData={cfgId:this.xmRptConfig.id,rptName:this.xmRptConfig.name,rptData:{}}
var compCfgList=JSON.parse(JSON.stringify(this.compCfgList))
compCfgList=compCfgList.map(k=>{
return {compId:k.compId,id:k.id}
})
compCfgList.forEach(k=>{
if(this.$refs[k.id] && this.$refs[k.id][0].$refs && this.$refs[k.id][0].$refs[k.id]){
var com=this.$refs[k.id][0].$refs[k.id]
k.params=com.params
k.title=com.title
k.remark=com.remark
}else{
var com=this.$refs[k.id][0]
k.params=com.params
k.title=com.title
k.remark=com.remark
}
})
xmRptConfig.cfg=JSON.stringify(compCfgList)
editXmRptConfig(xmRptConfig).then(res=>{
this.xmRptConfig=xmRptConfig;
callback(res)
})
}, },
undoRptCfg(){ undoRptCfg(){
this.xmRptConfig=null; this.xmRptConfig=null;

Loading…
Cancel
Save