+
@@ -2012,6 +2022,109 @@ Vue.component("ns-route-ranges-box", {
`
})
+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: `
`,
+})
+
// 选择单一线路
Vue.component("ns-route-selector", {
props: ["v-route-code"],
diff --git a/web/public/js/components/ns/ns-create-records-table.js b/web/public/js/components/ns/ns-create-records-table.js
new file mode 100644
index 00000000..53535d69
--- /dev/null
+++ b/web/public/js/components/ns/ns-create-records-table.js
@@ -0,0 +1,102 @@
+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: `
`,
+})
\ No newline at end of file
diff --git a/web/public/js/components/ns/ns-routes-selector.js b/web/public/js/components/ns/ns-routes-selector.js
index 9a208eef..7285fdf0 100644
--- a/web/public/js/components/ns/ns-routes-selector.js
+++ b/web/public/js/components/ns/ns-routes-selector.js
@@ -1,6 +1,6 @@
// 选择多个线路
Vue.component("ns-routes-selector", {
- props: ["v-routes"],
+ props: ["v-routes", "name"],
mounted: function () {
let that = this
Tea.action("/ns/routes/options")
@@ -15,12 +15,18 @@ Vue.component("ns-routes-selector", {
selectedRoutes = []
}
+ let inputName = this.name
+ if (typeof inputName != "string" || inputName.length == 0) {
+ inputName = "routeCodes"
+ }
+
return {
routeCode: "default",
+ inputName: inputName,
routes: [],
isAdding: false,
routeType: "default",
- selectedRoutes: selectedRoutes
+ selectedRoutes: selectedRoutes,
}
},
watch: {
@@ -39,9 +45,11 @@ Vue.component("ns-routes-selector", {
this.isAdding = true
this.routeType = "default"
this.routeCode = "default"
+ this.$emit("add")
},
cancel: function () {
this.isAdding = false
+ this.$emit("cancel")
},
confirm: function () {
if (this.routeCode.length == 0) {
@@ -54,17 +62,19 @@ Vue.component("ns-routes-selector", {
that.selectedRoutes.push(v)
}
})
+ this.$emit("change", this.selectedRoutes)
this.cancel()
},
remove: function (index) {
this.selectedRoutes.$remove(index)
+ this.$emit("change", this.selectedRoutes)
}
}
,
template: `