Vue.component("ns-create-records-table", { props: ["v-types"], data: function () { let types = this.vTypes if (types == null) { types = [] } return { types: types, records: [ { name: "", type: "A", value: "", routeCodes: [], ttl: 600, index: 0 } ], lastIndex: 0, isAddingRoutes: false // 是否正在添加线路 } }, methods: { add: function () { this.records.push({ name: "", type: "A", value: "", routeCodes: [], ttl: 600, index: ++this.lastIndex }) let that = this setTimeout(function () { that.$refs.nameInputs.$last().focus() }, 100) }, remove: function (index) { this.records.$remove(index) }, addRoutes: function () { this.isAddingRoutes = true }, cancelRoutes: function () { let that = this setTimeout(function () { that.isAddingRoutes = false }, 1000) }, changeRoutes: function (record, routes) { if (routes == null) { record.routeCodes = [] } else { record.routeCodes = routes.map(function (route) { return route.code }) } } }, template: `
记录名 记录类型 线路 记录值 TTL 操作
`, })