From d8d636fdbdf79d17c459a00e9381be0bf6b17a86 Mon Sep 17 00:00:00 2001 From: fungleo Date: Tue, 4 Aug 2020 11:39:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=EF=BC=88=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=95=B0=E7=BB=84=EF=BC=89JS=20=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/ruoyi.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 23879aaf8..08fbd9db1 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -78,18 +78,17 @@ export function selectDictLabel(datas, value) { } // 回显数据字典(字符串数组) -export function selectDictLabels(datas, value, separator) { - var actions = []; - var currentSeparator = undefined === separator ? "," : separator; - var temp = value.split(currentSeparator); - Object.keys(value.split(currentSeparator)).some((val) => { - Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + temp[val])) { - actions.push(datas[key].dictLabel + currentSeparator); - } - }) - }) - return actions.join('').substring(0, actions.join('').length - 1); +export function selectDictLabels (datas = {}, value = '', separator = ',') { + const actions = [] + const temp = value.split(separator) + temp.forEach((_, index) => { + Object.keys(datas).forEach(key => { + if (datas[key].dictValue === temp[index].toString()) { + actions.push(datas[key].dictLabel) + } + }) + }) + return actions.join(separator) } // 通用下载方法 From 876ecf21c713ce333e676f9b81c57de4ecc983d3 Mon Sep 17 00:00:00 2001 From: fungleo Date: Tue, 4 Aug 2020 14:11:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=A0=91=E5=BD=A2=E6=95=B0=E6=8D=AEJS=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/ruoyi.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 08fbd9db1..75613539d 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -126,23 +126,19 @@ export function praseStrEmpty(str) { * @param {*} children 孩子节点字段 默认 'children' * @param {*} rootId 根Id 默认 0 */ -export function handleTree(data, id, parentId, children, rootId) { - id = id || 'id' - parentId = parentId || 'parentId' - children = children || 'children' - rootId = rootId || 0 +export function handleTree(data = [], id = 'id', parentId = 'parentId', children = 'children', rootId = 0) { //对源数据深度克隆 const cloneData = JSON.parse(JSON.stringify(data)) //循环所有项 const treeData = cloneData.filter(father => { - let branchArr = cloneData.filter(child => { + const branchArr = cloneData.filter(child => { //返回每一项的子级数组 return father[id] === child[parentId] }); - branchArr.length > 0 ? father.children = branchArr : ''; + branchArr.length && (father.children = branchArr); //返回第一层 return father[parentId] === rootId; }); - return treeData != '' ? treeData : data; + return treeData !== '' ? treeData : data; } From 503dd64e3fa83f3615e833a9c679e4519053ff1b Mon Sep 17 00:00:00 2001 From: fungleo Date: Tue, 4 Aug 2020 14:32:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=20addDateRange=20js=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/ruoyi.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 75613539d..00dcb47b4 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -54,15 +54,12 @@ export function resetForm(refName) { } // 添加日期范围 -export function addDateRange(params, dateRange) { - var search = params; - search.beginTime = ""; - search.endTime = ""; - if (null != dateRange && '' != dateRange) { - search.beginTime = this.dateRange[0]; - search.endTime = this.dateRange[1]; - } - return search; +export function addDateRange (params = {}, dateRange) { + if (dateRange != null && dateRange !== '') { + params.beginTime = this.dateRange[0] + params.endTime = this.dateRange[1] + } + return params } // 回显数据字典 From 26dfee2ce8ac0112d698bffdb66c0e3ca5bf61d1 Mon Sep 17 00:00:00 2001 From: fungleo Date: Wed, 5 Aug 2020 10:24:54 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=BD=BB=E5=BA=95=E9=87=8D=E5=86=99?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- ruoyi-ui/src/utils/ruoyi.js | 27 +++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 4916f7a26..a58be0137 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,8 @@ nbdist/ # Others *.log *.xml.versionsBackup +*.swp !*/build/*.java !*/build/*.html -!*/build/*.xml \ No newline at end of file +!*/build/*.xml diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 00dcb47b4..b669fb319 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -63,29 +63,20 @@ export function addDateRange (params = {}, dateRange) { } // 回显数据字典 -export function selectDictLabel(datas, value) { - var actions = []; - Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + value)) { - actions.push(datas[key].dictLabel); - return true; - } - }) - return actions.join(''); +export function selectDictLabel(datas = [], value = '') { + if (!value) return '-'; + const dataArr = datas.filter(item => item.dictValue === value.toString()); + return dataArr.length ? dataArr[0].dictLabel : 'Error Dict'; } // 回显数据字典(字符串数组) -export function selectDictLabels (datas = {}, value = '', separator = ',') { - const actions = [] - const temp = value.split(separator) +export function selectDictLabels(datas = [], value = '', separator = ',') { + const actions = []; + const temp = value.split(separator).filter(item => item); temp.forEach((_, index) => { - Object.keys(datas).forEach(key => { - if (datas[key].dictValue === temp[index].toString()) { - actions.push(datas[key].dictLabel) - } - }) + actions.push(selectDictLabel(datas, temp[index])); }) - return actions.join(separator) + return actions.join(separator); } // 通用下载方法