From f9c926251d45fb4930317c545d2d77b5f1a338a9 Mon Sep 17 00:00:00 2001
From: master <master@163.com>
Date: 星期二, 08 三月 2022 14:52:08 +0800
Subject: [PATCH] 添加设备分组页面以及功能
---
src/cool/modules/index.ts | 4
src/cool/modules/taskSetting/pages/index.ts | 1
src/cool/modules/taskSetting/directives/index.ts | 1
src/cool/modules/taskSetting/views/index.ts | 1
src/cool/modules/deviceGroup/views/deviceGroup.vue | 134 +++++++++++++
src/cool/modules/device/views/device.vue | 4
src/cool/modules/taskSetting/service/index.ts | 1
src/cool/modules/taskSetting/store/index.ts | 1
src/cool/modules/taskSetting/index.ts | 15 +
src/cool/modules/taskSetting/views/taskSetting.vue | 115 +++++++++++
src/cool/modules/immediateTask/views/immediateTask.vue | 73 ++++++
src/cool/modules/taskSetting/components/index.ts | 1
src/service/request.ts | 211 ++++++++++----------
13 files changed, 446 insertions(+), 116 deletions(-)
diff --git a/src/cool/modules/device/views/device.vue b/src/cool/modules/device/views/device.vue
index 87f53d9..b941143 100644
--- a/src/cool/modules/device/views/device.vue
+++ b/src/cool/modules/device/views/device.vue
@@ -138,8 +138,8 @@
label: "杩愯鐘舵��",
prop: "status",
filters: [
- { text: "0", value: "宸插仠姝�" },
- { text: "1", value: "姝e湪杩愯" }
+ { text: 0, value: 0 },
+ { text: 1, value: 1 }
]
// filters:"[{ text: '瀹�', value: '瀹�' }, { text: '鍏徃', value: '鍏徃' }]"
},
diff --git a/src/cool/modules/deviceGroup/views/deviceGroup.vue b/src/cool/modules/deviceGroup/views/deviceGroup.vue
index 76812a8..13d8177 100644
--- a/src/cool/modules/deviceGroup/views/deviceGroup.vue
+++ b/src/cool/modules/deviceGroup/views/deviceGroup.vue
@@ -1,5 +1,131 @@
<template>
- <div>
- <h1>璁惧鍒嗙粍椤甸潰</h1>
- </div>
-</template>
\ No newline at end of file
+ <cl-crud :ref="setRefs('crud')"
+ @load="onLoad">
+ <el-row type="flex"
+ align="middle">
+ <!-- 鍒锋柊鎸夐挳 -->
+ <cl-refresh-btn />
+ <!-- 鏂板鎸夐挳 -->
+ <cl-add-btn />
+ <!-- 鍒犻櫎鎸夐挳 -->
+ <cl-multi-delete-btn />
+ <cl-flex1 />
+ <!-- 鍏抽敭瀛楁悳绱� -->
+ <cl-search-key />
+ </el-row>
+
+ <el-row>
+ <!-- 鏁版嵁琛ㄦ牸 -->
+ <cl-table :ref="setRefs('table')"
+ v-bind="table" />
+ </el-row>
+
+ <el-row type="flex">
+ <cl-flex1 />
+ <!-- 鍒嗛〉鎺т欢 -->
+ <cl-pagination />
+ </el-row>
+
+ <!-- 鏂板銆佺紪杈� -->
+ <cl-upsert :ref="setRefs('upsert')"
+ v-bind="upsert" />
+ </cl-crud>
+</template>
+
+<script lang="ts">
+import { defineComponent, reactive } from "vue";
+import { CrudLoad, Upsert, Table } from "@cool-vue/crud/types";
+import { useCool } from "/@/cool";
+
+export default defineComponent({
+ setup() {
+ const { refs, setRefs, service } = useCool();
+
+ // 鏂板銆佺紪杈戦厤缃�
+ const upsert = reactive<Upsert>({
+ items: [
+ {
+ label: "閫昏緫ID",
+ prop: "logic_id",
+ component: {
+ name: "el-input"
+ },
+ required: true
+ },
+ {
+ label: "閰嶇疆浜哄悕绉�",
+ prop: "configurator",
+ component: {
+ name: "el-input"
+ },
+ required: true
+ },
+ {
+ label: "澶囨敞",
+ prop: "remark",
+ component: {
+ name: "el-input"
+ }
+ },
+ {
+ label: "鐘舵��",
+ prop: "status",
+ component: {
+ name: "el-input"
+ }
+ }
+ ]
+ });
+
+ // 琛ㄦ牸閰嶇疆
+ const table = reactive<Table>({
+ columns: [
+ {
+ type: "selection",
+ align: "center"
+ },
+ {
+ label: "搴忓彿",
+ prop: "id",
+ sortable: true //鏄惁鎺掑簭鍔熻兘
+ },
+ {
+ label: "閫昏緫ID",
+ prop: "logic_id"
+ },
+ {
+ label: "閰嶇疆浜哄悕绉�",
+ prop: "configurator"
+ },
+ {
+ label: "澶囨敞",
+ prop: "remark"
+ },
+ {
+ label: "鐘舵��",
+ prop: "status"
+ },
+ {
+ label: "鎿嶄綔",
+ type: "op"
+ }
+ ]
+ });
+
+ // crud 鍔犺浇
+ function onLoad({ ctx, app }: CrudLoad) {
+ // 缁戝畾 service
+ ctx.service(service.deviceGroup.deviceGroup).done();
+ app.refresh();
+ }
+
+ return {
+ refs,
+ setRefs,
+ upsert,
+ table,
+ onLoad
+ };
+ }
+});
+</script>
diff --git a/src/cool/modules/immediateTask/views/immediateTask.vue b/src/cool/modules/immediateTask/views/immediateTask.vue
index 709071c..e8de2d1 100644
--- a/src/cool/modules/immediateTask/views/immediateTask.vue
+++ b/src/cool/modules/immediateTask/views/immediateTask.vue
@@ -1,5 +1,70 @@
<template>
- <div>
- 鍗虫椂浠诲姟
- </div>
-</template>
\ No newline at end of file
+ <cl-crud :ref="setRefs('crud')"
+ @load="onLoad">
+ <el-row type="flex"
+ align="middle">
+ <!-- 鍒锋柊鎸夐挳 -->
+ <cl-refresh-btn />
+ <!-- 鏂板鎸夐挳 -->
+ <cl-add-btn />
+ <!-- 鍒犻櫎鎸夐挳 -->
+ <cl-multi-delete-btn />
+ <cl-flex1 />
+ <!-- 鍏抽敭瀛楁悳绱� -->
+ <cl-search-key />
+ </el-row>
+
+ <el-row>
+ <!-- 鏁版嵁琛ㄦ牸 -->
+ <cl-table :ref="setRefs('table')"
+ v-bind="table" />
+ </el-row>
+
+ <el-row type="flex">
+ <cl-flex1 />
+ <!-- 鍒嗛〉鎺т欢 -->
+ <cl-pagination />
+ </el-row>
+
+ <!-- 鏂板銆佺紪杈� -->
+ <cl-upsert :ref="setRefs('upsert')"
+ v-bind="upsert" />
+ </cl-crud>
+</template>
+
+<script lang="ts">
+import { defineComponent, reactive } from "vue";
+import { CrudLoad, Upsert, Table } from "@cool-vue/crud/types";
+import { useCool } from "/@/cool";
+
+export default defineComponent({
+ setup() {
+ const { refs, setRefs, service } = useCool();
+
+ // 鏂板銆佺紪杈戦厤缃�
+ const upsert = reactive<Upsert>({
+ items: []
+ });
+
+ // 琛ㄦ牸閰嶇疆
+ const table = reactive<Table>({
+ columns: []
+ });
+
+ // crud 鍔犺浇
+ function onLoad({ ctx, app }: CrudLoad) {
+ // 缁戝畾 service
+ ctx.service(service.xx).done();
+ app.refresh();
+ }
+
+ return {
+ refs,
+ setRefs,
+ upsert,
+ table,
+ onLoad
+ };
+ }
+});
+</script>
diff --git a/src/cool/modules/index.ts b/src/cool/modules/index.ts
index 7782660..95cb9d2 100644
--- a/src/cool/modules/index.ts
+++ b/src/cool/modules/index.ts
@@ -18,5 +18,7 @@
}
},
"huaneng",
- "device"
+ "device",
+ "deviceGroup",
+ "taskSetting"
];
diff --git a/src/cool/modules/taskSetting/components/index.ts b/src/cool/modules/taskSetting/components/index.ts
new file mode 100644
index 0000000..ff8b4c5
--- /dev/null
+++ b/src/cool/modules/taskSetting/components/index.ts
@@ -0,0 +1 @@
+export default {};
diff --git a/src/cool/modules/taskSetting/directives/index.ts b/src/cool/modules/taskSetting/directives/index.ts
new file mode 100644
index 0000000..ff8b4c5
--- /dev/null
+++ b/src/cool/modules/taskSetting/directives/index.ts
@@ -0,0 +1 @@
+export default {};
diff --git a/src/cool/modules/taskSetting/index.ts b/src/cool/modules/taskSetting/index.ts
new file mode 100644
index 0000000..08b1faf
--- /dev/null
+++ b/src/cool/modules/taskSetting/index.ts
@@ -0,0 +1,15 @@
+import components from "./components";
+import directives from "./directives";
+import service from "./service";
+import store from "./store";
+import pages from "./pages";
+import views from "./views";
+
+export default {
+ components,
+ directives,
+ service,
+ store,
+ pages,
+ views
+};
diff --git a/src/cool/modules/taskSetting/pages/index.ts b/src/cool/modules/taskSetting/pages/index.ts
new file mode 100644
index 0000000..d6d1738
--- /dev/null
+++ b/src/cool/modules/taskSetting/pages/index.ts
@@ -0,0 +1 @@
+export default [];
diff --git a/src/cool/modules/taskSetting/service/index.ts b/src/cool/modules/taskSetting/service/index.ts
new file mode 100644
index 0000000..ff8b4c5
--- /dev/null
+++ b/src/cool/modules/taskSetting/service/index.ts
@@ -0,0 +1 @@
+export default {};
diff --git a/src/cool/modules/taskSetting/store/index.ts b/src/cool/modules/taskSetting/store/index.ts
new file mode 100644
index 0000000..ff8b4c5
--- /dev/null
+++ b/src/cool/modules/taskSetting/store/index.ts
@@ -0,0 +1 @@
+export default {};
diff --git a/src/cool/modules/taskSetting/views/index.ts b/src/cool/modules/taskSetting/views/index.ts
new file mode 100644
index 0000000..d6d1738
--- /dev/null
+++ b/src/cool/modules/taskSetting/views/index.ts
@@ -0,0 +1 @@
+export default [];
diff --git a/src/cool/modules/taskSetting/views/taskSetting.vue b/src/cool/modules/taskSetting/views/taskSetting.vue
new file mode 100644
index 0000000..a05bcf5
--- /dev/null
+++ b/src/cool/modules/taskSetting/views/taskSetting.vue
@@ -0,0 +1,115 @@
+<template>
+ <cl-crud :ref="setRefs('crud')"
+ @load="onLoad">
+ <el-row type="flex"
+ align="middle">
+ <!-- 鍒锋柊鎸夐挳 -->
+ <cl-refresh-btn />
+ <!-- 鏂板鎸夐挳 -->
+ <cl-add-btn />
+ <!-- 鍒犻櫎鎸夐挳 -->
+ <cl-multi-delete-btn />
+ <cl-flex1 />
+ <!-- 鍏抽敭瀛楁悳绱� -->
+ <cl-search-key />
+ </el-row>
+
+ <el-row>
+ <!-- 鏁版嵁琛ㄦ牸 -->
+ <cl-table :ref="setRefs('table')"
+ v-bind="table" />
+ </el-row>
+
+ <el-row type="flex">
+ <cl-flex1 />
+ <!-- 鍒嗛〉鎺т欢 -->
+ <cl-pagination />
+ </el-row>
+
+ <!-- 鏂板銆佺紪杈� -->
+ <cl-upsert :ref="setRefs('upsert')"
+ v-bind="upsert" />
+ </cl-crud>
+</template>
+
+<script lang="ts">
+import { defineComponent, reactive } from "vue";
+import { CrudLoad, Upsert, Table } from "@cool-vue/crud/types";
+import { useCool } from "/@/cool";
+
+export default defineComponent({
+ setup() {
+ const { refs, setRefs, service } = useCool();
+
+ // 鏂板銆佺紪杈戦厤缃�
+ const upsert = reactive<Upsert>({
+ items: []
+ });
+
+ // 琛ㄦ牸閰嶇疆
+ const table = reactive<Table>({
+ columns: [
+ {
+ label: "id",
+ prop: "id"
+ },
+ {
+ label: "璁惧鍒嗙粍ID",
+ prop: "group_id"
+ },
+ {
+ label: "浠诲姟绫诲瀷",
+ prop: "task_type"
+ },
+ {
+ label: "鍛ㄦ湡浠诲姟",
+ prop: "crontab_rule"
+ },
+ {
+ label: "浠诲姟鍐呭鎻忚堪",
+ prop: "task_content"
+ },
+ {
+ label: "浠诲姟鍙傛暟",
+ prop: "task_params"
+ },
+ {
+ label: "浠诲姟鍛戒护鏍煎紡",
+ prop: "task_command"
+ },
+ {
+ label: "璁剧疆浜�",
+ prop: "operator"
+ },
+ {
+ label: "澶囨敞",
+ prop: "remark"
+ },
+ {
+ label: "鐘舵��",
+ prop: "status"
+ },
+ {
+ label: "鎿嶄綔",
+ type: "op"
+ }
+ ]
+ });
+
+ // crud 鍔犺浇
+ function onLoad({ ctx, app }: CrudLoad) {
+ // 缁戝畾 service
+ ctx.service(service.taskSetting.taskSetting).done();
+ app.refresh();
+ }
+
+ return {
+ refs,
+ setRefs,
+ upsert,
+ table,
+ onLoad
+ };
+ }
+});
+</script>
diff --git a/src/service/request.ts b/src/service/request.ts
index d4be32f..1f6dbef 100644
--- a/src/service/request.ts
+++ b/src/service/request.ts
@@ -10,7 +10,7 @@
axios.defaults.withCredentials = true;
NProgress.configure({
- showSpinner: false
+ showSpinner: false
});
// 璇锋眰闃熷垪
@@ -21,137 +21,138 @@
// 蹇界暐瑙勫垯
const ignore = {
- NProgress: ["/sys/info/record"],
- token: ["/login", "/captcha"]
+ NProgress: ["/sys/info/record"],
+ token: ["/login", "/captcha"]
};
// Request
axios.interceptors.request.use(
- (config: any) => {
- const token = store.getters.token || "";
+ (config: any) => {
+ const token = store.getters.token || "";
- if (config.url) {
- if (!ignore.token.some((e) => config.url.includes(e))) {
- config.headers["Authorization"] = token;
- }
+ if (config.url) {
+ if (!ignore.token.some((e) => config.url.includes(e))) {
+ config.headers["Authorization"] = token;
+ }
- if (!ignore.NProgress.some((e) => config.url.includes(e))) {
- NProgress.start();
- }
- }
+ if (!ignore.NProgress.some((e) => config.url.includes(e))) {
+ NProgress.start();
+ }
+ }
- // 璇锋眰淇℃伅
- if (isDev) {
- console.group(config.url);
- console.log("method:", config.method);
- console.table("data:", config.method == "get" ? config.params : config.data);
- console.groupEnd();
- }
+ // 璇锋眰淇℃伅
+ if (isDev) {
+ console.log("config:", config);
+ console.group(config.url);
+ console.log("method:", config.method);
+ console.table("data:", config.method == "get" ? config.params : config.data);
+ console.groupEnd();
+ }
- // 楠岃瘉 token
- if (token) {
- if (config.url.includes("refreshToken")) {
- return config;
- }
+ // 楠岃瘉 token
+ if (token) {
+ if (config.url.includes("refreshToken")) {
+ return config;
+ }
- // 鍒ゆ柇 token 鏄惁杩囨湡
- if (storage.isExpired("token")) {
- // 鍒ゆ柇 refreshToken 鏄惁杩囨湡
- if (storage.isExpired("refreshToken")) {
- store.dispatch("userRemove");
- return href("/login");
- }
+ // 鍒ゆ柇 token 鏄惁杩囨湡
+ if (storage.isExpired("token")) {
+ // 鍒ゆ柇 refreshToken 鏄惁杩囨湡
+ if (storage.isExpired("refreshToken")) {
+ store.dispatch("userRemove");
+ return href("/login");
+ }
- // 鏄惁鍦ㄥ埛鏂颁腑
- if (!isRefreshing) {
- isRefreshing = true;
+ // 鏄惁鍦ㄥ埛鏂颁腑
+ if (!isRefreshing) {
+ isRefreshing = true;
- store.dispatch("refreshToken").then((token: string) => {
- requests.forEach((cb) => cb(token));
- requests = [];
- isRefreshing = false;
- });
- }
+ store.dispatch("refreshToken").then((token: string) => {
+ requests.forEach((cb) => cb(token));
+ requests = [];
+ isRefreshing = false;
+ });
+ }
- return new Promise((resolve) => {
- // 缁х画璇锋眰
- requests.push((token: string) => {
- // 閲嶆柊璁剧疆 token
- config.headers["Authorization"] = token;
- resolve(config);
- });
- });
- }
- }
+ return new Promise((resolve) => {
+ // 缁х画璇锋眰
+ requests.push((token: string) => {
+ // 閲嶆柊璁剧疆 token
+ config.headers["Authorization"] = token;
+ resolve(config);
+ });
+ });
+ }
+ }
- return config;
- },
- (error) => {
- return Promise.reject(error);
- }
+ return config;
+ },
+ (error) => {
+ return Promise.reject(error);
+ }
);
// Response
axios.interceptors.response.use(
- (res) => {
- NProgress.done();
- const { code, data, message } = res.data;
+ (res) => {
+ NProgress.done();
+ const { code, data, message } = res.data;
- if (!res.data) {
- return res;
- }
+ if (!res.data) {
+ return res;
+ }
- switch (code) {
- case 1000:
- return data;
- default:
- return Promise.reject(message);
- }
- },
- async (error) => {
- NProgress.done();
+ switch (code) {
+ case 1000:
+ return data;
+ default:
+ return Promise.reject(message);
+ }
+ },
+ async (error) => {
+ NProgress.done();
- if (error.response) {
- const { status, config } = error.response;
+ if (error.response) {
+ const { status, config } = error.response;
- switch (status) {
- case 401:
- await store.dispatch("userRemove");
- href("/login");
- break;
+ switch (status) {
+ case 401:
+ await store.dispatch("userRemove");
+ href("/login");
+ break;
- case 403:
- if (isDev) {
- ElMessage.error(`${config.url} 鏃犳潈闄愯闂紒锛乣);
- } else {
- href("/403");
- }
- break;
+ case 403:
+ if (isDev) {
+ ElMessage.error(`${config.url} 鏃犳潈闄愯闂紒锛乣);
+ } else {
+ href("/403");
+ }
+ break;
- case 404:
- break;
+ case 404:
+ break;
- case 500:
- if (!isDev) {
- href("/500");
- }
- break;
+ case 500:
+ if (!isDev) {
+ href("/500");
+ }
+ break;
- case 502:
- if (isDev) {
- ElMessage.error(`${config.url} 鏈嶅姟寮傚父锛侊紒`);
- } else {
- href("/502");
- }
- break;
+ case 502:
+ if (isDev) {
+ ElMessage.error(`${config.url} 鏈嶅姟寮傚父锛侊紒`);
+ } else {
+ href("/502");
+ }
+ break;
- default:
- console.error(status, config.url);
- }
- }
+ default:
+ console.error(status, config.url);
+ }
+ }
- return Promise.reject(error.message);
- }
+ return Promise.reject(error.message);
+ }
);
export default axios;
--
Gitblit v1.9.1