优化代码

This commit is contained in:
GoEdgeLab
2022-08-03 12:20:24 +08:00
parent cbaec61372
commit 16b33a4a5d
7 changed files with 99 additions and 110 deletions

View File

@@ -1,28 +1,14 @@
Vue.component("ns-user-selector", {
mounted: function () {
let that = this
Tea.action("/ns/users/options")
.post()
.success(function (resp) {
that.users = resp.data.users
})
},
props: ["v-user-id"],
data: function () {
let userId = this.vUserId
if (userId == null) {
userId = 0
}
return {
users: [],
userId: userId
return {}
},
methods: {
change: function (userId) {
this.$emit("change", userId)
}
},
template: `<div>
<select class="ui dropdown auto-width" name="userId" v-model="userId">
<option value="0">[选择用户]</option>
<option v-for="user in users" :value="user.id">{{user.fullname}} ({{user.username}})</option>
</select>
<user-selector :v-user-id="vUserId" data-url="/ns/users/options" @change="change"></user-selector>
</div>`
})