deesCloud-web/scripts/authinfo.js

1007 lines
28 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var authComponent = {
template:`
<div>
<div id="" style="display: inline-block;width: 100%;margin-top: 10px;">
<div style="float: left; width: 15%;background-color: #ECF5FF;">
<el-input v-model="input" placeholder="请输入系列号" clearable></el-input>
</div>
<div style="float: left; width: 15%;background-color: #ECF5FF;">
<el-input v-model="iid" placeholder="请输入编码" clearable></el-input>
</div>
<div style="float: left;margin-left: 5px;">
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="getAuthinfo(input)">搜索</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="addAuth()">新增</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_batch_auth" plain type="primary" icon="el-icon-circle-plus-outline" @click="batchAuth()">批量授权</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportAuth()">导出</el-button>
</div>
</div>
<div class="span">
<el-table
class="setscroll"
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
:height="tHeight"
:cell-style="{background:'#304156'}"
row-key="id"
@selection-change="handleSelectionChange"
border
:row-class-name="tableRowClassName"
>
<el-table-column
type="selection"
:reserve-selection="true"
width="55">
</el-table-column>
<el-table-column
fixed
prop="series"
label="仪器系列号"
width="80">
</el-table-column>
<el-table-column
fixed
prop="instrument_id"
label="仪器编码"
width="80">
</el-table-column>
<el-table-column
prop="auth_date"
label="授权时间"
width="150">
</el-table-column>
<el-table-column
prop="expire_date"
label="到期时间"
width="150">
</el-table-column>
<el-table-column
prop="authorizer"
label="授权人"
width="80">
</el-table-column>
<el-table-column
prop="applicanter"
label="申请人"
width="80">
</el-table-column>
<el-table-column
prop="auth_count"
label="授权次数"
width="80">
</el-table-column>
<el-table-column
prop="area_code"
label="区域代码"
width="80">
</el-table-column>
<el-table-column
prop="country"
label="国家名称"
width="100">
</el-table-column>
<el-table-column
prop="longitude"
label="经度"
width="100">
</el-table-column>
<el-table-column
prop="latitude"
label="纬度"
width="100">
</el-table-column>
<el-table-column
prop="auth_mark"
label="工作字"
width="60"
:show-overflow-tooltip="true">
</el-table-column>
<!--:width="flexColumnWidth('note',tableData)"-->
<el-table-column
prop="note"
label="备注"
:width="flexColumnWidth('note',tableData)">
</el-table-column>
<el-table-column
label="操作"
width="100">
<template slot-scope="scope">
<el-button @click="updateAuth(scope.row)" type="text" size="medium">修改</el-button>
<el-button @click="delAuth(scope.row)" type="text" size="medium">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="block" style="margin-top: 10px;">
<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>
<el-dialog
title="授权信息"
:visible.sync="dialogVisible"
:lock-scroll ="false"
width="60%">
<el-form ref="authform" :model="form" :rules="rules" label-width="80px" :inline="false" class="demo-form-inline" size="medium">
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="系列号" prop="series">
<el-input v-model="form.series" :disabled="form.change_series"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="编码" prop="instrument_id">
<el-input v-model="form.instrument_id" :disabled="form.change_series"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="16">
<el-form-item label="到期时间" prop="expire_date">
<el-date-picker
v-model="form.expire_date"
type="datetime"
placeholder="选择日期时间"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="区域代码">
<el-input v-model="form.area_code"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="国家名称">
<el-input v-model="form.country"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="经度">
<el-input v-model="form.longitude"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="纬度">
<el-input v-model="form.latitude"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="授权人" prop="authorizer">
<el-input v-model="form.authorizer" :disabled="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="工作字">
<el-input v-model="form.auth_mark"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="申请人" prop="applicanter">
<el-input v-model="form.applicanter" :disabled="false"></el-input>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="备注">
<el-input v-model="form.note"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button id ="bt_ok" plain type="primary" @click="postAuth()">确 定</el-button>
</span>
</el-dialog>
<el-dialog
title="批量授权"
:visible.sync="batch_auth_visible"
:lock-scroll ="false"
width="60%">
<div id="" style="display: block;">
<div style="float: left;width: 45%;">
<el-table
:data="multipleSelection"
style="width: 100%"
:cell-style="{background:'#fff'}"
height="300"
>
<el-table-column
prop="series"
label="仪器系列号"
width="120">
</el-table-column>
<el-table-column
prop="instrument_id"
label="仪器编码"
width="100">
</el-table-column>
</el-table>
</div>
<div id="" style="float: left;height: 300px;width: 3%;">
<!--<el-divider direction="vertical" style="height: 100%;"></el-divider>-->
</div>
<div style="float: left;height: 300px;width: 52%;">
<el-form ref="batchAuthform" :model="form" :rules="rules" label-width="110px" :inline="true">
<el-form-item label="到期时间" prop="expire_date">
<el-date-picker
v-model="form.expire_date"
type="datetime"
placeholder="选择日期时间"
value-format="yyyy-MM-dd HH:mm:ss"
style="width:100%">
</el-date-picker>
</el-form-item>
<el-form-item label="授权人" prop="authorizer">
<el-input v-model="form.authorizer" :disabled="true" style="width:120px"></el-input>
</el-form-item>
<el-form-item label="申请人" prop="applicanter">
<el-input v-model="form.applicanter" style="width:120px"></el-input>
</el-form-item>
<el-form-item label="备注" prop="note">
<el-input v-model="form.note" style="width:100%"></el-input>
</el-form-item>
</el-form>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="batch_auth_visible = false">取 消</el-button>
<el-button id ="bt_batch_auth_ok" plain type="primary" @click="batchAuth1()">确 定</el-button>
</span>
</el-dialog>
</div>
`,
data(){
exportconstvalidateContacts = (rule, value, callback) => {
if(!value) {
returncallback(new Error('请输入中文或者英文字母!'))
}
if(!/^[\u0391-\uFFE5A-Za-z_-]+$/.test(value)) {
callback(new Error('请输入中文或者英文字母!'))
} else {
callback()
}
}
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.innerHeight;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH-202,
tableData: [],
multipleSelection: [],
input:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
form: {
id:'',
series: '',
instrument_id:'',
auth_date:'',
expire_date: '',
area_code:'',
country:'',
longitude:'',
latitude:'',
auth_count:'',
auth_mark:'',
authorizer:'',
applicanter:'',
note:'',
change_series:false
},
dialogVisible:false,
oper_type:0,
rules: {
series: [
{ required: true, message: '系列号不可为空', trigger: 'blur' }
],
instrument_id: [
{ required: true, message: '编码不可为空', trigger: 'blur' }
],
expire_date: [
{ required: true, message: '到期时间不可为空', trigger: 'blur' }
],
authorizer: [
{ required: true, message: '授权人不可为空', trigger: 'blur' }
]
},
iid:'',
tableData1:[],
batch_auth_visible:false,
}
},
mounted() {
var _this = this;
var objs;
axios.post('/deescloud/getAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
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: {
tableRowClassName({row, rowIndex}) {
var newDate = new Date();
var year=newDate.getFullYear();
var month=(newDate.getMonth()+1)<10?"0"+(newDate.getMonth()+1):newDate.getMonth()+1;
var day=newDate.getDate()<10?"0"+newDate.getDate():newDate.getDate();
var hours=newDate.getHours()<10?"0"+newDate.getHours():newDate.getHours();
var minuts=newDate.getMinutes()<10?"0"+newDate.getMinutes():newDate.getMinutes();
var seconds=newDate.getSeconds()<10?"0"+newDate.getSeconds():newDate.getSeconds();
var tt = year+"-"+month+"-"+day+" "+hours+":"+minuts+":"+seconds
//console.log(tt);
if (month==12) {
month=1
year=parseInt(year)+1
} else{
month=parseInt(month)+1
}
if (month <10) {
month='0'+month;
}
var t = year+"-"+month+"-"+day+" "+hours+":"+minuts+":"+seconds
//console.log("t:",t);
if (row.expire_date< t) {
return 'warning-row';
}
return '';
},
batchAuth(){
document.getElementById("bt_batch_auth").blur();
var selectdata = this.multipleSelection;
if (selectdata.length == 0) {
this.$message({
message: "请选择仪器!",
type: "warning",
duration: 1500
});
return;
}
console.log(selectdata);
/*this.$data.tableData1=[];
for (var i = 0; i < selectdata.length; i++) {
this.$data.tableData1.push(selectdata[i]);
}*/
var newDate = new Date();
var year=newDate.getFullYear()+1;
var month=(newDate.getMonth()+1)<10?"0"+(newDate.getMonth()+1):newDate.getMonth()+1;
var day=newDate.getDate()<10?"0"+newDate.getDate():newDate.getDate();
var hours=newDate.getHours()<10?"0"+newDate.getHours():newDate.getHours();
var minuts=newDate.getMinutes()<10?"0"+newDate.getMinutes():newDate.getMinutes();
var seconds=newDate.getSeconds()<10?"0"+newDate.getSeconds():newDate.getSeconds();
this.$data.form = {
id:'',
series: '',
instrument_id:'',
auth_date:'',
expire_date: year+"-"+month+"-"+day+" "+hours+":"+minuts+":"+seconds,
area_code:'',
country:'',
longitude:'',
latitude:'',
auth_count:'',
auth_mark:'',
authorizer:localStorage.getItem("online_user"),
change_series:false,
applicanter:'',
note:'',
};
this.$nextTick(() => {
this.$refs['batchAuthform'].clearValidate()
});
this.$data.batch_auth_visible = true;
},
batchAuth1(){
this.$refs['batchAuthform'].validate((valid) => {
if (valid) {
//document.getElementById("bt_batch_auth_ok").blur();
var _this = this;
var selectdata = this.multipleSelection;
this.$data.batch_auth_visible = false;
var req = new Array();
for (var i = 0; i < selectdata.length; i++) {
req[i] = {series:selectdata[i].series,instrument_id:selectdata[i].instrument_id,auth_count:selectdata[i].auth_count};
}
var jreq = JSON.stringify(req);
console.log(jreq);
axios.post('deescloud/batchAuth',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
authorizer:this.$data.form.authorizer,
expire_date:this.$data.form.expire_date,
auth_data:req,
applicanter:this.$data.form.applicanter,
note:this.$data.form.note,
})
.then(function (response) {
console.log(response.data);
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
s = "批量授权成功!";
errType = "success"
for (var i = 0; i < selectdata.length; i++) {
let cnt = parseInt(selectdata[i].auth_count)+1
selectdata[i].auth_count = cnt.toString();
}
} else{
s = "批量授权失败!";
errType = "error"
}
_this.getAuthinfo(_this.$data.input);
_this.$message({
message: s,
type: errType,
duration: 1500
});
})
.catch(function (error) {
console.log(error);
});
}
});
},
exportAuthPos(){
document.getElementById("bt_export1").blur();
/*var selectdata = this.multipleSelection;
if (selectdata.length == 0) {
this.$message({
message: "请选择导出仪器!",
type: "warning",
duration: 1500
});
return;
}
console.log(selectdata);
var req = new Array();
for (var i = 0; i < selectdata.length; i++) {
//console.log(selectdata[i]);
req[i] = {series:selectdata[i].series,instrument_id:selectdata[i].instrument_id};
}
var jreq = JSON.stringify(req);
console.log(jreq);*/
axios.post('deescloud/getAuthorizePosCsv')
.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);
});
},
exportAuth(){
document.getElementById("bt_export").blur();
var selectdata = this.multipleSelection;
if (selectdata.length == 0) {
this.$message({
message: "请选择导出仪器!",
type: "warning",
duration: 1500
});
return;
}
console.log(selectdata);
var req = new Array();
for (var i = 0; i < selectdata.length; i++) {
//console.log(selectdata[i]);
req[i] = {series:selectdata[i].series,instrument_id:selectdata[i].instrument_id};
}
var jreq = JSON.stringify(req);
console.log(jreq);
axios.post('deescloud/getDeesAuthDb',jreq)
.then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
//console.log(data)
//downloadUrl("auth.db",'deescloud/getDeesAuthDb?id=123')
var downUrl = 'file/'+fileid + '.auf';
downloadUrl("auth.auf",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
postAuth(){
this.$refs['authform'].validate((valid) => {
if (valid) {
/*if (this.$data.form.series =='' || this.$data.form.instrument_id == '' || this.$data.form.expire_date == '' || this.$data.form.authorizer == '') {
this.$alert('仪器系列号、编码、授权到期时间、授权人不能为空!', '提示', {
confirmButtonText: '确定',
callback: action => {
},
lockScroll:false
});
return;
}*/
this.$data.dialogVisible = false;
console.log(this.$data.form);
var _this = this;
axios.post('/deescloud/postAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
oper_type: _this.$data.oper_type,
id:_this.$data.form.id,
series: _this.$data.form.series,
instrument_id:_this.$data.form.instrument_id,
auth_date:_this.$data.form.auth_date,
expire_date: _this.$data.form.expire_date,
area_code: _this.$data.form.area_code,
country:_this.$data.form.country,
longitude:_this.$data.form.longitude,
latitude:_this.$data.form.latitude,
auth_count:_this.$data.form.auth_count,
auth_mark:_this.$data.form.auth_mark,
authorizer:_this.$data.form.authorizer,
applicanter:_this.$data.form.applicanter,
note:_this.$data.form.note,
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
errType = "success"
} else{
errType = "error"
}
if (_this.$data.oper_type == 1) {
if (r ==0) {
s = "新增授权信息成功!";
} else if (r ==1) {
s = "已存在相同的仪器系列号和编码!";
}else{
s = "新增授权信息失败!";
}
} else if (_this.$data.oper_type ==2){
if (r ==0) {
s = "修改授权信息成功!";
} else if (r ==1){
s = "已存在相同的仪器系列号和编码!";
} else{
s = "修改授权信息失败!";
}
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
//更新页面
if (_this.$data.oper_type == 1) {
_this.getAuthinfo("");
}else{
_this.getAuthinfo(_this.$data.input);
}
})
.catch(function (error) {
console.log(error);
});
}
});
},
delAuth(authinfo){
this.$data.oper_type = 3;
var mul_cache = [];
for (var i = 0; i < this.multipleSelection.length; i++) {
if (this.multipleSelection[i].series == authinfo.series && this.multipleSelection[i].instrument_id == authinfo.instrument_id) {
}else{
mul_cache.push(this.multipleSelection[i]);
}
}
this.multipleSelection = mul_cache;
var _this = this;
var objs;
axios.post('/deescloud/postAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: authinfo.id,
oper_type: _this.$data.oper_type,
series: authinfo.series,
instrument_id:authinfo.instrument_id,
auth_date:authinfo.auth_date,
expire_date: authinfo.expire_date,
area_code: authinfo.area_code,
country:authinfo.country,
longitude:authinfo.longitude,
latitude:authinfo.latitude,
auth_count:authinfo.auth_count,
auth_mark:authinfo.auth_mark,
authorizer:authinfo.authorizer
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
s = "删除授权信息成功!";
errType = "success"
} else{
s = "删除授权信息失败!";
errType = "error"
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
if (r ==0) {
_this.getAuthinfo("");//更新页面
}
})
.catch(function (error) {
console.log(error);
});
},
addAuth(){
document.getElementById("bt_add").blur();
var newDate = new Date();
var year=newDate.getFullYear()+1;
var month=(newDate.getMonth()+1)<10?"0"+(newDate.getMonth()+1):newDate.getMonth()+1;
var day=newDate.getDate()<10?"0"+newDate.getDate():newDate.getDate();
var hours=newDate.getHours()<10?"0"+newDate.getHours():newDate.getHours();
var minuts=newDate.getMinutes()<10?"0"+newDate.getMinutes():newDate.getMinutes();
var seconds=newDate.getSeconds()<10?"0"+newDate.getSeconds():newDate.getSeconds();
var t = year+"-"+month+"-"+day+" "+hours+":"+minuts+":"+seconds;
console.log(t);
this.$data.oper_type = 1;
this.$data.form = {
id:'',
series: '',
instrument_id:'',
auth_date:'',
expire_date: t,
area_code:'',
country:'',
longitude:'',
latitude:'',
auth_count:'',
auth_mark:'',
authorizer:localStorage.getItem("online_user"),
applicanter:'',
note:'',
change_series:false
};
console.log(this.$data.form);
this.$nextTick(() => {
this.$refs['authform'].clearValidate()
});
this.$data.dialogVisible = true;
},
updateAuth(authinfo){
this.$data.oper_type = 2;
this.$data.form = {
id:authinfo.id,
series: authinfo.series,
instrument_id:authinfo.instrument_id,
auth_date:authinfo.auth_date,
expire_date: authinfo.expire_date,
area_code: authinfo.area_code,
country:authinfo.country,
longitude:authinfo.longitude,
latitude:authinfo.latitude,
auth_count:authinfo.auth_count,
auth_mark:authinfo.auth_mark,
//authorizer:authinfo.authorizer,
authorizer:localStorage.getItem("online_user"),
applicanter:authinfo.applicanter,
note:authinfo.note,
change_series:true
};
this.$nextTick(() => {
this.$refs['authform'].clearValidate()
});
this.$data.dialogVisible = true;
},
getAuthinfo(_search_name){
document.getElementById("bt_search").blur();
/*if (_search_name == '') {
this.$refs.multipleTable.clearSelection();
}*/
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/getAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: _search_name,
iid:_this.$data.iid,
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);
});
},
handleSizeChange(val) {
this.$data.pagesize = val;
var _this = this;
var objs;
axios.post('/deescloud/getAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: this.$data.input,
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);
});
},
handleCurrentChange(val) {
this.$data.currentPage = val;
var _this = this;
var objs;
axios.post('/deescloud/getAuth', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: this.$data.input,
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);
});
},
flexColumnWidth(str, tableData, flag = 'max') {
// str为该列的字段名(传字符串);tableData为该表格的数据源(传变量);
// flag为可选值可不传该参数,传参时可选'max'或'equal',默认为'max'
// flag为'max'则设置列宽适配该列中最长的内容,flag为'equal'则设置列宽适配该列中第一行内容的长度。
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 < 80) {
// 设置最小宽度
max_flex_width = 80
}
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'
},
}
}