Commit b61f1b8c authored by 郭铭瑶's avatar 郭铭瑶 🤘

删改代码,添加注释

parent 35728540
...@@ -6,14 +6,13 @@ import App from './App' ...@@ -6,14 +6,13 @@ import App from './App'
import router from './router' import router from './router'
import common from './util/common' import common from './util/common'
import api from './util/api' import api from './util/api'
import {Icon, Button, Collapse, Panel, Modal, Table, Drawer} from 'view-design' import {Button, Collapse, Panel, Modal, Table, Drawer} from 'view-design'
import 'view-design/dist/styles/iview.css' import 'view-design/dist/styles/iview.css'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$com = common Vue.prototype.$com = common
Vue.prototype.$api = api Vue.prototype.$api = api
Vue.component('Button', Button) Vue.component('Button', Button)
Vue.component('Icon', Icon)
Vue.component('Collapse', Collapse) Vue.component('Collapse', Collapse)
Vue.component('Panel', Panel) Vue.component('Panel', Panel)
Vue.component('Modal', Modal) Vue.component('Modal', Modal)
......
...@@ -11,6 +11,34 @@ export default{ ...@@ -11,6 +11,34 @@ export default{
return [] return []
} }
}, },
switchImg(ratio) {
if (!ratio) ratio = 0
if (ratio < 1) {
ratio = ratio * 100
}
if (ratio <= 10) return 1
if (ratio <= 20) return 2
if (ratio <= 30) return 3
if (ratio <= 40) return 4
if (ratio <= 50) return 5
if (ratio <= 60) return 6
if (ratio <= 70) return 7
if (ratio <= 80) return 8
if (ratio <= 90) return 9
if (ratio <= 100) return 10
},
switchColor(color) {
if (!color) return null
if (color.indexOf('绿') >= 0) return {'background-color': '#8fd618'}
if (color.indexOf('黄') >= 0) return {'background-color': 'gold'}
if (color.indexOf('红') >= 0) return {'background-color': 'red'}
},
switchStarNum(intention) {
if (!intention) return 0
if (intention.indexOf('一') >= 0) return 1
if (intention.indexOf('二') >= 0 || intention.indexOf('两') >= 0) return 2
if (intention.indexOf('三') >= 0) return 3
},
switchStatus(status) { switchStatus(status) {
status = Number(status) status = Number(status)
switch (status) { switch (status) {
...@@ -26,35 +54,4 @@ export default{ ...@@ -26,35 +54,4 @@ export default{
return '暂无状态' return '暂无状态'
} }
}, },
similar(str1, str2) {
if (!str1 || !str2 || typeof(str1) != 'string' || typeof(str2) != 'string') {
console.error('参数需要是string类型!')
return 0
}
const len1 = str1.length
const len2 = str2.length
const arr = []
for (let i = 0; i <= len1; i++) {
arr[i] = []
arr[i][0] = i
}
for (let i = 0; i <= len2; i++) {
arr[0][i] = i
}
let temp
for (let i = 1; i <= len1; i++) {
for (let j = 1; j <= len2; j++) {
if (str1.charAt(i - 1) == str2.charAt(j - 1)) {
temp = 0
} else {
temp = 1
}
arr[i][j] = Math.min(arr[i - 1][j - 1] + temp, arr[i][j - 1] + 1, arr[i - 1][j] + 1)
}
}
return (1 - arr[len1][len2] / Math.max(len1, len2)).toFixed(3)
}
} }
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