Commit 8136dab8 authored by 陈浩玮's avatar 陈浩玮

设备

parent ed54b020
import { delReq, getReq, postReq, putReq } from '@/utils';
function getOceanusTreeApi(data) {
return getReq('/oceanus/api/v1/categories', data);
}
function addOceanusTreeApi(data) {
return postReq('/oceanus/api/v1/categories', data);
}
export default {
getOceanusTree: getOceanusTreeApi,
addOceanusTree: addOceanusTreeApi,
};
......@@ -3,6 +3,7 @@ export default {
return {
type: 0,
form: {},
title: '',
};
},
computed: {
......@@ -29,7 +30,15 @@ export default {
setData(data, type) {
this.form = { ...data };
this.type = type;
console.log(data, type);
if (type === 0) {
this.title = '新增';
} else if (type === 1) {
this.title = '编辑';
} else if (type === 2) {
this.title = '查看';
} else {
this.title = '';
}
},
},
};
<template>
<Drawer ref="drawerRef" v-model="visible" :title="title">
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm"></a-form-model>
</Drawer>
</template>
<script>
import Drawer from '@/components/table/drawer.vue';
import FormMixin from '@/components/FormMixin';
import Api from '@/api/oceanus';
export default {
components: { Drawer },
props: {
refresh: Function,
},
mixins: [FormMixin],
data() {
return {
visible: false,
form: {},
rules: {
loginId: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
},
Api,
};
},
async mounted() {},
methods: {
open() {
this.form = {};
this.visible = true;
},
async onSubmit() {
this.visible = false;
this.refresh && this.refresh();
},
},
};
</script>
<template>
<a-row :gutter="24">
<a-col :span="8">
<my-card>
<a-row :gutter="[16, 16]">
<a-col :span="24">
<a-input-search
placeholder="input search text"
style="width: 100%"
@search="onSearch"
/>
</a-col>
<a-col :span="24">
<a-button-group>
<a-button type="link" @click="() => view()">新增</a-button>
<a-button type="link">编辑</a-button>
<a-button type="link">删除</a-button>
</a-button-group>
</a-col>
<a-col :span="24">
<a-tree
:showLine="true"
:treeData="treeData"
:replaceFields="replaceFields"
:expandedKeys="expandedKeys"
@select="onSelect"
@expand="onExpand"
/>
</a-col>
</a-row>
<OceanusTreeDrawer ref="OceanusTreeDrawer" />
</my-card>
</a-col>
<a-col :span="16">
<my-card></my-card>
</a-col>
</a-row>
</template>
<script>
import Api from '@/api/oceanus';
import { arrayToTree } from '@/utils';
import OceanusTreeDrawer from './components/OceanusTree.vue';
export default {
components: { OceanusTreeDrawer },
data() {
return {
treeData: [],
replaceFields: { title: 'categoryName', key: 'categoryId', children: 'children' },
selectedKeys: [],
expandedKeys: [],
};
},
async mounted() {
const expandedKeys = [];
const data = await Api.getOceanusTree();
const treeObj = new arrayToTree({
data: data,
rootValue: -1,
parentKey: 'parentCategoryId',
key: 'categoryId',
});
console.log(treeObj);
treeObj.data.map((i) => {
if (i.children) {
expandedKeys.push(i.categoryId);
}
});
this.treeData = treeObj.treeData;
this.expandedKeys = expandedKeys;
},
methods: {
onSearch(val) {},
onSelect(selectedKeys, info) {
console.log('selected', selectedKeys, info);
},
onExpand(expandedKeys) {
this.expandedKeys = expandedKeys;
},
async view(data = {}, type = 0) {
this.$refs['OceanusTreeDrawer']?.open();
this.$nextTick(() => {
this.$refs['OceanusTreeDrawer'].setData({ ...data }, type);
});
},
},
};
</script>
<style scoped>
</style>
<template>
<div>equipment</div>
</template>
<script>
export default {};
</script>
......@@ -37,9 +37,13 @@ export default {
};
},
async mounted() {
this.rawData = await api.getOrganizationList();
const rawData = await api.getOrganizationList();
const newData = rawData.map((i) => ({
...i,
selectable: i.orgType === 'DEPARTMENT',
}));
const newArr = new arrayToTree({
data: this.rawData,
data: newData,
rootValue: 0,
parentKey: 'parentOrgId',
key: 'orgId',
......
......@@ -52,8 +52,13 @@ export default {
});
},
formatData(data) {
const newData = data.map((i) => ({
...i,
selectable: i.orgType === 'DEPARTMENT',
}));
const newArr = new arrayToTree({
data: data,
data: newData,
rootValue: 0,
parentKey: 'parentOrgId',
key: 'orgId',
......
......@@ -143,6 +143,26 @@ const hasAuthorityRoutes = [
},
],
},
{
path: 'oceanus',
name: '设备管理',
meta: {
icon: 'control',
},
component: PageTemplateView,
children: [
{
path: 'category',
name: '分类配置',
component: () => import('@/pages/oceanus/category/index.vue'),
},
{
path: 'equipment',
name: '设备台账',
component: () => import('@/pages/oceanus/equipment/index.vue'),
},
],
},
{
path: 'user',
name: '个人中心',
......
......@@ -85,7 +85,6 @@ export function arrayToTree(options) {
const THISDATA = JSON.parse(JSON.stringify(this.data));
for (let i = 0; i < this.data.length; i++) {
let currentElement = this.data[i];
currentElement.selectable = currentElement.orgType === 'DEPARTMENT';
let tempCurrentElementParent = this.indexStorage[currentElement[this.parentKey]]; // 临时变量里面的当前元素的父元素
if (tempCurrentElementParent) {
// 如果存在父元素
......
......@@ -11,6 +11,8 @@ axios.defaults.withCredentials = true;
axios.defaults.xsrfHeaderName = xsrfHeaderName;
axios.defaults.xsrfCookieName = xsrfHeaderName;
axios.defaults.baseURL = '/api';
/**
* @param {*} info 提示函数
*/
......
......@@ -193,14 +193,14 @@ const assetsCDN = {
module.exports = {
devServer: {
proxy: {
'/api': {
'/api/': {
//此处要与 /services/api.js 中的 API_PROXY_PREFIX 值保持一致
// target: process.env.VUE_APP_API_BASE_URL,
target: 'http://platform.kuopu.net:9300',
changeOrigin: true,
// pathRewrite: {
// '^/api': ''
// }
pathRewrite: {
'^/api/': '',
},
},
},
},
......
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