/** * 处理流程图数据 * @param list 数据来源 * @param stepList 流程数据列表 */ export function dealStepData (list, stepList) { if (list) { stepList.push({ icon: 'el-icon-location', title: '开始' }) list.forEach((item) => { stepList.push({ // icon: item.approvalState === '0' ? 'el-icon-location' : 'el-icon-location-outline', icon: 'el-icon-location', title: item.stepName // description: formatStepDesc(item.processLogInfoList) }) }) stepList.push({ icon: 'el-icon-location', title: '结束' }) } } /** * 处理流程图日志数据 * @param list 数据来源 * @param stepLogList 流程日志数据 */ export function dealStepLogs (list, stepLogList) { if (!list) return list.forEach((item) => { stepLogList.push(item) }) } export function formatStepDesc (lst) { if (!lst) return '' let str = '' lst.forEach((item) => { str = str + '\n' + item.assigneeName + ' ' + item.createTime + ' ' + item.approvalState }) return str } /** * 获取文件后缀 */ export function getFileExt (fileName) { if (!fileName) return '' return fileName.split('.').pop().toLowerCase() } export function checkStr (currentStr, strList) { if (!currentStr || !strList) return false let list = strList.split(',') let index = list.findIndex(item => item === currentStr) // console.log('strList: ' + strList) // console.log('currentUser: ' + currentStr) // console.log('index: ' + index) return index > -1 } /** * 日期处理:字符串转日期 */ export function strToDate (str) { if (!str) return null return dateToString(Date.parse(str)) } export function dateToString (date) { let date1 = new Date(date) const year = date1.getFullYear() + '' let month = (date1.getMonth() + 1) + '' let day = (date1.getDate()) + '' if (month.length === 1) { month = '0' + month } if (day.length === 1) { day = '0' + day } return year + '-' + month + '-' + day } /** * 日期(带时间)转字符串 */ export function dateTimeToString (date) { let date1 = new Date(date) const year = date1.getFullYear() + '' let month = (date1.getMonth() + 1) + '' let day = (date1.getDate()) + '' let h = date1.getHours() + '' let m = date1.getMinutes() + '' let s = date1.getSeconds() + '' if (month.length === 1) { month = '0' + month } if (day.length === 1) { day = '0' + day } if (h.length === 1) { h = '0' + h } if (m.length === 1) { m = '0' + m } if (s.length === 1) { s = '0' + s } return year + '-' + month + '-' + day + ' ' + h + ':' + m + ':' + s }