// 请求方法列表 Vue.component("http-status-box", { props: ["v-status-list"], data: function () { let statusList = this.vStatusList if (statusList == null) { statusList = [] } return { statusList: statusList, isAdding: false, addingStatus: "" } }, methods: { add: function () { this.isAdding = true let that = this setTimeout(function () { that.$refs.addingStatus.focus() }, 100) }, confirm: function () { let that = this // 删除其中的空格 this.addingStatus = this.addingStatus.replace(/\s/g, "").toUpperCase() if (this.addingStatus.length == 0) { teaweb.warn("请输入要添加的状态码", function () { that.$refs.addingStatus.focus() }) return } // 是否已经存在 if (this.statusList.$contains(this.addingStatus)) { teaweb.warn("此状态码已经存在,无需重复添加", function () { that.$refs.addingStatus.focus() }) return } // 格式 if (!this.addingStatus.match(/^\d{3}$/)) { teaweb.warn("请输入正确的状态码", function () { that.$refs.addingStatus.focus() }) return } this.statusList.push(parseInt(this.addingStatus, 10)) this.cancel() }, remove: function (index) { this.statusList.$remove(index) }, cancel: function () { this.isAdding = false this.addingStatus = "" } }, template: `
` })