model.js
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2024-01-03 12:23:36
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2024-01-16 15:03:58
* @FilePath: \scrm-micro-peregrination\src\mixins\model.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { mapActions, mapState } from 'vuex'
export default {
data() {
return {
...mapActions('model', ['setModelList'])
}
},
computed: {
...mapState('model', ['modelList'])
},
mounted() {
if (!this.modelList) {
this.setModelList()
}
},
methods: {
...mapActions('model', ['setModelList']),
spiltString(data, n) {
let title = ''
try {
title += JSON.parse(data.paramRemark).title
} catch (error) {
console.log(error)
}
if (!data.flag) {
return data.name
}
const val = data.conditions.find(i => i.id == data.flag)
try {
title += JSON.parse(val.paramRemark).title
let day = ''
if (val.operators && val.operators.length) {
val.operators.forEach(item => {
if (item.value) {
day = [item.name, item.value]
}
})
}
if (/\[.*\]/.test(title) && day.length == 2) {
title = title.replace(/\[.*?\]/, day[0]).replace(/\[.*?\]/, day[1])
}
} catch (error) {
console.log(error)
}
val &&
val.subConditions &&
val.subConditions.length &&
val.subConditions.forEach(i => {
i.operators.forEach(o => {
if (o.value) {
title += `并且满足${i.name}${o.name}${o.value}${o.unit?o.unit:''},`
}
})
})
return title.replace(/,+$/, '')
}
}
}