| | |
| | | <div class="s-right-config"> |
| | | <el-form> |
| | | <el-form-item label="名称"> |
| | | <el-input v-model="eventData.name" placeholder="请输入名称" size="small" style="width:400px"></el-input> |
| | | <el-input |
| | | v-model="taskEditData.name" |
| | | placeholder="请输入名称" |
| | | size="small" |
| | | style="width:400px" |
| | | ></el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="时间"> |
| | | <el-date-picker |
| | | v-model="eventData.time" |
| | | v-model="taskEditData.time" |
| | | format="yyyy-MM-dd HH:mm:ss" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | type="datetimerange" |
| | |
| | | </div> |
| | | |
| | | <el-form-item label="联动方式" style="margin-top: 20px;width:100"> |
| | | <el-select v-model="eventData.lineWay" placeholder="请选择" size="small"> |
| | | <el-select v-model="taskEditData.lineWay" placeholder="请选择" size="small"> |
| | | <el-option |
| | | v-for="item in eventData.lineOptions" |
| | | v-for="item in taskEditData.lineOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="标签"> |
| | | <el-radio v-model="eventData.radioValue" label="1">满足全部</el-radio> |
| | | <el-radio v-model="eventData.radioValue" label="2">满足任意一个</el-radio> |
| | | <el-radio v-model="taskEditData.radioValue" label="1">满足全部</el-radio> |
| | | <el-radio v-model="taskEditData.radioValue" label="2">满足任意一个</el-radio> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | |
| | | |
| | | <div class="rule-title2"> |
| | | <b>规则</b> |
| | | <div class="div-border" v-html="eventData.eventTxt"></div> |
| | | <div class="div-border" v-html="taskEditData.eventTxt"></div> |
| | | </div> |
| | | <div class="save-btn"> |
| | | <el-button type="info" size="small" @click="onCancle" style="color:#222">取消</el-button> |
| | |
| | | }, |
| | | computed: { |
| | | urls() { |
| | | return this.eventData.urls |
| | | }, |
| | | ips() { |
| | | return this.eventData.urls.filter(item => { |
| | | return item.type === 'ip'; |
| | | }) |
| | | }, |
| | | domains() { |
| | | return this.eventData.urls.filter(item => { |
| | | return item.type === 'domain'; |
| | | }) |
| | | } |
| | | }, |
| | | watch: { |
| | | eventObject: { |
| | | handler(newVal, oldVal) { |
| | | this.eventData.enable = this.eventObject.enable; |
| | | if (newVal !== oldVal) { |
| | | if (this.eventData.id !== newVal.id) { |
| | | this.dataList = []; |
| | | |
| | | this.eventData.id = newVal.id; |
| | | this.eventData.name = newVal.name; |
| | | this.eventData.time = [ |
| | | this.eventObject.time_start, |
| | | this.eventObject.time_end |
| | | ]; |
| | | this.eventData.serverIp = newVal.ip_ports; |
| | | this.eventData.urls = newVal.urls; |
| | | this.eventData.lineWay = newVal.link_type; |
| | | this.eventData.eventTxt = newVal.rule_text; |
| | | this.eventData.radioValue = newVal.is_satisfy_all ? "1" : "2"; |
| | | |
| | | if (!this.eventData.urls) { |
| | | this.$set(this.eventData, "urls", []) |
| | | } |
| | | if (newVal.rules) { |
| | | newVal.rules.forEach(element => { |
| | | let newRule = Object.assign(JSON.parse(JSON.stringify(this.baseRule)), element) |
| | | this.dataList.push(newRule) |
| | | this.selectTopic(newRule); |
| | | this.selectOperator(newRule); |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | deep: true |
| | | return this.taskEditData.urls |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | eventData: {}, |
| | | taskEditData: {}, |
| | | dataList: [], |
| | | dictionary: [], |
| | | cameras: [], |
| | |
| | | }, |
| | | }; |
| | | }, |
| | | watch: { |
| | | eventObject: { |
| | | handler(newVal, oldVal) { |
| | | this.taskEditData.enable = this.eventObject.enable; |
| | | if (newVal !== oldVal) { |
| | | if (this.taskEditData.id !== newVal.id) { |
| | | this.dataList = []; |
| | | |
| | | this.taskEditData.id = newVal.id; |
| | | this.taskEditData.name = newVal.name; |
| | | this.taskEditData.time = [ |
| | | this.eventObject.time_start, |
| | | this.eventObject.time_end |
| | | ]; |
| | | this.taskEditData.serverIp = newVal.ip_ports; |
| | | this.taskEditData.urls = newVal.urls; |
| | | this.taskEditData.lineWay = newVal.link_type; |
| | | this.taskEditData.eventTxt = newVal.rule_text; |
| | | this.taskEditData.radioValue = newVal.is_satisfy_all ? "1" : "2"; |
| | | |
| | | if (!this.taskEditData.urls) { |
| | | this.$set(this.taskEditData, "urls", []) |
| | | } |
| | | if (newVal.rules) { |
| | | newVal.rules.forEach(element => { |
| | | let newRule = Object.assign(JSON.parse(JSON.stringify(this.baseRule)), element) |
| | | this.dataList.push(newRule) |
| | | this.selectTopic(newRule); |
| | | this.selectOperator(newRule); |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | created() { |
| | | this.reAdd(); |
| | | }, |
| | |
| | | }, |
| | | methods: { |
| | | addUrl() { |
| | | this.eventData.urls.push({ |
| | | this.taskEditData.urls.push({ |
| | | checked: true, |
| | | hash: Math.random().toString(36).substr(2), |
| | | url: "", |
| | | }); |
| | | }, |
| | | delUrl(index) { |
| | | this.$set(this.eventData.urls, index, this.baseRule) |
| | | this.eventData.urls.splice(index, 1) |
| | | this.$set(this.taskEditData.urls, index, this.baseRule) |
| | | this.taskEditData.urls.splice(index, 1) |
| | | }, |
| | | // 保存 |
| | | async eventPushsSave() { |
| | | // 判断保存的ip是否符合格式要求 |
| | | if (this.eventData.urls.length < 1) { |
| | | if (this.taskEditData.urls.length < 1) { |
| | | this.$notify({ |
| | | type: "warning", |
| | | message: "请配置至少一台推送服务器" |
| | | }); |
| | | return; |
| | | } |
| | | for (let i = 0; i < this.eventData.urls.length; i++) { |
| | | if (this.eventData.urls[i].url.length < 1) { |
| | | for (let i = 0; i < this.taskEditData.urls.length; i++) { |
| | | if (this.taskEditData.urls[i].url.length < 1) { |
| | | this.$notify({ |
| | | type: "warning", |
| | | message: "接口URL地址不允许为空" |
| | |
| | | }); |
| | | |
| | | let json = { |
| | | enable: this.eventData.enable, |
| | | id: this.eventData.id, |
| | | ip_ports: this.eventData.serverIp, |
| | | name: this.eventData.name, |
| | | enable: this.taskEditData.enable, |
| | | id: this.taskEditData.id, |
| | | ip_ports: this.taskEditData.serverIp, |
| | | name: this.taskEditData.name, |
| | | rule_text: ruleDesc.join("<br/>"), |
| | | rules: ruleList, |
| | | time_start: this.eventData.time[0], |
| | | time_end: this.eventData.time[1], |
| | | urls: this.eventData.urls, |
| | | is_satisfy_all: this.eventData.radioValue === "1", |
| | | link_type: this.eventData.lineWay |
| | | time_start: this.taskEditData.time[0], |
| | | time_end: this.taskEditData.time[1], |
| | | urls: this.taskEditData.urls, |
| | | is_satisfy_all: this.taskEditData.radioValue === "1", |
| | | link_type: this.taskEditData.lineWay |
| | | }; |
| | | |
| | | let res = await eventPushsSave(json); |
| | | if (res && res.success) { |
| | | this.eventData.eventTxt = ruleDesc.join("<br/>"); |
| | | this.taskEditData.eventTxt = ruleDesc.join("<br/>"); |
| | | this.$emit("updateList", res.data.id); |
| | | this.$notify({ |
| | | type: "success", |
| | |
| | | this.dictionary = Object.assign(this.dictionary, res.data) |
| | | this.baseRule.topicTypeOptions = this.dictionary.EVENTRULETOPIC |
| | | this.baseRule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE |
| | | this.dictionary['alarmLevel'] = this.dictionary.ALARMLEVEL |
| | | this.dictionary['alarmLevel'] = this.dictionary.ALARMLEVEL.map(el => { |
| | | return { |
| | | name: el.name, |
| | | value: el.name |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | async getCameras() { |
| | |
| | | }, |
| | | // 清空重新新增 |
| | | reAdd() { |
| | | this.eventData = { |
| | | this.taskEditData = { |
| | | id: "", |
| | | name: "", |
| | | time: [ |