| | |
| | | <div class="s-right-config">
|
| | | <el-form>
|
| | | <el-form-item label="名称">
|
| | | <el-input v-model="taskEditData.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="时间">
|
| | |
| | | <i class="el-icon-circle-plus-outline"></i>
|
| | | <span> 添加接口地址</span>
|
| | | </div>
|
| | | <div v-for="(item, index) in urls" :key="item.hash" class="flex-box server-url">
|
| | | <div
|
| | | v-for="(item, index) in urls"
|
| | | :key="item.hash"
|
| | | class="flex-box server-url"
|
| | | >
|
| | | <div>
|
| | | <el-checkbox v-model="item.enable"></el-checkbox>
|
| | | <span class="ml20">{{ "URL " }}</span>
|
| | |
| | | ></el-input>
|
| | | </div>
|
| | | <div class="server-add">
|
| | | <i class="el-icon-remove-outline" @click="delUrl(index)" style="color: red; margin-right: 10px" />
|
| | | <i
|
| | | class="el-icon-remove-outline"
|
| | | @click="delUrl(index)"
|
| | | style="color: red; margin-right: 10px"
|
| | | />
|
| | | <i class="el-icon-circle-plus-outline" @click="addUrl()"></i>
|
| | | </div>
|
| | | </div>
|
| | |
|
| | | <el-form-item label="联动方式" style="margin-top: 20px; width: 100">
|
| | | <el-select v-model="taskEditData.lineWay" placeholder="请选择" size="small">
|
| | | <el-select
|
| | | v-model="taskEditData.lineWay"
|
| | | placeholder="请选择"
|
| | | size="small"
|
| | | >
|
| | | <el-option label="请选择" value=""></el-option>
|
| | | <el-option
|
| | | v-for="item in taskEditData.lineOptions"
|
| | | :key="item.value"
|
| | |
| | | </el-form-item>
|
| | |
|
| | | <el-form-item label="标签">
|
| | | <el-radio v-model="taskEditData.radioValue" label="1">满足全部</el-radio>
|
| | | <el-radio v-model="taskEditData.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>
|
| | | </div>
|
| | |
|
| | | <div v-for="(rule, index) in dataList" :key="index" style="margin-top: 10px">
|
| | | <div
|
| | | v-for="(rule, index) in dataList"
|
| | | :key="index"
|
| | | style="margin-top: 10px"
|
| | | >
|
| | | <el-row :gutter="20">
|
| | | <!-- 主题 -->
|
| | | <el-col :span="4">
|
| | | <el-select v-model="rule.topic_type" placeholder="请选择" @change="selectTopic(rule, true)" size="small">
|
| | | <el-select
|
| | | v-model="rule.topic_type"
|
| | | placeholder="请选择"
|
| | | @change="selectTopic(rule, true)"
|
| | | size="small"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in rule.topicTypeOptions"
|
| | | :key="item.id"
|
| | |
| | |
|
| | | <!-- 过滤值 -->
|
| | | <el-col :span="4">
|
| | | <el-select v-model="rule.topic_arg" placeholder="请选择" @change="selectArg(rule, true)" size="small">
|
| | | <el-select
|
| | | v-model="rule.topic_arg"
|
| | | placeholder="请选择"
|
| | | @change="selectArg(rule, true)"
|
| | | size="small"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in rule.topicArgOptions"
|
| | | :key="item.id"
|
| | |
| | |
|
| | | <!-- 操作符 -->
|
| | | <el-col :span="4">
|
| | | <el-select v-model="rule.operator" placeholder="请选择" size="small">
|
| | | <el-select
|
| | | v-model="rule.operator"
|
| | | placeholder="请选择"
|
| | | size="small"
|
| | | >
|
| | | <el-option label="==" value="="></el-option>
|
| | | </el-select>
|
| | | </el-col>
|
| | |
| | | <!-- 过滤值 -->
|
| | | <el-col :span="4">
|
| | | <div v-if="rule.operator_type === 'custom'">
|
| | | <el-input v-model="rule.rule_value" placeholder="请输入内容" size="small"></el-input>
|
| | | <el-input
|
| | | v-model="rule.rule_value"
|
| | | placeholder="请输入内容"
|
| | | size="small"
|
| | | ></el-input>
|
| | | </div>
|
| | | <div v-else>
|
| | | <el-select
|
| | |
| | | </div>
|
| | | <div class="config-item">
|
| | | <b>推送字段</b>
|
| | | <el-button type="primary" size="mini" @click="openPushSetDialog">设置</el-button>
|
| | | <el-button type="primary" size="mini" @click="openPushSetDialog"
|
| | | >设置</el-button
|
| | | >
|
| | | </div>
|
| | | <div class="save-btn">
|
| | | <el-button type="info" size="small" @click="onCancle" style="color: #222">取消</el-button>
|
| | | <el-button type="primary" @click="eventPushsSave" size="small">保存</el-button>
|
| | | <el-button
|
| | | type="info"
|
| | | size="small"
|
| | | @click="onCancle"
|
| | | style="color: #222"
|
| | | >取消</el-button
|
| | | >
|
| | | <el-button type="primary" @click="eventPushsSave" size="small"
|
| | | >保存</el-button
|
| | | >
|
| | | </div>
|
| | | </div>
|
| | | <el-dialog
|
| | |
| | | <div slot="title" class="slot-title">
|
| | | <p>请选择想要推送的字段</p>
|
| | | <div class="right">
|
| | | <el-checkbox v-model="allFieldChecked" @change="allCheckChange"></el-checkbox>
|
| | | <el-checkbox
|
| | | v-model="allFieldChecked"
|
| | | @change="allCheckChange"
|
| | | ></el-checkbox>
|
| | | </div>
|
| | | </div>
|
| | | <div class="check-area" v-for="configObj in tempPushSet" :key="configObj.id">
|
| | | <div
|
| | | class="check-area"
|
| | | v-for="configObj in tempPushSet"
|
| | | :key="configObj.id"
|
| | | >
|
| | | <div class="header">
|
| | | <div class="title">{{ configObj.name }}</div>
|
| | | <div class="right">
|
| | | <el-checkbox v-model="configObj.checked" @change="toggleConfigCheck(configObj)">全选</el-checkbox>
|
| | | <el-checkbox
|
| | | v-model="configObj.checked"
|
| | | @change="toggleConfigCheck(configObj)"
|
| | | >全选</el-checkbox
|
| | | >
|
| | | </div>
|
| | | </div>
|
| | | <div class="flex-box flex-wrap">
|
| | | <div class="param flex-box" v-for="param in configObj.children" :key="param.id">
|
| | | <el-checkbox v-model="param.checked" @change="checkChildren"></el-checkbox>
|
| | | <div
|
| | | class="param flex-box"
|
| | | v-for="param in configObj.children"
|
| | | :key="param.id"
|
| | | >
|
| | | <el-checkbox
|
| | | v-model="param.checked"
|
| | | @change="checkChildren"
|
| | | ></el-checkbox>
|
| | | <span class="param-name">{{ param.name }}</span>
|
| | | <el-input
|
| | | v-model="param.alias"
|
| | |
| | | @input="varifyField(param)"
|
| | | :style="{
|
| | | color: param.error ? 'red' : '',
|
| | | borderColor: param.error ? 'red' : ''
|
| | | borderColor: param.error ? 'red' : '',
|
| | | }"
|
| | | ></el-input>
|
| | | </div>
|
| | |
| | | </div>
|
| | | <div slot="footer" class="text-center">
|
| | | <el-button size="small" @click="canclePushFieldSet">取消</el-button>
|
| | | <el-button size="small" type="primary" :disabled="disabledPushFieldSet" @click="submitPushFieldSet"
|
| | | <el-button
|
| | | size="small"
|
| | | type="primary"
|
| | | :disabled="disabledPushFieldSet"
|
| | | @click="submitPushFieldSet"
|
| | | >保存</el-button
|
| | | >
|
| | | </div>
|
| | |
| | | </div>
|
| | | </template>
|
| | | <script>
|
| | | import { eventPushsSave, findByEventTopic, getPushSet } from "@/api/event"
|
| | | import { findDictionaryByType, findDictionaryByID } from "@/api/dictionary"
|
| | | import { getTaskList } from "@/api/search"
|
| | | import { eventPushsSave, findByEventTopic, getPushSet } from "@/api/event";
|
| | | import { findDictionaryByType, findDictionaryByID } from "@/api/dictionary";
|
| | | import { getTaskList } from "@/api/search";
|
| | |
|
| | | export default {
|
| | | name: "rightEvent",
|
| | |
| | | eventObject: {
|
| | | type: Object,
|
| | | default: () => {
|
| | | return {}
|
| | | }
|
| | | }
|
| | | return {};
|
| | | },
|
| | | },
|
| | | },
|
| | | computed: {
|
| | | urls() {
|
| | | return this.taskEditData.urls
|
| | | }
|
| | | return this.taskEditData.urls;
|
| | | },
|
| | | },
|
| | | data() {
|
| | | return {
|
| | |
| | | topicArgOptions: {},
|
| | | operatorOptions: {},
|
| | | operatorTypeOpionts: {},
|
| | | ruleValueOptions: []
|
| | | ruleValueOptions: [],
|
| | | },
|
| | | pushFieldDialog: false,
|
| | | tempPushSet: [],
|
| | | pushFields: [],
|
| | | allFieldChecked: false,
|
| | | disabledPushFieldSet: true
|
| | | }
|
| | | disabledPushFieldSet: true,
|
| | | };
|
| | | },
|
| | | watch: {
|
| | | eventObject: {
|
| | | handler(newVal, oldVal) {
|
| | | this.taskEditData.enable = this.eventObject.enable
|
| | | this.taskEditData.enable = this.eventObject.enable;
|
| | | if (newVal !== oldVal) {
|
| | | if (this.taskEditData.id !== newVal.id) {
|
| | | this.dataList = []
|
| | | 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"
|
| | | 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", [])
|
| | | this.$set(this.taskEditData, "urls", []);
|
| | | }
|
| | | //this.taskEditData.push_set = this.eventObject.push_set;
|
| | | if (!this.eventObject.push_set.length) {
|
| | | this.$set(this.taskEditData, "push_set", this.pushFields)
|
| | | this.$set(this.taskEditData, "push_set", this.pushFields);
|
| | | } else {
|
| | | this.$set(this.taskEditData, "push_set", this.eventObject.push_set)
|
| | | this.$set(
|
| | | this.taskEditData,
|
| | | "push_set",
|
| | | this.eventObject.push_set
|
| | | );
|
| | | }
|
| | | 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)
|
| | | })
|
| | | let newRule = Object.assign(
|
| | | JSON.parse(JSON.stringify(this.baseRule)),
|
| | | element
|
| | | );
|
| | | this.dataList.push(newRule);
|
| | | this.selectTopic(newRule);
|
| | | this.selectOperator(newRule);
|
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | | },
|
| | | deep: true
|
| | | deep: true,
|
| | | },
|
| | | tempPushSet: {
|
| | | handler(n, o) {
|
| | | let _this = this
|
| | | let flag = false
|
| | | let _this = this;
|
| | | let flag = false;
|
| | | n.forEach((configObj) => {
|
| | | let notChecked = configObj.children.find((param) => !param.checked)
|
| | | let notChecked = configObj.children.find((param) => !param.checked);
|
| | | if (!notChecked) {
|
| | | configObj.checked = true
|
| | | configObj.checked = true;
|
| | | } else {
|
| | | configObj.checked = false
|
| | | configObj.checked = false;
|
| | | }
|
| | | let someoneChecked = configObj.children.find((param) => param.checked)
|
| | | let someoneChecked = configObj.children.find(
|
| | | (param) => param.checked
|
| | | );
|
| | | if (someoneChecked) {
|
| | | flag = true
|
| | | flag = true;
|
| | | }
|
| | | })
|
| | | });
|
| | | if (flag) {
|
| | | this.disabledPushFieldSet = false
|
| | | this.disabledPushFieldSet = false;
|
| | | } else {
|
| | | this.disabledPushFieldSet = true
|
| | | this.disabledPushFieldSet = true;
|
| | | }
|
| | | },
|
| | | deep: true
|
| | | }
|
| | | deep: true,
|
| | | },
|
| | | },
|
| | | created() {
|
| | | this.reAdd()
|
| | | this.reAdd();
|
| | | },
|
| | | mounted() {
|
| | | // 加载字典
|
| | | this.findByType()
|
| | | this.getCameras()
|
| | | this.getTasks()
|
| | | this.getPushFields()
|
| | | this.findByType();
|
| | | this.getCameras();
|
| | | this.getTasks();
|
| | | this.getPushFields();
|
| | | },
|
| | | methods: {
|
| | | openPushSetDialog() {
|
| | | this.pushFieldDialog = true
|
| | | this.tempPushSet = JSON.parse(JSON.stringify(this.taskEditData.push_set))
|
| | | this.checkFlag()
|
| | | this.pushFieldDialog = true;
|
| | | this.tempPushSet = JSON.parse(JSON.stringify(this.taskEditData.push_set));
|
| | | this.checkFlag();
|
| | | },
|
| | | checkFlag() {
|
| | | // debugger
|
| | | let flag = true
|
| | | let flag = true;
|
| | | this.tempPushSet.forEach((item) => {
|
| | | if (item.checked == false) {
|
| | | flag = false
|
| | | flag = false;
|
| | | }
|
| | | })
|
| | | this.allFieldChecked = flag
|
| | | });
|
| | | this.allFieldChecked = flag;
|
| | | },
|
| | | checkChildren(val) {
|
| | | console.log(val, 12121)
|
| | | console.log(val, 12121);
|
| | | if (val == false) {
|
| | | this.allFieldChecked = false
|
| | | this.allFieldChecked = false;
|
| | | } else if (val == true && this.allFieldChecked == false) {
|
| | | this.$nextTick(() => {
|
| | | this.checkFlag()
|
| | | })
|
| | | this.checkFlag();
|
| | | });
|
| | | }
|
| | | },
|
| | | varifyField(param) {
|
| | | var reg = /^[A-Za-z]+[0-9-_]?$/
|
| | | var reg = /^[A-Za-z]+[0-9-_]?$/;
|
| | | if (!reg.test(param.alias)) {
|
| | | this.$message("请输入合法字段名")
|
| | | param.error = true
|
| | | this.$message("请输入合法字段名");
|
| | | param.error = true;
|
| | | } else {
|
| | | param.error = false
|
| | | param.error = false;
|
| | | }
|
| | | // this.pushFields.forEach(configObj => {
|
| | | // configObj.children.find(param => param.error)
|
| | | // })
|
| | | },
|
| | | canclePushFieldSet() {
|
| | | this.pushFieldDialog = false
|
| | | this.pushFieldDialog = false;
|
| | | },
|
| | | allCheckChange(val) {
|
| | | this.tempPushSet.forEach(function(item) {
|
| | | item.checked = val
|
| | | item.children.forEach(function(child) {
|
| | | child.checked = val
|
| | | })
|
| | | })
|
| | | this.tempPushSet.forEach(function (item) {
|
| | | item.checked = val;
|
| | | item.children.forEach(function (child) {
|
| | | child.checked = val;
|
| | | });
|
| | | });
|
| | | },
|
| | | submitPushFieldSet() {
|
| | | let flag = false
|
| | | let flag = false;
|
| | | //this.pushFields.forEach(configObj => {
|
| | | this.tempPushSet.forEach((configObj) => {
|
| | | let errorOne = configObj.children.find((param) => param.checked && param.error)
|
| | | let errorOne = configObj.children.find(
|
| | | (param) => param.checked && param.error
|
| | | );
|
| | | if (errorOne) {
|
| | | this.$notify({
|
| | | type: "error",
|
| | | message: "请将选中字段输入合法字段名"
|
| | | })
|
| | | flag = true
|
| | | message: "请将选中字段输入合法字段名",
|
| | | });
|
| | | flag = true;
|
| | | }
|
| | | })
|
| | | });
|
| | | if (flag) {
|
| | | //NO SUBMIT
|
| | | return
|
| | | return;
|
| | | }
|
| | |
|
| | | this.taskEditData.push_set = this.tempPushSet
|
| | | this.pushFieldDialog = false
|
| | | this.taskEditData.push_set = this.tempPushSet;
|
| | | this.pushFieldDialog = false;
|
| | |
|
| | | // 保存规则
|
| | | this.eventPushsSave()
|
| | | this.eventPushsSave();
|
| | | },
|
| | | toggleConfigCheck(configObj) {
|
| | | configObj.children.forEach((child) => {
|
| | | child.checked = configObj.checked
|
| | | })
|
| | | this.checkFlag()
|
| | | child.checked = configObj.checked;
|
| | | });
|
| | | this.checkFlag();
|
| | | },
|
| | | getPushFields() {
|
| | | let _this = this
|
| | | let _this = this;
|
| | | getPushSet().then((res) => {
|
| | | _this.pushFields = res.data
|
| | | })
|
| | | _this.pushFields = res.data;
|
| | | });
|
| | | // this.pushFields = [
|
| | | // { id: 'sxjxx', name: '摄像机信息', checked: false, alias: '',
|
| | | // children: [
|
| | |
| | | addUrl() {
|
| | | this.taskEditData.urls.push({
|
| | | checked: true,
|
| | | hash: Math.random()
|
| | | .toString(36)
|
| | | .substr(2),
|
| | | url: ""
|
| | | })
|
| | | hash: Math.random().toString(36).substr(2),
|
| | | url: "",
|
| | | });
|
| | | },
|
| | | delUrl(index) {
|
| | | this.$set(this.taskEditData.urls, index, this.baseRule)
|
| | | this.taskEditData.urls.splice(index, 1)
|
| | | this.$set(this.taskEditData.urls, index, this.baseRule);
|
| | | this.taskEditData.urls.splice(index, 1);
|
| | | },
|
| | | // 保存
|
| | | async eventPushsSave() {
|
| | | if (this.taskEditData.name.length < 1) {
|
| | | this.$notify({
|
| | | type: "warning",
|
| | | message: "请填写推送任务名称"
|
| | | })
|
| | | return
|
| | | message: "请填写推送任务名称",
|
| | | });
|
| | | return;
|
| | | }
|
| | | // 判断保存的ip是否符合格式要求
|
| | | if (this.taskEditData.urls.length < 1) {
|
| | | this.$notify({
|
| | | type: "warning",
|
| | | message: "请配置至少一台推送服务器"
|
| | | })
|
| | | return
|
| | | message: "请配置至少一台推送服务器",
|
| | | });
|
| | | return;
|
| | | }
|
| | | for (let i = 0; i < this.taskEditData.urls.length; i++) {
|
| | | if (this.taskEditData.urls[i].url.length < 1) {
|
| | | this.$notify({
|
| | | type: "warning",
|
| | | message: "接口URL地址不允许为空"
|
| | | })
|
| | | return
|
| | | message: "接口URL地址不允许为空",
|
| | | });
|
| | | return;
|
| | | }
|
| | | }
|
| | | if (this.dataList.length < 1) {
|
| | | this.$notify({
|
| | | type: "warning",
|
| | | message: "请在任务配置中维护规则!"
|
| | | })
|
| | | return
|
| | | message: "请在任务配置中维护规则!",
|
| | | });
|
| | | return;
|
| | | }
|
| | | // 拼接字符串
|
| | | let ruleDesc = []
|
| | | let ruleDesc = [];
|
| | | this.dataList.forEach((i) => {
|
| | | let str = ""
|
| | | let str = "";
|
| | | if (i.topic_type) {
|
| | | str += this.getNameByValue(i.topicTypeOptions, i.topic_type)
|
| | | str += this.getNameByValue(i.topicTypeOptions, i.topic_type);
|
| | | }
|
| | | if (i.topic_arg) {
|
| | | str += this.getNameByValue(i.topicArgOptions, i.topic_arg)
|
| | | str += this.getNameByValue(i.topicArgOptions, i.topic_arg);
|
| | | }
|
| | | if (i.operator === "==") {
|
| | | str += " = "
|
| | | str += " = ";
|
| | | }
|
| | |
|
| | | if (i.rule_value === "all*all") {
|
| | | str += "全部"
|
| | | str += "全部";
|
| | | } else if (i.rule_value === "null*null") {
|
| | | str += "空"
|
| | | str += "空";
|
| | | } else {
|
| | | str += i.rule_value
|
| | | str += i.rule_value;
|
| | | }
|
| | |
|
| | | if (str.length > 0) {
|
| | | ruleDesc.push(str)
|
| | | ruleDesc.push(str);
|
| | | }
|
| | | })
|
| | | });
|
| | | // 处理规则列表数据结构
|
| | | let ruleList = this.dataList.map((i) => {
|
| | | return {
|
| | |
| | | topic_arg: i.topic_arg,
|
| | | operator: i.operator,
|
| | | operator_type: i.operator_type,
|
| | | rule_value: i.rule_value
|
| | | }
|
| | | })
|
| | | rule_value: i.rule_value,
|
| | | };
|
| | | });
|
| | |
|
| | | let json = {
|
| | | enable: this.taskEditData.enable,
|
| | |
| | | urls: this.taskEditData.urls,
|
| | | is_satisfy_all: this.taskEditData.radioValue === "1",
|
| | | link_type: this.taskEditData.lineWay,
|
| | | push_set: this.taskEditData.push_set
|
| | | }
|
| | | push_set: this.taskEditData.push_set,
|
| | | };
|
| | |
|
| | | let res = await eventPushsSave(json)
|
| | | let res = await eventPushsSave(json);
|
| | | if (res && res.success) {
|
| | | this.taskEditData.eventTxt = ruleDesc.join("<br/>")
|
| | | this.$emit("updateList", res.data.id)
|
| | | this.taskEditData.eventTxt = ruleDesc.join("<br/>");
|
| | | this.$emit("updateList", res.data.id);
|
| | | this.$notify({
|
| | | type: "success",
|
| | | message: "保存成功"
|
| | | })
|
| | | message: "保存成功",
|
| | | });
|
| | | }
|
| | | },
|
| | | // 查找字典
|
| | | async findByType() {
|
| | | let res = await findDictionaryByType()
|
| | | let res = await findDictionaryByType();
|
| | | if (res && res.success) {
|
| | | this.dictionary = Object.assign(this.dictionary, res.data)
|
| | | this.baseRule.topicTypeOptions = this.dictionary.EVENTRULETOPIC
|
| | | this.baseRule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE
|
| | | 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.map((el) => {
|
| | | return {
|
| | | name: el.name,
|
| | | value: el.name
|
| | | }
|
| | | })
|
| | | value: el.name,
|
| | | };
|
| | | });
|
| | | }
|
| | | },
|
| | | async getCameras() {
|
| | | let rsp = await findByEventTopic({ topic: "camera", type: "name" })
|
| | | let rsp = await findByEventTopic({ topic: "camera", type: "name" });
|
| | | if (rsp && rsp.success) {
|
| | | this.dictionary["camera"] = rsp.data
|
| | | this.dictionary["camera"] = rsp.data;
|
| | | }
|
| | |
|
| | | rsp = await findByEventTopic({ topic: "dbtable" })
|
| | | rsp = await findByEventTopic({ topic: "dbtable" });
|
| | | if (rsp && rsp.success) {
|
| | | this.dictionary["dbtable"] = rsp.data.map((el) => {
|
| | | return {
|
| | | name: el.name,
|
| | | value: el.name
|
| | | }
|
| | | })
|
| | | value: el.name,
|
| | | };
|
| | | });
|
| | | }
|
| | | },
|
| | | async getTasks() {
|
| | | this.dictionary["task"] = []
|
| | | let rsp = await getTaskList()
|
| | | this.dictionary["task"] = [];
|
| | | let rsp = await getTaskList();
|
| | | if (rsp && rsp.success) {
|
| | | let hash = {}
|
| | | let hash = {};
|
| | | rsp.data.forEach((task) => {
|
| | | if (!task.isDelete && !hash[task.name]) {
|
| | | this.dictionary["task"].push({
|
| | | value: task.name,
|
| | | name: task.name
|
| | | })
|
| | | hash[task.name] = true
|
| | | name: task.name,
|
| | | });
|
| | | hash[task.name] = true;
|
| | | }
|
| | | })
|
| | | });
|
| | | }
|
| | | },
|
| | | // 新建配置
|
| | | createSet() {
|
| | | this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)))
|
| | | this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)));
|
| | | },
|
| | | cleanSet() {
|
| | | this.dataList.splice(0, this.dataList.length)
|
| | | this.dataList.splice(0, this.dataList.length);
|
| | | },
|
| | | // 添加子规则
|
| | | addRule() {
|
| | | this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)))
|
| | | this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)));
|
| | | },
|
| | | // 删除子规则
|
| | | delRule(index) {
|
| | | this.dataList.splice(index, 1)
|
| | | this.dataList.splice(index, 1);
|
| | | },
|
| | | // 规则中下拉框的选择回调
|
| | | selectTopic(rule, resetNext = false) {
|
| | | rule.topicTypeOptions.forEach((element) => {
|
| | | if (element.value === rule.topic_type) {
|
| | | rule.topicArgOptions = element.children
|
| | | rule.topicArgOptions = element.children;
|
| | | if (resetNext) {
|
| | | rule.topic_arg = rule.topicArgOptions[0].value
|
| | | this.selectArg(rule, resetNext)
|
| | | rule.topic_arg = rule.topicArgOptions[0].value;
|
| | | this.selectArg(rule, resetNext);
|
| | | }
|
| | | }
|
| | | })
|
| | | });
|
| | | },
|
| | | selectArg(rule, resetNext = false) {
|
| | | debugger
|
| | | debugger;
|
| | | let argInfo = rule.topicArgOptions.filter((arg) => {
|
| | | return arg.value === rule.topic_arg
|
| | | })
|
| | | return arg.value === rule.topic_arg;
|
| | | });
|
| | |
|
| | | if (argInfo.length > 0) {
|
| | | let desc = argInfo[0].description.split(",")
|
| | | let desc = argInfo[0].description.split(",");
|
| | | if (desc.length > 0) {
|
| | | rule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE.filter((el) => {
|
| | | return desc.indexOf(el.value) >= 0
|
| | | })
|
| | | rule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE.filter(
|
| | | (el) => {
|
| | | return desc.indexOf(el.value) >= 0;
|
| | | }
|
| | | );
|
| | | }
|
| | | }
|
| | |
|
| | | if (resetNext) {
|
| | | rule.operator_type = rule.operatorTypeOpionts[rule.operatorTypeOpionts.length - 1].value
|
| | | this.selectOperator(rule, resetNext)
|
| | | rule.operator_type =
|
| | | rule.operatorTypeOpionts[rule.operatorTypeOpionts.length - 1].value;
|
| | | this.selectOperator(rule, resetNext);
|
| | | }
|
| | | },
|
| | | selectOperator(rule, resetNext = false) {
|
| | | if (rule.operator_type === "option") {
|
| | | rule.ruleValueOptions = this.dictionary[rule.topic_type] ? this.dictionary[rule.topic_type] : []
|
| | | rule.ruleValueOptions = this.dictionary[rule.topic_type]
|
| | | ? this.dictionary[rule.topic_type]
|
| | | : [];
|
| | |
|
| | | if (rule.rule_value != "") {
|
| | | rule.rule_values = rule.rule_value.split(",")
|
| | | rule.rule_values = rule.rule_value.split(",");
|
| | | }
|
| | |
|
| | | // 处理 全部/空
|
| | | for (let i = 0; i < rule.rule_values.length; i++) {
|
| | | if (rule.rule_values[i] === "all*all") {
|
| | | rule.rule_values[i] = "全部"
|
| | | rule.rule_values[i] = "全部";
|
| | | }
|
| | |
|
| | | if (rule.rule_values[i] === "null*null") {
|
| | | rule.rule_values[i] = "空"
|
| | | rule.rule_values[i] = "空";
|
| | | }
|
| | | }
|
| | | console.log("-----------")
|
| | | this.setOptionsDisable(rule)
|
| | | console.log("-----------");
|
| | | this.setOptionsDisable(rule);
|
| | | }
|
| | |
|
| | | if (resetNext) {
|
| | | rule.rule_value = ""
|
| | | rule.rule_values = []
|
| | | rule.rule_value = "";
|
| | | rule.rule_values = [];
|
| | | }
|
| | | },
|
| | | selectValue(rule, val) {
|
| | | if (rule.operator_type === "option") {
|
| | | this.setOptionsDisable(rule)
|
| | | this.setOptionsDisable(rule);
|
| | |
|
| | | if (val.indexOf("全部") >= 0) {
|
| | | rule.rule_value = "all*all"
|
| | | return
|
| | | rule.rule_value = "all*all";
|
| | | return;
|
| | | }
|
| | |
|
| | | if (val.indexOf("空") >= 0) {
|
| | | rule.rule_value = "null*null"
|
| | | return
|
| | | rule.rule_value = "null*null";
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | rule.rule_value = val.join(",")
|
| | | rule.rule_value = val.join(",");
|
| | | },
|
| | | setOptionsDisable(rule) {
|
| | | let isAllSelect = rule.rule_values.indexOf("全部") >= 0
|
| | | let isNullSelect = rule.rule_values.indexOf("空") >= 0
|
| | | console.log(rule.rule_values)
|
| | | let isAllSelect = rule.rule_values.indexOf("全部") >= 0;
|
| | | let isNullSelect = rule.rule_values.indexOf("空") >= 0;
|
| | | console.log(rule.rule_values);
|
| | |
|
| | | rule.ruleValueOptions.forEach((opt) => {
|
| | | if (!rule.rule_values.length) {
|
| | | opt.disabled = false
|
| | | return
|
| | | opt.disabled = false;
|
| | | return;
|
| | | }
|
| | |
|
| | | if (opt.name === "空") {
|
| | | opt.disabled = !isNullSelect
|
| | | return
|
| | | opt.disabled = !isNullSelect;
|
| | | return;
|
| | | }
|
| | |
|
| | | opt.disabled = isAllSelect || isNullSelect
|
| | | })
|
| | | opt.disabled = isAllSelect || isNullSelect;
|
| | | });
|
| | | },
|
| | | // 根据value返回对应的name
|
| | | getNameByValue(arr, value) {
|
| | | let s = arr.find((item) => {
|
| | | return item.value === value
|
| | | })
|
| | | return item.value === value;
|
| | | });
|
| | |
|
| | | return s.name
|
| | | return s.name;
|
| | | },
|
| | | // 清空重新新增
|
| | | reAdd() {
|
| | | this.taskEditData = {
|
| | | id: "",
|
| | | name: "",
|
| | | time: [this.$moment().format("YYYY-MM-DD 00:00:00"), this.$moment().format("YYYY-MM-DD HH:mm:ss")],
|
| | | time: [
|
| | | this.$moment().format("YYYY-MM-DD 00:00:00"),
|
| | | this.$moment().format("YYYY-MM-DD HH:mm:ss"),
|
| | | ],
|
| | | serverIp: [
|
| | | {
|
| | | enable: true,
|
| | | server_ip: "",
|
| | | port: 0
|
| | | }
|
| | | port: 0,
|
| | | },
|
| | | ],
|
| | | urls: [],
|
| | | lineWay: "",
|
| | | lineOptions: [
|
| | | {
|
| | | value: "001",
|
| | | label: "IP广播"
|
| | | }
|
| | | label: "IP广播",
|
| | | },
|
| | | ],
|
| | | radioValue: "1",
|
| | | eventTxt: "",
|
| | | push_set: this.pushFields
|
| | | }
|
| | | this.dataList = []
|
| | | push_set: this.pushFields,
|
| | | };
|
| | | this.dataList = [];
|
| | | },
|
| | | onCancle() {
|
| | | this.$emit("onCancle")
|
| | | }
|
| | | }
|
| | | }
|
| | | this.$emit("onCancle");
|
| | | },
|
| | | },
|
| | | };
|
| | | </script>
|
| | | <style lang="scss">
|
| | | .s-event-push-right {
|