Commit 9732195b authored by renjintao's avatar renjintao

转换title

parent 7ca70bdf
This diff is collapsed.
...@@ -207,7 +207,7 @@ henq.getNowTime = () => { ...@@ -207,7 +207,7 @@ henq.getNowTime = () => {
return year + month + date + hours + minutes + seconds; return year + month + date + hours + minutes + seconds;
} }
//读取本地excel //读取本地excel
henq.readXLSX=(file)=>{ henq.readXLSX = (file) => {
let nameSplit = file.name.split("."); let nameSplit = file.name.split(".");
let format = nameSplit[nameSplit.length - 1]; let format = nameSplit[nameSplit.length - 1];
if (!["xlsx", "csv"].includes(format)) { if (!["xlsx", "csv"].includes(format)) {
...@@ -218,31 +218,41 @@ henq.readXLSX=(file)=>{ ...@@ -218,31 +218,41 @@ henq.readXLSX=(file)=>{
reader.readAsBinaryString(file); reader.readAsBinaryString(file);
reader.onload = function (evt) { reader.onload = function (evt) {
let data = evt.target.result; // 读到的数据 let data = evt.target.result; // 读到的数据
var workbook = XLSX.read(data, { type: "binary" }); var workbook = XLSX.read(data, {
type: "binary"
});
resolve(workbook); resolve(workbook);
}; };
}); });
} }
//得到根据value得到对应数据字典的name //得到根据value得到对应数据字典的name
henq.dirName=(code,v)=>{ henq.dirName = (code, v) => {
var items="" var items = ""
code.forEach(ele => { let i = 0
if(ele.code==v) code.forEach(ele => {
{ if (ele.code == v) {
items=ele.name items = ele.name
} i++
}); }
return items });
if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].name
}
return items
} }
//得到根据name得到对应数据字典的code //得到根据name得到对应数据字典的code
henq.dirCode=(code,v)=>{ henq.dirCode = (code, v) => {
var items="" var items = ""
let i = 0
code.forEach(ele => { code.forEach(ele => {
if(ele.name==v) if (ele.name == v) {
{ items = ele.code
items=ele.code i++
} }
}); });
return items if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].code
}
return items
} }
export default henq; export default henq;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment