refactor(xumu): 重构耳标选择器组件
- 新增计算属性 api,用于生成请求 URL - 将 watch 目标从 action 改为 api - 优化 getEartag 方法,使用计算属性 api 替代手动构建 URL
This commit is contained in:
@@ -18,8 +18,17 @@ export default {
|
|||||||
selected: []
|
selected: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
api: v => {
|
||||||
|
let url = v.action
|
||||||
|
if (v.penId) {
|
||||||
|
url += `?penId=${v.penId}`
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
action: {
|
api: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler() {
|
handler() {
|
||||||
this.getEartag()
|
this.getEartag()
|
||||||
@@ -28,11 +37,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEartag() {
|
getEartag() {
|
||||||
let url = this.action
|
!/undefined/.test(this.api) && this.instance.post(this.api).then(res => {
|
||||||
if (this.penId) {
|
|
||||||
url += `?penId=${this.penId}`
|
|
||||||
}
|
|
||||||
!/undefined/.test(url) && this.instance.post(url).then(res => {
|
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
this.list = res.data
|
this.list = res.data
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user