Commit 8e6cac78 authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 优化代码,去掉无用的依赖

parent f069dc81
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"date-fns": "^2.14.0", "date-fns": "^2.14.0",
"enquire.js": "^2.1.6",
"highlight.js": "^10.2.1", "highlight.js": "^10.2.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
...@@ -41,12 +40,12 @@ ...@@ -41,12 +40,12 @@
}, },
"devDependencies": { "devDependencies": {
"@ant-design/colors": "^4.0.1", "@ant-design/colors": "^4.0.1",
"@babel/eslint-parser": "^7.14.7",
"@vue/cli-plugin-babel": "^4.4.0", "@vue/cli-plugin-babel": "^4.4.0",
"@vue/cli-plugin-eslint": "^4.4.0", "@vue/cli-plugin-eslint": "^4.4.0",
"@vue/cli-service": "^4.4.0", "@vue/cli-service": "^4.4.0",
"@vuepress/plugin-back-to-top": "^1.5.2", "@vuepress/plugin-back-to-top": "^1.5.2",
"autoprefixer": "^9.8.6", "autoprefixer": "^9.8.6",
"babel-eslint": "^10.1.0",
"babel-plugin-transform-remove-console": "^6.9.4", "babel-plugin-transform-remove-console": "^6.9.4",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"compression-webpack-plugin": "^2.0.0", "compression-webpack-plugin": "^2.0.0",
...@@ -74,7 +73,7 @@ ...@@ -74,7 +73,7 @@
"eslint:recommended" "eslint:recommended"
], ],
"parserOptions": { "parserOptions": {
"parser": "babel-eslint" "parser": "@babel/eslint-parser"
}, },
"rules": { "rules": {
"no-unused-vars": "off" "no-unused-vars": "off"
......
This diff is collapsed.
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
</template> </template>
<script> <script>
import { enquireScreen } from './utils/commonUtil'; import { mapState } from 'vuex';
import { mapState, mapMutations } from 'vuex';
import { changeThemeColor } from '@/utils/themeUtil'; import { changeThemeColor } from '@/utils/themeUtil';
import langUtils from '@/utils/langUtils';
export default { export default {
name: 'App', name: 'App',
...@@ -18,15 +18,10 @@ export default { ...@@ -18,15 +18,10 @@ export default {
}, },
created() { created() {
this.setHtmlTitle(); this.setHtmlTitle();
this.setLanguage(this.lang); this.setLanguage();
enquireScreen(isMobile => this.setDevice(isMobile));
}, },
watch: { watch: {
lang(val) {
this.setLanguage(val);
this.setHtmlTitle();
},
$route() { $route() {
this.setHtmlTitle(); this.setHtmlTitle();
}, },
...@@ -44,12 +39,11 @@ export default { ...@@ -44,12 +39,11 @@ export default {
}, },
computed: { computed: {
//setting = mapStore.name //setting = mapStore.name
...mapState('settingModule', ['layout', 'theme', 'lang']), ...mapState('settingModule', ['layout', 'theme']),
}, },
methods: { methods: {
...mapMutations('settingModule', ['setDevice']), setLanguage() {
const lang = langUtils.get();
setLanguage(lang) {
this.$i18n.locale = lang; this.$i18n.locale = lang;
switch (lang) { switch (lang) {
case 'zh_CN': case 'zh_CN':
......
import { postReq, putReq } from '@/utils'; import { getReq, postReq, putReq } from '@/utils';
export function addTaskApi(data) { export function addTaskApi(data) {
return postReq('/api/v1/schedules', data); return postReq('/api/v1/schedules', data);
...@@ -7,3 +7,7 @@ export function addTaskApi(data) { ...@@ -7,3 +7,7 @@ export function addTaskApi(data) {
export function updateTaskApi(data) { export function updateTaskApi(data) {
return putReq('/api/v1/schedules', data); return putReq('/api/v1/schedules', data);
} }
export function getRangerInspectionTaskDetailApi(id) {
return getReq(`/ranger/inspection/api/v1/jobs/tasks/${id}`);
}
<template> <template>
<a-layout-sider <a-layout-sider
:theme="sideTheme" :theme="sideTheme"
:class="['side-menu', 'beauty-scroll', isMobile ? null : 'shadow']" :class="['side-menu', 'beauty-scroll']"
width="256px" width="256px"
:collapsible="collapsible" :collapsible="collapsible"
v-model="collapsed" v-model="collapsed"
...@@ -49,15 +49,12 @@ export default { ...@@ -49,15 +49,12 @@ export default {
sideTheme() { sideTheme() {
return this.theme == 'light' ? this.theme : 'dark'; return this.theme == 'light' ? this.theme : 'dark';
}, },
...mapState('settingModule', ['isMobile', 'systemName']), ...mapState('settingModule', ['systemName']),
}, },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.shadow {
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
}
.side-menu { .side-menu {
min-height: 100vh; min-height: 100vh;
overflow-y: auto; overflow-y: auto;
......
<template> <template>
<a-layout-header :class="[headerTheme, 'admin-header']"> <a-layout-header :class="[headerTheme, 'admin-header']">
<div :class="['admin-header-wide', layout, pageWidth]"> <div :class="['admin-header-wide', layout, pageWidth]">
<router-link <router-link v-if="layout === 'head'" to="/" :class="['logo', 'pc', headerTheme]">
v-if="isMobile || layout === 'head'"
to="/"
:class="['logo', isMobile ? null : 'pc', headerTheme]"
>
<img width="32" src="@/assets/img/logo.png" /> <img width="32" src="@/assets/img/logo.png" />
<h1 v-if="!isMobile">{{ systemName }}</h1> <h1>{{ systemName }}</h1>
</router-link> </router-link>
<a-icon <a-icon
...@@ -16,11 +12,7 @@ ...@@ -16,11 +12,7 @@
:type="collapsed ? 'menu-unfold' : 'menu-fold'" :type="collapsed ? 'menu-unfold' : 'menu-fold'"
@click="toggleCollapse" @click="toggleCollapse"
/> />
<div <div v-if="layout !== 'side'" class="admin-header-menu" :style="`width: ${menuWidth};`">
v-if="layout !== 'side' && !isMobile"
class="admin-header-menu"
:style="`width: ${menuWidth};`"
>
<i-menu <i-menu
class="head-menu" class="head-menu"
:theme="headerTheme" :theme="headerTheme"
...@@ -53,9 +45,9 @@ export default { ...@@ -53,9 +45,9 @@ export default {
return {}; return {};
}, },
computed: { computed: {
...mapState('settingModule', ['theme', 'isMobile', 'layout', 'systemName', 'pageWidth']), ...mapState('settingModule', ['theme', 'layout', 'systemName', 'pageWidth']),
headerTheme() { headerTheme() {
if (this.layout == 'side' && this.theme.mode == 'dark' && !this.isMobile) { if (this.layout == 'side' && this.theme.mode == 'dark') {
return 'light'; return 'light';
} }
return this.theme.mode; return this.theme.mode;
...@@ -67,7 +59,7 @@ export default { ...@@ -67,7 +59,7 @@ export default {
return `calc(${headWidth} - ${extraWidth})`; return `calc(${headWidth} - ${extraWidth})`;
}, },
showToggleCollapse() { showToggleCollapse() {
if (this.layout !== 'head' && this.isMobile === false) { if (this.layout !== 'head') {
return true; return true;
} else { } else {
return false; return false;
......
<template> <template>
<a-layout :class="['admin-layout', 'beauty-scroll']"> <a-layout :class="['admin-layout', 'beauty-scroll']">
<drawer v-if="isMobile" v-model="drawerOpen">
<side-menu
:theme="theme.mode"
:menuData="menuData"
:collapsed="false"
:collapsible="false"
@menuSelect="onMenuSelect"
/>
</drawer>
<side-menu <side-menu
:class="[fixedSideBar ? 'fixed-side' : '']" :class="[fixedSideBar ? 'fixed-side' : '']"
:theme="theme.mode" :theme="theme.mode"
v-else-if="layout === 'side' || layout === 'mix'" v-if="layout === 'side' || layout === 'mix'"
:menuData="sideMenuData" :menuData="sideMenuData"
:collapsed="collapsed" :collapsed="collapsed"
:collapsible="true" :collapsible="true"
/> />
<div <div
v-if="fixedSideBar && !isMobile" v-if="fixedSideBar"
:style="`width: ${sideMenuWidth}; min-width: ${sideMenuWidth};max-width: ${sideMenuWidth};`" :style="`width: ${sideMenuWidth}; min-width: ${sideMenuWidth};max-width: ${sideMenuWidth};`"
class="virtual-side" class="virtual-side"
/> />
...@@ -73,7 +63,6 @@ export default { ...@@ -73,7 +63,6 @@ export default {
minHeight: window.innerHeight - 64 - 122, minHeight: window.innerHeight - 64 - 122,
collapsed: false, collapsed: false,
showSetting: false, showSetting: false,
drawerOpen: false,
menuData: [], menuData: [],
firstMenu: [], firstMenu: [],
subMenu: [], subMenu: [],
...@@ -86,18 +75,12 @@ export default { ...@@ -86,18 +75,12 @@ export default {
}; };
}, },
watch: { watch: {
isMobile(val) {
if (!val) {
this.drawerOpen = false;
}
},
layout(layout) { layout(layout) {
this.updateSildeMenu(layout); this.updateSildeMenu(layout);
}, },
}, },
computed: { computed: {
...mapState('settingModule', [ ...mapState('settingModule', [
'isMobile',
'theme', 'theme',
'layout', 'layout',
'footerLinks', 'footerLinks',
...@@ -120,9 +103,7 @@ export default { ...@@ -120,9 +103,7 @@ export default {
}, },
headerStyle() { headerStyle() {
let width = let width =
this.fixedHeader && this.layout !== 'head' && !this.isMobile this.fixedHeader && this.layout !== 'head' ? `calc(100% - ${this.sideMenuWidth})` : '100%';
? `calc(100% - ${this.sideMenuWidth})`
: '100%';
let position = this.fixedHeader ? 'fixed' : 'static'; let position = this.fixedHeader ? 'fixed' : 'static';
return `width: ${width}; position: ${position};`; return `width: ${width}; position: ${position};`;
}, },
...@@ -147,11 +128,11 @@ export default { ...@@ -147,11 +128,11 @@ export default {
updateSildeMenu(layout) { updateSildeMenu(layout) {
if (layout === 'mix') { if (layout === 'mix') {
const { path } = this.$route; const { path } = this.$route;
let currentMenu = this.menuList.find(i => i.menuUrl === path); let currentMenu = this.menuList.find((i) => i.menuUrl === path);
let parentMenuId = currentMenu.parentMenuId; let parentMenuId = currentMenu.parentMenuId;
while (parentMenuId !== 0) { while (parentMenuId !== 0) {
currentMenu = this.menuList.find(i => i.menuId === parentMenuId); currentMenu = this.menuList.find((i) => i.menuId === parentMenuId);
parentMenuId = currentMenu.parentMenuId; parentMenuId = currentMenu.parentMenuId;
} }
this.subMenu = currentMenu.children || []; this.subMenu = currentMenu.children || [];
...@@ -161,7 +142,7 @@ export default { ...@@ -161,7 +142,7 @@ export default {
menuSelect(obj) { menuSelect(obj) {
// 拿到 菜单id // 拿到 菜单id
const menuId = obj.key; const menuId = obj.key;
const currentMenu = this.menuList.find(i => i.menuId === menuId); const currentMenu = this.menuList.find((i) => i.menuId === menuId);
if (currentMenu.menuType === 'MENU') { if (currentMenu.menuType === 'MENU') {
this.subMenu = []; this.subMenu = [];
...@@ -177,7 +158,7 @@ export default { ...@@ -177,7 +158,7 @@ export default {
const menuData = convertListToTree(menuList || [], false, true); const menuData = convertListToTree(menuList || [], false, true);
this.menuData = menuData; this.menuData = menuData;
this.menuList = menuList; this.menuList = menuList;
this.firstMenu = JSON.parse(JSON.stringify(menuData)).map(i => { this.firstMenu = JSON.parse(JSON.stringify(menuData)).map((i) => {
delete i.children; delete i.children;
return i; return i;
}); });
......
...@@ -12,7 +12,6 @@ const customTitles = (customTitlesStr && JSON.parse(customTitlesStr)) || []; ...@@ -12,7 +12,6 @@ const customTitles = (customTitlesStr && JSON.parse(customTitlesStr)) || [];
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
isMobile: false,
animates: globalConfig.animates.preset, animates: globalConfig.animates.preset,
palettes: globalConfig.palettes, palettes: globalConfig.palettes,
pageMinHeight: 0, pageMinHeight: 0,
...@@ -36,7 +35,7 @@ export default { ...@@ -36,7 +35,7 @@ export default {
if (menuData.length > 0 && !menuData[0].fullPath) { if (menuData.length > 0 && !menuData[0].fullPath) {
formatFullPath(menuData); formatFullPath(menuData);
} }
return menuData.map(item => { return menuData.map((item) => {
const menuItem = { ...item }; const menuItem = { ...item };
delete menuItem.children; delete menuItem.children;
return menuItem; return menuItem;
...@@ -44,9 +43,6 @@ export default { ...@@ -44,9 +43,6 @@ export default {
}, },
}, },
mutations: { mutations: {
setDevice(state, isMobile) {
state.isMobile = isMobile;
},
setTheme(state, theme) { setTheme(state, theme) {
state.theme = theme; state.theme = theme;
}, },
...@@ -92,7 +88,7 @@ export default { ...@@ -92,7 +88,7 @@ export default {
}, },
setCustomTitle(state, { path, title }) { setCustomTitle(state, { path, title }) {
if (title) { if (title) {
const obj = state.customTitles.find(item => item.path === path); const obj = state.customTitles.find((item) => item.path === path);
if (obj) { if (obj) {
obj.title = title; obj.title = title;
} else { } else {
......
<template> <template>
<page-layout :desc="desc" :linkList="linkList"> <page-layout :desc="desc" :linkList="linkList">
<div v-if="this.extraImage && !isMobile" slot="extra" :class="$style.extraImg"> <div v-if="extraImage" slot="extra" :class="$style.extraImg">
<img :src="extraImage" /> <img :src="extraImage" />
</div> </div>
<router-view ref="page" /> <router-view ref="page" />
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState('settingModule', ['isMobile', 'multiPage']), ...mapState('settingModule', ['multiPage']),
desc() { desc() {
return this.page?.desc; return this.page?.desc;
}, },
......
<template> <template>
<Wraper :hidden="hidden" noFooter> <Wraper :hidden="hidden" noFooter>
<Table :url="tableUrl" rowKey="taskId" noPadding :buttons="buttons" :scroll="scroll" :width="600"> <Table
:url="tableUrl"
rowKey="taskId"
noPadding
:buttons="buttons"
:scroll="scroll"
:width="600"
ref="table"
>
<template #search="{ query }"> <template #search="{ query }">
<MoreItem label="开始时间"> <MoreItem label="开始时间">
<a-date-picker <a-date-picker
...@@ -99,6 +107,10 @@ ...@@ -99,6 +107,10 @@
</MoreItem> </MoreItem>
</template> </template>
<template #drawer="drawer">
<ViewDetailCom v-bind="drawer" />
</template>
<a-table-column title="巡检项目" data-index="taskName" /> <a-table-column title="巡检项目" data-index="taskName" />
<a-table-column title="参考值" data-index="referenceValue" width="150px" /> <a-table-column title="参考值" data-index="referenceValue" width="150px" />
<a-table-column title="采集数据" data-index="value" width="150px" /> <a-table-column title="采集数据" data-index="value" width="150px" />
...@@ -109,6 +121,7 @@ ...@@ -109,6 +121,7 @@
</Table> </Table>
</Wraper> </Wraper>
</template> </template>
<script> <script>
import Table from '@/components/table/table.vue'; import Table from '@/components/table/table.vue';
import Wraper from '@/components/table/wraper.vue'; import Wraper from '@/components/table/wraper.vue';
...@@ -116,10 +129,12 @@ import UrlSelect from '@/components/MySelect/url_select.vue'; ...@@ -116,10 +129,12 @@ import UrlSelect from '@/components/MySelect/url_select.vue';
import SearchSelect from '@/components/MySelect/search_select.vue'; import SearchSelect from '@/components/MySelect/search_select.vue';
import langUtils from '@/utils/langUtils'; import langUtils from '@/utils/langUtils';
import MoreItem from '@/components/table/more_item.vue'; import MoreItem from '@/components/table/more_item.vue';
import ViewDetailCom from './view_detail.vue';
export default { export default {
props: { hidden: Function, row: Object }, props: { hidden: Function, row: Object },
components: { Table, Wraper, SearchSelect, UrlSelect, MoreItem }, components: { Table, Wraper, SearchSelect, UrlSelect, MoreItem, ViewDetailCom },
data() { data() {
return { return {
scroll: { x: 1200 }, scroll: { x: 1200 },
...@@ -152,6 +167,7 @@ export default { ...@@ -152,6 +167,7 @@ export default {
methods: { methods: {
viewDetail(row) { viewDetail(row) {
console.log(row); console.log(row);
this.$refs.table.show({ row, title: '备注 & 附件' });
}, },
}, },
}; };
......
<template>
<Wraper noFooter :hidden="hidden">
<span>备注:</span>
<div style="min-height: 100px" class="tw-font-medium tw-mt-2">{{ detailData.inspectionRemark }}</div>
<a-tabs>
<!-- Todo -->
<a-tab-pane key="1" tab="图片"></a-tab-pane>
<a-tab-pane key="2" tab="视频"></a-tab-pane>
</a-tabs>
</Wraper>
</template>
<script>
import Wraper from '@/components/table/wraper.vue';
import { getRangerInspectionTaskDetailApi } from '@/api';
export default {
props: { hidden: Function, row: Object },
components: { Wraper },
data() {
return {
detailData: {},
};
},
async mounted() {
this.detailData = await getRangerInspectionTaskDetailApi(this.row.taskId);
console.log(this.detailData);
},
};
</script>
//enquire.js 纯 JavaScript 实现的 CSS 媒体查询库
import enquireJs from "enquire.js";
export function isDef(v) { export function isDef(v) {
return v !== undefined && v !== null; return v !== undefined && v !== null;
} }
...@@ -18,19 +15,7 @@ export function remove(arr, item) { ...@@ -18,19 +15,7 @@ export function remove(arr, item) {
} }
export function isRegExp(v) { export function isRegExp(v) {
return _toString.call(v) === "[object RegExp]"; return _toString.call(v) === '[object RegExp]';
}
export function enquireScreen(call) {
const handler = {
match: function() {
call && call(true);
},
unmatch: function() {
call && call(false);
},
};
enquireJs.register("only screen and (max-width: 767.99px)", handler);
} }
const _toString = Object.prototype.toString; const _toString = Object.prototype.toString;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment