From 9d95569c3d5e803dac6bc1edb2c786cac8f4bb4c Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Mon, 25 Dec 2023 23:44:47 +0800 Subject: [PATCH] 123 --- src/api/infoApi.js | 24 ++ src/components/AddRule.vue | 161 +++++++++++++ src/components/Sidebar.vue | 7 + src/proto/data/pd.js | 474 +++++++++++++++++++++++++++++++++++++ src/proto/rule.proto | 12 + src/router/index.js | 5 + src/utils/index.js | 3 +- src/views/Rules.vue | 195 +++++++++++++++ vite.config.js | 4 +- 9 files changed, 882 insertions(+), 3 deletions(-) create mode 100644 src/components/AddRule.vue create mode 100644 src/proto/rule.proto create mode 100644 src/views/Rules.vue diff --git a/src/api/infoApi.js b/src/api/infoApi.js index e531ab2..2ed5796 100644 --- a/src/api/infoApi.js +++ b/src/api/infoApi.js @@ -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; diff --git a/src/components/AddRule.vue b/src/components/AddRule.vue new file mode 100644 index 0000000..5fa64d6 --- /dev/null +++ b/src/components/AddRule.vue @@ -0,0 +1,161 @@ + + + diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 0ced832..3a205a8 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -63,6 +63,13 @@ export default { iconName: 'Management', children: [], }, + { + id: 2, + name: "规则引擎", + index: "/rules", + iconName: 'Management', + children: [], + }, // { // id: 4, // name: "透传管理", diff --git a/src/proto/data/pd.js b/src/proto/data/pd.js index 5ca8e17..03607e6 100644 --- a/src/proto/data/pd.js +++ b/src/proto/data/pd.js @@ -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.|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.} 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.} 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.} 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.} 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.} 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.} 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.} 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.} 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.} 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 = (() => { /** diff --git a/src/proto/rule.proto b/src/proto/rule.proto new file mode 100644 index 0000000..e29e0e2 --- /dev/null +++ b/src/proto/rule.proto @@ -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; +} \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index e3683f0..6c30a21 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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') } ] }) diff --git a/src/utils/index.js b/src/utils/index.js index d8e126e..bd387fc 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -35,5 +35,6 @@ export const pathMap = { page: '通讯管理', data: '实时数据', report: '上报管理', - transparent: '透传管理' + transparent: '透传管理', + rules: '规则引擎' } \ No newline at end of file diff --git a/src/views/Rules.vue b/src/views/Rules.vue new file mode 100644 index 0000000..1c5a302 --- /dev/null +++ b/src/views/Rules.vue @@ -0,0 +1,195 @@ + + + + diff --git a/vite.config.js b/vite.config.js index e55dc58..0dbeec6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -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') }