// 选择多个线路 Vue.component("ns-routes-selector", { props: ["v-route-ids"], mounted: function () { let that = this let routeIds = this.vRouteIds if (routeIds == null) { routeIds = [] } Tea.action("/ns/routes/options") .post() .success(function (resp) { that.allRoutes = resp.data.routes that.allRoutes.forEach(function (v) { v.isChecked = (routeIds.$contains(v.id)) }) }) }, data: function () { return { routeId: 0, allRoutes: [], routes: [], isAdding: false } } , methods: { add: function () { this.isAdding = true this.routes = this.allRoutes.$findAll(function (k, v) { return !v.isChecked }) this.routeId = 0 }, cancel: function () { this.isAdding = false }, confirm: function () { if (this.routeId == 0) { return } let that = this this.routes.forEach(function (v) { if (v.id == that.routeId) { v.isChecked = true } }) this.cancel() }, remove: function (index) { this.allRoutes[index].isChecked = false Vue.set(this.allRoutes, index, this.allRoutes[index]) } } , template: `
{{route.name}}  
 
` })