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