Browse Source

优化添加任务访问api

master
陈裕财 4 years ago
parent
commit
ddbe62f1b5
  1. 44
      src/api/xm/core/xmRecordVisit.js
  2. 186
      src/views/xm/core/xmRecordVisit/XmRecordVisitEdit.vue
  3. 342
      src/views/xm/core/xmRecordVisit/XmRecordVisitMng.vue
  4. 8
      src/views/xm/core/xmTask/XmTaskEdit.vue

44
src/api/xm/core/xmRecordVisit.js

@ -0,0 +1,44 @@
import axios from '@/utils/request'
import { getDicts,initSimpleDicts,initComplexDicts } from '@/api/mdp/meta/item';//字典表
import config from '@/common/config'
let base = config.getCoreBasePath();
/**-------------------------与后端通讯接口------------------请写在下面-------------------------------------------- */
/**
* 重要页面访问记录
*1 默认只开放普通查询所有查询只要上传 分页参数 {pageNum:当前页码从1开始,pageSize:每页记录数,total:总记录数如果是0后台会自动计算总记录数非0不会自动计算}后台都会自动按分页查询 其它 api用到再打开没用到的api请注释掉
*2 查询新增修改的参数格式 params={id:'日志编号 主键',operUserid:'操作人id',operUsername:'操作人名字',operTime:'操作时间',objType:'对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6',action:'操作的id',remarks:'备注-只描述新旧值之间的变化',gloNo:'全局根踪号,用于跟踪日志',branchId:'机构编号',ip:'ip地址',bizId:'业务主键编号',pbizId:'对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号',bizName:'对象名称'}
**/
//普通查询 条件之间and关系
export const listXmRecordVisit = params => { return axios.get(`${base}/xm/core/xmRecordVisit/list`, { params: params }); };
//删除一条重要页面访问记录 params={id:'日志编号 主键'}
export const delXmRecordVisit = params => { return axios.post(`${base}/xm/core/xmRecordVisit/del`,params); };
//批量删除重要页面访问记录 params=[{id:'日志编号 主键'}]
export const batchDelXmRecordVisit = params => { return axios.post(`${base}/xm/core/xmRecordVisit/batchDel`, params); };
//修改一条重要页面访问记录记录
export const editXmRecordVisit = params => { return axios.post(`${base}/xm/core/xmRecordVisit/edit`, params); };
//新增一条重要页面访问记录
export const addXmRecordVisit = params => { return axios.post(`${base}/xm/core/xmRecordVisit/add`, params); };
//批量修改某些字段
export const editSomeFieldsXmRecordVisit = params => { return axios.post(`${base}/xm/core/xmRecordVisit/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)
});
}
};

186
src/views/xm/core/xmRecordVisit/XmRecordVisitEdit.vue

@ -0,0 +1,186 @@
<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">
<!--编辑界面 XmRecordVisit 重要页面访问记录-->
<el-form :model="editForm" label-width="120px" :rules="editFormRules" ref="editFormRef">
<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="操作人id" prop="operUserid">
<el-input v-model="editForm.operUserid" placeholder="操作人id" :maxlength="50" @change="editSomeFields(editForm,'operUserid',$event)"></el-input>
</el-form-item>
<el-form-item label="操作人名字" prop="operUsername">
<el-input v-model="editForm.operUsername" placeholder="操作人名字" :maxlength="50" @change="editSomeFields(editForm,'operUsername',$event)"></el-input>
</el-form-item>
<el-form-item label="操作时间" prop="operTime">
<el-date-picker type="date" placeholder="选择日期" v-model="editForm.operTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
<el-form-item label="对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6" prop="objType">
<el-input v-model="editForm.objType" placeholder="对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6" :maxlength="50" @change="editSomeFields(editForm,'objType',$event)"></el-input>
</el-form-item>
<el-form-item label="操作的id" prop="action">
<el-input v-model="editForm.action" placeholder="操作的id" :maxlength="50" @change="editSomeFields(editForm,'action',$event)"></el-input>
</el-form-item>
<el-form-item label="备注-只描述新旧值之间的变化" prop="remarks">
<el-input v-model="editForm.remarks" placeholder="备注-只描述新旧值之间的变化" :maxlength="65535" @change="editSomeFields(editForm,'remarks',$event)"></el-input>
</el-form-item>
<el-form-item label="全局根踪号,用于跟踪日志" prop="gloNo">
<el-input v-model="editForm.gloNo" placeholder="全局根踪号,用于跟踪日志" :maxlength="50" @change="editSomeFields(editForm,'gloNo',$event)"></el-input>
</el-form-item>
<el-form-item label="机构编号" prop="branchId">
<el-input v-model="editForm.branchId" placeholder="机构编号" :maxlength="50" @change="editSomeFields(editForm,'branchId',$event)"></el-input>
</el-form-item>
<el-form-item label="ip地址" prop="ip">
<el-input v-model="editForm.ip" placeholder="ip地址" :maxlength="255" @change="editSomeFields(editForm,'ip',$event)"></el-input>
</el-form-item>
<el-form-item label="业务主键编号" prop="bizId">
<el-input v-model="editForm.bizId" placeholder="业务主键编号" :maxlength="50" @change="editSomeFields(editForm,'bizId',$event)"></el-input>
</el-form-item>
<el-form-item label="对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号" prop="pbizId">
<el-input v-model="editForm.pbizId" placeholder="对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号" :maxlength="50" @change="editSomeFields(editForm,'pbizId',$event)"></el-input>
</el-form-item>
<el-form-item label="对象名称" prop="bizName">
<el-input v-model="editForm.bizName" placeholder="对象名称" :maxlength="255" @change="editSomeFields(editForm,'bizName',$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, addXmRecordVisit,editXmRecordVisit,editSomeFieldsXmRecordVisit } from '@/api/xm/core/xmRecordVisit';
import { mapGetters } from 'vuex'
export default {
name:'xmRecordVisitEdit',
components: {
},
computed: {
...mapGetters([ 'userInfo' ]),
},
props:['xmRecordVisit','visible','opType'],
watch: {
'xmRecordVisit':function( xmRecordVisit ) {
if(xmRecordVisit){
this.editForm = {...xmRecordVisit};
}
},
'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: {
id:'',operUserid:'',operUsername:'',operTime:'',objType:'',action:'',remarks:'',gloNo:'',branchId:'',ip:'',bizId:'',pbizId:'',bizName:''
},
maxTableHeight:300,
}//end return
},//end data
methods: {
...util,
// @cancel="editFormVisible=false"
handleCancel:function(){
this.$refs['editFormRef'].resetFields();
this.$emit('cancel');
},
//XmRecordVisit 访@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=addXmRecordVisit
if(this.currOpType=='edit'){
func=editXmRecordVisit
}
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.xmRecordVisit){
this.editForm = Object.assign({},this.xmRecordVisit);
}
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 = editSomeFieldsXmRecordVisit
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>

342
src/views/xm/core/xmRecordVisit/XmRecordVisitMng.vue

@ -0,0 +1,342 @@
<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="searchXmRecordVisits" 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">
<!--列表 XmRecordVisit 重要页面访问记录-->
<el-table ref="xmRecordVisitTable" :data="xmRecordVisits" :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="operUserid" label="操作人id" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.operUserid}} </span>
</template>
</el-table-column>
<el-table-column prop="operUsername" label="操作人名字" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.operUsername}} </span>
</template>
</el-table-column>
<el-table-column prop="operTime" label="操作时间" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.operTime}} </span>
</template>
</el-table-column>
<el-table-column prop="objType" label="对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.objType}} </span>
</template>
</el-table-column>
<el-table-column prop="action" label="操作的id" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.action}} </span>
</template>
</el-table-column>
<el-table-column prop="remarks" label="备注-只描述新旧值之间的变化" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.remarks}} </span>
</template>
</el-table-column>
<el-table-column prop="gloNo" label="全局根踪号,用于跟踪日志" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.gloNo}} </span>
</template>
</el-table-column>
<el-table-column prop="branchId" label="机构编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.branchId}} </span>
</template>
</el-table-column>
<el-table-column prop="ip" label="ip地址" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.ip}} </span>
</template>
</el-table-column>
<el-table-column prop="bizId" label="业务主键编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.bizId}} </span>
</template>
</el-table-column>
<el-table-column prop="pbizId" label="对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.pbizId}} </span>
</template>
</el-table-column>
<el-table-column prop="bizName" label="对象名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.bizName}} </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>
<!--编辑 XmRecordVisit 重要页面访问记录界面-->
<el-drawer title="编辑重要页面访问记录" :visible.sync="editFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-record-visit-edit op-type="edit" :xm-record-visit="editForm" :visible="editFormVisible" @cancel="editFormVisible=false" @submit="afterEditSubmit"></xm-record-visit-edit>
</el-drawer>
<!--新增 XmRecordVisit 重要页面访问记录界面-->
<el-drawer title="新增重要页面访问记录" :visible.sync="addFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-record-visit-edit op-type="add" :visible="addFormVisible" @cancel="addFormVisible=false" @submit="afterAddSubmit"></xm-record-visit-edit>
</el-drawer>
</el-row>
</section>
</template>
<script>
import util from '@/common/js/util';//
import config from '@/common/config';//
import { initDicts,listXmRecordVisit, delXmRecordVisit, batchDelXmRecordVisit,editSomeFieldsXmRecordVisit } from '@/api/xm/core/xmRecordVisit';
import XmRecordVisitEdit from './XmRecordVisitEdit';//
import { mapGetters } from 'vuex'
export default {
name:'xmRecordVisitMng',
components: {
XmRecordVisitEdit,
},
props:['visible'],
computed: {
...mapGetters(['userInfo']),
},
watch:{
visible(val){
if(val==true){
this.initData();
this.searchXmRecordVisits()
}
}
},
data() {
return {
filters: {
key: ''
},
xmRecordVisits: [],//
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,//xmRecordVisit
addForm: {
id:'',operUserid:'',operUsername:'',operTime:'',objType:'',action:'',remarks:'',gloNo:'',branchId:'',ip:'',bizId:'',pbizId:'',bizName:''
},
editFormVisible: false,//
editForm: {
id:'',operUserid:'',operUsername:'',operTime:'',objType:'',action:'',remarks:'',gloNo:'',branchId:'',ip:'',bizId:'',pbizId:'',bizName:''
},
maxTableHeight:300,
}
},//end data
methods: {
...util,
handleSizeChange(pageSize) {
this.pageInfo.pageSize=pageSize;
this.getXmRecordVisits();
},
handleCurrentChange(pageNum) {
this.pageInfo.pageNum = pageNum;
this.getXmRecordVisits();
},
// 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.getXmRecordVisits();
},
searchXmRecordVisits(){
this.pageInfo.count=true;
this.getXmRecordVisits();
},
// XmRecordVisit 访
getXmRecordVisits() {
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;
listXmRecordVisit(params).then((res) => {
var tips=res.data.tips;
if(tips.isOk){
this.pageInfo.total = res.data.total;
this.pageInfo.count=false;
this.xmRecordVisits = 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 );
},
// XmRecordVisit 访
showEdit: function ( row,index ) {
this.editFormVisible = true;
this.editForm = Object.assign({}, row);
},
// XmRecordVisit 访
showAdd: function () {
this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm);
},
afterAddSubmit(){
this.addFormVisible=false;
this.pageInfo.count=true;
this.getXmRecordVisits();
},
afterEditSubmit(){
this.editFormVisible=false;
},
//xmRecordVisit
selsChange: function (sels) {
this.sels = sels;
},
//xmRecordVisit
handleDel: function (row,index) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.load.del=true;
let params = { id:row.id };
delXmRecordVisit(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if(tips.isOk){
this.searchXmRecordVisits();
}
this.$notify({ position:'bottom-left', showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.del=false );
});
},
//xmRecordVisit
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;
batchDelXmRecordVisit(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if( tips.isOk ){
this.searchXmRecordVisits();
}
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 = editSomeFieldsXmRecordVisit
func(params).then(res=>{
let tips = res.data.tips;
if(tips.isOk){
if(this.sels.length>0){
this.searchXmRecordVisits();
}
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.searchXmRecordVisits();
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.xmRecordVisitTable.$el)
});
}
}
</script>
<style scoped>
</style>

8
src/views/xm/core/xmTask/XmTaskEdit.vue

@ -334,6 +334,7 @@
<script>
import util from '@/common/js/util';//
import {initDicts,editXmTask,setTaskCreateUser,editXmTaskSomeFields,batchChangeParentTask } from '@/api/xm/core/xmTask';
import {addXmRecordVisit } from '@/api/xm/core/xmRecordVisit';
import { mapGetters } from 'vuex';
import {sn} from '@/common/js/sequence';
import xmSkillMng from '../xmTaskSkill/XmTaskSkillMng';
@ -375,7 +376,8 @@
this.editFormBak=Object.assign({},this.editForm)
this.setSkills()
this.activateTabPaneName="2"
this.supRequires=this.editForm.supRequires?this.editForm.supRequires.split(","):[]
this.supRequires=this.editForm.supRequires?this.editForm.supRequires.split(","):[]
this.doAddXmRecordVisit()
//
}
},
@ -748,6 +750,9 @@
});
})
},
doAddXmRecordVisit(){
addXmRecordVisit({bizId:this.editForm.id,objType:'2',pbizId:this.editForm.projectId})
}
},//end method
components: {
xmSkillMng,
@ -762,6 +767,7 @@
this.editFormBak=Object.assign({},this.editForm)
this.supRequires=this.editForm.supRequires?this.editForm.supRequires.split(","):[]
this.setSkills();
this.doAddXmRecordVisit()
/**在下面写其它函数***/
}//end mounted

Loading…
Cancel
Save