Commit 3aea43de authored by 姬鋆屾's avatar 姬鋆屾

tui

parent 11b25d03
#开发环境
NODE_ENV = "development"
VUE_APP_API_BASE_URL= http://112.19.80.237:11039
VUE_APP_API_ZWFW_URL= http://112.19.80.237:11031
# VUE_APP_API_BASE_URL= http://192.168.0.98:11039
\ No newline at end of file
# VUE_APP_API_BASE_URL= http://112.19.80.237:11039
VUE_APP_API_BASE_URL= http://192.168.0.98:11039
VUE_APP_API_ZWFW_URL= http://112.19.80.237:11031
\ No newline at end of file
// table-list 所需的一系列操作方法
/**
* formatter
*
......@@ -10,8 +9,8 @@
*/
const formatter = (tableData, column, val) => {
const key = column.property;
if(tableData.dict && tableData.dict[key]){
const dict = tableData.dict[key]
if (tableData.dict && tableData.dict[key]) {
const dict = tableData.dict[key];
return dict[val] || val;
}
return val;
......@@ -27,11 +26,11 @@ const formatter = (tableData, column, val) => {
const formatterAmount = (row, column) => {
const property = column.property;
const amount = row[property];
if(!amount){
return '0.00';
if (!amount) {
return "0.00";
}
if(amount == 0){
return '0.00';
if (amount == 0) {
return "0.00";
}
return amount;
};
......@@ -46,15 +45,19 @@ const formatterAmount = (row, column) => {
const formatterDate = (row, column) => {
const property = column.property;
const time = row[property];
if(!time) return '--';
let date = time.length<13?new Date(Number(time) * 1000) : new Date(Number(time));
let Y = date.getFullYear() + '-';
let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
let D = panLeft(date.getDate()) + ' ';
let h = panLeft(date.getHours()) + ':';
let m = panLeft(date.getMinutes()) + ':';
if (!time) return "--";
let date =
time.length < 13 ? new Date(Number(time) * 1000) : new Date(Number(time));
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = panLeft(date.getDate()) + " ";
let h = panLeft(date.getHours()) + ":";
let m = panLeft(date.getMinutes()) + ":";
let s = panLeft(date.getSeconds());
return Y+M+D+h+m+s;
return Y + M + D + h + m + s;
};
/**
......@@ -67,16 +70,19 @@ const formatterDate = (row, column) => {
const formatterDateOnly = (row, column) => {
const property = column.property;
const time = row[property];
if(!time) return '-';
if (!time) return "-";
let date = new Date(Number(time));
let Y = date.getFullYear() + '-';
let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
let D = panLeft(date.getDate()) + ' ';
return Y+M+D;
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = panLeft(date.getDate()) + " ";
return Y + M + D;
};
function panLeft(num){
return num < 10 ? '0'+num : num;
function panLeft(num) {
return num < 10 ? "0" + num : num;
}
/**
......@@ -90,18 +96,18 @@ function panLeft(num){
const find = (list, key, val) => {
let index = -1;
let data = null;
list.forEach((item, i)=>{
if(item[key] === val){
list.forEach((item, i) => {
if (item[key] === val) {
index = i;
data = JSON.parse(JSON.stringify(item));
return;
}
})
});
return {
index,
data,
}
}
};
};
/**
* 构造树型结构数据
......@@ -112,24 +118,34 @@ const find = (list, key, val) => {
* @param {*} rootId 根Id 默认 0
*/
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id'
parentId = parentId || 'parentId'
children = children || 'children'
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
id = id || "id";
parentId = parentId || "parentId";
children = children || "children";
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
})
) ||
null;
//对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
const cloneData = JSON.parse(JSON.stringify(data));
//循环所有项
const treeData = cloneData.filter(father => {
let branchArr = cloneData.filter(child => {
const treeData = cloneData.filter((father) => {
let branchArr = cloneData.filter((child) => {
//返回每一项的子级数组
return father[id] === child[parentId]
console.log(child[parentId]);
return father[id] === child[parentId];
});
branchArr.length > 0 ? father.children = branchArr : '';
branchArr.length > 0 ? (father.children = branchArr) : "";
//返回第一层
return father[parentId] === rootId;
});
return treeData != '' ? treeData : data;
};
console.log(treeData);
return treeData != "" ? treeData : data;
}
export {
formatter,
......@@ -137,5 +153,5 @@ export {
formatterDate,
formatterDateOnly,
find,
handleTree
handleTree,
};
......@@ -17,8 +17,8 @@ module.exports = {
hot: true,//自动保存
proxy: {
'/attendance': {
//target: 'http://192.168.0.98:11039',
target: 'http://112.19.80.237:11039',
target: 'http://192.168.0.98:11039',
// target: 'http://112.19.80.237:11039',
// target: 'http://localhost:17500',
changeOrigin: true,
secure: false,
......
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