123
							parent
							
								
									18756324e0
								
							
						
					
					
						commit
						9d95569c3d
					
				| 
						 | 
				
			
			@ -130,5 +130,29 @@ const infoApi = {
 | 
			
		|||
  delSc(params) {
 | 
			
		||||
    return deleteRequest("/sb", params);
 | 
			
		||||
  },
 | 
			
		||||
  // 获取规则列表
 | 
			
		||||
  getRules(params) {
 | 
			
		||||
    return getRequest('/rule', params);
 | 
			
		||||
  },
 | 
			
		||||
  // 新增规则
 | 
			
		||||
  addRules(params) {
 | 
			
		||||
    return postJsonRequest('/rule', params)
 | 
			
		||||
  },
 | 
			
		||||
  // 编辑规则
 | 
			
		||||
  editRule(params) {
 | 
			
		||||
    return putRequest('/rule', params)
 | 
			
		||||
  },
 | 
			
		||||
  // 删除规则
 | 
			
		||||
  delRules(params) {
 | 
			
		||||
    return deleteRequest('/rule', params)
 | 
			
		||||
  },
 | 
			
		||||
  // 规则启用
 | 
			
		||||
  startStatus(params) {
 | 
			
		||||
    return postJsonRequest('/enable', params);
 | 
			
		||||
  },
 | 
			
		||||
  // 规则停用
 | 
			
		||||
  stopStatus(params) {
 | 
			
		||||
    return postJsonRequest('/disable', params);
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
export default infoApi;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,161 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <el-dialog
 | 
			
		||||
    v-model="visible"
 | 
			
		||||
    :title="type === 'I' ? '新增规则': '编辑规则'"
 | 
			
		||||
    width="30%"
 | 
			
		||||
    :before-close="closeDialog"
 | 
			
		||||
  >
 | 
			
		||||
    <el-form
 | 
			
		||||
      :model="addForm"
 | 
			
		||||
      label-width="100px"
 | 
			
		||||
      :rules="rules"
 | 
			
		||||
      ref="ruleFormRef"
 | 
			
		||||
    >
 | 
			
		||||
      <el-form-item label="规则标题:" prop="name">
 | 
			
		||||
        <el-input
 | 
			
		||||
          v-model="addForm.name"
 | 
			
		||||
          placeholder="请输入规则标题"
 | 
			
		||||
          clearable
 | 
			
		||||
          :disabled="type === 'I' ? false: true"
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item label="规则描述:" prop="description">
 | 
			
		||||
        <el-input
 | 
			
		||||
          v-model="addForm.description"
 | 
			
		||||
          placeholder="请输入规则描述"
 | 
			
		||||
          clearable
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
    </el-form>
 | 
			
		||||
    <template #footer>
 | 
			
		||||
      <span class="dialog-footer">
 | 
			
		||||
          <el-button @click="closeDialog">取消</el-button>
 | 
			
		||||
          <el-button type="primary" @click="saveFormData"> 保存 </el-button>
 | 
			
		||||
      </span>
 | 
			
		||||
    </template>
 | 
			
		||||
  </el-dialog>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
 | 
			
		||||
import infoApi from "@/api/infoApi.js";
 | 
			
		||||
import { ElMessage, ElMessageBox } from "element-plus";
 | 
			
		||||
import { rule_info, response} from '../proto/data/pd'
 | 
			
		||||
export default {
 | 
			
		||||
  props: ["formData", "dialogVisible", "type"],
 | 
			
		||||
  emits: ["dialogClose", "dialogSuccess"],
 | 
			
		||||
  setup(props, ctx) { 
 | 
			
		||||
    const ruleFormRef = ref(null); 
 | 
			
		||||
    const state = reactive({
 | 
			
		||||
      addForm: {},
 | 
			
		||||
      rules: {
 | 
			
		||||
        name: [
 | 
			
		||||
          { required: true, message: "请输入规则标题", trigger: "blur" }
 | 
			
		||||
        ],
 | 
			
		||||
        description: [
 | 
			
		||||
          { required: true, message: "请输入规则描述", trigger: "blur" }
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
    const visible = computed(() => {
 | 
			
		||||
      return props.dialogVisible;
 | 
			
		||||
    });
 | 
			
		||||
    const type = computed(() => {
 | 
			
		||||
      return props.type;
 | 
			
		||||
    });
 | 
			
		||||
    onMounted(() => {
 | 
			
		||||
      // state.addForm = props.formData; 
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const closeDialog = () => {
 | 
			
		||||
      ctx.emit("dialogClose");
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const importData = () => {};
 | 
			
		||||
 | 
			
		||||
    const exoportData = () => {};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    const saveFormData = () => {
 | 
			
		||||
      ruleFormRef.value.validate(async (valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          const req_databuf = rule_info.encode(state.addForm).finish();
 | 
			
		||||
          // 截取有效长度
 | 
			
		||||
          const req_data = req_databuf.slice(0, req_databuf.length);
 | 
			
		||||
          const res = props.type === 'I' ? await infoApi.addRules(req_data) : await infoApi.editRule(req_data);
 | 
			
		||||
          console.log(555, res)
 | 
			
		||||
          const ret = response.decode(new Uint8Array(res));
 | 
			
		||||
          if (ret.code == 0) {
 | 
			
		||||
              // 获取数据
 | 
			
		||||
              console.log(new TextDecoder().decode(ret.data));
 | 
			
		||||
              ElMessage.success(new TextDecoder().decode(ret.data) || "请求成功");
 | 
			
		||||
              // 关闭弹框
 | 
			
		||||
              ctx.emit("dialogSuccess");
 | 
			
		||||
          } else {
 | 
			
		||||
              console.log(res);
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          console.log("error submit!");
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    };
 | 
			
		||||
    return {
 | 
			
		||||
      ...toRefs(state),
 | 
			
		||||
      visible,
 | 
			
		||||
      type,
 | 
			
		||||
      closeDialog,
 | 
			
		||||
      importData,
 | 
			
		||||
      exoportData,
 | 
			
		||||
      saveFormData,
 | 
			
		||||
      ruleFormRef
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.title-div {
 | 
			
		||||
  height: 40px;
 | 
			
		||||
  line-height: 40px;
 | 
			
		||||
  display: flex;
 | 
			
		||||
 | 
			
		||||
  > div {
 | 
			
		||||
    width: 15%;
 | 
			
		||||
    span {
 | 
			
		||||
      margin-right: 10px;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
.tree-div {
 | 
			
		||||
  height: 780px;
 | 
			
		||||
  display: flex;
 | 
			
		||||
  justify-content: space-between;
 | 
			
		||||
  .tree {
 | 
			
		||||
    width: 20%;
 | 
			
		||||
    border: 1px solid #f2f2f2;
 | 
			
		||||
    height: 100%;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
  }
 | 
			
		||||
  .table {
 | 
			
		||||
    height: 100%;
 | 
			
		||||
    width: 79%;
 | 
			
		||||
    display: flex;
 | 
			
		||||
    flex-direction: column;
 | 
			
		||||
    justify-content: space-between;
 | 
			
		||||
    .point-table {
 | 
			
		||||
      border: 1px solid #f2f2f2;
 | 
			
		||||
      padding: 10px;
 | 
			
		||||
    }
 | 
			
		||||
    .propertie-table {
 | 
			
		||||
      padding: 10px;
 | 
			
		||||
      border: 1px solid #f2f2f2;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  .custom-tree-node {
 | 
			
		||||
    display: flex;
 | 
			
		||||
    justify-content: space-between;
 | 
			
		||||
    width: 100%;
 | 
			
		||||
    .add-icon {
 | 
			
		||||
      padding-right: 15px;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +63,13 @@ export default {
 | 
			
		|||
          iconName: 'Management',
 | 
			
		||||
          children: [],
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          id: 2,
 | 
			
		||||
          name: "规则引擎",
 | 
			
		||||
          index: "/rules",
 | 
			
		||||
          iconName: 'Management',
 | 
			
		||||
          children: [],
 | 
			
		||||
        },
 | 
			
		||||
        // {
 | 
			
		||||
        //   id: 4,
 | 
			
		||||
        //   name: "透传管理",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4809,6 +4809,480 @@ export const response = $root.response = (() => {
 | 
			
		|||
    return response;
 | 
			
		||||
})();
 | 
			
		||||
 | 
			
		||||
export const rule = $root.rule = (() => {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Properties of a rule.
 | 
			
		||||
     * @exports Irule
 | 
			
		||||
     * @interface Irule
 | 
			
		||||
     * @property {Array.<Irule_info>|null} [rule] rule rule
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new rule.
 | 
			
		||||
     * @exports rule
 | 
			
		||||
     * @classdesc Represents a rule.
 | 
			
		||||
     * @implements Irule
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @param {Irule=} [properties] Properties to set
 | 
			
		||||
     */
 | 
			
		||||
    function rule(properties) {
 | 
			
		||||
        this.rule = [];
 | 
			
		||||
        if (properties)
 | 
			
		||||
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
 | 
			
		||||
                if (properties[keys[i]] != null)
 | 
			
		||||
                    this[keys[i]] = properties[keys[i]];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * rule rule.
 | 
			
		||||
     * @member {Array.<Irule_info>} rule
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @instance
 | 
			
		||||
     */
 | 
			
		||||
    rule.prototype.rule = $util.emptyArray;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new rule instance using the specified properties.
 | 
			
		||||
     * @function create
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule=} [properties] Properties to set
 | 
			
		||||
     * @returns {rule} rule instance
 | 
			
		||||
     */
 | 
			
		||||
    rule.create = function create(properties) {
 | 
			
		||||
        return new rule(properties);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Encodes the specified rule message. Does not implicitly {@link rule.verify|verify} messages.
 | 
			
		||||
     * @function encode
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule} message rule message or plain object to encode
 | 
			
		||||
     * @param {$protobuf.Writer} [writer] Writer to encode to
 | 
			
		||||
     * @returns {$protobuf.Writer} Writer
 | 
			
		||||
     */
 | 
			
		||||
    rule.encode = function encode(message, writer) {
 | 
			
		||||
        if (!writer)
 | 
			
		||||
            writer = $Writer.create();
 | 
			
		||||
        if (message.rule != null && message.rule.length)
 | 
			
		||||
            for (let i = 0; i < message.rule.length; ++i)
 | 
			
		||||
                $root.rule_info.encode(message.rule[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
 | 
			
		||||
        return writer;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Encodes the specified rule message, length delimited. Does not implicitly {@link rule.verify|verify} messages.
 | 
			
		||||
     * @function encodeDelimited
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule} message rule message or plain object to encode
 | 
			
		||||
     * @param {$protobuf.Writer} [writer] Writer to encode to
 | 
			
		||||
     * @returns {$protobuf.Writer} Writer
 | 
			
		||||
     */
 | 
			
		||||
    rule.encodeDelimited = function encodeDelimited(message, writer) {
 | 
			
		||||
        return this.encode(message, writer).ldelim();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Decodes a rule message from the specified reader or buffer.
 | 
			
		||||
     * @function decode
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
 | 
			
		||||
     * @param {number} [length] Message length if known beforehand
 | 
			
		||||
     * @returns {rule} rule
 | 
			
		||||
     * @throws {Error} If the payload is not a reader or valid buffer
 | 
			
		||||
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
 | 
			
		||||
     */
 | 
			
		||||
    rule.decode = function decode(reader, length) {
 | 
			
		||||
        if (!(reader instanceof $Reader))
 | 
			
		||||
            reader = $Reader.create(reader);
 | 
			
		||||
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.rule();
 | 
			
		||||
        while (reader.pos < end) {
 | 
			
		||||
            let tag = reader.uint32();
 | 
			
		||||
            switch (tag >>> 3) {
 | 
			
		||||
            case 1: {
 | 
			
		||||
                    if (!(message.rule && message.rule.length))
 | 
			
		||||
                        message.rule = [];
 | 
			
		||||
                    message.rule.push($root.rule_info.decode(reader, reader.uint32()));
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            default:
 | 
			
		||||
                reader.skipType(tag & 7);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return message;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Decodes a rule message from the specified reader or buffer, length delimited.
 | 
			
		||||
     * @function decodeDelimited
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
 | 
			
		||||
     * @returns {rule} rule
 | 
			
		||||
     * @throws {Error} If the payload is not a reader or valid buffer
 | 
			
		||||
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
 | 
			
		||||
     */
 | 
			
		||||
    rule.decodeDelimited = function decodeDelimited(reader) {
 | 
			
		||||
        if (!(reader instanceof $Reader))
 | 
			
		||||
            reader = new $Reader(reader);
 | 
			
		||||
        return this.decode(reader, reader.uint32());
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Verifies a rule message.
 | 
			
		||||
     * @function verify
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Object.<string,*>} message Plain object to verify
 | 
			
		||||
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
 | 
			
		||||
     */
 | 
			
		||||
    rule.verify = function verify(message) {
 | 
			
		||||
        if (typeof message !== "object" || message === null)
 | 
			
		||||
            return "object expected";
 | 
			
		||||
        if (message.rule != null && message.hasOwnProperty("rule")) {
 | 
			
		||||
            if (!Array.isArray(message.rule))
 | 
			
		||||
                return "rule: array expected";
 | 
			
		||||
            for (let i = 0; i < message.rule.length; ++i) {
 | 
			
		||||
                let error = $root.rule_info.verify(message.rule[i]);
 | 
			
		||||
                if (error)
 | 
			
		||||
                    return "rule." + error;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a rule message from a plain object. Also converts values to their respective internal types.
 | 
			
		||||
     * @function fromObject
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Object.<string,*>} object Plain object
 | 
			
		||||
     * @returns {rule} rule
 | 
			
		||||
     */
 | 
			
		||||
    rule.fromObject = function fromObject(object) {
 | 
			
		||||
        if (object instanceof $root.rule)
 | 
			
		||||
            return object;
 | 
			
		||||
        let message = new $root.rule();
 | 
			
		||||
        if (object.rule) {
 | 
			
		||||
            if (!Array.isArray(object.rule))
 | 
			
		||||
                throw TypeError(".rule.rule: array expected");
 | 
			
		||||
            message.rule = [];
 | 
			
		||||
            for (let i = 0; i < object.rule.length; ++i) {
 | 
			
		||||
                if (typeof object.rule[i] !== "object")
 | 
			
		||||
                    throw TypeError(".rule.rule: object expected");
 | 
			
		||||
                message.rule[i] = $root.rule_info.fromObject(object.rule[i]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return message;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a plain object from a rule message. Also converts values to other types if specified.
 | 
			
		||||
     * @function toObject
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {rule} message rule
 | 
			
		||||
     * @param {$protobuf.IConversionOptions} [options] Conversion options
 | 
			
		||||
     * @returns {Object.<string,*>} Plain object
 | 
			
		||||
     */
 | 
			
		||||
    rule.toObject = function toObject(message, options) {
 | 
			
		||||
        if (!options)
 | 
			
		||||
            options = {};
 | 
			
		||||
        let object = {};
 | 
			
		||||
        if (options.arrays || options.defaults)
 | 
			
		||||
            object.rule = [];
 | 
			
		||||
        if (message.rule && message.rule.length) {
 | 
			
		||||
            object.rule = [];
 | 
			
		||||
            for (let j = 0; j < message.rule.length; ++j)
 | 
			
		||||
                object.rule[j] = $root.rule_info.toObject(message.rule[j], options);
 | 
			
		||||
        }
 | 
			
		||||
        return object;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Converts this rule to JSON.
 | 
			
		||||
     * @function toJSON
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @instance
 | 
			
		||||
     * @returns {Object.<string,*>} JSON object
 | 
			
		||||
     */
 | 
			
		||||
    rule.prototype.toJSON = function toJSON() {
 | 
			
		||||
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the default type url for rule
 | 
			
		||||
     * @function getTypeUrl
 | 
			
		||||
     * @memberof rule
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
 | 
			
		||||
     * @returns {string} The default type url
 | 
			
		||||
     */
 | 
			
		||||
    rule.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
 | 
			
		||||
        if (typeUrlPrefix === undefined) {
 | 
			
		||||
            typeUrlPrefix = "type.googleapis.com";
 | 
			
		||||
        }
 | 
			
		||||
        return typeUrlPrefix + "/rule";
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    return rule;
 | 
			
		||||
})();
 | 
			
		||||
 | 
			
		||||
export const rule_info = $root.rule_info = (() => {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Properties of a rule_info.
 | 
			
		||||
     * @exports Irule_info
 | 
			
		||||
     * @interface Irule_info
 | 
			
		||||
     * @property {string|null} [id] rule_info id
 | 
			
		||||
     * @property {string|null} [label] rule_info label
 | 
			
		||||
     * @property {boolean|null} [disabled] rule_info disabled
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new rule_info.
 | 
			
		||||
     * @exports rule_info
 | 
			
		||||
     * @classdesc Represents a rule_info.
 | 
			
		||||
     * @implements Irule_info
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @param {Irule_info=} [properties] Properties to set
 | 
			
		||||
     */
 | 
			
		||||
    function rule_info(properties) {
 | 
			
		||||
        if (properties)
 | 
			
		||||
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
 | 
			
		||||
                if (properties[keys[i]] != null)
 | 
			
		||||
                    this[keys[i]] = properties[keys[i]];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * rule_info id.
 | 
			
		||||
     * @member {string} id
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @instance
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.prototype.id = "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * rule_info label.
 | 
			
		||||
     * @member {string} label
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @instance
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.prototype.label = "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * rule_info disabled.
 | 
			
		||||
     * @member {boolean} disabled
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @instance
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.prototype.disabled = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new rule_info instance using the specified properties.
 | 
			
		||||
     * @function create
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule_info=} [properties] Properties to set
 | 
			
		||||
     * @returns {rule_info} rule_info instance
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.create = function create(properties) {
 | 
			
		||||
        return new rule_info(properties);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Encodes the specified rule_info message. Does not implicitly {@link rule_info.verify|verify} messages.
 | 
			
		||||
     * @function encode
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule_info} message rule_info message or plain object to encode
 | 
			
		||||
     * @param {$protobuf.Writer} [writer] Writer to encode to
 | 
			
		||||
     * @returns {$protobuf.Writer} Writer
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.encode = function encode(message, writer) {
 | 
			
		||||
        if (!writer)
 | 
			
		||||
            writer = $Writer.create();
 | 
			
		||||
        if (message.id != null && Object.hasOwnProperty.call(message, "id"))
 | 
			
		||||
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.id);
 | 
			
		||||
        if (message.label != null && Object.hasOwnProperty.call(message, "label"))
 | 
			
		||||
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.label);
 | 
			
		||||
        if (message.disabled != null && Object.hasOwnProperty.call(message, "disabled"))
 | 
			
		||||
            writer.uint32(/* id 3, wireType 0 =*/24).bool(message.disabled);
 | 
			
		||||
        return writer;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Encodes the specified rule_info message, length delimited. Does not implicitly {@link rule_info.verify|verify} messages.
 | 
			
		||||
     * @function encodeDelimited
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Irule_info} message rule_info message or plain object to encode
 | 
			
		||||
     * @param {$protobuf.Writer} [writer] Writer to encode to
 | 
			
		||||
     * @returns {$protobuf.Writer} Writer
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.encodeDelimited = function encodeDelimited(message, writer) {
 | 
			
		||||
        return this.encode(message, writer).ldelim();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Decodes a rule_info message from the specified reader or buffer.
 | 
			
		||||
     * @function decode
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
 | 
			
		||||
     * @param {number} [length] Message length if known beforehand
 | 
			
		||||
     * @returns {rule_info} rule_info
 | 
			
		||||
     * @throws {Error} If the payload is not a reader or valid buffer
 | 
			
		||||
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.decode = function decode(reader, length) {
 | 
			
		||||
        if (!(reader instanceof $Reader))
 | 
			
		||||
            reader = $Reader.create(reader);
 | 
			
		||||
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.rule_info();
 | 
			
		||||
        while (reader.pos < end) {
 | 
			
		||||
            let tag = reader.uint32();
 | 
			
		||||
            switch (tag >>> 3) {
 | 
			
		||||
            case 1: {
 | 
			
		||||
                    message.id = reader.string();
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            case 2: {
 | 
			
		||||
                    message.label = reader.string();
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            case 3: {
 | 
			
		||||
                    message.disabled = reader.bool();
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            default:
 | 
			
		||||
                reader.skipType(tag & 7);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return message;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Decodes a rule_info message from the specified reader or buffer, length delimited.
 | 
			
		||||
     * @function decodeDelimited
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
 | 
			
		||||
     * @returns {rule_info} rule_info
 | 
			
		||||
     * @throws {Error} If the payload is not a reader or valid buffer
 | 
			
		||||
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.decodeDelimited = function decodeDelimited(reader) {
 | 
			
		||||
        if (!(reader instanceof $Reader))
 | 
			
		||||
            reader = new $Reader(reader);
 | 
			
		||||
        return this.decode(reader, reader.uint32());
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Verifies a rule_info message.
 | 
			
		||||
     * @function verify
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Object.<string,*>} message Plain object to verify
 | 
			
		||||
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.verify = function verify(message) {
 | 
			
		||||
        if (typeof message !== "object" || message === null)
 | 
			
		||||
            return "object expected";
 | 
			
		||||
        if (message.id != null && message.hasOwnProperty("id"))
 | 
			
		||||
            if (!$util.isString(message.id))
 | 
			
		||||
                return "id: string expected";
 | 
			
		||||
        if (message.label != null && message.hasOwnProperty("label"))
 | 
			
		||||
            if (!$util.isString(message.label))
 | 
			
		||||
                return "label: string expected";
 | 
			
		||||
        if (message.disabled != null && message.hasOwnProperty("disabled"))
 | 
			
		||||
            if (typeof message.disabled !== "boolean")
 | 
			
		||||
                return "disabled: boolean expected";
 | 
			
		||||
        return null;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a rule_info message from a plain object. Also converts values to their respective internal types.
 | 
			
		||||
     * @function fromObject
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {Object.<string,*>} object Plain object
 | 
			
		||||
     * @returns {rule_info} rule_info
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.fromObject = function fromObject(object) {
 | 
			
		||||
        if (object instanceof $root.rule_info)
 | 
			
		||||
            return object;
 | 
			
		||||
        let message = new $root.rule_info();
 | 
			
		||||
        if (object.id != null)
 | 
			
		||||
            message.id = String(object.id);
 | 
			
		||||
        if (object.label != null)
 | 
			
		||||
            message.label = String(object.label);
 | 
			
		||||
        if (object.disabled != null)
 | 
			
		||||
            message.disabled = Boolean(object.disabled);
 | 
			
		||||
        return message;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a plain object from a rule_info message. Also converts values to other types if specified.
 | 
			
		||||
     * @function toObject
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {rule_info} message rule_info
 | 
			
		||||
     * @param {$protobuf.IConversionOptions} [options] Conversion options
 | 
			
		||||
     * @returns {Object.<string,*>} Plain object
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.toObject = function toObject(message, options) {
 | 
			
		||||
        if (!options)
 | 
			
		||||
            options = {};
 | 
			
		||||
        let object = {};
 | 
			
		||||
        if (options.defaults) {
 | 
			
		||||
            object.id = "";
 | 
			
		||||
            object.label = "";
 | 
			
		||||
            object.disabled = false;
 | 
			
		||||
        }
 | 
			
		||||
        if (message.id != null && message.hasOwnProperty("id"))
 | 
			
		||||
            object.id = message.id;
 | 
			
		||||
        if (message.label != null && message.hasOwnProperty("label"))
 | 
			
		||||
            object.label = message.label;
 | 
			
		||||
        if (message.disabled != null && message.hasOwnProperty("disabled"))
 | 
			
		||||
            object.disabled = message.disabled;
 | 
			
		||||
        return object;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Converts this rule_info to JSON.
 | 
			
		||||
     * @function toJSON
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @instance
 | 
			
		||||
     * @returns {Object.<string,*>} JSON object
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.prototype.toJSON = function toJSON() {
 | 
			
		||||
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the default type url for rule_info
 | 
			
		||||
     * @function getTypeUrl
 | 
			
		||||
     * @memberof rule_info
 | 
			
		||||
     * @static
 | 
			
		||||
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
 | 
			
		||||
     * @returns {string} The default type url
 | 
			
		||||
     */
 | 
			
		||||
    rule_info.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
 | 
			
		||||
        if (typeUrlPrefix === undefined) {
 | 
			
		||||
            typeUrlPrefix = "type.googleapis.com";
 | 
			
		||||
        }
 | 
			
		||||
        return typeUrlPrefix + "/rule_info";
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    return rule_info;
 | 
			
		||||
})();
 | 
			
		||||
 | 
			
		||||
export const sb_list = $root.sb_list = (() => {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
syntax = "proto3";
 | 
			
		||||
option go_package = "data/";
 | 
			
		||||
 | 
			
		||||
message rule{
 | 
			
		||||
    repeated rule_info rule = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message rule_info{
 | 
			
		||||
    string id = 1;
 | 
			
		||||
    string label = 2;
 | 
			
		||||
    bool disabled = 3;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +46,11 @@ const router = createRouter({
 | 
			
		|||
      path: '/transparent',
 | 
			
		||||
      name: 'transparent',
 | 
			
		||||
      component: () => import('../views/Transparent.vue')
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      path: '/rules',
 | 
			
		||||
      name: 'rules',
 | 
			
		||||
      component: () => import('../views/Rules.vue')
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,5 +35,6 @@ export const pathMap = {
 | 
			
		|||
  page: '通讯管理',
 | 
			
		||||
  data: '实时数据',
 | 
			
		||||
  report: '上报管理',
 | 
			
		||||
  transparent: '透传管理'
 | 
			
		||||
  transparent: '透传管理',
 | 
			
		||||
  rules: '规则引擎'
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,195 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <el-card class="content-div">
 | 
			
		||||
    <div class="all-content">
 | 
			
		||||
      <div class="top-div">
 | 
			
		||||
        <el-button type="primary" @click="addData">新增</el-button>
 | 
			
		||||
      </div> 
 | 
			
		||||
      <el-table
 | 
			
		||||
        :data="tableData"
 | 
			
		||||
        height="730"
 | 
			
		||||
        style="width: 100%"
 | 
			
		||||
        border
 | 
			
		||||
        stripe
 | 
			
		||||
        :header-cell-style="{ background: '#F6F7FC' }"
 | 
			
		||||
      >
 | 
			
		||||
        <el-table-column type="index" label="序号" width="80" align="center" />
 | 
			
		||||
        <el-table-column
 | 
			
		||||
          prop="title"
 | 
			
		||||
          label="标题"
 | 
			
		||||
          width="200"
 | 
			
		||||
          align="center"
 | 
			
		||||
          show-overflow-tooltip
 | 
			
		||||
        />
 | 
			
		||||
        <el-table-column
 | 
			
		||||
          prop="description"
 | 
			
		||||
          label="描述"
 | 
			
		||||
          width="200"
 | 
			
		||||
          align="center"
 | 
			
		||||
          show-overflow-tooltip
 | 
			
		||||
        /> 
 | 
			
		||||
        <el-table-column label="规则管理" align="center" show-overflow-tooltip>
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-button type="primary" @click="editData(scope.row)">
 | 
			
		||||
              编辑
 | 
			
		||||
            </el-button>
 | 
			
		||||
            <el-button type="danger" @click="delData(scope.row)">
 | 
			
		||||
              删除
 | 
			
		||||
            </el-button>
 | 
			
		||||
            <el-switch
 | 
			
		||||
              v-model="scope.row.enable"
 | 
			
		||||
              inline-prompt
 | 
			
		||||
              active-text="启用"
 | 
			
		||||
              inactive-text="停用"
 | 
			
		||||
              :active-value="false"
 | 
			
		||||
              :inactive-value="true"
 | 
			
		||||
              active-color="#13ce66"
 | 
			
		||||
              inactive-color="red"
 | 
			
		||||
              @change="changeStatus(scope.row)"
 | 
			
		||||
            />
 | 
			
		||||
            <el-button type="danger" @click="setData(scope.row)">
 | 
			
		||||
              设计
 | 
			
		||||
            </el-button>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
      </el-table>
 | 
			
		||||
    </div> 
 | 
			
		||||
    <AddRule
 | 
			
		||||
      :type="type"
 | 
			
		||||
      :formData="formData"
 | 
			
		||||
      :dialogVisible="dialogVisible"
 | 
			
		||||
      v-if="dialogVisible"
 | 
			
		||||
      @dialogClose="dialogClose"
 | 
			
		||||
      @dialogSuccess="dialogSuccess"
 | 
			
		||||
    >
 | 
			
		||||
    </AddRule>
 | 
			
		||||
  </el-card>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { onMounted, reactive, ref, toRefs } from "vue"; 
 | 
			
		||||
import { ElMessage, ElMessageBox } from "element-plus"; 
 | 
			
		||||
import infoApi from "@/api/infoApi.js";
 | 
			
		||||
import { response, rule_info } from '../proto/data/pd'
 | 
			
		||||
import AddRule from "@/components/AddRule.vue";
 | 
			
		||||
export default {
 | 
			
		||||
  name: "rules",
 | 
			
		||||
  components: {
 | 
			
		||||
    AddRule
 | 
			
		||||
  },
 | 
			
		||||
  setup() {
 | 
			
		||||
    const state = reactive({
 | 
			
		||||
      tableData: [],
 | 
			
		||||
      formData: {
 | 
			
		||||
        title: '',
 | 
			
		||||
        description: ''
 | 
			
		||||
      },
 | 
			
		||||
      dialogVisible: false,
 | 
			
		||||
      type: 'I'
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    onMounted(() => {
 | 
			
		||||
      getTableData();
 | 
			
		||||
    });
 | 
			
		||||
    // 获取列表
 | 
			
		||||
    const getTableData = async () => {
 | 
			
		||||
      const res = await infoApi.getRules();
 | 
			
		||||
      const ret = response.decode(new Uint8Array(res));
 | 
			
		||||
      
 | 
			
		||||
      if (ret.code == 0) {
 | 
			
		||||
          // 获取数据
 | 
			
		||||
          state.tableData = rule_info.decode(ret.data);
 | 
			
		||||
          console.log(rule_info.decode(ret.data));
 | 
			
		||||
      } else {
 | 
			
		||||
          console.log(res);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
    // 编辑
 | 
			
		||||
    const editData = (item) => {
 | 
			
		||||
      state.dialogVisible = true;
 | 
			
		||||
      state.type = 'U';
 | 
			
		||||
      state.formData = JSON.parse(JSON.stringify(item));
 | 
			
		||||
    };
 | 
			
		||||
    // 删除
 | 
			
		||||
    const delData = (item) => {
 | 
			
		||||
      ElMessageBox.confirm("确定删除该数据?", "提示", {
 | 
			
		||||
        confirmButtonText: "确定",
 | 
			
		||||
        cancelButtonText: "取消",
 | 
			
		||||
        type: "warning",
 | 
			
		||||
      })
 | 
			
		||||
        .then(async () => {
 | 
			
		||||
          const req_databuf = rule_info.encode({
 | 
			
		||||
            id: item.id,
 | 
			
		||||
          }).finish();
 | 
			
		||||
          // 截取有效长度
 | 
			
		||||
          const req_data = req_databuf.slice(0, req_databuf.length);
 | 
			
		||||
 
 | 
			
		||||
          const res = await infoApi.delRules(req_data);
 | 
			
		||||
          const ret = response.decode(new Uint8Array(res));
 | 
			
		||||
          if (ret.code == 0) {
 | 
			
		||||
            ElMessage.success(res.msg || "请求成功");
 | 
			
		||||
            getTableData();
 | 
			
		||||
          } else {
 | 
			
		||||
            ElMessage.error(res.msg);
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        .catch(() => {
 | 
			
		||||
          ElMessage.info("已取消删除");
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
    // 新增
 | 
			
		||||
    const addData = () => {
 | 
			
		||||
      state.dialogVisible = true;
 | 
			
		||||
      //清空数据
 | 
			
		||||
      state.formData = {
 | 
			
		||||
        title: '',
 | 
			
		||||
        description: ''
 | 
			
		||||
      }
 | 
			
		||||
      state.type = 'I';
 | 
			
		||||
    };
 | 
			
		||||
    // 启用停用
 | 
			
		||||
    const changeStatus = async (item) => {
 | 
			
		||||
      const req_databuf = rule_info.encode({
 | 
			
		||||
          id: item.id,
 | 
			
		||||
      }).finish();
 | 
			
		||||
      // 截取有效长度
 | 
			
		||||
      const req_data = req_databuf.slice(0, req_databuf.length);
 | 
			
		||||
 | 
			
		||||
      const res =  item.enable==='启动' ? await infoApi.startStatus(req_data) : await infoApi.stopStatus(req_data);
 | 
			
		||||
      const ret = response.decode(new Uint8Array(res));
 | 
			
		||||
      if (ret.code == 0) {
 | 
			
		||||
        ElMessage.success(res.msg || "更新成功");
 | 
			
		||||
        getTableData();
 | 
			
		||||
      } else {
 | 
			
		||||
        ElMessage.error(res.msg);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
    const dialogClose = () => {
 | 
			
		||||
      state.dialogVisible = false;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const dialogSuccess = () => {
 | 
			
		||||
      state.dialogVisible = false;
 | 
			
		||||
      getTableData();
 | 
			
		||||
    };
 | 
			
		||||
    return {
 | 
			
		||||
      ...toRefs(state),
 | 
			
		||||
      editData,
 | 
			
		||||
      delData,
 | 
			
		||||
      getTableData,
 | 
			
		||||
      addData,
 | 
			
		||||
      dialogSuccess,
 | 
			
		||||
      dialogClose
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.all-content {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  flex-direction: column;
 | 
			
		||||
} 
 | 
			
		||||
.top-div {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  justify-content: flex-end;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -24,9 +24,9 @@ export default ({ mode }) =>  defineConfig({
 | 
			
		|||
  server: {
 | 
			
		||||
    proxy: {
 | 
			
		||||
      '/api': {
 | 
			
		||||
        // target: 'http://192.168.1.123:8866',
 | 
			
		||||
        target: 'http://api.shikicc.com:58909',
 | 
			
		||||
        // target: 'http://10.10.14.123',
 | 
			
		||||
        target: 'https://cdcmapi.shikicc.com',
 | 
			
		||||
        // target: 'https://cdcmapi.shikicc.com',
 | 
			
		||||
        changeOrigin: true,
 | 
			
		||||
        rewrite: path => path.replace(/^\/api/, '/api')
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue