boxu.zheng 1 year ago
parent
commit
e3fd23ecc0
  1. 35
      Code/Fe/src/api/wms-api.js
  2. 113
      Code/Fe/src/components/addEditFromApiPop/index.vue
  3. 312
      Code/Fe/src/components/addEditFromApiPop/index_mst.vue
  4. 46
      Code/Fe/src/components/commonTabel-drawer/index.vue
  5. 42
      Code/Fe/src/components/currenTableFlex/index.vue
  6. 5
      Code/Fe/src/components/rowDrop/index.vue
  7. 284
      Code/Fe/src/components/showCopyJsonPop/index.vue
  8. 600
      Code/Fe/src/components/umyTable/_index.vue
  9. 413
      Code/Fe/src/components/umyTable/index.vue
  10. 30
      Code/Fe/src/lang/en.js
  11. 3
      Code/Fe/src/lang/index.js
  12. 14
      Code/Fe/src/lang/zh.js
  13. 34
      Code/Fe/src/mixins/TableMixins.js
  14. 6
      Code/Fe/src/mixins/mixins.js
  15. 1
      Code/Fe/src/store/getters.js
  16. 20
      Code/Fe/src/store/modules/definition.js
  17. 6
      Code/Fe/src/utils/auth.js
  18. 19
      Code/Fe/src/utils/defaultButtons.js
  19. 112
      Code/Fe/src/views/demo/demo_api_handle.vue
  20. 26
      Code/Fe/src/views/demo/demo_read.vue

35
Code/Fe/src/api/wms-api.js

@ -1,6 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
import store from '@/store' import store from '@/store'
// let baseURL = process.env.VUE_APP_BASE_API + '/' // let baseURL = process.env.VUE_APP_BASE_API + '/'
let baseAPI = localStorage.getItem('baseApi') + '/'
let baseURL = localStorage.getItem('baseApi') + '/api/' let baseURL = localStorage.getItem('baseApi') + '/api/'
//新建 //新建
@ -148,11 +149,29 @@ export function getVsersion() {
}) })
} }
// // 测试数据-明细-删除 // fast-new
// export function TestSchoolDetailList_delete(id) { //API-POST
// return request({ export function ApiTypePost(data, url) {
// method:'DELETE', return request({
// url: base_api + '/api/TestStudentDetail/base/delete-by-id', url: baseAPI + url,
// params:{id:id} method: 'post',
// }) data
// } })
}
//API-PUT
export function ApiTypePut(data, id, url) {
return request({
url: baseAPI + url,
method: 'put',
data,
params:{id:id}
})
}
//API-DELETE
export function ApiTypeDelete(id, url) {
return request({
url: baseAPI + url,
method: 'delete',
params:{id:id}
})
}

113
Code/Fe/src/components/addEditFromApiPop/index.vue

@ -11,10 +11,12 @@
style="width:calc(100% - 28px);left:14px;top:14px;height:calc(100% - 28px)" style="width:calc(100% - 28px);left:14px;top:14px;height:calc(100% - 28px)"
v-loading="Loading.addEditApiLoading" v-loading="Loading.addEditApiLoading"
> >
<!-- 表单 --> <!-- 数据填写 -->
<div v-if="active === 0" style="height: 100%;"> <div v-if="active === 0" style="height: 100%;">
<!-- 标题 --> <div class="centerInnerContent" :class="{'hasDetails' : flexTableData}">
<div class="dialogOuterTitle">{{formTitle}}</div> <!-- 左侧主表 -->
<div class="leftMainForm">
<div class="dialogOuterTitle">{{formTitle}} 主表信息</div>
<!-- 表单 --> <!-- 表单 -->
<el-form <el-form
class="addEditFrom" class="addEditFrom"
@ -32,6 +34,7 @@
<el-form-item <el-form-item
:label="item.label" :label="item.label"
:prop="item.prop" :prop="item.prop"
v-if="item.label.toUpperCase() != 'DETAILS'"
> >
<!-- 数值 --> <!-- 数值 -->
<el-input-number <el-input-number
@ -93,6 +96,21 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
</div>
<!-- 右侧子表 -->
<div class="rightDetailTable" v-if="flexTableData">
<div class="dialogOuterTitle">{{formTitle}} 子表信息</div>
<currenTableFlex
ref="currenTableFlex_Ref"
:isShowIndex="true"
:isEditable="true"
:setUTableHeight="230"
class="currenTableFlex"
:flexTableData="flexTableData"
:flexTableColumns="flexTableColumns"
></currenTableFlex>
</div>
</div>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="show = false"> </el-button> <el-button @click="show = false"> </el-button>
@ -125,13 +143,16 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { postCreate, postUpdate } from "@/api/wms-api" import { ApiTypePost, ApiTypePut } from "@/api/wms-api"
import { LoadingMixins } from "@/mixins/LoadingMixins"; import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins" import { tableMixins } from "@/mixins/TableMixins"
import currenTableFlex from "@/components/currenTableFlex"
import * as allUrlOption from '@/utils/baseData/urlOption' import * as allUrlOption from '@/utils/baseData/urlOption'
import { timeAgo } from "@/filters";
export default { export default {
name:"addEditFromApiPop", name:"addEditFromApiPop",
mixins:[ LoadingMixins,tableMixins ], mixins:[ LoadingMixins,tableMixins ],
components: { currenTableFlex },
props: { props: {
// //
editRowData:{ editRowData:{
@ -157,22 +178,23 @@ export default {
editSubmitUrl:{ editSubmitUrl:{
type: String, type: String,
default: null default: null
} },
}, },
data () { data () {
return { return {
// //-
URLOption_base:allUrlOption[this.$route.name].baseURL, URLOption_detailList:allUrlOption[this.$route.name].detailListURL,
// // dto
URLOption_add:allUrlOption[this.$route.name].addURL, currentDtos:this.$store.getters.dtoColumnTypes[this.$route.name],
//
URLOption_edit:allUrlOption[this.$route.name].editURL,
active:0,//0 1 2 active:0,//0 1 2
show:true, show:true,
formTitle:null,//form formTitle:null,//form
formData:{},// formData:{},//
formItemData:null,//item formItemData:null,//item
formRules: {},// formRules: {},//
flexTableData:null,//table
// flexTableColumns:null,//table
flexTableColumns: null,
} }
}, },
mounted(){ mounted(){
@ -188,16 +210,37 @@ export default {
}, },
// rules // rules
initFormItems(){ initFormItems(){
let data = this.$store.getters.dtoColumnTypes
let _dtoList_type = this.handleType == 'add' ? 'C' : 'U' let _dtoList_type = this.handleType == 'add' ? 'C' : 'U'
let _dtoList = data[this.$route.name][_dtoList_type].dtoList let _dtoList = this.currentDtos[_dtoList_type].dtoList
this.formItemData = JSON.parse(JSON.stringify(_dtoList)) //
let _formItems = _dtoList.filter(item=>{
return item.prop.toUpperCase() != 'DETAILS'
})
if(_formItems)this.formItemData = _formItems
// //
if(this.handleType == 'edit' && this.editRowData){ if(this.handleType == 'edit' && this.editRowData){
this.formData = JSON.parse(JSON.stringify(this.editRowData)) this.formData = JSON.parse(JSON.stringify(this.editRowData))
}else{ }else{
this.formData = {} this.formData = {}
} }
//
let _list = _dtoList.filter(item=>{
return item.prop.toUpperCase() == 'DETAILS'
})
if(_list && _list.length > 0){
if(this.handleType == 'edit'){
this.flexTableData = this.formData[_list[0].prop]
}else{
this.flexTableData = []
}
}
//
if(this.URLOption_detailList){
let _detailApi = this.URLOption_detailList.slice(0,this.URLOption_detailList.lastIndexOf('/'))
let _detailDtos = this.$store.getters.dtoColumnTypes[_detailApi].S.dtoList
this.flexTableColumns = _detailDtos
}
// //
this.formRules={} this.formRules={}
_dtoList.forEach(item=>{ _dtoList.forEach(item=>{
@ -236,14 +279,15 @@ export default {
this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules) this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules)
return return
} }
let _updata = this.handleType == 'add' ? this.URLOption_add : this.URLOption_edit this.formData.details = this.flexTableData
let _url = _updata ? _updata : this.URLOption_base
this.Loading.addEditApiLoading = true this.Loading.addEditApiLoading = true
if (valid) { if (valid) {
// //
if(this.handleType == 'add'){ if(this.handleType == 'add'){
if(!_updata){_url = _url + '/create'} ApiTypePost(
postCreate(this.formData, _url).then(res => { this.formData,
this.currentDtos.C.actionsUrl
).then(res => {
this.changeActive(1) this.changeActive(1)
}).catch(err => { }).catch(err => {
this.changeActive(2) this.changeActive(2)
@ -251,8 +295,11 @@ export default {
} }
// //
else{ else{
if(!_updata){_url = _url + '/update-by-id'} ApiTypePut(
postUpdate(this.formData, this.formData.id, _url).then(res => { this.formData,
this.formData.id,
this.currentDtos.U.actionsUrl
).then(res => {
this.changeActive(1) this.changeActive(1)
}).catch(err => { }).catch(err => {
this.changeActive(2) this.changeActive(2)
@ -298,7 +345,7 @@ export default {
width: 100%; width: 100%;
} }
::v-deep .addEditFrom{ ::v-deep .addEditFrom{
height: calc(100% - 120px); height: calc(100%);
overflow: auto; overflow: auto;
} }
::v-deep .el-form-item__label{ ::v-deep .el-form-item__label{
@ -313,4 +360,28 @@ export default {
padding-top: 15px; padding-top: 15px;
text-align: right; text-align: right;
} }
.centerInnerContent{
height: calc(100% - 60px);
overflow: auto;
.leftMainForm{
height: calc(100% - 60px);
}
&.hasDetails{
display: flex;
.leftMainForm{
width: 50%;
flex-shrink: 0;
}
.rightDetailTable{
height: calc(100% - 60px);
width: calc(50%);
padding-left:40px;
border-left: #ddd solid 1px;
}
}
}
</style> </style>

312
Code/Fe/src/components/addEditFromApiPop/index_mst.vue

@ -0,0 +1,312 @@
<template>
<!-- 组件功能普通新增编辑目前只有主表参数配置从api获取 -->
<el-dialog
:visible.sync="show"
:modal="false"
:modal-append-to-body="false"
:show-close="true"
@close="close"
class="searchPageComponents"
:fullscreen="true"
style="width:calc(100% - 28px);left:14px;top:14px;height:calc(100% - 28px)"
v-loading="Loading.addEditApiLoading"
>
<!-- 表单 -->
<div v-if="active === 0" style="height: 100%;">
<!-- 标题 -->
<div class="dialogOuterTitle">{{formTitle}}</div>
<!-- 表单 -->
<el-form
class="addEditFrom"
ref="addEditFrom_Ref"
v-if="formData"
:model="formData"
:rules="formRules"
>
<el-row :gutter="40">
<el-col
:span="item.colSpan || 12"
v-for="(item, index) in formItemData"
:key="index"
>
<el-form-item
:label="item.label"
:prop="item.prop"
>
<!-- 数值 -->
<el-input-number
v-if="item.apiBaseType === 'number'"
v-model="formData[item.prop]"
:min="item.minimum || undefined"
:max="item.maximum || undefined"
:maxlength="item.maxLength || undefined"
:minlength="item.minLength || undefined"
:disabled="Boolean(item.disabled)"
:placeholder="item.placeholder || '请输入' + item.label"
@change="changeValue(item.prop,item,$event)"
@clear="clearValue(item.prop,$event)"
></el-input-number>
<!-- 时间转换 -->
<el-date-picker
v-else-if="item.apiBaseType === 'datetime'"
v-model="formData[item.prop]"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-ddTHH:mm:ss"
:disabled="Boolean(item.disabled)"
></el-date-picker>
<!-- 布尔枚举 -->
<el-select
v-else-if="item.isEnums || item.apiBaseType === 'boolean'"
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请选择' + item.label"
:disabled="Boolean(item.disabled)"
>
<el-option
v-for="item in getItemEnums(item)"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 文本框 -->
<!-- <el-input
v-else
type="textarea"
autosize
resize="none"
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
></el-input> -->
<el-input
v-else
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 操作按钮 -->
<div slot="footer" class="dialog-footer">
<el-button @click="show = false"> </el-button>
<el-button type="primary" @click="submitHandle()"> </el-button>
</div>
</div>
<!-- 成功提示 -->
<div v-if="active === 1">
<el-result icon="success" title="成功提示" :subTitle="formTitle + '成功'">
<template slot="extra">
<el-button type="primary" size="medium" @click="exitHandle"
>退出</el-button
>
</template>
</el-result>
</div>
<!-- 错误提示 -->
<div v-if="active === 2">
<el-result icon="error" title="错误提示" :subTitle="formTitle + '失败'">
<template slot="extra">
<el-button type="primary" size="medium" @click="changeActive(0)"
>返回</el-button
>
<el-button type="primary" size="medium" @click="exitHandle"
>退出</el-button
>
</template>
</el-result>
</div>
</el-dialog>
</template>
<script>
import { ApiTypePost, ApiTypePut } from "@/api/wms-api"
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
export default {
name:"addEditFromApiPop",
mixins:[ LoadingMixins,tableMixins ],
props: {
//
editRowData:{
type: Object,
default: null
},
// add/edit
handleType:{
type: String,
default: null
},
//
submitForm:{
type:Function,
default:null
},
//
addSubmitUrl:{
type: String,
default: null
},
//
editSubmitUrl:{
type: String,
default: null
}
},
data () {
return {
currentDtos:this.$store.getters.dtoColumnTypes[this.$route.name],
active:0,//0 1 2
show:true,
formTitle:null,//form
formData:{},//
formItemData:null,//item
formRules: {},//
}
},
mounted(){
this.initTitle()
this.initFormItems()
},
methods: {
// form
initTitle(){
if(this.handleType){
this.formTitle = this.handleType == 'add' ? '新增'+this.$route.name : '编辑'+this.$route.name
}
},
// rules
initFormItems(){
let _dtoList_type = this.handleType == 'add' ? 'C' : 'U'
let _dtoList = this.currentDtos[_dtoList_type].dtoList
this.formItemData = JSON.parse(JSON.stringify(_dtoList))
//
if(this.handleType == 'edit' && this.editRowData){
this.formData = JSON.parse(JSON.stringify(this.editRowData))
}else{
this.formData = {}
}
//
this.formRules={}
_dtoList.forEach(item=>{
if(item.isRequired){
this.formRules[item.prop] = [{ required: true, trigger: "blur", message: "不可为空" }]
}
})
},
//
getItemEnums(item){
let _option = []
//
if(item.apiBaseType == 'boolean'){
_option = [{
value: true,
label: '是'
},{
value: false,
label: '否'
},]
}
if(item.isEnums){
_option = item.enums_list
}
return _option
},
//
close() {
this.show = false
this.$emit("closePop")
},
//
submitHandle(){
this.$refs.addEditFrom_Ref.validate((valid) => {
if(this.submitForm){
this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules)
return
}
this.Loading.addEditApiLoading = true
if (valid) {
//
if(this.handleType == 'add'){
ApiTypePost(
this.formData,
this.currentDtos.C.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)
})
}
//
else{
ApiTypePut(
this.formData,
this.formData.id,
this.currentDtos.U.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)
})
}
} else {
return false;
}
});
},
// 退
exitHandle(){
this.close()
if(this.active == '1')this.oldSkipCount = 1;
this.show = false
this.paging()
this.$nextTick(()=>{
this.active = 0
})
},
//
changeActive(sta){
this.active = sta
this.Loading.addEditApiLoading = false
},
//
changeValue(prop,item,val) {
this.$emit("changeValue", prop, item, val)
},
//
clearValue(prop,item,val) {
this.$emit("clearValue", prop, item, val)
},
}
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__header{
padding: 0 !important;
}
::v-deep .el-row{
width: 100%;
}
::v-deep .addEditFrom{
height: calc(100% - 120px);
overflow: auto;
}
::v-deep .el-form-item__label{
float: unset;
}
::v-deep .el-input,.el-select,.el-input-number{
width: 100% !important;
}
.dialog-footer{
padding-top: 15px;
text-align: right;
}
</style>

46
Code/Fe/src/components/commonTabel-drawer/index.vue

@ -157,9 +157,7 @@
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
import { getListByItemcode,byItem,byProduct,byComponent,bySupplierCode,byLocation,byLocationCode, import { getPageListForDetail } from "@/api/wms-api"
relationByLocationCode,byComponentCJ,purRecNoteCustomInfo,getPageListForDetail
} from "@/api/wms-api"
import searchOverall from "@/components/searchOverall" import searchOverall from "@/components/searchOverall"
import currenButton from "@/components/currenButton" import currenButton from "@/components/currenButton"
import currenDescriptions from "@/components/currenDescriptions" import currenDescriptions from "@/components/currenDescriptions"
@ -580,27 +578,27 @@ export default {
this.otherData = [] this.otherData = []
// this.firstTabs = val.name // this.firstTabs = val.name
// tab // tab
if (item.functionName == 'getListByItemcode') { // if (item.functionName == 'getListByItemcode') {
let params = { // let params = {
itemCode: this.propsData.code // itemCode: this.propsData.code
} // }
getListByItemcode(params, item.url).then(res => { // getListByItemcode(params, item.url).then(res => {
let zdyTableColumnsJSON = JSON.parse(JSON.stringify(this.$isTableColumns[item.tableColumns])); // let zdyTableColumnsJSON = JSON.parse(JSON.stringify(this.$isTableColumns[item.tableColumns]));
delete zdyTableColumnsJSON[0].type // delete zdyTableColumnsJSON[0].type
this.zdyTableColumns = zdyTableColumnsJSON // this.zdyTableColumns = zdyTableColumnsJSON
this.otherData = res // this.otherData = res
parent.tableLoading = false // parent.tableLoading = false
}).catch(err => { // }).catch(err => {
console.log(err) // console.log(err)
parent.tableLoading = false // parent.tableLoading = false
}) // })
} // }
else if(item.functionName == "customerDismantleBackFlushNote"){ // else if(item.functionName == "customerDismantleBackFlushNote"){
let zdyTableColumnsJSON = JSON.parse(JSON.stringify(this.$isTableColumns[item.tableColumns])); // let zdyTableColumnsJSON = JSON.parse(JSON.stringify(this.$isTableColumns[item.tableColumns]));
delete zdyTableColumnsJSON[0].type // delete zdyTableColumnsJSON[0].type
this.zdyTableColumns = zdyTableColumnsJSON // this.zdyTableColumns = zdyTableColumnsJSON
this.otherData = this.propsData.noteAndBackFlushDetails // this.otherData = this.propsData.noteAndBackFlushDetails
} // }
} }
} }
}) })

42
Code/Fe/src/components/currenTableFlex/index.vue

@ -1,5 +1,5 @@
<template> <template>
<div class="currenTableFlex"> <div class="currenTableFlex">
<div class="headerButtons"> <div class="headerButtons">
<el-button <el-button
type="primary" type="primary"
@ -11,13 +11,15 @@
<slot name="headerBtns"></slot> <slot name="headerBtns"></slot>
</div> </div>
<!-- todo:多选处理selectionTable --> <!-- todo:多选处理selectionTable -->
<currenTable <umyTable
:isEditable="isEditable"
class="flexTable" class="flexTable"
:tableData="flexTableData" :tableData="flexTableData"
:searchOptions="flexSearchOptions" :searchOptions="flexSearchOptions"
:tableColumns="flexTableColumns" :tableColumns="flexTableColumns"
:selectionTable="selectionTable" :selectionTable="selectionTable"
:isShowIndex="isShowIndex" :isShowIndex="isShowIndex"
:setUTableHeight="setUTableHeight"
@push="detailsDataPush(arguments)" @push="detailsDataPush(arguments)"
> >
<template v-if="showAllDeleteButton"> <template v-if="showAllDeleteButton">
@ -38,13 +40,13 @@
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
</currenTable> </umyTable>
</div> </div>
</template> </template>
<script> <script>
import currenTable from "@/components/currenTable" import currenTable from "@/components/currenTable"
import { mixins } from "@/mixins/mixins" import { mixins } from "@/mixins/mixins"
export default { export default {
name: 'currenTableFlex', name: 'currenTableFlex',
components: { components: {
currenTable currenTable
@ -85,6 +87,18 @@ export default {
// } // }
}, },
props: { props: {
// table
isEditable:{
type: Boolean,
default: false
},
// app-main100%
setUTableHeight: {
type: Number,
default: () => {
return 280;
}
},
// //
showAddBtn:{ showAddBtn:{
type: Boolean, type: Boolean,
@ -301,8 +315,8 @@ export default {
this.$emit("detailsDataPush", val) this.$emit("detailsDataPush", val)
}, },
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./style/index.scss"; @import "./style/index.scss";
</style> </style>

5
Code/Fe/src/components/rowDrop/index.vue

@ -47,6 +47,7 @@
<script> <script>
import draggable from "vuedraggable"; import draggable from "vuedraggable";
import Sortable from "sortablejs"; import Sortable from "sortablejs";
import { getLoginName } from "@/utils/auth"
export default { export default {
components: { components: {
draggable, draggable,
@ -61,7 +62,7 @@ export default {
dataList: [], dataList: [],
// allSelect hasSelect NoSelect // allSelect hasSelect NoSelect
allSeletType:'NoSelect', allSeletType:'NoSelect',
userName:this.$store.getters.currentUserInfo.userName userName: getLoginName()
} }
}, },
props: { props: {
@ -100,7 +101,7 @@ export default {
type: 'warning', type: 'warning',
cancelButtonClass:'rowDropNotHideItem' cancelButtonClass:'rowDropNotHideItem'
}).then(() => { }).then(() => {
// set this.$store.getters.currentUserInfo.userName // set
localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify([])) localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify([]))
localStorage.removeItem('file_Columns_' + this.source + '_' +this.userName + '_' + this.$route.name) localStorage.removeItem('file_Columns_' + this.source + '_' +this.userName + '_' + this.$route.name)
// let _resetCol = this.$isTableColumns[this.$route.name] // let _resetCol = this.$isTableColumns[this.$route.name]

284
Code/Fe/src/components/showCopyJsonPop/index.vue

@ -0,0 +1,284 @@
<template>
<!-- 组件功能查看json及复制 -->
<div class="showCopyJsonPop">
<!-- 点开查看Json转换后table弹窗 -->
<el-dialog
top="50px"
:visible.sync="JsonTableShow"
:modal-append-to-body="true"
:append-to-body="true"
:show-close="true"
:close-on-click-modal="true"
:close-on-press-escape="true"
width="90%"
@close="closePop"
>
<template #title>
内容详情
<el-button
size="mini"
@click="copyJsonHandle()"
type="primary"
style="margin-right: 30px;float: right;"
>复制JSON</el-button>
</template>
<el-table
height="calc(100vh - 220px)"
:data="JsonTableData"
:border="true"
style="width: 100%">
<el-table-column
prop="name"
width="220"
label="属性"
>
<template slot-scope="scope">
{{ scope.row.name }}
<el-button
type="primary"
v-if="(scope.row.name).toUpperCase() == 'DETAILS'"
size="mini"
style="margin-left: 20px;"
@click="showDetailTableHandle(scope.row)"
>查看详情</el-button>
</template>
</el-table-column>
<el-table-column
label="值"
>
<template slot-scope="scope">
<!-- DETAILS todo:DETAILS判断条件需要优化使用传参的方式 -->
<span v-if="(scope.row.name).toUpperCase() != 'DETAILS'">{{scope.row.value}}</span>
<el-table
v-else
:data="scope.row.value"
stripe
:border="true"
style="width: 100%"
height="300"
>
<el-table-column
label="序号"
fixed="left"
type="index"
width="50">
</el-table-column>
<el-table-column
v-for="(head,h_key) in detailTableHeader"
:key="h_key"
min-width="120"
>
<template #header>
<span :title="head">{{ head }}</span>
</template>
<template slot-scope="scope2">
<div v-if="typeof scope2.row[head] == 'object'">
<div v-for="(o,o_key) in scope2.row[head]">
{{ o_key }}{{ o }}
<div style="border-bottom: dashed 1px #ddd;"></div>
</div>
</div>
<div v-else>{{ scope2.row[head] }}</div>
</template>
</el-table-column>
</el-table>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!-- json复制内容弹窗 -->
<el-dialog
top="50px"
:visible.sync="JsonCopyShow"
:modal-append-to-body="false"
:append-to-body="true"
:show-close="true"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="'JSON详情'"
>
<el-input
class="copyJsonTextarea"
ref="copyJsonTextarea_ref"
type="textarea"
readonly
autosize
resize="none"
v-model="JsonCopyData"
></el-input>
</el-dialog>
<!-- details的table -->
<el-dialog
top="80px"
width="86%"
v-if="detailTableRow"
:visible.sync="detailsTableShow"
:modal-append-to-body="true"
:append-to-body="true"
:show-close="true"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="detailTableRow.name+' 详情'"
>
<!-- row-key 默认不处理解决id可能重复问题此处没有选择框可以这么处理 -->
<umyTable
:isShowIndex="true"
:tableBorder="true"
:setUTableHeight="170"
:row-key="null"
:tableData="detailTableRow.value"
:tableColumns="detailTableColumns"
:selectionTable="false"
></umyTable>
</el-dialog>
</div>
</template>
<script>
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
export default {
name:"showCopyJsonPop",
mixins:[ LoadingMixins,tableMixins ],
props: {
// Json
JsonData:{
type: Object,
default: null,
},
},
data () {
return {
JsonTableShow:true,//Jsontable
JsonTableData:null,//json
JsonCopyData:null,//Json
JsonCopyShow:false,//jsonDialog
detailTableHeader:null,//detailsHeader
detailTableRow:null,//details
detailsTableShow:false,//details
detailTableColumns:false,//detailsheader
}
},
mounted(){
this.initJsonData()
},
methods: {
//
closePop() {
this.JsonTableShow = false
this.$emit("closePop")
},
// json
initJsonData(){
let _arr = []
let __initJson = (data) => {
let _init = []
for(let item in data){
_init.push({name:item,value:data[item]})
}
return _init
}
let _json = this.JsonData
for(let item in _json){
//
if(!_json[item]){
_arr.push({name:item,value:_json[item]})
}else{
if(typeof _json[item] != 'object'){
_arr.push({name:item,value:_json[item] + ""})
}else{
//
if(Array.isArray(_json[item])){
// DETAILS todo:DETAILS使
// let _value = (item).toUpperCase() == 'DETAILS' ? __initJson(_json[item][0]) : (_json[item]).join(",")
this.detailTableHeader = []
for(let h in _json[item][0]){
this.detailTableHeader.push(h)
}
let _value = (item).toUpperCase() == 'DETAILS' ? _json[item] : (_json[item]).join(",")
_arr.push({name:item,value:_value})
}
//
else{
let _obj_arr = __initJson(_json[item])
//
if(_obj_arr.length > 0){
_arr = [..._obj_arr]
}else{
//
_arr.push({name:item,value:""})
}
}
}
}
}
this.JsonTableData = _arr
this.JsonCopyData = JSON.stringify(_json, null, '\t')//使
},
//
copyJsonInputHandle(type){
if(type == 'error')this.$message.error('复制失败');
if(type == 'success')this.$message.success('复制成功');
if(this.$refs.copyJsonTextarea_ref){
this.$refs.copyJsonTextarea_ref.focus()
this.$refs.copyJsonTextarea_ref.$refs.textarea.scrollTop = 0
}
},
// Json
copyJsonHandle(){
this.JsonCopyShow = true
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(this.JsonCopyData)
.then(() => {
this.copyJsonInputHandle('success')
})
.catch(err => {
this.copyJsonInputHandle('error')
});
}else {
// text area
const textArea = document.createElement('textarea')
textArea.value = this.JsonCopyData
// 使text areaviewport
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
return new Promise((resolve, reject) => {
//
document.execCommand('copy') ? resolve() : reject(new Error('出错了'))
textArea.remove()
}).then(() => {
this.$nextTick(()=>{
this.copyJsonInputHandle('success')
})
},() => {
this.copyJsonInputHandle('error')
})
}
},
// detailtable
showDetailTableHandle(row){
this.detailTableRow = row
this.detailTableColumns = []
this.detailTableHeader.forEach(item=>{
this.detailTableColumns.push({
prop:item,
label:item
})
})
this.detailsTableShow = true
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .copyJsonTextarea{
textarea{
max-height: calc(100vh - 220px) !important;
overflow: auto !important;
}
}
</style>

600
Code/Fe/src/components/umyTable/index copy.vue → Code/Fe/src/components/umyTable/_index.vue

@ -1,10 +1,9 @@
<template> <template>
<!-- 解决el-table 数据量过大导致卡顿现象 --> <!-- 解决el-table 数据量过大导致卡顿现象 json查看没有拆出版本 -->
<u-table <u-table
:id="_uid" :id="_uid"
:key="isUpdate" :key="isUpdate"
v-loading="tableLoading" v-loading="tableLoading"
element-loading-text="拼命加载中..."
@sort-change="sortChange" @sort-change="sortChange"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
ref="multipleTable" ref="multipleTable"
@ -14,11 +13,118 @@
style="width: 100%" style="width: 100%"
:cell-style="cellStyle" :cell-style="cellStyle"
use-virtual use-virtual
:row-height="50"
:height="uTableHeight" :height="uTableHeight"
header-row-class-name="uTableHeader" header-row-class-name="uTableHeader"
> >
<!-- :tree-props="treeProps" height 不能共存 此组件暂不支持tree的格式--> <!-- :tree-props="treeProps" height 不能共存 此组件暂不支持tree的格式-->
<u-table-column v-if="selectionTable" fixed="left" type="selection" :reserve-selection="true" />
<u-table-column v-if="isShowIndex" type="index" fixed="left" label="序号" width="50" />
<template v-for="(item, index) in TableSize">
<u-table-column
min-width="150"
:key="index"
:prop="item.showProp ? item.prop + '.' + item.showProp : item.prop"
:sortable="item.sortable"
:fixed="setItemFixed(item,index)"
:show-overflow-tooltip="showOverflowTooltip"
:width="item.width"
:align="item.tableAlign"
:header-align="item.tableHeaderAlign"
v-if="item.istrue==null?true:item.istrue"
>
<template #header>
<span>{{ item.label }}</span>
<i style="color: #f56c6c" v-if="item.rules && requiredRules">*</i>
</template>
<template slot-scope="scope">
<!-- 正常表格回显 -->
<div v-if="!isEditable">
<!-- 时间转换 -->
<span v-if="item.apiBaseType == 'datetime'"
@click="showDetailInfo(scope.row[item.prop],'time')"
style="cursor: pointer;"
:title="'点击查看详情'"
class="showDetailHover itemSpan"
>
{{ scope.row[item.prop] | formatDate }}
</span>
<!-- 枚举 -->
<span v-else-if="item.isEnums" class="itemSpan">
{{ initApiEnumList(item,scope.row[item.prop]) }}
</span>
<!-- 布尔 -->
<span v-else-if="item.apiBaseType == 'boolean'" class="itemSpan">
{{ scope.row[item.prop] ? '是' : '否' }}
</span>
<!-- 数值 -->
<span v-else-if="item.apiBaseType == 'number'" class="itemSpan">
{{ scope.row[item.prop] }}
</span>
<!-- 点击可出详情 | 点击可点出json 目前已知String|Guid-->
<span v-else
class="itemSpan"
@click="showTypeHandle(initApiOtherType(scope.row[item.prop])[1],scope.row[item.prop])"
:style="initApiOtherType(scope.row[item.prop])[1] != 'show' ? 'cursor: pointer' : ''"
:title="'点击查看详情'"
:class="{ showDetailHover: initApiOtherType(scope.row[item.prop])[1] != 'show' }"
>
{{ initApiOtherType(scope.row[item.prop])[0] }}
</span>
</div>
<!-- 可编辑表格 -->
<div v-else>
<!-- 时间转换 -->
<el-date-picker
v-if="item.apiBaseType === 'datetime'"
v-model="scope.row[item.prop]"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-ddTHH:mm:ss"
:disabled="Boolean(item.disabled)"
size="mini"
></el-date-picker>
<!-- 布尔枚举 -->
<el-select
v-else-if="item.isEnums || item.apiBaseType === 'boolean'"
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请选择' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
>
<el-option
v-for="item in getItemEnums(item)"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 数值 -->
<el-input-number
v-else-if="item.apiBaseType === 'number'"
v-model="scope.row[item.prop]"
:min="item.minimum || undefined"
:max="item.maximum || undefined"
:maxlength="item.maxLength || undefined"
:minlength="item.minLength || undefined"
:disabled="Boolean(item.disabled)"
:placeholder="item.placeholder || '请输入' + item.label"
@change="changeValue(item.prop,item,$event)"
@clear="clearValue(item.prop,$event)"
size="mini"
></el-input-number>
<!-- 文本值 -->
<el-input
v-else
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
></el-input>
</div>
</template>
</u-table-column>
</template>
<!-- 操作列 左侧--> <!-- 操作列 左侧-->
<u-table-column <u-table-column
v-if="buttonOperationList_left" v-if="buttonOperationList_left"
@ -29,7 +135,7 @@
:header-align="'center'" :header-align="'center'"
> >
<template #header> <template #header>
<span>操作</span> <span>{{ $t('common.handle') }}</span>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -51,7 +157,7 @@
:header-align="'center'" :header-align="'center'"
> >
<template #header> <template #header>
<span>操作</span> <span>{{ $t('common.handle') }}</span>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -60,311 +166,11 @@
:key="indexButton" :key="indexButton"
type="text" type="text"
size="mini" size="mini"
:style="{color:itemButton.color || '#409EFF'}"
@click="buttonOperationClick_right(scope.row, itemButton, indexButton)" @click="buttonOperationClick_right(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button> >{{itemButton.label}}</el-button>
</template> </template>
</u-table-column> </u-table-column>
<u-table-column v-if="selectionTable" fixed="left" type="selection" :reserve-selection="true" />
<u-table-column v-if="isShowIndex" type="index" fixed="left" label="序号" width="50" />
<template v-for="(item, index) in TableSize">
<u-table-column
min-width="150"
:key="index"
:prop="item.showProp ? item.prop + '.' + item.showProp : item.prop"
:sortable="item.sortable"
:fixed="setItemFixed(item,index)"
:show-overflow-tooltip="showOverflowTooltip"
:width="item.width"
:align="item.tableAlign"
:header-align="item.tableHeaderAlign"
v-if="item.istrue==null?true:item.istrue"
>
<template #header>
<span>{{ item.label }}</span>
<i style="color: #f56c6c" v-if="item.rules && requiredRules">*</i>
</template>
<template slot-scope="scope">
<el-form>
<el-form-item
v-if="item.type == 'input'"
:onkeyup="itemOnKeyUp(item,searchData[item.prop])"
:prop="'details.' + scope.$index + '.' + item.prop"
:rules="item.rules"
>
<el-input
:placeholder="'请输入' + item.label"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
v-model="scope.row[item.prop]"
@blur="
inputPlaceholder($event, item, 'blur',scope.row)
"
@focus="inputPlaceholder($event, item, 'focus')"
clearable
>
</el-input>
</el-form-item>
<!-- 输入框(数字) onkeyup: 正则表达式用于前端输入校验工作-->
<el-form-item
v-if="item.type == 'inputNumber'"
:prop="'details.' + scope.$index + '.' + item.prop"
:rules="item.rules"
>
<el-input
v-model="searchData[item.prop]"
:maxlength="item.maxlength"
:onkeyup="typeNumberOnkeyup(item,searchData[item.prop])"
clearable
:disabled="Boolean(item.disabled)"
:placeholder="'请输入' + item.label"
:prefix-icon="item.icon"
:show-password="item.showPassword"
@change="changeInput(item.prop,$event)"
@clear="clearInput(item.prop,$event)"
@blur="
inputPlaceholder($event, item, 'blur',searchData)
"
@focus="inputPlaceholder($event, item, 'focus')"
></el-input>
</el-form-item>
<el-form-item
v-if="item.type == 'objectInput'"
:prop="
'details.' + scope.$index + '.' + item.prop + '.' + item.showProp
"
:rules="item.rules"
>
<el-input
:placeholder="'请输入' + item.label"
v-model="scope.row[item.prop][item.showProp]"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
@blur="
inputPlaceholder($event, item, 'blur', scope.row)
"
@focus="inputPlaceholder($event, item, 'focus')"
clearable
>
</el-input>
</el-form-item>
<!-- 下拉框 -->
<el-select
v-if="item.type === 'select'"
v-model="scope.row[item.prop]"
:loading="selectLoading"
:clearable="item.clearable"
:multiple="item.multiple"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
:filterable="item.filterable"
:allow-create="item.allowCreate"
style="width: 100%"
:placeholder="'请输入' + item.label"
>
<el-option
v-for="(op, index) in selectOptions(item.options) ||
searchOptions['options']"
:label="op[item.optionsLabel] || op.label"
:value="op[item.optionsValue] || op.value"
:key="index"
></el-option>
</el-select>
<!--对象下拉框 -->
<el-select
v-if="item.type === 'objectSelect'"
v-model="scope.row[item.prop][item.showProp]"
:loading="selectLoading"
:clearable="item.clearable"
:multiple="item.multiple"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
:filterable="item.filterable"
:allow-create="item.allowCreate"
style="width: 100%"
:placeholder="'请输入' + item.label"
>
<el-option
v-for="(op, index) in selectOptions(item.options) ||
searchOptions['options']"
:label="op[item.optionsLabel] || op.label"
:value="op[item.optionsValue] || op.value"
:key="index"
></el-option>
</el-select>
<!--查询下拉-->
<el-form-item
v-if="item.type === 'autocomplete'"
:prop="'details.' + scope.$index + '.' + item.prop"
:rules="item.rules"
>
<el-autocomplete
class="inline-input"
style="width: 100%"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
v-model="scope.row[item.prop]"
:fetch-suggestions="
(queryString, cb) => {
querySearch(queryString, cb, item, scope);
}
"
:placeholder="'请输入' + item.label"
@select="handleSelect($event, item, scope)"
>
<!-- <template slot-scope="{item}">
<div class="name" style="color:green">{{item.value = item.name}}</div>
<div class="name" >{{item.address = item.code}}</div>
</template> -->
<el-button
v-if="item.click"
slot="append"
icon="el-icon-search"
@click="item.click({ scope, item })"
style="color: #1890ff; background-color: #ffffff"
></el-button>
</el-autocomplete>
</el-form-item>
<!-- 对象查询下拉 -->
<el-form-item
v-if="item.type === 'objectAutocomplete'"
:prop="
'details.' + scope.$index + '.' + item.prop + '.' + item.showProp
"
:rules="item.rules"
>
<el-autocomplete
class="inline-input"
style="width: 100%"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
v-model="scope.row[item.prop][item.showProp]"
:fetch-suggestions="
(queryString, cb) => {
querySearch(queryString, cb, item, scope);
}
"
:placeholder="'请输入' + item.label"
@select="handleSelect($event, item, scope)"
>
<!-- <template slot-scope="{item}">
<div class="name" style="color:green">{{item.value = item.name}}</div>
<div class="name" >{{item.address = item.code}}</div>
</template> -->
<el-button
v-if="item.click"
slot="append"
icon="el-icon-search"
@click="item.click({ scope, item })"
style="color: #1890ff; background-color: #ffffff"
></el-button>
</el-autocomplete>
</el-form-item>
<!-- <el-form-item v-if="item.type == 'inputEnum'" :prop="item.prop">
<el-input
placeholder="请输入内容"
v-model="scope.row[item.prop]"
clearable
>
</el-input>
</el-form-item> -->
<el-form-item
v-if="item.type == 'dateTimeInput'"
:prop="'details.' + scope.$index + '.' + item.prop"
:rules="item.rules"
>
<el-date-picker
type="datetime"
v-model="scope.row[item.prop]"
placeholder="选择日期"
style="width: 100%"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
value-format="yyyy-MM-ddTHH:mm:ss.sssZ"
format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item
v-if="item.type == 'objectDateTimeInput'"
:prop="'details.' + scope.$index + '.' + item.prop + '.' + item.showProp"
:rules="item.rules"
>
<el-date-picker
type="datetime"
v-model="scope.row[item.prop][item.showProp]"
placeholder="选择日期"
style="width: 100%"
:disabled="Boolean(item.disabled) || Boolean(scope.row['disabled'])"
value-format="yyyy-MM-ddTHH:mm:ss.sssZ"
format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<!-- table表添加按钮事件 v-show="scope.row.number == 'PRJ202210060001'" -->
<!-- <el-form-item v-if="item.type == 'button'" > -->
<div v-if="item.type == 'button'">
<el-button
v-show="scope.row[item.prop]==undefined?true:false"
type="primary"
size="mini"
@click="buttonClick(scope.row, scope.$index, item.label)"
>{{item.label}}</el-button>
</div>
<!-- </el-form-item> -->
<span v-if="item.type == 'object'">
{{ scope.row[item.prop] ? scope.row[item.prop][item.showProp] : "" }}
</span>
<span v-if="item.type == 'objectDateTime'">
{{ scope.row[item.prop]? scope.row[item.prop][item.showProp]: "" | formatDate }}
</span>
<span v-if="item.type == 'dateTime'">
{{ scope.row[item.prop] | formatDate }}
</span>
<!-- 调用主表信息 -->
<span v-else-if="item.type && item.type == 'outerMainFilter'">
{{ propsData[item.showProp] }}
</span>
<el-tag
v-if="item.type == 'tagFilter'"
:effect="'dark'"
size="medium"
class="tagFilterTypeDarkItem"
:color="scope.row[item.prop] | trigger(item.filters, 'background')"
>
{{ scope.row[item.prop] | trigger(item.filters, "label") }}
</el-tag>
<span
v-if="item.type == 'filter'"
:style="scope.row[item.prop]"
>
{{ scope.row[item.prop] | trigger(item.filters, "label", item.dictType) }}
</span>
<span
v-if="item.type == 'objectFilter'"
:style="scope.row[item.prop][item.showProp]"
>
{{ scope.row[item.prop][item.showProp] | trigger(item.filters, "label") }}
</span>
<span v-else-if="item.type == 'filterList'" >
{{ scope.row[item.prop] | triggerList(item.filters, "label") }}
</span>
<!-- 可点出详情 -->
<span
v-if="item.type == 'showDetail'"
@click="showDetailInfo(scope.row[item.prop])"
style="cursor: pointer;"
:title="'点击查看详情'"
:class="{ showDetailHover: item.type == 'showDetail' }"
>{{ scope.row[item.prop] ? scope.row[item.prop] + "" : scope.row[item.prop] }}</span>
<!-- 可点出json转换的table弹窗 -->
<span
v-if="item.type == 'showJsonTable'"
@click="showJsonTable(scope.row[item.prop])"
style="cursor: pointer;"
:title="'点击查看详情'"
:class="{ showDetailHover: item.type == 'showJsonTable' }"
>{{ scope.row[item.prop] ? scope.row[item.prop] + "" : scope.row[item.prop] }}</span>
<span
v-if="item.type == 'name' || !item.type"
@click="item.type == 'name' && inlineDialog(scope.row)"
:class="{ spamHover: item.type == 'name' }"
>{{ scope.row[item.prop] ? scope.row[item.prop] + "" : scope.row[item.prop] }}</span>
</el-form>
</template>
</u-table-column>
</template>
<slot></slot> <slot></slot>
<!-- 点开查看全部弹窗 --> <!-- 点开查看全部弹窗 -->
@ -375,11 +181,20 @@
:append-to-body="true" :append-to-body="true"
:show-close="true" :show-close="true"
:title="'内容详情'" :title="'内容详情'"
:close-on-click-modal="true"
:close-on-press-escape="true"
> >
{{ showDetailData ? showDetailData + "" : showDetailData }} <el-input
type="textarea"
readonly
autosize
resize="none"
v-model="showDetailData">
</el-input>
<!-- {{ showDetailData ? showDetailData + "" : showDetailData }} -->
</el-dialog> </el-dialog>
<!-- json弹窗复制的json内容 --> <!-- json弹窗 -->
<el-dialog <el-dialog
id="copyJsonTextarea_dialog_ref" id="copyJsonTextarea_dialog_ref"
:visible.sync="showJsonCopy" :visible.sync="showJsonCopy"
@ -395,7 +210,7 @@
type="textarea" type="textarea"
readonly readonly
autosize autosize
placeholder="请输入内容" resize="none"
v-model="showJsonData_str"> v-model="showJsonData_str">
</el-input> </el-input>
</el-dialog> </el-dialog>
@ -409,12 +224,28 @@
:close-on-click-modal="true" :close-on-click-modal="true"
:close-on-press-escape="true" :close-on-press-escape="true"
:title="'内容详情'" :title="'内容详情'"
width="80%"
> >
<el-button <el-button
@click="copyJsonHandle()" @click="copyJsonHandle()"
type="primary" type="primary"
style="margin-bottom: 10px;float: right;" style="margin-bottom: 10px;float: right;"
>复制JSON</el-button> >复制JSON</el-button>
<!-- <el-table
:data="showJsonData_str"
stripe
style="width: 100%"
>
<el-table-column
v-for="(item,key) in showJsonHeader"
>
<template #header>
<span>{{ item }}</span>
</template>
<template slot-scope="scope">
</template>
</el-table-column>
</el-table> -->
<el-table <el-table
:data="showJsonData" :data="showJsonData"
:border="true" :border="true"
@ -431,6 +262,33 @@
<!-- DETAILS todo:DETAILS判断条件需要优化使用传参的方式 --> <!-- DETAILS todo:DETAILS判断条件需要优化使用传参的方式 -->
<span v-if="(scope.row.name).toUpperCase() != 'DETAILS'">{{scope.row.value}}</span> <span v-if="(scope.row.name).toUpperCase() != 'DETAILS'">{{scope.row.value}}</span>
<el-table <el-table
v-else
:data="scope.row.value"
stripe
:border="true"
style="width: 100%"
height="300"
>
<el-table-column
v-for="(head,h_key) in showJsonHeader"
:key="h_key"
min-width="120"
>
<template #header>
<span :title="head">{{ head }}</span>
</template>
<template slot-scope="scope2">
<div v-if="typeof scope2.row[head] == 'object'">
<div v-for="(o,o_key) in scope2.row[head]">
{{ o_key }}{{ o }}
<div style="border-bottom: dashed 1px #ddd;"></div>
</div>
</div>
<div v-else>{{ scope2.row[head] }}</div>
</template>
</el-table-column>
</el-table>
<!-- <el-table
v-else v-else
height="300" height="300"
:data="scope.row.value" :data="scope.row.value"
@ -444,7 +302,7 @@
label="子值" label="子值"
prop="value" prop="value"
></el-table-column> ></el-table-column>
</el-table> </el-table> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -466,6 +324,11 @@ export default {
}, },
}, },
props: { props: {
// table
isEditable:{
type: Boolean,
default: false
},
// //
buttonOperationList_left:{ buttonOperationList_left:{
type: Array, type: Array,
@ -571,6 +434,7 @@ export default {
showDetailDialog:false,// showDetailDialog:false,//
showDetailData:null,// showDetailData:null,//
showJsonDialog:false,//Jsontable showJsonDialog:false,//Jsontable
showJsonHeader:null,//Jsonheader
showJsonData:null,//Json showJsonData:null,//Json
showJsonData_str:null,//Json showJsonData_str:null,//Json
showJsonCopy:false,//jsonDialog showJsonCopy:false,//jsonDialog
@ -633,6 +497,10 @@ export default {
let _height = height || this.setUTableHeight let _height = height || this.setUTableHeight
let _app_height = document.getElementsByClassName('app-main')[0].clientHeight let _app_height = document.getElementsByClassName('app-main')[0].clientHeight
this.uTableHeight = Number(_app_height) - Number(_height) this.uTableHeight = Number(_app_height) - Number(_height)
this.$nextTick(() => {
this.$refs.multipleTable.doLayout()
this.$refs.multipleTable.$forceUpdate()
});
}, },
// //
getTableHeight(){ getTableHeight(){
@ -693,7 +561,7 @@ export default {
} else if (item.width == '100%') { } else if (item.width == '100%') {
item.width = '' item.width = ''
} else { } else {
item.width =item.width ? item.width: "auto"; item.width =item.width ? item.width: 'auto';
} }
} }
return widthSize return widthSize
@ -840,15 +708,16 @@ export default {
this.$emit("inlineDialog", row); this.$emit("inlineDialog", row);
}, },
// //
showDetailInfo(row) { showDetailInfo(row,type) {
this.showDetailDialog = true this.showDetailDialog = true
this.showDetailData = row this.showDetailData = type == 'time' ? formatTimeStrToStr(row) : row
this.$emit("showDetailInfo", row); this.$emit("showDetailInfo", this.showDetailData);
}, },
// jsontable // jsontable
showJsonTable(row){ showJsonTable(row){
this.showJsonDialog = true this.showJsonDialog = true
let _json = eval('(' + row + ')') let _json = eval('(' + row + ')')
this.showJsonData_str = JSON.stringify(_json, null, '\t')//使
let _arr = [] let _arr = []
let __initJson = (data) => { let __initJson = (data) => {
let _init = [] let _init = []
@ -861,13 +730,19 @@ export default {
// //
if(!_json[item]){ if(!_json[item]){
_arr.push({name:item,value:_json[item]}) _arr.push({name:item,value:_json[item]})
}else if(_json[item] && typeof _json[item] != 'object'){ }else{
if(typeof _json[item] != 'object'){
_arr.push({name:item,value:_json[item] + ""}) _arr.push({name:item,value:_json[item] + ""})
}else{ }else{
// //
if(Array.isArray(_json[item])){ if(Array.isArray(_json[item])){
// DETAILS todo:DETAILS使 // DETAILS todo:DETAILS使
let _value = (item).toUpperCase() == 'DETAILS' ? __initJson(_json[item][0]) : (_json[item]).join(",") // let _value = (item).toUpperCase() == 'DETAILS' ? __initJson(_json[item][0]) : (_json[item]).join(",")
this.showJsonHeader = []
for(let h in _json[item][0]){
this.showJsonHeader.push(h)
}
let _value = (item).toUpperCase() == 'DETAILS' ? _json[item] : (_json[item]).join(",")
_arr.push({name:item,value:_value}) _arr.push({name:item,value:_value})
} }
// //
@ -883,28 +758,52 @@ export default {
} }
} }
} }
}
this.showJsonData = _arr this.showJsonData = _arr
this.showJsonData_str = JSON.stringify(JSON.parse(JSON.stringify(this.showJsonData)), null, '\t')
this.$emit("showJsonTable", row); this.$emit("showJsonTable", row);
}, },
// Json // Json
copyJsonHandle(){ copyJsonHandle(){
this.showJsonCopy = true this.showJsonCopy = true
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(this.showJsonData_str) navigator.clipboard.writeText(this.showJsonData_str)
.then(() => { .then(() => {
this.$message.success('复制成功'); this.$message.success('复制成功');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
}) })
.catch(err => { .catch(err => {
this.$message.error('复制失败'); this.$message.error('复制失败');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
}); });
}else {
// text area
const textArea = document.createElement('textarea')
textArea.value = this.showJsonData_str
// 使text areaviewport
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
return new Promise((resolve, reject) => {
//
document.execCommand('copy') ? resolve() : reject(new Error('出错了'))
textArea.remove()
}).then(() => {
this.$nextTick(()=>{ this.$nextTick(()=>{
if(this.$refs.copyJsonTextarea_ref){ if(this.$refs.copyJsonTextarea_ref){
this.$message.success('复制成功');
this.$refs.copyJsonTextarea_ref.focus() this.$refs.copyJsonTextarea_ref.focus()
this.$nextTick(()=>{
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0 document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
})
} }
}) })
},() => {
this.$message.error('复制失败');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
})
}
}, },
// //
buttonClick(row, index, label) { buttonClick(row, index, label) {
@ -918,6 +817,61 @@ export default {
buttonOperationClick_right(row, item, index) { buttonOperationClick_right(row, item, index) {
this.$emit("buttonOperationClick_right", row, item, index); this.$emit("buttonOperationClick_right", row, item, index);
}, },
//
initApiEnumList(item,data){
let _item_enumList = {}
item.enums_list.forEach((item,key)=>{
_item_enumList[item.value] = item.label
})
return _item_enumList[data] || '未定义'
},
// | | json
initApiOtherType(data){
try {
let _json = JSON.parse(data)
//
if(typeof _json == 'number' && _json){
return [data,'show']
}else{
return [data,'json']
}
}
//
catch(err){
return [data,'detail']
}
},
//
showTypeHandle(type,row){
if(type == 'detail')this.showDetailInfo(row)
if(type == 'json')this.showJsonTable(row)
},
//
getItemEnums(item){
let _option = []
//
if(item.apiBaseType == 'boolean'){
_option = [{
value: true,
label: '是'
},{
value: false,
label: '否'
},]
}
if(item.isEnums){
_option = item.enums_list
}
return _option
},
//
changeValue(prop,item,val) {
this.$emit("changeValue", prop, item, val)
},
//
clearValue(prop,item,val) {
this.$emit("clearValue", prop, item, val)
},
}, },
}; };
</script> </script>
@ -935,8 +889,8 @@ export default {
} }
::v-deep .el-table__fixed { ::v-deep .el-table__fixed {
display: block-inline !important; display: block-inline !important;
height: auto !important; height: 100% !important;
bottom: 13px !important; // bottom: 13px !important;
.el-table__fixed-header-wrapper { .el-table__fixed-header-wrapper {
z-index: auto !important; z-index: auto !important;
} }
@ -990,4 +944,8 @@ span {
.u-table::before { .u-table::before {
height: 0px; height: 0px;
} }
.itemSpan{
white-space: nowrap !important
}
</style> </style>

413
Code/Fe/src/components/umyTable/index.vue

@ -4,7 +4,6 @@
:id="_uid" :id="_uid"
:key="isUpdate" :key="isUpdate"
v-loading="tableLoading" v-loading="tableLoading"
element-loading-text="拼命加载中..."
@sort-change="sortChange" @sort-change="sortChange"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
ref="multipleTable" ref="multipleTable"
@ -14,57 +13,10 @@
style="width: 100%" style="width: 100%"
:cell-style="cellStyle" :cell-style="cellStyle"
use-virtual use-virtual
:row-height="50"
:height="uTableHeight" :height="uTableHeight"
header-row-class-name="uTableHeader" header-row-class-name="uTableHeader"
> >
<!-- :tree-props="treeProps" height 不能共存 此组件暂不支持tree的格式--> <!-- :tree-props="treeProps" height 不能共存 此组件暂不支持tree的格式-->
<!-- 操作列 左侧-->
<u-table-column
v-if="buttonOperationList_left"
:fixed="'left'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>操作</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_left"
:key="indexButton"
type="text"
size="mini"
@click="buttonOperationClick_left(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<!-- 操作列 右侧-->
<u-table-column
v-if="buttonOperationList_right"
:fixed="'right'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>操作</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_right(scope.row)"
v-show="!itemButton.hide"
:key="indexButton"
type="text"
size="mini"
:style="{color:itemButton.color || '#409EFF'}"
@click="buttonOperationClick_right(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<u-table-column v-if="selectionTable" fixed="left" type="selection" :reserve-selection="true" /> <u-table-column v-if="selectionTable" fixed="left" type="selection" :reserve-selection="true" />
<u-table-column v-if="isShowIndex" type="index" fixed="left" label="序号" width="50" /> <u-table-column v-if="isShowIndex" type="index" fixed="left" label="序号" width="50" />
<template v-for="(item, index) in TableSize"> <template v-for="(item, index) in TableSize">
@ -85,6 +37,8 @@
<i style="color: #f56c6c" v-if="item.rules && requiredRules">*</i> <i style="color: #f56c6c" v-if="item.rules && requiredRules">*</i>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 正常表格回显 -->
<div v-if="!isEditable">
<!-- 时间转换 --> <!-- 时间转换 -->
<span v-if="item.apiBaseType == 'datetime'" <span v-if="item.apiBaseType == 'datetime'"
@click="showDetailInfo(scope.row[item.prop],'time')" @click="showDetailInfo(scope.row[item.prop],'time')"
@ -116,13 +70,112 @@
> >
{{ initApiOtherType(scope.row[item.prop])[0] }} {{ initApiOtherType(scope.row[item.prop])[0] }}
</span> </span>
</div>
<!-- 可编辑表格 -->
<div v-else>
<!-- 时间转换 -->
<el-date-picker
v-if="item.apiBaseType === 'datetime'"
v-model="scope.row[item.prop]"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-ddTHH:mm:ss"
:disabled="Boolean(item.disabled)"
size="mini"
></el-date-picker>
<!-- 布尔枚举 -->
<el-select
v-else-if="item.isEnums || item.apiBaseType === 'boolean'"
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请选择' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
>
<el-option
v-for="item in getItemEnums(item)"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 数值 -->
<el-input-number
v-else-if="item.apiBaseType === 'number'"
v-model="scope.row[item.prop]"
:min="item.minimum || undefined"
:max="item.maximum || undefined"
:maxlength="item.maxLength || undefined"
:minlength="item.minLength || undefined"
:disabled="Boolean(item.disabled)"
:placeholder="item.placeholder || '请输入' + item.label"
@change="changeValue(item.prop,item,$event)"
@clear="clearValue(item.prop,$event)"
size="mini"
></el-input-number>
<!-- 文本值 -->
<el-input
v-else
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
></el-input>
</div>
</template> </template>
</u-table-column> </u-table-column>
</template> </template>
<!-- 操作列 左侧-->
<u-table-column
v-if="buttonOperationList_left"
:fixed="'left'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_left"
:key="indexButton"
type="text"
size="mini"
@click="buttonOperationClick_left(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<!-- 操作列 右侧-->
<u-table-column
v-if="buttonOperationList_right"
:fixed="'right'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_right(scope.row)"
v-show="!itemButton.hide"
:key="indexButton"
type="text"
size="mini"
:style="{color:itemButton.color || '#409EFF'}"
@click="buttonOperationClick_right(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<slot></slot> <slot></slot>
<!-- 点开查看全部弹窗 --> <!-- 点开查看全部弹窗 -->
<el-dialog <el-dialog
top="50px"
:visible.sync="showDetailDialog" :visible.sync="showDetailDialog"
width="35%" width="35%"
:modal-append-to-body="false" :modal-append-to-body="false"
@ -133,6 +186,8 @@
:close-on-press-escape="true" :close-on-press-escape="true"
> >
<el-input <el-input
class="copyDetailInput"
ref="copyDetailInput_ref"
type="textarea" type="textarea"
readonly readonly
autosize autosize
@ -142,127 +197,23 @@
<!-- {{ showDetailData ? showDetailData + "" : showDetailData }} --> <!-- {{ showDetailData ? showDetailData + "" : showDetailData }} -->
</el-dialog> </el-dialog>
<!-- json弹窗 --> <!-- 查看Json -->
<el-dialog <showCopyJsonPop
id="copyJsonTextarea_dialog_ref" v-if="showJsonDialog"
:visible.sync="showJsonCopy" :JsonData="showJsonData"
:modal-append-to-body="false" @closePop="closeJsonPop"
:append-to-body="true" ></showCopyJsonPop>
:show-close="true"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="'JSON详情'"
>
<el-input
ref="copyJsonTextarea_ref"
type="textarea"
readonly
autosize
resize="none"
v-model="showJsonData_str">
</el-input>
</el-dialog>
<!-- 点开查看Json转换后table弹窗 -->
<el-dialog
:visible.sync="showJsonDialog"
:modal-append-to-body="false"
:append-to-body="true"
:show-close="true"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="'内容详情'"
width="80%"
>
<el-button
@click="copyJsonHandle()"
type="primary"
style="margin-bottom: 10px;float: right;"
>复制JSON</el-button>
<!-- <el-table
:data="showJsonData_str"
stripe
style="width: 100%"
>
<el-table-column
v-for="(item,key) in showJsonHeader"
>
<template #header>
<span>{{ item }}</span>
</template>
<template slot-scope="scope">
</template>
</el-table-column>
</el-table> -->
<el-table
:data="showJsonData"
:border="true"
style="width: 100%">
<el-table-column
prop="name"
width="220"
label="属性">
</el-table-column>
<el-table-column
label="值"
>
<template slot-scope="scope">
<!-- DETAILS todo:DETAILS判断条件需要优化使用传参的方式 -->
<span v-if="(scope.row.name).toUpperCase() != 'DETAILS'">{{scope.row.value}}</span>
<el-table
v-else
:data="scope.row.value"
stripe
:border="true"
style="width: 100%"
height="500"
>
<el-table-column
v-for="(head) in showJsonHeader"
:key="h_key"
min-width="120"
>
<template #header>
<span :title="head">{{ head }}</span>
</template>
<template slot-scope="scope" v-for="item in scope.row.value">
<div v-if="typeof item[head] == 'object'">
<div v-for="(o,o_key) in item[head]">
{{ o_key }}{{ o }}
<div style="border-bottom: dashed 1px #ddd;"></div>
</div>
</div>
<div v-else>{{ item[head] }}</div>
</template>
</el-table-column>
</el-table>
<!-- <el-table
v-else
height="300"
:data="scope.row.value"
:border="true"
style="width: 100%">
<el-table-column
prop="name"
label="子属性"
></el-table-column>
<el-table-column
label="子值"
prop="value"
></el-table-column>
</el-table> -->
</template>
</el-table-column>
</el-table>
</el-dialog>
</u-table> </u-table>
</template> </template>
<script> <script>
import { formatTimeStrToStr } from "@/utils/formatTime"; import { formatTimeStrToStr } from "@/utils/formatTime";
import _ from "lodash"; import _ from "lodash";
import { getMatchRegConformValue } from "@/utils/index" import { getMatchRegConformValue } from "@/utils/index"
import showCopyJsonPop from "@/components/showCopyJsonPop"
export default { export default {
name: "currenTable", name: "currenTable",
components:{ showCopyJsonPop },
filters: { filters: {
formatDate(time) { formatDate(time) {
if (time == null) { if (time == null) {
@ -272,6 +223,11 @@ export default {
}, },
}, },
props: { props: {
// table
isEditable:{
type: Boolean,
default: false
},
// //
buttonOperationList_left:{ buttonOperationList_left:{
type: Array, type: Array,
@ -377,10 +333,7 @@ export default {
showDetailDialog:false,// showDetailDialog:false,//
showDetailData:null,// showDetailData:null,//
showJsonDialog:false,//Jsontable showJsonDialog:false,//Jsontable
showJsonHeader:null,//Jsonheader
showJsonData:null,//Json showJsonData:null,//Json
showJsonData_str:null,//Json
showJsonCopy:false,//jsonDialog
}; };
}, },
computed: { computed: {
@ -653,98 +606,24 @@ export default {
// //
showDetailInfo(row,type) { showDetailInfo(row,type) {
this.showDetailDialog = true this.showDetailDialog = true
this.showDetailData = type == 'time' ? formatTimeStrToStr(row) : row let _row = typeof row == 'object' ? JSON.stringify(row, null, '\t') : row
this.showDetailData = type == 'time' ? formatTimeStrToStr(row) : _row
this.$emit("showDetailInfo", this.showDetailData); this.$emit("showDetailInfo", this.showDetailData);
this.$nextTick(()=>{
if(this.$refs.copyDetailInput_ref){
this.$refs.copyDetailInput_ref.focus()
this.$refs.copyDetailInput_ref.$refs.textarea.scrollTop = 0
}
})
},
closeJsonPop(){
this.showJsonDialog = false
}, },
// jsontable // jsontable
showJsonTable(row){ showJsonTable(row){
this.showJsonDialog = true this.showJsonDialog = true
let _json = eval('(' + row + ')') let _json = eval('(' + row + ')')
this.showJsonData_str = JSON.stringify(_json, null, '\t')//使 this.showJsonData = _json
let _arr = []
let __initJson = (data) => {
let _init = []
for(let item in data){
_init.push({name:item,value:data[item]})
}
return _init
}
for(let item in _json){
//
if(!_json[item]){
_arr.push({name:item,value:_json[item]})
}else if(_json[item] && typeof _json[item] != 'object'){
_arr.push({name:item,value:_json[item] + ""})
}else{
//
if(Array.isArray(_json[item])){
// DETAILS todo:DETAILS使
// let _value = (item).toUpperCase() == 'DETAILS' ? __initJson(_json[item][0]) : (_json[item]).join(",")
this.showJsonHeader = []
for(let h in _json[item][0]){
this.showJsonHeader.push(h)
}
let _value = (item).toUpperCase() == 'DETAILS' ? _json[item] : (_json[item]).join(",")
_arr.push({name:item,value:_value})
}
//
else{
let _obj_arr = __initJson(_json[item])
//
if(_obj_arr.length > 0){
_arr = [..._obj_arr]
}else{
//
_arr.push({name:item,value:""})
}
}
}
}
this.showJsonData = _arr
this.$emit("showJsonTable", row);
},
// Json
copyJsonHandle(){
this.showJsonCopy = true
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(this.showJsonData_str)
.then(() => {
this.$message.success('复制成功');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
})
.catch(err => {
this.$message.error('复制失败');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
});
}else {
// text area
const textArea = document.createElement('textarea')
textArea.value = this.showJsonData_str
// 使text areaviewport
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
return new Promise((resolve, reject) => {
//
document.execCommand('copy') ? resolve() : reject(new Error('出错了'))
textArea.remove()
}).then(() => {
this.$nextTick(()=>{
if(this.$refs.copyJsonTextarea_ref){
this.$message.success('复制成功');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
}
})
},() => {
this.$message.error('复制失败');
this.$refs.copyJsonTextarea_ref.focus()
document.getElementById('copyJsonTextarea_dialog_ref').scrollTop = 0
})
}
}, },
// //
buttonClick(row, index, label) { buttonClick(row, index, label) {
@ -787,6 +666,32 @@ export default {
if(type == 'detail')this.showDetailInfo(row) if(type == 'detail')this.showDetailInfo(row)
if(type == 'json')this.showJsonTable(row) if(type == 'json')this.showJsonTable(row)
}, },
//
getItemEnums(item){
let _option = []
//
if(item.apiBaseType == 'boolean'){
_option = [{
value: true,
label: '是'
},{
value: false,
label: '否'
},]
}
if(item.isEnums){
_option = item.enums_list
}
return _option
},
//
changeValue(prop,item,val) {
this.$emit("changeValue", prop, item, val)
},
//
clearValue(prop,item,val) {
this.$emit("clearValue", prop, item, val)
},
}, },
}; };
</script> </script>
@ -804,8 +709,8 @@ export default {
} }
::v-deep .el-table__fixed { ::v-deep .el-table__fixed {
display: block-inline !important; display: block-inline !important;
height: auto !important; height: 100% !important;
bottom: 13px !important; // bottom: 13px !important;
.el-table__fixed-header-wrapper { .el-table__fixed-header-wrapper {
z-index: auto !important; z-index: auto !important;
} }
@ -863,4 +768,10 @@ span {
.itemSpan{ .itemSpan{
white-space: nowrap !important white-space: nowrap !important
} }
::v-deep .copyDetailInput{
textarea{
max-height: calc(100vh - 220px) !important;
overflow: auto !important;
}
}
</style> </style>

30
Code/Fe/src/lang/en.js

@ -1,5 +1,33 @@
export default { export default {
// todo:后期做语言时候统一处理,暂时都使用中文
// common: {
// home:'Home',
// handle:'Operate',
// },
// btns:{
// add:'Create',
// filter:'Filtrate',
// fresh:'Refresh',
// field:'Field Setting',
// export:'Export File',
// import:'Import File',
// edit:'Edit',
// delete:'Delete',
// DetailedQuery:'Detailed Query'
// },
common: { common: {
home:'home' home:'Home',
handle:'操作',
},
btns:{
add:'新增',
filter:'筛选',
fresh:'刷新',
field:'字段设置',
export:'导出',
import:'导入',
edit:'编辑',
delete:'删除',
DetailedQuery:'明细查询'
} }
} }

3
Code/Fe/src/lang/index.js

@ -35,6 +35,7 @@ const i18n = new VueI18n({
locale: InitLanguage(), locale: InitLanguage(),
}) })
locale.i18n((key, value) => i18n.t(key, value)) // todo:element的i18n语言转义,开始使用i18n时候打开下方代码
// locale.i18n((key, value) => i18n.t(key, value))
export default i18n export default i18n

14
Code/Fe/src/lang/zh.js

@ -1,5 +1,17 @@
export default { export default {
common: { common: {
home:'系统首页' home:'系统首页',
handle:'操作',
},
btns:{
add:'新增',
filter:'筛选',
fresh:'刷新',
field:'字段设置',
export:'导出',
import:'导入',
edit:'编辑',
delete:'删除',
DetailedQuery:'明细查询'
} }
} }

34
Code/Fe/src/mixins/TableMixins.js

@ -1,7 +1,8 @@
import { import {
getPageList, getPageList,
getDetailed, getDetailed,
postDelete postDelete,
ApiTypeDelete
} from '@/api/wms-api' } from '@/api/wms-api'
import { zhApiColumnsLable,firstWordSizeChange } from '@/utils/index' import { zhApiColumnsLable,firstWordSizeChange } from '@/utils/index'
export const tableMixins = { export const tableMixins = {
@ -71,6 +72,13 @@ export const tableMixins = {
color:'#ff9000' color:'#ff9000'
}) })
} }
if(type.indexOf('delete') >= 0){
_btns.push({
label:'删除',
name:'deleteFromApi',
color:'red'
})
}
return _btns return _btns
}, },
// 主表-右侧操作列基础按钮操作 // 主表-右侧操作列基础按钮操作
@ -89,7 +97,7 @@ export const tableMixins = {
this.displayDialog.editDialog = true this.displayDialog.editDialog = true
} }
// 编辑 api // 编辑 api
if (item.name == "editFromApi") { else if (item.name == "editFromApi") {
this.addEditApiType = 'edit' this.addEditApiType = 'edit'
this.editFromApiRowData = row this.editFromApiRowData = row
this.displayDialog.addEditApiDialog = true; this.displayDialog.addEditApiDialog = true;
@ -114,6 +122,28 @@ export const tableMixins = {
this.Loading.tableLoading = false this.Loading.tableLoading = false
}); });
} }
// 删除 api
else if (item.name == "deleteFromApi") {
this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.Loading.tableLoading = true
ApiTypeDelete(
row.id,
this.$store.getters.apiActions[this.$route.name].DeleteAsyncById.url
).then(res => {
this.$successMsg('删除成功!')
this.Loading.tableLoading = false
this.paging()
}).catch(err => {
this.Loading.tableLoading = false
})
}).catch(() => {
this.Loading.tableLoading = false
});
}
}, },
// 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题 // 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题
// initApiColumns(table,des,detailsTable,detailsPage){ // initApiColumns(table,des,detailsTable,detailsPage){

6
Code/Fe/src/mixins/mixins.js

@ -3,6 +3,8 @@ import {
postImport, postImport,
} from '@/api/wms-api' } from '@/api/wms-api'
import * as allUrlOption from '@/utils/baseData/urlOption' import * as allUrlOption from '@/utils/baseData/urlOption'
import { getLoginName } from "@/utils/auth"
export const mixins = { export const mixins = {
data() { data() {
return { return {
@ -74,8 +76,8 @@ export const mixins = {
let _list_defalut = columnsData ? columnsData : this.$isTableColumns[this.$route.name] let _list_defalut = columnsData ? columnsData : this.$isTableColumns[this.$route.name]
let _type = type ? type : 'list_api' let _type = type ? type : 'list_api'
if(!_list_defalut)return if(!_list_defalut)return
let _local = localStorage.getItem('file_Columns_' + _type + '_' + this.$store.getters.currentUserInfo.userName + '_' + this.$route.name) let _local = localStorage.getItem('file_Columns_' + _type + '_' + getLoginName() + '_' + this.$route.name)
let _list_local = JSON.parse(localStorage.getItem('file_Columns_' + _type + '_' + this.$store.getters.currentUserInfo.userName + '_' + this.$route.name)) let _list_local = JSON.parse(localStorage.getItem('file_Columns_' + _type + '_' + getLoginName() + '_' + this.$route.name))
let _new_list = [] //格式化后的数据 let _new_list = [] //格式化后的数据
// 如果没有缓存则直接为默认值 // 如果没有缓存则直接为默认值
if(!_local){ if(!_local){

1
Code/Fe/src/store/getters.js

@ -15,5 +15,6 @@ const getters = {
enumList: state => state.definition.enumList,//接口获取的枚举 enumList: state => state.definition.enumList,//接口获取的枚举
columZHList: state => state.definition.columZHList,//接口转义的表头 columZHList: state => state.definition.columZHList,//接口转义的表头
dtoColumnTypes: state => state.definition.dtoColumnTypes,//所有页面的dto类型 dtoColumnTypes: state => state.definition.dtoColumnTypes,//所有页面的dto类型
apiActions: state => state.definition.apiActions,//所有api的动作(增删改查等)
} }
export default getters export default getters

20
Code/Fe/src/store/modules/definition.js

@ -5,6 +5,7 @@ const state = {
enumList: [],//枚举 enumList: [],//枚举
columZHList:null,//表头转义 columZHList:null,//表头转义
dtoColumnTypes:[],//所有页面的dto类型 dtoColumnTypes:[],//所有页面的dto类型
apiActions:[],//所有api的动作(增删改查等)
} }
const mutations = { const mutations = {
@ -20,6 +21,10 @@ const mutations = {
SET_DTOCOLUMN_TYPES: (state, data) => { SET_DTOCOLUMN_TYPES: (state, data) => {
state.dtoColumnTypes=data state.dtoColumnTypes=data
}, },
// 所有api的动作(增删改查等)
SET_API_ACTIONS: (state, data) => {
state.apiActions=data
}
} }
// 通过url做方法处理转换(S/C/U/G等)目前做了S查询/C新增/U编辑。如果有需要在丰富 // 通过url做方法处理转换(S/C/U/G等)目前做了S查询/C新增/U编辑。如果有需要在丰富
@ -69,14 +74,15 @@ export function initDtoTypesAndEnums(res,typeName,apiName) {
} }
} }
d.baseApiName = apiName + d.name d.baseApiName = apiName + d.name
d.label = zhApiColumnsLable(apiName + d.name,res.types) || d.name d.label = zhApiColumnsLable(apiName + d.name) || d.name
d.prop = firstWordSizeChange(d.name) d.prop = firstWordSizeChange(d.name)
}) })
return _dtos return _dtos
} }
// DTO列类型转义 // DTO列类型转义
export function initDtoColumnTypes(res) { export function initDtoColumnTypes(res,commit) {
let _actionsObj = {}// 所有actions处理暂存数据
// modules>app>controller>这里是所有的接口 // modules>app>controller>这里是所有的接口
let _controller = res.modules.app.controllers let _controller = res.modules.app.controllers
let _allData = {} let _allData = {}
@ -84,6 +90,9 @@ export function initDtoColumnTypes(res) {
let _com = 'AppService' let _com = 'AppService'
// 获取简单的api(路由,如:IncomingData) // 获取简单的api(路由,如:IncomingData)
let _api = item.substring(item.lastIndexOf('.') + 1,item.length - _com.length) let _api = item.substring(item.lastIndexOf('.') + 1,item.length - _com.length)
// 所有actions处理
_actionsObj[_api] = _controller[item].actions;
// dto处理
let inner_item = { let inner_item = {
baseApi:_api, baseApi:_api,
dtoList:[], dtoList:[],
@ -101,23 +110,28 @@ export function initDtoColumnTypes(res) {
// 查询处理 // 查询处理
let _type = _actions.returnValue.type let _type = _actions.returnValue.type
if(initDtoTypeByUrl(_actions.url) == 'S'){ if(initDtoTypeByUrl(_actions.url) == 'S'){
_item.S.actionsUrl = _actions.url
let _type_value = _type.substring(_type.indexOf('<') + 1,_type.indexOf('>')) let _type_value = _type.substring(_type.indexOf('<') + 1,_type.indexOf('>'))
_item.S.columnsType=_type_value _item.S.columnsType=_type_value
_item.S.dtoList = initDtoTypesAndEnums(res,_type_value,_api) _item.S.dtoList = initDtoTypesAndEnums(res,_type_value,_api)
} }
// 新增处理 // 新增处理
if( initDtoTypeByUrl(_actions.url) == 'C' ){ if( initDtoTypeByUrl(_actions.url) == 'C' ){
_item.C.actionsUrl = _actions.url
_item.C.columnsType = _type _item.C.columnsType = _type
_item.C.dtoList = initDtoTypesAndEnums(res,_type,_api) _item.C.dtoList = initDtoTypesAndEnums(res,_type,_api)
} }
// 编辑处理 // 编辑处理
if( initDtoTypeByUrl(_actions.url) == 'U' ){ if( initDtoTypeByUrl(_actions.url) == 'U' ){
_item.U.actionsUrl = _actions.url
_item.U.columnsType = _type _item.U.columnsType = _type
_item.U.dtoList = initDtoTypesAndEnums(res,_type,_api) _item.U.dtoList = initDtoTypesAndEnums(res,_type,_api)
} }
} }
_allData[_api] = _item _allData[_api] = _item
} }
// 设置所有actions
commit('SET_API_ACTIONS', _actionsObj)
return _allData return _allData
} }
@ -127,7 +141,7 @@ const actions = {
return new Promise(resolve => { return new Promise(resolve => {
getApiDefinition().then(res=>{ getApiDefinition().then(res=>{
commit('SET_ENUM_LIST', res.types) commit('SET_ENUM_LIST', res.types)
commit('SET_DTOCOLUMN_TYPES', initDtoColumnTypes(res)) commit('SET_DTOCOLUMN_TYPES', initDtoColumnTypes(res,commit))
resolve(res) resolve(res)
}) })
}) })

6
Code/Fe/src/utils/auth.js

@ -1,4 +1,5 @@
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import store from '@/store'
const TokenKey = 'Admin-Token' const TokenKey = 'Admin-Token'
const CompanyKey = 'Admin-Company' const CompanyKey = 'Admin-Company'
@ -15,3 +16,8 @@ export function setToken(token) {
export function removeToken() { export function removeToken() {
return Cookies.remove(TokenKey) return Cookies.remove(TokenKey)
} }
// fast-new
export function getLoginName() {
return (store.getters.currentUserInfo && store.getters.currentUserInfo.name) ? store.getters.currentUserInfo.name : localStorage.getItem('isLoginName')
}

19
Code/Fe/src/utils/defaultButtons.js

@ -1,4 +1,6 @@
// 页面基础按钮样式 // 页面基础按钮样式
import i18n from "@/lang"
import { getLoginName } from "@/utils/auth"
/** /**
* 如果需要更改配置格式如defaultExportBtn({label:'自定义'}) * 如果需要更改配置格式如defaultExportBtn({label:'自定义'})
* @param {*} option * @param {*} option
@ -10,7 +12,7 @@ export function defaultAddBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
type: "primary", type: "primary",
icon: "el-icon-plus", icon: "el-icon-plus",
label: "新增", label: i18n.t('btns.add'),
name: "newly", name: "newly",
size: "mini", size: "mini",
background:"#31bb99" background:"#31bb99"
@ -22,7 +24,7 @@ export function defaultImportBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
type: "primary", type: "primary",
icon: "el-icon-bottom-left", icon: "el-icon-bottom-left",
label: "导入", label: i18n.t('btns.import'),
name: "import", name: "import",
size: "mini", size: "mini",
}) })
@ -33,7 +35,7 @@ export function defaultExportBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
type: "primary", type: "primary",
icon: "el-icon-top-right", icon: "el-icon-top-right",
label: "导出", label: i18n.t('btns.export'),
name: "export", name: "export",
size: "mini", size: "mini",
}) })
@ -43,7 +45,7 @@ export function defaultExportBtn(option) {
export function defaultFieldSettingBtn(option,source) { export function defaultFieldSettingBtn(option,source) {
let _source = source ? source : 'list_api' let _source = source ? source : 'list_api'
// todo:监听已经配置过的字段按钮更改状态特殊显示 // todo:监听已经配置过的字段按钮更改状态特殊显示
let _local = localStorage.getItem('file_Columns_' + _source + '_' + this.$store.getters.currentUserInfo.userName + '_' + this.$route.name) let _local = localStorage.getItem('file_Columns_' + _source + '_' + getLoginName() + '_' + this.$route.name)
let _type = '' let _type = ''
let _num = 0 let _num = 0
if(_local){ if(_local){
@ -62,7 +64,7 @@ export function defaultFieldSettingBtn(option,source) {
// type: _type,//暂不处理颜色 // type: _type,//暂不处理颜色
plain: true, plain: true,
icon: "el-icon-setting", icon: "el-icon-setting",
label: "字段设置", label: i18n.t('btns.field'),
name: "field", name: "field",
size: "mini", size: "mini",
float: 'right', float: 'right',
@ -74,7 +76,7 @@ export function defaultFieldSettingBtn(option,source) {
export function defaultFreshBtn(option) { export function defaultFreshBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
icon: "el-icon-refresh", icon: "el-icon-refresh",
label: "刷新", label: i18n.t('btns.fresh'),
name: "refresh", name: "refresh",
size: "mini", size: "mini",
float: 'right' float: 'right'
@ -86,7 +88,7 @@ export function defaultFilterBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
type: "primary", type: "primary",
icon: "el-icon-finished", icon: "el-icon-finished",
label: "筛选", label: i18n.t('btns.filter'),
name: "filter", name: "filter",
size: "mini", size: "mini",
float: 'right' float: 'right'
@ -98,7 +100,7 @@ export function defaultFilterForDetailBtn(option) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
type: "warning", type: "warning",
icon: "el-icon-finished", icon: "el-icon-finished",
label: "明细查询", label: i18n.t('btns.DetailedQuery'),
name: "filterForDetail", name: "filterForDetail",
size: "mini", size: "mini",
float: 'right', float: 'right',
@ -122,4 +124,3 @@ function __defaultBtnOption(option,specific){
isRedundance:option && option.isRedundance ? option.isRedundance : false, isRedundance:option && option.isRedundance ? option.isRedundance : false,
} }
} }

112
Code/Fe/src/views/demo/demo_api_handle.vue

@ -0,0 +1,112 @@
<template>
<div class="page-box" v-loading="Loading.tableLoading">
<!-- DEMO: API新增编辑删除 根据details判断是否有子表编辑-->
<tablePagination
v-if="apiColumns_Table"
:currenButtonData="currenButtonData"
:tableData="tableData"
:tableLoading="Loading.tableLoading"
:tableColumns="apiColumns_Table"
@rowDrop="rowDrop"
:totalCount="totalCount"
:multipleSelection="multipleSelection"
:MaxResultCount="PageListParams.MaxResultCount"
@topbutton="topbutton"
@inlineDialog="inlineDialog"
@sortChange="sortChange"
@alertoldSkipCount="alertoldSkipCount"
@alterResultCount="alterResultCount"
@handleSelectionChange="handleSelectionChange"
:currentPageProps="oldSkipCount"
:quicklySearchOption="quicklySearchOption"
@quicklySearchClick="quicklySearchClick"
@quicklySearchClear="quicklySearchClear"
:primarySearchOption="primarySearchOption"
@overallSearchFormClick="overallSearchFormClick"
:httpOverallSearchData="httpOverallSearchData"
:buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left"
:buttonOperationList_right="(data)=>{return buttonOperationList_rightApi(data,'edit|delete')}"
@buttonOperationClick_right="buttonOperationClick_right"
></tablePagination>
<curren-Drawer
ref="currenDrawer_Ref"
:title="apiColumns_DesTions"
@rowDrop="rowDrop"
:tableColumns="apiColumns_DetailsTable"
:tabsDesTions="apiColumns_DesTions"
:DrawerLoading="Loading.DrawerLoading"
:drawer="displayDialog.detailsDialog"
:propsData="propsData"
:Butttondata="[]"
@drawerShut="(val) => (displayDialog.detailsDialog = val)"
@drawerbutton="drawerbutton"
@handleCommand="drawerHandle"
@close-value="closeValue"
:totalCount="totalCountDetails"
:currentPage="oldSkipCountDetails"
:MaxResultCount="MaxResultCountDetails"
@alterResultCountDetails="alterResultCountDetails"
@alertoldSkipCountDetails="alertoldSkipCountDetails"
:buttonOperationList_left="operationButtonsDetail"
></curren-Drawer>
<!-- 导出弹窗 -->
<exportDrop
v-if="displayDialog.exportDialog"
@closeDialog="closeExportDrop"
@exportDropSubmit="exportDropSubmit"
></exportDrop>
<!-- Api新增 -->
<addEditFromApiPop
v-if="displayDialog.addEditApiDialog"
:handleType="addEditApiType"
:editRowData="editFromApiRowData"
@closePop="closeAddEditApiPop"
></addEditFromApiPop>
</div>
</template>
<script>
import { tableMixins } from "@/mixins/TableMixins";
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins";
import { mixins } from "@/mixins/mixins";
import { filterSelectMixins } from '@/mixins/filter-Select'
import { getToken } from '@/utils/auth'
export default {
name: "IncomingData",
mixins: [
tableMixins,
LoadingMixins,
drawerMixins,
TableHeaderMixins,
mixins,
filterSelectMixins,
],
data() {
return {
//
currenButtonData: [
this.defaultAddBtn({
name:'addFromApi'
}),//
this.defaultExportBtn({
isRedundance:true,
isDetailExport:true
}),//
this.defaultFieldSettingBtn(),//
this.defaultFreshBtn(),//
this.defaultFilterBtn(),//
],
};
},
mounted() {
this.paging();
},
}
</script>
<style lang="scss" scoped>
@import "@/styles/basicData.scss";
</style>

26
Code/Fe/src/views/demo/demo_read.vue

@ -25,6 +25,29 @@
@overallSearchFormClick="overallSearchFormClick" @overallSearchFormClick="overallSearchFormClick"
:httpOverallSearchData="httpOverallSearchData" :httpOverallSearchData="httpOverallSearchData"
></tablePagination> ></tablePagination>
<!-- :buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left" -->
<!-- <curren-Drawer
ref="currenDrawer_Ref"
:title="apiColumns_DesTions"
@rowDrop="rowDrop"
:tableColumns="apiColumns_DetailsTable"
:tabsDesTions="apiColumns_DesTions"
:DrawerLoading="Loading.DrawerLoading"
:drawer="displayDialog.detailsDialog"
:propsData="propsData"
:Butttondata="[]"
@drawerShut="(val) => (displayDialog.detailsDialog = val)"
@drawerbutton="drawerbutton"
@handleCommand="drawerHandle"
@close-value="closeValue"
:totalCount="totalCountDetails"
:currentPage="oldSkipCountDetails"
:MaxResultCount="MaxResultCountDetails"
@alterResultCountDetails="alterResultCountDetails"
@alertoldSkipCountDetails="alertoldSkipCountDetails"
:buttonOperationList_left="operationButtonsDetail"
></curren-Drawer> -->
<!-- 导出弹窗 --> <!-- 导出弹窗 -->
<exportDrop <exportDrop
v-if="displayDialog.exportDialog" v-if="displayDialog.exportDialog"
@ -41,11 +64,10 @@ import { TableHeaderMixins } from "@/mixins/TableHeaderMixins";
import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins" import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins"
import { mixins } from "@/mixins/mixins"; import { mixins } from "@/mixins/mixins";
import { filterSelectMixins } from '@/mixins/filter-Select' import { filterSelectMixins } from '@/mixins/filter-Select'
import { getToken } from '@/utils/auth'
export default { export default {
name: "IncomingData", name: "demo_read",
mixins: [ mixins: [
tableMixins, tableMixins,
LoadingMixins, LoadingMixins,

Loading…
Cancel
Save