569 lines
19 KiB
JavaScript
569 lines
19 KiB
JavaScript
|
|
//组件
|
|||
|
|
var Welltypecomponent = {
|
|||
|
|
template:`
|
|||
|
|
<div>
|
|||
|
|
<div v-show="if_show0">
|
|||
|
|
<div style="display: inline-block;width: 100%;margin-top: 10px;">
|
|||
|
|
<div style="float: left;width: 20%;background-color: #ECF5FF;">
|
|||
|
|
<el-input v-model="input" placeholder="请输入井名" clearable></el-input>
|
|||
|
|
</div>
|
|||
|
|
<div style="float: left;background-color: #ECF5FF;">
|
|||
|
|
<el-select v-model="value" multiple collapse-tags filterable clearable placeholder="请选择测井类型" >
|
|||
|
|
<el-option
|
|||
|
|
v-for="item in options"
|
|||
|
|
:key="item.value"
|
|||
|
|
:label="item.label"
|
|||
|
|
:value="item.value">
|
|||
|
|
</el-option>
|
|||
|
|
</el-select>
|
|||
|
|
</div>
|
|||
|
|
<div style="float: left;background-color: #ECF5FF;">
|
|||
|
|
<el-date-picker
|
|||
|
|
v-if="if_show_bt==1"
|
|||
|
|
v-model="date_value"
|
|||
|
|
type="datetimerange"
|
|||
|
|
range-separator="至"
|
|||
|
|
start-placeholder="上传开始日期"
|
|||
|
|
end-placeholder="上传结束日期"
|
|||
|
|
value-format="yyyy-MM-dd HH:mm:ss">
|
|||
|
|
</el-date-picker>
|
|||
|
|
<el-date-picker
|
|||
|
|
v-if="if_show_bt==2"
|
|||
|
|
v-model="date_value"
|
|||
|
|
type="datetimerange"
|
|||
|
|
range-separator="至"
|
|||
|
|
start-placeholder="上传开始日期"
|
|||
|
|
end-placeholder="上传结束日期"
|
|||
|
|
format="MM-dd-yyyy HH:mm:ss"
|
|||
|
|
value-format="yyyy-MM-dd HH:mm:ss">
|
|||
|
|
</el-date-picker>
|
|||
|
|
<el-date-picker
|
|||
|
|
v-if="if_show_bt==3"
|
|||
|
|
v-model="date_value"
|
|||
|
|
type="datetimerange"
|
|||
|
|
range-separator="至"
|
|||
|
|
start-placeholder="上传开始日期"
|
|||
|
|
end-placeholder="上传结束日期"
|
|||
|
|
format="dd-MM-yyyy HH:mm:ss"
|
|||
|
|
value-format="yyyy-MM-dd HH:mm:ss">
|
|||
|
|
</el-date-picker>
|
|||
|
|
</div>
|
|||
|
|
<div style="float: left; margin-left: 5px;">
|
|||
|
|
<el-button id ="bt_serach" plain type="primary" icon="el-icon-search" @click="getWellTestType(input)">搜索</el-button>
|
|||
|
|
</div>
|
|||
|
|
<div style="float: left;margin-left: 5px;">
|
|||
|
|
<el-button id ="bt_export_welltype" plain type="primary" icon="el-icon-document" @click="exportWellTestType()">导出</el-button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="span">
|
|||
|
|
<el-table
|
|||
|
|
:data="tableData"
|
|||
|
|
style="width: 100%"
|
|||
|
|
:height="tHeight"
|
|||
|
|
:cell-style="{background:'#304156'}"
|
|||
|
|
border
|
|||
|
|
>
|
|||
|
|
<el-table-column
|
|||
|
|
prop="wellname"
|
|||
|
|
label="井名称"
|
|||
|
|
:width="150"
|
|||
|
|
:show-overflow-tooltip="true">
|
|||
|
|
</el-table-column>
|
|||
|
|
<el-table-column
|
|||
|
|
prop="type"
|
|||
|
|
label="井测试类型"
|
|||
|
|
:width="200"
|
|||
|
|
:show-overflow-tooltip="true">
|
|||
|
|
</el-table-column>
|
|||
|
|
|
|||
|
|
<el-table-column
|
|||
|
|
prop="well_create_time"
|
|||
|
|
label="井创建时间"
|
|||
|
|
:width="170">
|
|||
|
|
</el-table-column>
|
|||
|
|
|
|||
|
|
<el-table-column label="操作" :width="180">
|
|||
|
|
<template slot-scope="scope">
|
|||
|
|
<el-button
|
|||
|
|
v-if="scope.row.type.includes('振动粘滑')"
|
|||
|
|
type="text"
|
|||
|
|
size="small"
|
|||
|
|
@click="showReportDialog(scope.row)">
|
|||
|
|
振动粘滑报告
|
|||
|
|
</el-button>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</el-table-column>
|
|||
|
|
</el-table-column>
|
|||
|
|
</el-table>
|
|||
|
|
</div>
|
|||
|
|
<div class="block">
|
|||
|
|
<span class="demonstration" style="background-color: #ECF5FF;"></span>
|
|||
|
|
<el-pagination
|
|||
|
|
@size-change="handleSizeChange"
|
|||
|
|
@current-change="handleCurrentChange"
|
|||
|
|
:current-page="currentPage"
|
|||
|
|
:page-sizes="[50,100, 200, 300]"
|
|||
|
|
:page-size="pagesize"
|
|||
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|||
|
|
:total="recordTotal" style="background-color: #ECF5FF;">
|
|||
|
|
</el-pagination>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div v-show="if_show" style="text-align: center; width: 100%;;font-size: 14px;">
|
|||
|
|
<el-tag type="warning" style="width: 100%;height: 50px;font-size: 14px;">用户没有本菜单权限!</el-tag>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
`,
|
|||
|
|
data(){
|
|||
|
|
// 获取当前屏幕的分辨率
|
|||
|
|
let screenW = window.screen.width;
|
|||
|
|
let screenH = window.innerHeight;
|
|||
|
|
console.log("screen width:",screenW);
|
|||
|
|
console.log("screen height:",screenH);
|
|||
|
|
return {
|
|||
|
|
tHeight:screenH-192,
|
|||
|
|
tableData: Array(0),
|
|||
|
|
currentPage: 1,
|
|||
|
|
pagesize:50,
|
|||
|
|
recordTotal:0,
|
|||
|
|
input:'',
|
|||
|
|
options: [{
|
|||
|
|
value: 0,
|
|||
|
|
label: '测斜'
|
|||
|
|
}, {
|
|||
|
|
value: 1,
|
|||
|
|
label: '近钻头'
|
|||
|
|
}, {
|
|||
|
|
value: 2,
|
|||
|
|
label: '电阻率'
|
|||
|
|
}, {
|
|||
|
|
value: 3,
|
|||
|
|
label: '探管式方位伽马'
|
|||
|
|
}, {
|
|||
|
|
value: 4,
|
|||
|
|
label: '钻铤式方位伽马',
|
|||
|
|
},{
|
|||
|
|
value: 5,
|
|||
|
|
label: '自然伽马',
|
|||
|
|
},{
|
|||
|
|
value: 6,
|
|||
|
|
label: '工程参数',
|
|||
|
|
},{
|
|||
|
|
value: 7,
|
|||
|
|
label: '振动粘滑',
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
value: [],
|
|||
|
|
date_value:[],
|
|||
|
|
if_show0:false,
|
|||
|
|
if_show:false,
|
|||
|
|
|
|||
|
|
if_show_bt:1,
|
|||
|
|
if_show_et:false,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
mounted() {
|
|||
|
|
if (localStorage.getItem("level")==4) {
|
|||
|
|
this.$data.if_show = true;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var _this = this;
|
|||
|
|
|
|||
|
|
axios.post('/deescloud/get_page_setting', {
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
if(response.data.r3=="1"){
|
|||
|
|
_this.$data.if_show_bt=1;
|
|||
|
|
//_this.$data.if_show_et=false;
|
|||
|
|
}else if(response.data.r3=="2"){
|
|||
|
|
//_this.$data.if_show_et=true;
|
|||
|
|
_this.$data.if_show_bt=2;
|
|||
|
|
}else if(response.data.r3=="3"){
|
|||
|
|
//_this.$data.if_show_et=true;
|
|||
|
|
_this.$data.if_show_bt=3;
|
|||
|
|
}else{
|
|||
|
|
_this.$data.if_show_bt=1;
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.$data.if_show0= true;
|
|||
|
|
|
|||
|
|
this.$data.currentPage = 1;
|
|||
|
|
|
|||
|
|
var objs;
|
|||
|
|
axios.post('/deescloud/getwtt', {
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
wellname: '',
|
|||
|
|
index: this.$data.currentPage,
|
|||
|
|
count: this.$data.pagesize
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
objs = response.data.data;
|
|||
|
|
rcnt = response.data.total;
|
|||
|
|
_this.$data.tableData = objs;
|
|||
|
|
_this.$data.recordTotal = rcnt;
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
// 新增弹窗方法
|
|||
|
|
showReportDialog(row) {
|
|||
|
|
this.$confirm(
|
|||
|
|
'<br/><br/>' ,
|
|||
|
|
'📊 报告导出', // 这是标题参数
|
|||
|
|
{
|
|||
|
|
dangerouslyUseHTMLString: true,
|
|||
|
|
confirmButtonText: '生成解码报告',
|
|||
|
|
cancelButtonText: '生成存储报告',
|
|||
|
|
distinguishCancelAndClose: true,
|
|||
|
|
// type: 'success',
|
|||
|
|
center: true,
|
|||
|
|
customClass: 'report-confirm'
|
|||
|
|
}
|
|||
|
|
).then(() => {
|
|||
|
|
this.export_pdf(row, false);
|
|||
|
|
}).catch(action => {
|
|||
|
|
if (action === 'cancel') {
|
|||
|
|
this.export_pdf(row, true);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
export_pdf(row, is_memory = false) {
|
|||
|
|
const loading = this.$loading({
|
|||
|
|
lock: true,
|
|||
|
|
text: '报告生成中...',
|
|||
|
|
spinner: 'el-icon-loading',
|
|||
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
axios.post('deescloud/get_vibration_report_pdf', {
|
|||
|
|
opuser: localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid: localStorage.getItem("uuid"),
|
|||
|
|
wellname: row.wellname,
|
|||
|
|
is_memory: is_memory
|
|||
|
|
})
|
|||
|
|
.then(response => {
|
|||
|
|
loading.close();
|
|||
|
|
const fileid = response.data.fileId;
|
|||
|
|
// downloadUrl(`${row.wellname}-振动粘滑报告.pdf`, `file/${fileid}`);
|
|||
|
|
const filename = is_memory ? `${row.wellname}_振动粘滑存储报告.pdf` : `${row.wellname}_振动粘滑解码报告.pdf`;
|
|||
|
|
downloadUrl(filename, `file/${fileid}`);
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(error => {
|
|||
|
|
loading.close();
|
|||
|
|
console.log(error);
|
|||
|
|
this.$notify.error({
|
|||
|
|
title: '导出失败',
|
|||
|
|
message: '请检查网络或联系管理员',
|
|||
|
|
duration: 5000
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// export_pdf(row, is_memory = false) {
|
|||
|
|
// var _this = this;
|
|||
|
|
// axios.post('deescloud/get_vibration_report_pdf', {
|
|||
|
|
// opuser: localStorage.getItem("online_user"),
|
|||
|
|
// opuser_uuid: localStorage.getItem("uuid"),
|
|||
|
|
// wellname: row.wellname,
|
|||
|
|
// is_memory: is_memory // 使用传入的参数
|
|||
|
|
// })
|
|||
|
|
// .then(function (response) {
|
|||
|
|
// console.log(response.data);
|
|||
|
|
// var fileid = response.data.fileId;
|
|||
|
|
// var downUrl = 'file/' + fileid;
|
|||
|
|
// downloadUrl(row.wellname + "-振动粘滑报告.pdf", downUrl);
|
|||
|
|
// })
|
|||
|
|
// .catch(function (error) {
|
|||
|
|
// console.log(error);
|
|||
|
|
// });
|
|||
|
|
// },
|
|||
|
|
|
|||
|
|
|
|||
|
|
exportWellTestType(){
|
|||
|
|
document.getElementById("bt_export_welltype").blur();
|
|||
|
|
|
|||
|
|
var beginTime= '';
|
|||
|
|
var endTime = '';
|
|||
|
|
|
|||
|
|
if (this.$data.date_value != null && this.$data.date_value.length > 1) {
|
|||
|
|
console.log("len:",this.$data.date_value.length)
|
|||
|
|
console.log("date_value:",this.$data.date_value);
|
|||
|
|
beginTime = this.$data.date_value[0];
|
|||
|
|
endTime = this.$data.date_value[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var type =0 ;
|
|||
|
|
console.log("---",this.$data.value);
|
|||
|
|
if (this.$data.value.length != 0) {
|
|||
|
|
|
|||
|
|
var len = this.$data.value.length;
|
|||
|
|
for (var i = 0; i< len; i++) {
|
|||
|
|
type = type+(1<<this.$data.value[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
axios.post('deescloud/getWellTypeCsv',{
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
wellname: this.$data.input,
|
|||
|
|
type:type,
|
|||
|
|
beginTime:beginTime,
|
|||
|
|
endTime:endTime
|
|||
|
|
}
|
|||
|
|
).then(function (response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
var fileid = response.data.fileId;
|
|||
|
|
|
|||
|
|
var downUrl = 'file/'+fileid;
|
|||
|
|
downloadUrl("测井类型统计.csv",downUrl);
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getWellTestType(_search_name){
|
|||
|
|
document.getElementById("bt_serach").blur();
|
|||
|
|
|
|||
|
|
var beginTime= '';
|
|||
|
|
var endTime = '';
|
|||
|
|
|
|||
|
|
if (this.$data.date_value != null && this.$data.date_value.length > 1) {
|
|||
|
|
console.log("len:",this.$data.date_value.length)
|
|||
|
|
console.log("date_value:",this.$data.date_value);
|
|||
|
|
beginTime = this.$data.date_value[0];
|
|||
|
|
endTime = this.$data.date_value[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var type =0 ;
|
|||
|
|
console.log("---",this.$data.value);
|
|||
|
|
if (this.$data.value.length != 0) {
|
|||
|
|
|
|||
|
|
var len = this.$data.value.length;
|
|||
|
|
for (var i = 0; i< len; i++) {
|
|||
|
|
type = type+(1<<this.$data.value[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log("req type:",type);
|
|||
|
|
|
|||
|
|
this.$data.currentPage = 1;
|
|||
|
|
|
|||
|
|
var _this = this;
|
|||
|
|
var objs;
|
|||
|
|
axios.post('/deescloud/getwtt', {
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
wellname: _search_name,
|
|||
|
|
type:type,
|
|||
|
|
index: this.$data.currentPage,
|
|||
|
|
count: this.$data.pagesize,
|
|||
|
|
beginTime:beginTime,
|
|||
|
|
endTime:endTime
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
objs = response.data.data;
|
|||
|
|
rcnt = response.data.total;
|
|||
|
|
_this.$data.tableData = objs;
|
|||
|
|
_this.$data.recordTotal = rcnt;
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
handleSizeChange(val) {
|
|||
|
|
this.$data.pagesize = val;
|
|||
|
|
|
|||
|
|
var beginTime= '';
|
|||
|
|
var endTime = '';
|
|||
|
|
|
|||
|
|
if (this.$data.date_value != null && this.$data.date_value.length > 1) {
|
|||
|
|
console.log("len:",this.$data.date_value.length)
|
|||
|
|
console.log("date_value:",this.$data.date_value);
|
|||
|
|
beginTime = this.$data.date_value[0];
|
|||
|
|
endTime = this.$data.date_value[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var type =0 ;
|
|||
|
|
console.log("---",this.$data.value);
|
|||
|
|
if (this.$data.value.length != 0) {
|
|||
|
|
|
|||
|
|
var len = this.$data.value.length;
|
|||
|
|
for (var i = 0; i< len; i++) {
|
|||
|
|
type = type+(1<<this.$data.value[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log("req type:",type);
|
|||
|
|
|
|||
|
|
var _this = this;
|
|||
|
|
|
|||
|
|
var objs;
|
|||
|
|
axios.post('/deescloud/getwtt', {
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
wellname: this.$data.input,
|
|||
|
|
type:type,
|
|||
|
|
index: this.$data.currentPage,
|
|||
|
|
count: this.$data.pagesize,
|
|||
|
|
beginTime:beginTime,
|
|||
|
|
endTime:endTime
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
objs = response.data.data;
|
|||
|
|
rcnt = response.data.total;
|
|||
|
|
_this.$data.tableData = objs;
|
|||
|
|
_this.$data.recordTotal = rcnt;
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
handleCurrentChange(val) {
|
|||
|
|
this.$data.currentPage = val;
|
|||
|
|
|
|||
|
|
var beginTime= '';
|
|||
|
|
var endTime = '';
|
|||
|
|
|
|||
|
|
if (this.$data.date_value != null && this.$data.date_value.length > 1) {
|
|||
|
|
console.log("len:",this.$data.date_value.length)
|
|||
|
|
console.log("date_value:",this.$data.date_value);
|
|||
|
|
beginTime = this.$data.date_value[0];
|
|||
|
|
endTime = this.$data.date_value[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var type =0 ;
|
|||
|
|
console.log("---",this.$data.value);
|
|||
|
|
if (this.$data.value.length != 0) {
|
|||
|
|
|
|||
|
|
var len = this.$data.value.length;
|
|||
|
|
for (var i = 0; i< len; i++) {
|
|||
|
|
type = type+(1<<this.$data.value[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log("req type:",type);
|
|||
|
|
|
|||
|
|
var _this = this;
|
|||
|
|
|
|||
|
|
var objs;
|
|||
|
|
axios.post('/deescloud/getwtt', {
|
|||
|
|
opuser:localStorage.getItem("online_user"),
|
|||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
|||
|
|
wellname: this.$data.input,
|
|||
|
|
type:type,
|
|||
|
|
index: this.$data.currentPage,
|
|||
|
|
count: this.$data.pagesize,
|
|||
|
|
beginTime:beginTime,
|
|||
|
|
endTime:endTime
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
objs = response.data.data;
|
|||
|
|
rcnt = response.data.total;
|
|||
|
|
_this.$data.tableData = objs;
|
|||
|
|
_this.$data.recordTotal = rcnt;
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
flexColumnWidth(str, tableData, flag = 'max') {
|
|||
|
|
|
|||
|
|
let maxContext = new Array();
|
|||
|
|
|
|||
|
|
str = str + ''
|
|||
|
|
let columnContent = ''
|
|||
|
|
if (!tableData || !tableData.length || tableData.length === 0 || tableData === undefined) {
|
|||
|
|
return '120px'
|
|||
|
|
}
|
|||
|
|
if (!str || !str.length || str.length === 0 || str === undefined) {
|
|||
|
|
return '120px'
|
|||
|
|
}
|
|||
|
|
if (flag === 'equal') {
|
|||
|
|
// 获取该列中第一个不为空的数据(内容)
|
|||
|
|
for (let i = 0; i < tableData.length; i++) {
|
|||
|
|
if (tableData[i][str].length > 0) {
|
|||
|
|
// console.log('该列数据[0]:', tableData[0][str])
|
|||
|
|
columnContent = tableData[i][str]
|
|||
|
|
break
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
// 获取该列中最长的数据(内容)
|
|||
|
|
let index = 0
|
|||
|
|
for (let i = 0; i < tableData.length; i++) {
|
|||
|
|
if (tableData[i][str] === null) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
const now_temp = tableData[i][str] + ''
|
|||
|
|
const max_temp = tableData[index][str] + ''
|
|||
|
|
if (now_temp.length >= max_temp.length) {
|
|||
|
|
index = i
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
columnContent = tableData[index][str]
|
|||
|
|
|
|||
|
|
maxContext.push(columnContent);
|
|||
|
|
}
|
|||
|
|
// console.log('该列数据[i]:', columnContent)
|
|||
|
|
// 以下分配的单位长度可根据实际需求进行调整
|
|||
|
|
|
|||
|
|
//console.log(columnContent);
|
|||
|
|
let max_flex_width = 0
|
|||
|
|
|
|||
|
|
for (let i = 0; i < maxContext.length; i++) {
|
|||
|
|
let flexWidth = 0;
|
|||
|
|
for (const char of maxContext[i]) {
|
|||
|
|
if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) {
|
|||
|
|
// 如果是英文字符,为字符分配8个单位宽度
|
|||
|
|
flexWidth += 8
|
|||
|
|
} else if (char >= '\u4e00' && char <= '\u9fa5') {
|
|||
|
|
// 如果是中文字符,为字符分配15个单位宽度
|
|||
|
|
flexWidth += 15
|
|||
|
|
} else {
|
|||
|
|
// 其他种类字符,为字符分配8个单位宽度
|
|||
|
|
flexWidth += 8
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flexWidth>max_flex_width) {
|
|||
|
|
max_flex_width = flexWidth;
|
|||
|
|
console.log(maxContext[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (max_flex_width < 120) {
|
|||
|
|
// 设置最小宽度
|
|||
|
|
max_flex_width = 120
|
|||
|
|
}
|
|||
|
|
if (max_flex_width > 300) {
|
|||
|
|
// 设置最大宽度
|
|||
|
|
max_flex_width = 300
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//flexWidth = flexWidth;//20-padding
|
|||
|
|
console.log("max_flex_width:",max_flex_width);
|
|||
|
|
return max_flex_width + 'px'
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
}
|