Browse Source

【埃驰-接口-new】表格参数为array类型处理及点击事件封装开发

master
安虹睿 1 day ago
parent
commit
1dcb8837a2
  1. 156
      PC/InterFace.New/src/components/arrayTableDialog/index.vue
  2. 2
      PC/InterFace.New/src/components/showCopyJsonPop/index.vue
  3. 33
      PC/InterFace.New/src/components/umyTable/index.vue
  4. 12
      PC/InterFace.New/src/utils/baseData/urlOption.js

156
PC/InterFace.New/src/components/arrayTableDialog/index.vue

@ -0,0 +1,156 @@
<template>
<!-- 组件功能查看json及复制 -->
<div class="arrayTableDialog">
<!-- 点开查看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;"
>复制数据</el-button>
</template>
<umyTable
:isShowIndex="true"
:tableBorder="true"
:setUTableHeight="170"
:row-key="null"
:tableData="arrTableData"
:tableColumns="arrTableColumns"
:selectionTable="false"
></umyTable>
</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="'数据详情'"
>
<el-input
class="copyJsonTextarea"
ref="copyJsonTextarea_ref"
type="textarea"
readonly
autosize
resize="none"
v-model="JsonCopyData"
></el-input>
</el-dialog>
</div>
</template>
<script>
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
export default {
name:"arrayTableDialog",
mixins:[ LoadingMixins,tableMixins ],
props: {
// Json
arrTableData:{
type: Array,
default: null,
},
},
data () {
return {
JsonTableShow:true,//Jsontable
JsonTableData:null,//json
JsonCopyData:null,//Json
JsonCopyShow:false,//Dialog
arrTableColumns:null,//
}
},
mounted(){
this.initData()
},
methods: {
//
initData(){
//
this.arrTableColumns = []
for(let i in this.arrTableData[0]){
this.arrTableColumns.push({
prop:i,
label:i
})
}
//
this.JsonCopyData = JSON.stringify(this.arrTableData, null, '\t')
},
//
closePop() {
this.JsonTableShow = false
this.$emit("closePop")
},
//
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
}
},
//
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')
})
}
},
}
}
</script>
<style lang="scss" scoped>
::v-deep .copyJsonTextarea{
textarea{
max-height: calc(100vh - 220px) !important;
overflow: auto !important;
}
}
</style>

2
PC/InterFace.New/src/components/showCopyJsonPop/index.vue

@ -197,7 +197,7 @@ export default {
for(let h in _json[item][0]){ for(let h in _json[item][0]){
this.detailTableHeader.push(h) this.detailTableHeader.push(h)
} }
let _value = (item).toUpperCase() == 'DETAILS' ? _json[item] : (_json[item]).join(",") let _value = ((item).toUpperCase() == 'DETAILS' || typeof _json[item] == 'object') ? _json[item] : (_json[item]).join(",")
_arr.push({name:item,value:_value}) _arr.push({name:item,value:_value})
} }
// //

33
PC/InterFace.New/src/components/umyTable/index.vue

@ -213,6 +213,13 @@
@closePop="closeJsonPop" @closePop="closeJsonPop"
></showCopyJsonPop> ></showCopyJsonPop>
<!-- 查看Array列表 -->
<arrayTableDialog
v-if="showArrayTableDialog"
:arrTableData="showArrayTableData"
@closePop="closeArrayTablePop"
></arrayTableDialog>
</u-table> </u-table>
</template> </template>
<script> <script>
@ -220,11 +227,12 @@ 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" import showCopyJsonPop from "@/components/showCopyJsonPop"
import arrayTableDialog from "@/components/arrayTableDialog"
import permission from "@/directive/permission/index" import permission from "@/directive/permission/index"
export default { export default {
name: "currenTable", name: "currenTable",
directives: { permission }, directives: { permission },
components:{ showCopyJsonPop }, components:{ showCopyJsonPop,arrayTableDialog },
filters: { filters: {
formatDate(time) { formatDate(time) {
if (time == null) { if (time == null) {
@ -356,6 +364,8 @@ export default {
showDetailData:null,// showDetailData:null,//
showJsonDialog:false,//Jsontable showJsonDialog:false,//Jsontable
showJsonData:null,//Json showJsonData:null,//Json
showArrayTableDialog:false,//arraytable
showArrayTableData:null,//array
}; };
}, },
computed: { computed: {
@ -660,12 +670,21 @@ export default {
closeJsonPop(){ closeJsonPop(){
this.showJsonDialog = false this.showJsonDialog = false
}, },
// jsontable closeArrayTablePop(){
this.showArrayTableDialog = false
},
// jsontablejson
showJsonTable(row){ showJsonTable(row){
this.showJsonDialog = true this.showJsonDialog = true
let _json = eval('(' + row + ')') let _json = eval('(' + row + ')')
this.showJsonData = _json this.showJsonData = _json
}, },
// jsontableArray
showArrayTable(row){
this.showArrayTableDialog = true
let _json = eval('(' + row + ')')
this.showArrayTableData = _json
},
// //
buttonClick(row, index, label) { buttonClick(row, index, label) {
this.$emit("buttonClick", row, index, label); this.$emit("buttonClick", row, index, label);
@ -693,10 +712,14 @@ export default {
try { try {
let _json = JSON.parse(data) let _json = JSON.parse(data)
// //
if(typeof _json == 'number' && _json){ if((typeof _json == 'number' || typeof _json == 'boolean') && (_json || _json == '0' || _json == 'false')){
return [data,'show'] return [data,'show']
}else{ }else{
return [data,'json'] if (Array.isArray(_json)) {
return [data,'array']
} else {
return [data,'json']
}
} }
} }
// //
@ -706,8 +729,10 @@ export default {
}, },
// //
showTypeHandle(type,row){ showTypeHandle(type,row){
console.log(732,type)
if(type == 'detail')this.showDetailInfo(row) if(type == 'detail')this.showDetailInfo(row)
if(type == 'json')this.showJsonTable(row) if(type == 'json')this.showJsonTable(row)
if(type == 'array')this.showArrayTable(row)
}, },
// //
changeValue(prop,item,val) { changeValue(prop,item,val) {

12
PC/InterFace.New/src/utils/baseData/urlOption.js

@ -131,13 +131,11 @@ export const FromWms_PoDet = {
//开始------------------只有主表 FromWms_PoMstr------------------ //开始------------------只有主表 FromWms_PoMstr------------------
export const FromWms_PoMstr = { export const FromWms_PoMstr = {
baseURL:'FromWms_PoMstr/base',//主表-列表 baseURL:'FromWms_PoMstr/base',//主表-列表
detailURL:'FromWms_PoMstr/Base/Get-By-Id',//主表-明细 + 明细-查看主表 detailURL:'FromWms_PoMstr/Base/Get-By-Id',//主表-明细 + 明细-查看主表
detailListURL:'FromWms_PoDet/Base',
masterId:'FromWms_PoMstrId',
hasDetail:false hasDetail:false
} }
//结束------------------------------------ //结束------------------------------------
@ -245,9 +243,7 @@ export const ToScp_Part = {
export const ToScp_PoDet = { export const ToScp_PoDet = {
baseURL:'ToScp_PoDet/base',//主表-列表 baseURL:'ToScp_PoDet/base',//主表-列表
detailURL:'ToScp_PoDet/Base/Get-By-Id',//主表-明细 + 明细-查看主表 detailURL:'ToScp_PoDet/Base/Get-By-Id',//主表-明细 + 明细-查看主表
hasDetail:false hasDetail:false
} }
@ -261,9 +257,9 @@ export const ToScp_PoDet = {
export const ToScp_PoMstr = { export const ToScp_PoMstr = {
baseURL:'ToScp_PoMstr/base',//主表-列表 baseURL:'ToScp_PoMstr/base',//主表-列表
detailURL:'ToScp_PoMstr/Base/Get-By-Id',//主表-明细 + 明细-查看主表 detailURL:'ToScp_PoMstr/Base/Get-By-Id',//主表-明细 + 明细-查看主表
detailListURL:'ToScp_PoDet/Base',
masterId:'ToScp_PoMstrId',
hasDetail:false hasDetail:false
} }

Loading…
Cancel
Save