desc: 调整代码
This commit is contained in:
parent
850f492b45
commit
443051edc3
@ -25,7 +25,7 @@ export function checkCodeExist(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取产品类目数*/
|
||||
/** 获取产品树*/
|
||||
export function getProductTree() {
|
||||
return request({
|
||||
url: `/api/mapPrd/tree`,
|
||||
|
@ -21,11 +21,11 @@ import Errpr404 from '@/views/error-page/404';
|
||||
|
||||
import SkinCode from '@/views/system/skinCode/index';
|
||||
import SkinCodeDraft from '@/views/system/skinCode/draft';
|
||||
import MapProduct from '@/views/system/product/index';
|
||||
|
||||
import Mapdraft from '@/views/map/mapdraft/index';
|
||||
// import Mapdraft from '@/views/map/mapdraft/index';
|
||||
import Mapedit from '@/views/map/mapdraft/mapedit/index';
|
||||
import Runplan from '@/views/map/runplan/index';
|
||||
import MapProduct from '@/views/map/product/index';
|
||||
// import Runplan from '@/views/map/runplan/index';
|
||||
import RunplanView from '@/views/map/runplan/chart';
|
||||
|
||||
import Trainingrecord from '@/views/lesson/trainingrecord/index';
|
||||
@ -54,22 +54,23 @@ import PublishExamRule from '@/views/publish/examRule/index';
|
||||
import PublishExamRuleDraft from '@/views/publish/examRule/draft/index';
|
||||
|
||||
import DemonstrationDetail from '@/views/demonstration/detail/index';
|
||||
import ScreenMonitor from '@/views/screenMonitor/index';
|
||||
import ScreenMonitorHome from '@/views/screenMonitor/home';
|
||||
import ScreenMonitorDetail from '@/views/screenMonitor/detail/index';
|
||||
// import ScreenMonitor from '@/views/screenMonitor/index';
|
||||
// import ScreenMonitorHome from '@/views/screenMonitor/home';
|
||||
// import ScreenMonitorDetail from '@/views/screenMonitor/detail/index';
|
||||
|
||||
import PlanMonitorEditTool from '@/views/planMonitor/editTool/index';
|
||||
import PlanMonitorEditUserTool from '@/views/planMonitor/editTool/userindex';
|
||||
import PlanMonitor from '@/views/planMonitor/index';
|
||||
import PlanMonitorHome from '@/views/planMonitor/home';
|
||||
// import PlanMonitor from '@/views/planMonitor/index';
|
||||
// import PlanMonitorHome from '@/views/planMonitor/home';
|
||||
import PlanMonitorDetail from '@/views/planMonitor/detail';
|
||||
|
||||
import DesignPlatformHome from '@/views/designPlatform/home';
|
||||
import DesignPlatform from '@/views/designPlatform/index';
|
||||
import DesignPlatformUser from '@/views/designPlatform/userIndex';
|
||||
import MapPreview from '@/views/designPlatform/mapPreview';
|
||||
|
||||
import Replay from '@/views/replay/index';
|
||||
import DesignPlatformUser from '@/views/designUser/index';
|
||||
|
||||
// import Replay from '@/views/replay/index';
|
||||
import Package from '@/views/package/index';
|
||||
import PackageDraft from '@/views/package/draft/ruleForm';
|
||||
import PackageDetail from '@/views/package/detail';
|
||||
@ -321,7 +322,7 @@ export const constantRoutes = [
|
||||
];
|
||||
|
||||
export const asyncRouter = [
|
||||
{
|
||||
{ // 公共地图
|
||||
path: '/design',
|
||||
component: Layout,
|
||||
redirect: '/design/home',
|
||||
@ -424,7 +425,7 @@ export const asyncRouter = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
{ // 个人地图
|
||||
path: '/design/userlist',
|
||||
redirect: '/design/userlist/home',
|
||||
component: Layout,
|
||||
@ -484,7 +485,7 @@ export const asyncRouter = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
{ // 全屏战场图
|
||||
path: '/display/:mode',
|
||||
component: Display,
|
||||
meta: {
|
||||
@ -505,7 +506,7 @@ export const asyncRouter = [
|
||||
},
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
{ // 综合演练室
|
||||
path: '/trainroom',
|
||||
component: TrainRoom,
|
||||
meta: {
|
||||
@ -685,67 +686,67 @@ export const asyncRouter = [
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
{ // 运行图编辑
|
||||
path: '/plan/usertool',
|
||||
component: PlanMonitorEditUserTool,
|
||||
meta: {
|
||||
},
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
{ // 运行图编辑
|
||||
path: '/plan/tool',
|
||||
component: PlanMonitorEditTool,
|
||||
meta: {
|
||||
},
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/plan',
|
||||
redirect: '/plan/home',
|
||||
component: PlanMonitor,
|
||||
hidden: true,
|
||||
meta: {
|
||||
roles: [admin, user, userDesign]
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'home',
|
||||
component: PlanMonitorHome,
|
||||
meta: {
|
||||
i18n: 'router.planSystem'
|
||||
},
|
||||
target: true
|
||||
},
|
||||
{
|
||||
path: 'detail/:lessonId',
|
||||
component: PlanMonitorDetail,
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: 'pay/:lessonId',
|
||||
component: Pay,
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/replay',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
meta: {
|
||||
roles: [admin, userDesign]
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'manage',
|
||||
component: Replay,
|
||||
meta: {
|
||||
i18n: 'router.replayManage'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// { // 琏计划
|
||||
// path: '/plan',
|
||||
// redirect: '/plan/home',
|
||||
// component: PlanMonitor,
|
||||
// hidden: true,
|
||||
// meta: {
|
||||
// roles: [admin, user, userDesign]
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// path: 'home',
|
||||
// component: PlanMonitorHome,
|
||||
// meta: {
|
||||
// i18n: 'router.planSystem'
|
||||
// },
|
||||
// target: true
|
||||
// },
|
||||
// {
|
||||
// path: 'detail/:lessonId',
|
||||
// component: PlanMonitorDetail,
|
||||
// hidden: true
|
||||
// },
|
||||
// {
|
||||
// path: 'pay/:lessonId',
|
||||
// component: Pay,
|
||||
// hidden: true
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// path: '/replay',
|
||||
// component: Layout,
|
||||
// hidden: true,
|
||||
// meta: {
|
||||
// roles: [admin, userDesign]
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// path: 'manage',
|
||||
// component: Replay,
|
||||
// meta: {
|
||||
// i18n: 'router.replayManage'
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{ // 发布内容管理
|
||||
path: '/publish',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@ -829,7 +830,7 @@ export const asyncRouter = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
{ // 订单权限管理
|
||||
path: '/orderauthor',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@ -921,7 +922,7 @@ export const asyncRouter = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
{ // 系统管理
|
||||
path: '/system',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@ -1037,7 +1038,7 @@ export const asyncRouter = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
{ // 发布申请
|
||||
path: '/apply',
|
||||
component: Layout,
|
||||
meta: {
|
||||
|
@ -3,10 +3,10 @@ export function getBaseUrl() {
|
||||
let BASE_API;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// BASE_API = 'https://joylink.club/jlcloud';
|
||||
// BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
||||
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
||||
BASE_API = 'http://192.168.3.41:9000'; // 王兴杰
|
||||
// BASE_API = 'http://192.168.3.41:9000'; // 王兴杰
|
||||
} else {
|
||||
BASE_API = process.env.VUE_APP_BASE_API;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.currentWidth=this.$store.state.app.width - this.widthLeft;
|
||||
this.currentWidth = this.$store.state.app.width - this.widthLeft;
|
||||
const againEnter = getSessionStorage('againEnter') || null;
|
||||
if (!againEnter) {
|
||||
launchFullscreen();
|
||||
@ -76,7 +76,7 @@ export default {
|
||||
this.$store.dispatch('config/resize', { width: width });
|
||||
},
|
||||
setMapResize(LeftWidth) {
|
||||
this.currentWidth=this.$store.state.app.width - this.widthLeft;
|
||||
this.currentWidth = this.$store.state.app.width - this.widthLeft;
|
||||
const widths = this.$store.state.app.width - 521 - LeftWidth;
|
||||
// const heights = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: widths });
|
||||
|
@ -32,7 +32,7 @@ export default {
|
||||
return this.$route.params.mapId;
|
||||
},
|
||||
height() {
|
||||
return this.$store.state.app.height - 50-30;
|
||||
return this.$store.state.app.height - 50 - 30;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
},
|
||||
setWindowSize() {
|
||||
this.$nextTick(() => {
|
||||
const width = this.$store.state.app.width-(this.widthLeft||450);
|
||||
const width = this.$store.state.app.width - (this.widthLeft || 450);
|
||||
const height = this.height;
|
||||
this.$store.dispatch('config/resize', { width, height });
|
||||
// this.$store.dispatch('training/updateOffsetStationCode', { offsetStationCode: this.offsetStationCode });
|
||||
|
@ -1,136 +0,0 @@
|
||||
<template>
|
||||
<div class="app-wrapper" style="height: 100%;">
|
||||
<map-create ref="mapCreate" :skin-code="skinCode" @refresh="refresh1" @editmap="handleNodeClick" />
|
||||
<div v-show="listShow" class="examList" :style="{width: widthLeft+'px'}">
|
||||
<demon-list ref="demonList" :width="widthLeft" @createMap="createMap" />
|
||||
</div>
|
||||
<drap-left :width-left="widthLeft" @drapWidth="drapWidth" />
|
||||
<transition>
|
||||
<router-view :product-list="productList" />
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import demonList from './userDemonList';
|
||||
import drapLeft from '@/views/components/drapLeft/index';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import localStore from 'storejs';
|
||||
import { getSessionStorage, setSessionStorage } from '@/utils/auth';
|
||||
import MapCreate from '@/views/map/mapdraft/mapmanage/create';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
|
||||
export default {
|
||||
name: 'DesignPlatform',
|
||||
components: {
|
||||
demonList,
|
||||
drapLeft,
|
||||
MapCreate
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
listShow: true,
|
||||
widthLeft: Number(localStore.get('LeftWidth')) || 450,
|
||||
productList: [],
|
||||
skinCode: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'lessonbar'
|
||||
]),
|
||||
width() {
|
||||
return this.$store.state.app.width;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'lessonbar.opened': function (val) {
|
||||
this.listShow = val;
|
||||
},
|
||||
widthLeft(val) {
|
||||
this.setMapResize(val);
|
||||
},
|
||||
'$store.state.app.windowSizeCount': function() {
|
||||
this.resize();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const againEnter = getSessionStorage('againEnter') || null;
|
||||
if (!againEnter) {
|
||||
launchFullscreen();
|
||||
setSessionStorage('againEnter', true);
|
||||
}
|
||||
this.resize();
|
||||
this.widthLeft = Number(localStore.get('LeftWidth'));
|
||||
},
|
||||
methods: {
|
||||
refresh() {
|
||||
this.$refs && this.$refs.demonList && this.$refs.demonList.loadInitData();
|
||||
},
|
||||
drapWidth(width) {
|
||||
this.widthLeft = Number(width);
|
||||
},
|
||||
|
||||
createMap() {
|
||||
this.$refs.mapCreate.show();
|
||||
},
|
||||
|
||||
refresh1() {
|
||||
this.$refs.demonList.loadInitData();
|
||||
},
|
||||
|
||||
getSkinCode(node) {
|
||||
let next = node;
|
||||
while (next) {
|
||||
if (next.data && next.data.type == 'skin') {
|
||||
this.skinCode = next.data.id;
|
||||
break;
|
||||
}
|
||||
next = next.parent;
|
||||
}
|
||||
},
|
||||
handleNodeClick(obj, node) {
|
||||
this.getSkinCode(node);
|
||||
if (obj && obj.type == 'map') {
|
||||
this.editModel = obj;
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.mapSelected({ view: 'draft' });
|
||||
}
|
||||
},
|
||||
mapSelected(data) {
|
||||
if (data && this.editModel) {
|
||||
this.$router.push({ path: `${UrlConfig.map.draft}/${this.editModel.id}/${data.view}`, query: { name: this.editModel.name } });
|
||||
}
|
||||
},
|
||||
resize() {
|
||||
this.widthLeft = Number(localStore.get('LeftWidth')) || this.widthLeft;
|
||||
const width = this.$store.state.app.width - 521 - this.widthLeft;
|
||||
const height = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: width, height: height });
|
||||
},
|
||||
setMapResize(LeftWidth) {
|
||||
const widths = this.$store.state.app.width - 521 - LeftWidth;
|
||||
const heights = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: widths, height: heights });
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.app-wrapper {
|
||||
@include clearfix;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.examList {
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
136
src/views/designUser/index.vue
Normal file
136
src/views/designUser/index.vue
Normal file
@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div class="app-wrapper" style="height: 100%;">
|
||||
<map-create ref="mapCreate" :skin-code="skinCode" @refresh="refresh1" @editmap="handleNodeClick" />
|
||||
<div v-show="listShow" class="examList" :style="{width: widthLeft+'px'}">
|
||||
<demon-list ref="demonList" :width="widthLeft" @createMap="createMap" />
|
||||
</div>
|
||||
<drap-left :width-left="widthLeft" @drapWidth="drapWidth" />
|
||||
<transition>
|
||||
<router-view :product-list="productList" />
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import demonList from './demonList';
|
||||
import drapLeft from '@/views/components/drapLeft/index';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import localStore from 'storejs';
|
||||
import { getSessionStorage, setSessionStorage } from '@/utils/auth';
|
||||
import MapCreate from '@/views/map/mapdraft/mapmanage/create';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
|
||||
export default {
|
||||
name: 'DesignPlatform',
|
||||
components: {
|
||||
demonList,
|
||||
drapLeft,
|
||||
MapCreate
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
listShow: true,
|
||||
widthLeft: Number(localStore.get('LeftWidth')) || 450,
|
||||
productList: [],
|
||||
skinCode: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'lessonbar'
|
||||
]),
|
||||
width() {
|
||||
return this.$store.state.app.width;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'lessonbar.opened': function (val) {
|
||||
this.listShow = val;
|
||||
},
|
||||
widthLeft(val) {
|
||||
this.setMapResize(val);
|
||||
},
|
||||
'$store.state.app.windowSizeCount': function() {
|
||||
this.resize();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const againEnter = getSessionStorage('againEnter') || null;
|
||||
if (!againEnter) {
|
||||
launchFullscreen();
|
||||
setSessionStorage('againEnter', true);
|
||||
}
|
||||
this.resize();
|
||||
this.widthLeft = Number(localStore.get('LeftWidth'));
|
||||
},
|
||||
methods: {
|
||||
refresh() {
|
||||
this.$refs && this.$refs.demonList && this.$refs.demonList.loadInitData();
|
||||
},
|
||||
drapWidth(width) {
|
||||
this.widthLeft = Number(width);
|
||||
},
|
||||
|
||||
createMap() {
|
||||
this.$refs.mapCreate.show();
|
||||
},
|
||||
|
||||
refresh1() {
|
||||
this.$refs.demonList.loadInitData();
|
||||
},
|
||||
|
||||
getSkinCode(node) {
|
||||
let next = node;
|
||||
while (next) {
|
||||
if (next.data && next.data.type == 'skin') {
|
||||
this.skinCode = next.data.id;
|
||||
break;
|
||||
}
|
||||
next = next.parent;
|
||||
}
|
||||
},
|
||||
handleNodeClick(obj, node) {
|
||||
this.getSkinCode(node);
|
||||
if (obj && obj.type == 'map') {
|
||||
this.editModel = obj;
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.mapSelected({ view: 'draft' });
|
||||
}
|
||||
},
|
||||
mapSelected(data) {
|
||||
if (data && this.editModel) {
|
||||
this.$router.push({ path: `${UrlConfig.map.draft}/${this.editModel.id}/${data.view}`, query: { name: this.editModel.name } });
|
||||
}
|
||||
},
|
||||
resize() {
|
||||
this.widthLeft = Number(localStore.get('LeftWidth')) || this.widthLeft;
|
||||
const width = this.$store.state.app.width - 521 - this.widthLeft;
|
||||
const height = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: width, height: height });
|
||||
},
|
||||
setMapResize(LeftWidth) {
|
||||
const widths = this.$store.state.app.width - 521 - LeftWidth;
|
||||
const heights = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: widths, height: heights });
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.app-wrapper {
|
||||
@include clearfix;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.examList {
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
@ -76,13 +76,13 @@ import { mapGetters } from 'vuex';
|
||||
import { getTrainingDetail, getTrainingStepsDetail } from '@/api/jmap/training';
|
||||
import { setGoodsTryUse } from '@/api/management/goods';
|
||||
import { getProductDetail } from '@/api/management/mapprd';
|
||||
import { runDiagramQuit, loadScript, getSimulationInfo } from '@/api/simulation';
|
||||
import { runDiagramQuit, getSimulationInfo } from '@/api/simulation';
|
||||
import { OperateMode, TrainingMode } from '@/scripts/ConstDic';
|
||||
import { checkLoginLine } from '@/api/login';
|
||||
import { loadMapData, loadMapDataById } from '@/utils/loaddata';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
import Vue from 'vue';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
// import { UrlConfig } from '@/router/index';
|
||||
import {loadDraftScript} from '@/api/designPlatform';
|
||||
|
||||
// 三维
|
||||
@ -227,8 +227,8 @@ export default {
|
||||
},
|
||||
'$store.state.training.prdType': function(val) {
|
||||
// this.prdType=val;
|
||||
this.isDrive=(val == '04');
|
||||
this.isShowScheduling=(val == '05');
|
||||
this.isDrive = (val == '04');
|
||||
this.isShowScheduling = (val == '05');
|
||||
},
|
||||
'$store.state.socket.permissionOver': function () {
|
||||
this.$alert('用户权限已被收回', '提示', {
|
||||
@ -482,37 +482,37 @@ export default {
|
||||
async runAddRolesLoadShow() {
|
||||
// this.$refs.addQuest.doShow();
|
||||
// const row={id: this.$route.query.scriptId};
|
||||
const row={group: this.$route.query.group,id: this.$route.query.scriptId};
|
||||
const row = {group: this.$route.query.group, id: this.$route.query.scriptId};
|
||||
this.$refs.addQuest.handleLoad(1, row);
|
||||
},
|
||||
// 选择脚本
|
||||
async selectQuest(row, id, mapLocation, roleName) {
|
||||
try {
|
||||
let prdType='';
|
||||
let prdType = '';
|
||||
switch (roleName) {
|
||||
case 'Attendant': {
|
||||
prdType='01';
|
||||
prdType = '01';
|
||||
break;
|
||||
}
|
||||
case 'Dispatcher': {
|
||||
prdType='02';
|
||||
prdType = '02';
|
||||
break;
|
||||
}
|
||||
case 'Driver': {
|
||||
prdType='04';
|
||||
prdType = '04';
|
||||
break;
|
||||
}
|
||||
case 'Repair': {
|
||||
prdType='';
|
||||
prdType = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.switchMode(prdType);
|
||||
const res = await loadDraftScript(row.id,id, this.group);
|
||||
const res = await loadDraftScript(row.id, id, this.group);
|
||||
if (res && res.code == 200) {
|
||||
this.questId = parseInt(row.id);
|
||||
if (mapLocation) {
|
||||
const newMapLocation={'offsetX': mapLocation.x, 'offsetY': mapLocation.y, 'scaleRate': mapLocation.scale};
|
||||
const newMapLocation = {'offsetX': mapLocation.x, 'offsetY': mapLocation.y, 'scaleRate': mapLocation.scale};
|
||||
Vue.prototype.$jlmap.setOptions(newMapLocation);
|
||||
}
|
||||
// if (res.data && res.data.mapLocation) {
|
||||
|
@ -1,69 +0,0 @@
|
||||
<template>
|
||||
<div id="mapMain" class="mapDraft">
|
||||
<div class="map-list" :style="{width: widthLeft+'px'}">
|
||||
<map-list-operation ref="mapListOperation" />
|
||||
</div>
|
||||
<drap-left :width-left="widthLeft" @drapWidth="drapWidth" />
|
||||
<transition>
|
||||
<router-view />
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import MapListOperation from './mapmanage/maplist';
|
||||
import localStore from 'storejs';
|
||||
import DrapLeft from '@/views/components/drapLeft/index';
|
||||
|
||||
export default {
|
||||
name: 'MapDraft',
|
||||
components: {
|
||||
MapListOperation,
|
||||
DrapLeft
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
widthLeft: 320
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
widthLeft(val) {
|
||||
this.setMapResize(val);
|
||||
},
|
||||
'$store.state.app.windowSizeCount': function() {
|
||||
this.resize();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('training/setPrdType', null);
|
||||
this.resize();
|
||||
},
|
||||
methods: {
|
||||
drapWidth(width) {
|
||||
this.widthLeft = Number(width);
|
||||
},
|
||||
resize() {
|
||||
this.widthLeft = Number(localStore.get('LeftWidth')) || this.widthLeft;
|
||||
const width = this.$store.state.app.width - 521 - this.widthLeft;
|
||||
const height = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: width, height: height });
|
||||
},
|
||||
setMapResize(LeftWidth) {
|
||||
const widths = this.$store.state.app.width - 521 - LeftWidth;
|
||||
const heights = this.$store.state.app.height - 90;
|
||||
this.$store.dispatch('config/resize', { width: widths, height: heights });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.mapDraft {
|
||||
overflow: hidden;
|
||||
|
||||
.map-list {
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -81,7 +81,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
cardHeight() {
|
||||
return this.$store.state.app.height - 195-30;
|
||||
return this.$store.state.app.height - 195 - 30;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -1,361 +0,0 @@
|
||||
<template>
|
||||
<el-card v-loading="loading" class="map-list-main">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>{{ $t('map.sketchMap') }}</span>
|
||||
<el-button type="text" style="float: right; padding: 3px 0" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
|
||||
<el-button type="text" class="uploadDemo">
|
||||
<!-- <input
|
||||
ref="files"
|
||||
type="file"
|
||||
class="file_box"
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
@change="importf"
|
||||
> -->
|
||||
<input
|
||||
ref="files"
|
||||
type="file"
|
||||
class="file_box"
|
||||
accept=".json, application/json"
|
||||
@change="importf"
|
||||
>
|
||||
{{ $t('map.importMap') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: height + 'px'}">
|
||||
<el-tree
|
||||
ref="tree"
|
||||
:data="mapList"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
:props="defaultProps"
|
||||
class="tree-height-max"
|
||||
@node-click="handleNodeClick"
|
||||
@node-contextmenu="showContextMenu"
|
||||
>
|
||||
<span slot-scope="{ node }">
|
||||
<span v-if="node.data.type == 'skin'" class="el-icon-news"></span>
|
||||
<span v-if="node.data.type == 'map'" class="el-icon-edit-outline"></span>
|
||||
<span> {{ node.label }}</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</el-scrollbar>
|
||||
<map-create ref="mapCreate" :skin-code="skinCode" @refresh="refresh" @editmap="handleNodeClick" />
|
||||
<map-operate-menu
|
||||
ref="menu"
|
||||
:point="point"
|
||||
:edit-model="editModel"
|
||||
:skin-code="skinCode"
|
||||
@refresh="refresh"
|
||||
@jlmap3d="jlmap3d"
|
||||
/>
|
||||
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { DeviceMenu } from '@/scripts/ConstDic';
|
||||
import { getMapTree, getMapDetail, postBuildMapImport } from '@/api/jmap/mapdraft';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { translate, translateSheetTitle } from '@/scripts/translate';
|
||||
// import { sheet_to_json } from '@/utils/Export2Excel';
|
||||
// import PopMenu from '@/components/PopMenu';
|
||||
import MapOperateMenu from './operateMenu';
|
||||
import MapCreate from './create';
|
||||
// import XLSX from 'xlsx';
|
||||
|
||||
export default {
|
||||
name: 'MapListDraft',
|
||||
components: {
|
||||
MapCreate,
|
||||
MapOperateMenu
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
activeName: 'first',
|
||||
mapList: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
editModel: {},
|
||||
skinCode: '',
|
||||
point: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
height() {
|
||||
return this.$store.state.app.height - 115;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.refresh();
|
||||
},
|
||||
methods: {
|
||||
getSkinCode(node) {
|
||||
let next = node;
|
||||
while (next) {
|
||||
if (next.data && next.data.type == 'skin') {
|
||||
this.skinCode = next.data.id;
|
||||
break;
|
||||
}
|
||||
next = next.parent;
|
||||
}
|
||||
},
|
||||
showContextMenu(e, obj, node, vueElem) {
|
||||
if (obj && obj.type == 'map') {
|
||||
e.preventDefault();
|
||||
const menu = DeviceMenu.Map;
|
||||
|
||||
this.point = {
|
||||
x: e.clientX,
|
||||
y: e.clientY
|
||||
};
|
||||
this.editModel = obj;
|
||||
this.editModel.skinCode = node.parent.data.id;
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
|
||||
}
|
||||
},
|
||||
handleNodeClick(obj, node) {
|
||||
this.getSkinCode(node);
|
||||
if (obj && obj.type == 'map') {
|
||||
this.editModel = obj;
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.mapSelected({ view: 'draft' });
|
||||
}
|
||||
},
|
||||
mapSelected(data) {
|
||||
if (data && this.editModel) {
|
||||
this.$router.push({ path: `${UrlConfig.map.draft}/${this.editModel.id}/${data.view}`, query: { name: this.editModel.name } });
|
||||
}
|
||||
},
|
||||
jlmap3d() {
|
||||
this.$router.push({ path: '/jlmap3d/edit', query: { mapid: this.editModel.id } });
|
||||
},
|
||||
createMap() {
|
||||
this.$refs.mapCreate.show();
|
||||
},
|
||||
refresh() {
|
||||
this.mapList = [];
|
||||
this.loading = true;
|
||||
getMapTree().then(response => {
|
||||
this.loading = false;
|
||||
this.mapList = response.data;
|
||||
this.$refs.tree.setCurrentKey(this.$route.params.mapId); // value 绑定的node-key
|
||||
}).catch(() => {
|
||||
this.$messageBox('刷新树级列表失败');
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
importf() {
|
||||
// const loading = this.$loading({
|
||||
// lock: true,
|
||||
// text: '正在导入中...',
|
||||
// spinner: 'el-icon-loading',
|
||||
// background: 'rgba(0, 0, 0, 0.7)'
|
||||
// });
|
||||
// const obj = this.$refs.files;
|
||||
// let wb;
|
||||
// if (!obj.files) return;
|
||||
// const f = obj.files[0];
|
||||
// const reader = new FileReader();
|
||||
// const that = this;
|
||||
// reader.onload = function (e) {
|
||||
// const data = e.target.result;
|
||||
// if (that.rABS) {
|
||||
// wb = XLSX.read(btoa(that.fixdata(data)), {// 手动转化
|
||||
// type: 'base64'
|
||||
// });
|
||||
// } else {
|
||||
// wb = XLSX.read(data, {
|
||||
// type: 'binary'
|
||||
// });
|
||||
// }
|
||||
// const resultJSONData = { 'devices': {} };
|
||||
// for (const index in wb.Sheets) {
|
||||
|
||||
// const titleNum = that.formatSheetTitle(index);
|
||||
// const key = translateSheetTitle.sheetName[titleNum];
|
||||
|
||||
// const filterVal = that.handelData(key);
|
||||
// const jsonData = sheet_to_json(wb.Sheets[index]);
|
||||
// const data = that.formatJson(filterVal, jsonData, key);
|
||||
// if (key === 'base') {
|
||||
// Object.assign(resultJSONData, data[0]);
|
||||
// } else if (key === 'skinVO') {
|
||||
// resultJSONData['devices'][key] = data[0];
|
||||
// } else {
|
||||
// resultJSONData['devices'][key] = data;
|
||||
// }
|
||||
// }
|
||||
// that.resultJSON = resultJSONData;
|
||||
// if (that.resultJSON) {
|
||||
// postBuildMapImport(that.resultJSON).then(res => {
|
||||
// loading.close();
|
||||
// that.$message.success('导入成功!');
|
||||
// that.refresh();
|
||||
// }).catch(error => {
|
||||
// loading.close();
|
||||
// that.$message.error('导入失败' + error.message);
|
||||
// });
|
||||
// }
|
||||
// obj.value = ''; // 清空上次导入文件
|
||||
// };
|
||||
// if (that.rABS) {
|
||||
// reader.readAsArrayBuffer(f);
|
||||
// } else {
|
||||
// reader.readAsBinaryString(f);
|
||||
// }
|
||||
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在导入中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
setTimeout(() => {
|
||||
const obj = this.$refs.files;
|
||||
if (!obj.files) return;
|
||||
const f = obj.files[0];
|
||||
const reader = new FileReader();
|
||||
const that = this;
|
||||
reader.readAsText(f, 'utf-8');
|
||||
reader.onload = function(e) {
|
||||
const data = e.target.result;
|
||||
postBuildMapImport(JSON.parse(data)).then(res => {
|
||||
loading.close();
|
||||
that.$message.success('导入成功!');
|
||||
that.refresh();
|
||||
loading.close();
|
||||
}).catch(error => {
|
||||
loading.close();
|
||||
that.$message.error('导入失败' + error.message);
|
||||
});
|
||||
obj.value = '';
|
||||
};
|
||||
});
|
||||
|
||||
},
|
||||
// 转换数据格式
|
||||
handelData(key) {
|
||||
const tHeader = [];
|
||||
const tHeaderF = [];
|
||||
if (translate[key]) {
|
||||
translate[key].columns.forEach(item => {
|
||||
tHeader.push(item.tHeader);
|
||||
tHeaderF.push(item.key);
|
||||
});
|
||||
}
|
||||
const filterVal = {
|
||||
tHeader: tHeader,
|
||||
tHeaderF: tHeaderF
|
||||
};
|
||||
return filterVal;
|
||||
},
|
||||
// 文件流转BinaryString
|
||||
fixdata(data) {
|
||||
var o = '';
|
||||
var l = 0;
|
||||
var w = 10240;
|
||||
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
|
||||
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
|
||||
return o;
|
||||
},
|
||||
// 转换属性名称 格式
|
||||
formatJson(filterVal, jsonData, key) {
|
||||
jsonData.map((item, index) => {
|
||||
const json = {};
|
||||
filterVal.tHeader.map((j, o) => {
|
||||
if (item[j] != undefined) {
|
||||
json[filterVal.tHeaderF[o]] = translate[key].columns[o].formatter(item[j]);
|
||||
}
|
||||
});
|
||||
jsonData.splice(index, 1, json);
|
||||
});
|
||||
return jsonData;
|
||||
},
|
||||
// 转换sheet名字
|
||||
formatSheetTitle(title) {
|
||||
let index;
|
||||
translateSheetTitle.sheetTitle.forEach((v, i) => {
|
||||
if (title == v) index = i;
|
||||
});
|
||||
return index;
|
||||
},
|
||||
|
||||
// 前端方式导出
|
||||
async doExportFront() {
|
||||
const res = await getMapDetail(this.$route.params.mapId);
|
||||
const resultData = res.data;
|
||||
if (resultData === false) {
|
||||
return;
|
||||
}
|
||||
const self = this;
|
||||
import('@/utils/Export2Excel').then(excel => {
|
||||
self.queryExportData(resultData).then(data => {
|
||||
excel.export_json_excel(data, resultData.name);
|
||||
}).catch(error => {
|
||||
self.$message.error('导出执行异常:' + error.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 格式化数据列表
|
||||
queryExportData(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = {
|
||||
base: []
|
||||
};
|
||||
const obj = {};
|
||||
for (const i in data) {
|
||||
if (typeof data[i] != 'object') {
|
||||
obj[i] = data[i];
|
||||
} else if (data[i] instanceof Array) {
|
||||
if (data[i].length) {
|
||||
result[i] = [...data[i]];
|
||||
}
|
||||
} else if (data[i] instanceof Object) {
|
||||
obj[i] = data[i];
|
||||
}
|
||||
}
|
||||
result.base.push(obj);
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped rel="stylesheet/scss" lang="scss">
|
||||
.uploadDemo {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
float: right;
|
||||
padding: 3px 0;
|
||||
margin-right: 3px;
|
||||
cursor: pointer;
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.el-tree {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.el-card__body {
|
||||
padding: 0px;
|
||||
}
|
||||
.el-tree-node.is-current>.el-tree-node__content {
|
||||
background-color: #e4e3e3 !important;
|
||||
}
|
||||
</style>
|
@ -1,312 +0,0 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="card-box">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step :title="title" icon="el-icon-edit-outline" />
|
||||
<el-step title="" icon="el-icon-upload" />
|
||||
</el-steps>
|
||||
<el-card class="forms">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{height:height -120 + 'px'}" style="padding-top: 40px">
|
||||
<el-form ref="form" :model="addModel" label-width="140px">
|
||||
<el-form-item :label="$t('map.skinStyleColon')" prop="mapName">
|
||||
<el-input v-model="addModel.mapName" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productType') + ':'" prop="prdType">
|
||||
<el-radio-group v-model="addModel.prdType" :disabled="isUpdate">
|
||||
<template v-for="item in chooseList">
|
||||
<el-radio-button :key="item.code" :label="item.code">{{ item.name }}</el-radio-button>
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('map.productCode') + ':'"
|
||||
prop="code"
|
||||
:rules="node && node.data.type ==='skin' ? baseRules.code:{}"
|
||||
>
|
||||
<el-input v-model="addModel.code" :disabled="codeDisabled" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productName') + ':'" prop="name" :rules="baseRules.name">
|
||||
<el-input v-model="addModel.name" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="isShowTrainTypes"
|
||||
:label="$t('map.associateTrainingTypes') + ':'"
|
||||
prop="trainTypes"
|
||||
:rules="baseRules.trainTypes"
|
||||
>
|
||||
<el-select v-model="addModel.trainTypes" multiple :placeholder="$t('map.pleaseSelect')" @change="trainTypesChange">
|
||||
<el-option
|
||||
v-for="item in trainTypesList"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productDescription') + ':'" prop="remarks" :rules="baseRules.remarks">
|
||||
<el-input v-model="addModel.remarks" type="textarea" :rows="4" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button v-if="isCreate" type="primary" @click="create">{{ $t('map.create') }}</el-button>
|
||||
<el-button v-if="isUpdate" type="primary" @click="update">{{ $t('map.updata') }}</el-button>
|
||||
<el-button v-if="isDelete" type="danger" @click="deleteObj">{{ $t('map.deleteObj') }}</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createTrainingCategory, updateTrainingCategory, getProductDetail, deleteTrainingCategory, checkMapProductCodeExist } from '@/api/management/mapprd';
|
||||
|
||||
export default {
|
||||
name: 'ShowDetail',
|
||||
props: {
|
||||
height: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
node: null,
|
||||
display: 1,
|
||||
codeDisabled: true,
|
||||
rules: {},
|
||||
trainTypesList: [],
|
||||
initTrainTypes: [],
|
||||
chooseList: [],
|
||||
addModel: {
|
||||
id: '',
|
||||
mapId: '',
|
||||
mapName: '',
|
||||
skinCode: '',
|
||||
name: '',
|
||||
remarks: '',
|
||||
code: '',
|
||||
prdType: '01',
|
||||
trainTypes: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
if (this.node && this.node.data) {
|
||||
if (this.node.data.type === 'Skin') {
|
||||
return this.$t('map.createProductCategories');
|
||||
} else if (this.node.data.type === 'Prd' ||
|
||||
this.node.data.type === 'Prd') {
|
||||
return this.$t('map.editTraining');
|
||||
}
|
||||
}
|
||||
return this.$t('map.selectOperation');
|
||||
},
|
||||
isCreate() {
|
||||
return this.node && this.node.data.type === 'Skin';
|
||||
},
|
||||
isUpdate() {
|
||||
return this.node && this.node.data.type === 'Prd';
|
||||
},
|
||||
isDelete() {
|
||||
return this.node && this.node.data.type === 'Prd';
|
||||
},
|
||||
isShowTrainTypes() {
|
||||
return this.addModel.prdType != '03' && this.addModel.prdType != '04';
|
||||
},
|
||||
baseRules() {
|
||||
return {
|
||||
code: [
|
||||
{ required: true, message: this.$t('rules.productCodeEnter'), trigger: 'change' }
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: this.$t('rules.productNameEnter'), trigger: 'change' }
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: this.$t('rules.productDescriptionEnter'), trigger: 'change' }
|
||||
],
|
||||
trainTypes: [
|
||||
{ required: true, message: this.$t('rules.trainingTypeSelect'), trigger: 'change' }
|
||||
]
|
||||
};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$Dictionary.trainingType().then(list => {
|
||||
this.trainTypesList = list;
|
||||
});
|
||||
this.$Dictionary.productPostType().then(list => {
|
||||
this.chooseList = list;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
loadData(node) {
|
||||
if (node) {
|
||||
// 清除数据
|
||||
this.node = node;
|
||||
this.initTrainTypes = [];
|
||||
this.$refs.form.resetFields();
|
||||
this.loading = true;
|
||||
if (node.data.type === 'Skin') {
|
||||
this.codeDisabled = false;
|
||||
this.addModel.mapName = node.data.name;
|
||||
this.addModel.skinCode = node.data.id;
|
||||
this.loading = false;
|
||||
} else if (node.data.type === 'Prd') {
|
||||
this.codeDisabled = true;
|
||||
getProductDetail(node.data.id).then(response => {
|
||||
this.addModel.mapName = node.parent.data.name;
|
||||
this.addModel.mapId = node.parent.data.id;
|
||||
this.addModel.name = response.data.name;
|
||||
this.addModel.remarks = response.data.remarks;
|
||||
this.addModel.prdType = response.data.prdType;
|
||||
this.addModel.code = response.data.code;
|
||||
this.addModel.skinCode = response.data.skinCode;
|
||||
this.addModel.trainTypes = this.initTrainTypes = response.data.trainTypes;
|
||||
this.addModel.id = response.data.id;
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
} else {
|
||||
this.addModel.prdType = '01';
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
// 清除表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.form.clearValidate();
|
||||
});
|
||||
}
|
||||
},
|
||||
create() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
skinCode: this.addModel.skinCode,
|
||||
mapName: this.addModel.mapName,
|
||||
name: this.addModel.name,
|
||||
remarks: this.addModel.remarks,
|
||||
prdType: this.addModel.prdType,
|
||||
code: this.addModel.code,
|
||||
trainTypes: this.isShowTrainTypes ? this.addModel.trainTypes : []
|
||||
};
|
||||
checkMapProductCodeExist({ code: this.addModel.code }).then(response => {
|
||||
if (!response.data) {
|
||||
createTrainingCategory(data).then(response => {
|
||||
this.initTrainTypes = this.addModel.trainTypes;
|
||||
this.$emit('refresh');
|
||||
this.$message.success(this.$t('tip.productCreationSuccessfully'));
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.productCreationFailed'));
|
||||
});
|
||||
} else {
|
||||
this.$messageBox(this.$t('tip.productCodeExists'));
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.productCodeExists'));
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.addModel.trainTypes = this.isShowTrainTypes ? this.addModel.trainTypes : [];
|
||||
updateTrainingCategory(this.addModel).then(response => {
|
||||
this.initTrainTypes = this.addModel.trainTypes;
|
||||
this.$message.success(this.$t('tip.updateProductSuccessfully'));
|
||||
this.$emit('refresh');
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.updateProductFailed'));
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
trainTypesChange(tag) {
|
||||
if (this.initTrainTypes && this.initTrainTypes.length > 0) {
|
||||
this.initTrainTypes.forEach(elem => {
|
||||
if (this.addModel.trainTypes.indexOf(elem) < 0) {
|
||||
this.addModel.trainTypes = this.initTrainTypes;
|
||||
this.$messageBox(this.$t('tip.narrowScope'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteObj() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
deleteTrainingCategory(this.addModel).then(response => {
|
||||
this.$message.success(this.$t('tip.deleteProductSuccessfully'));
|
||||
this.$refs.form.resetFields();
|
||||
this.node = null;
|
||||
this.$emit('refresh');
|
||||
}).catch(error => {
|
||||
if (error.code === 500009) {
|
||||
this.$messageBox(this.$t('tip.cannotDeleteProduct'));
|
||||
} else {
|
||||
this.$messageBox(this.$t('tip.deleteProductFailed'));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.card-box {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.steps {
|
||||
width: 980px;
|
||||
margin: 0 auto;
|
||||
padding-top: 20px;
|
||||
height: 100%;
|
||||
|
||||
/deep/ {
|
||||
.el-step__icon.is-icon {
|
||||
width: 95px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.forms {
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
margin-top: 20px;
|
||||
|
||||
/deep/ {
|
||||
.el-select {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-textarea {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-form-item__content>.el-input {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
float: left;
|
||||
width: calc(250px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.draft {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
margin: 20px auto;
|
||||
}
|
||||
</style>
|
@ -1,59 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="training-tree">
|
||||
<training-tree-operate ref="trainingTree" :height="height" @loadData="loadData" />
|
||||
</div>
|
||||
<div class="training-draft" :style="{width: width +'px'}">
|
||||
<edit-detail-operate ref="training" :height="height" @refresh="refresh" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TrainingTreeOperate from './tree';
|
||||
import EditDetailOperate from './edit';
|
||||
|
||||
export default {
|
||||
name: 'TrainingEditOperate',
|
||||
components: {
|
||||
EditDetailOperate,
|
||||
TrainingTreeOperate
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
width() {
|
||||
return this.$store.state.app.width - 420;
|
||||
},
|
||||
height() {
|
||||
return this.$store.state.app.height -150;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadData(node) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.training.loadData(node);
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.trainingTree.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.training-tree {
|
||||
float: left;
|
||||
width: 420px;
|
||||
}
|
||||
|
||||
.training-draft {
|
||||
float: left;
|
||||
}
|
||||
</style>
|
@ -1,119 +0,0 @@
|
||||
<template>
|
||||
<el-card v-loading="loading" class="map-list-main">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>{{ $t('map.productCategories') }}</span>
|
||||
</div>
|
||||
<el-input v-model="filterText" :placeholder="$t('tip.enterKeywordsFiltering')" clearable />
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: height +'px' }">
|
||||
<el-tree
|
||||
ref="trainingTree"
|
||||
:data="treeData"
|
||||
:filter-node-method="filterNode"
|
||||
:lazy="false"
|
||||
:props="defaultProps"
|
||||
class="tree-height-max"
|
||||
expand-on-click-node
|
||||
highlight-current
|
||||
@node-click="clickEvent"
|
||||
>
|
||||
<span slot-scope="{ node }">
|
||||
<span v-if="node.data.type == 'skin'" class="el-icon-news" />
|
||||
<span v-if="node.data.type == 'prd'" class="el-icon-tickets" />
|
||||
<span v-if="node.data.type == 'trainingType'" class="el-icon-document" />
|
||||
<span v-if="node.data.type == 'trainingType'" class="el-icon-edit" />
|
||||
<span> {{ node.label }}</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
</template>
|
||||
<script>
|
||||
import { getProductTree } from '@/api/management/mapprd';
|
||||
|
||||
export default {
|
||||
name: 'TreeOperate',
|
||||
props: {
|
||||
height: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
filterText: '',
|
||||
treeData: [],
|
||||
node: {},
|
||||
point: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
filterText(val) {
|
||||
this.$refs.trainingTree.filter(val);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.refresh();
|
||||
},
|
||||
methods: {
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.name.indexOf(value) !== -1;
|
||||
},
|
||||
showContextMenu(e, obj, node, vueElem) {
|
||||
e.preventDefault();
|
||||
this.point = {
|
||||
x: e.clientX,
|
||||
y: e.clientY
|
||||
};
|
||||
if (obj) {
|
||||
this.node = node;
|
||||
this.$refs.menu.show();
|
||||
}
|
||||
},
|
||||
clickEvent(obj, node, data) {
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.$emit('loadData', node);
|
||||
},
|
||||
convertTreeData(list) {
|
||||
const tree = [];
|
||||
if (list && list.length) {
|
||||
/* 去除列表的training节点*/
|
||||
list.forEach(elem => {
|
||||
elem.children = this.convertTreeData(elem.children);
|
||||
if (elem.type !== 'TrainingType') {
|
||||
tree.push(elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
return tree;
|
||||
},
|
||||
refresh() {
|
||||
getProductTree().then(response => {
|
||||
this.treeData = this.convertTreeData(response.data);
|
||||
this.$nextTick(() => { this.loading = false; });
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.refreshFailure'));
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-tree {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.el-tree-node.is-current>.el-tree-node__content {
|
||||
background-color: #e4e3e3 !important;
|
||||
}
|
||||
</style>
|
305
src/views/system/product/edit.vue
Normal file
305
src/views/system/product/edit.vue
Normal file
@ -0,0 +1,305 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="card-box">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step :title="title" icon="el-icon-edit-outline" />
|
||||
<el-step title="" icon="el-icon-upload" />
|
||||
</el-steps>
|
||||
<el-card class="forms" style="padding-top: 40px">
|
||||
<el-form ref="form" :model="addModel" label-width="140px">
|
||||
<el-form-item :label="$t('map.skinStyleColon')" prop="mapName">
|
||||
<el-input v-model="addModel.mapName" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productType') + ':'" prop="prdType">
|
||||
<el-radio-group v-model="addModel.prdType" :disabled="isUpdate">
|
||||
<template v-for="item in chooseList">
|
||||
<el-radio-button :key="item.code" :label="item.code">{{ item.name }}</el-radio-button>
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('map.productCode') + ':'"
|
||||
prop="code"
|
||||
:rules="node && node.data.type ==='skin' ? baseRules.code:{}"
|
||||
>
|
||||
<el-input v-model="addModel.code" :disabled="codeDisabled" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productName') + ':'" prop="name" :rules="baseRules.name">
|
||||
<el-input v-model="addModel.name" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="isShowTrainTypes"
|
||||
:label="$t('map.associateTrainingTypes') + ':'"
|
||||
prop="trainTypes"
|
||||
:rules="baseRules.trainTypes"
|
||||
>
|
||||
<el-select v-model="addModel.trainTypes" multiple :placeholder="$t('map.pleaseSelect')" @change="trainTypesChange">
|
||||
<el-option
|
||||
v-for="item in trainTypesList"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('map.productDescription') + ':'" prop="remarks" :rules="baseRules.remarks">
|
||||
<el-input v-model="addModel.remarks" type="textarea" :rows="4" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button v-if="isCreate" type="primary" @click="create">{{ $t('map.create') }}</el-button>
|
||||
<el-button v-if="isUpdate" type="primary" @click="update">{{ $t('map.updata') }}</el-button>
|
||||
<el-button v-if="isDelete" type="danger" @click="deleteObj">{{ $t('map.deleteObj') }}</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createTrainingCategory, updateTrainingCategory, getProductDetail, deleteTrainingCategory, checkMapProductCodeExist } from '@/api/management/mapprd';
|
||||
|
||||
export default {
|
||||
name: 'ShowDetail',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
node: null,
|
||||
display: 1,
|
||||
codeDisabled: true,
|
||||
rules: {},
|
||||
trainTypesList: [],
|
||||
initTrainTypes: [],
|
||||
chooseList: [],
|
||||
addModel: {
|
||||
id: '',
|
||||
mapId: '',
|
||||
mapName: '',
|
||||
skinCode: '',
|
||||
name: '',
|
||||
remarks: '',
|
||||
code: '',
|
||||
prdType: '01',
|
||||
trainTypes: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
if (this.node && this.node.data) {
|
||||
if (this.node.data.type === 'Skin') {
|
||||
return this.$t('map.createProductCategories');
|
||||
} else if (this.node.data.type === 'Prd' ||
|
||||
this.node.data.type === 'Prd') {
|
||||
return this.$t('map.editTraining');
|
||||
}
|
||||
}
|
||||
return this.$t('map.selectOperation');
|
||||
},
|
||||
isCreate() {
|
||||
return this.node && this.node.data.type === 'Skin';
|
||||
},
|
||||
isUpdate() {
|
||||
return this.node && this.node.data.type === 'Prd';
|
||||
},
|
||||
isDelete() {
|
||||
return this.node && this.node.data.type === 'Prd';
|
||||
},
|
||||
isShowTrainTypes() {
|
||||
return this.addModel.prdType != '03' && this.addModel.prdType != '04';
|
||||
},
|
||||
baseRules() {
|
||||
return {
|
||||
code: [
|
||||
{ required: true, message: this.$t('rules.productCodeEnter'), trigger: 'change' }
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: this.$t('rules.productNameEnter'), trigger: 'change' }
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: this.$t('rules.productDescriptionEnter'), trigger: 'change' }
|
||||
],
|
||||
trainTypes: [
|
||||
{ required: true, message: this.$t('rules.trainingTypeSelect'), trigger: 'change' }
|
||||
]
|
||||
};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$Dictionary.trainingType().then(list => {
|
||||
this.trainTypesList = list;
|
||||
});
|
||||
this.$Dictionary.productPostType().then(list => {
|
||||
this.chooseList = list;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
loadData(node) {
|
||||
if (node) {
|
||||
// 清除数据
|
||||
this.node = node;
|
||||
this.initTrainTypes = [];
|
||||
this.$refs.form.resetFields();
|
||||
this.loading = true;
|
||||
if (node.data.type === 'Skin') {
|
||||
this.codeDisabled = false;
|
||||
this.addModel.mapName = node.data.name;
|
||||
this.addModel.skinCode = node.data.id;
|
||||
this.loading = false;
|
||||
} else if (node.data.type === 'Prd') {
|
||||
this.codeDisabled = true;
|
||||
getProductDetail(node.data.id).then(response => {
|
||||
this.addModel.mapName = node.parent.data.name;
|
||||
this.addModel.mapId = node.parent.data.id;
|
||||
this.addModel.name = response.data.name;
|
||||
this.addModel.remarks = response.data.remarks;
|
||||
this.addModel.prdType = response.data.prdType;
|
||||
this.addModel.code = response.data.code;
|
||||
this.addModel.skinCode = response.data.skinCode;
|
||||
this.addModel.trainTypes = this.initTrainTypes = response.data.trainTypes;
|
||||
this.addModel.id = response.data.id;
|
||||
this.loading = false;
|
||||
}).catch((error) => {
|
||||
this.loading = false;
|
||||
this.$message.error(error.message);
|
||||
});
|
||||
} else {
|
||||
this.addModel.prdType = '01';
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
// 清除表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.form.clearValidate();
|
||||
});
|
||||
}
|
||||
},
|
||||
create() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
skinCode: this.addModel.skinCode,
|
||||
mapName: this.addModel.mapName,
|
||||
name: this.addModel.name,
|
||||
remarks: this.addModel.remarks,
|
||||
prdType: this.addModel.prdType,
|
||||
code: this.addModel.code,
|
||||
trainTypes: this.isShowTrainTypes ? this.addModel.trainTypes : []
|
||||
};
|
||||
checkMapProductCodeExist({ code: this.addModel.code }).then(response => {
|
||||
if (!response.data) {
|
||||
createTrainingCategory(data).then(response => {
|
||||
this.initTrainTypes = this.addModel.trainTypes;
|
||||
this.$emit('refresh');
|
||||
this.$message.success(this.$t('tip.productCreationSuccessfully'));
|
||||
}).catch((error) => {
|
||||
this.$message.error(`${this.$t('tip.productCreationFailed')}, ${error.message}`);
|
||||
});
|
||||
} else {
|
||||
this.$message(this.$t('tip.productCodeExists'));
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message(this.$t('tip.productCodeExists'));
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.addModel.trainTypes = this.isShowTrainTypes ? this.addModel.trainTypes : [];
|
||||
updateTrainingCategory(this.addModel).then(response => {
|
||||
this.initTrainTypes = this.addModel.trainTypes;
|
||||
this.$message.success(this.$t('tip.updateProductSuccessfully'));
|
||||
this.$emit('refresh');
|
||||
}).catch((error) => {
|
||||
this.$message.error(`${this.$t('tip.updateProductFailed')}, ${error.message}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
trainTypesChange(tag) {
|
||||
if (this.initTrainTypes && this.initTrainTypes.length > 0) {
|
||||
this.initTrainTypes.forEach(elem => {
|
||||
if (this.addModel.trainTypes.indexOf(elem) < 0) {
|
||||
this.addModel.trainTypes = this.initTrainTypes;
|
||||
this.$messageBox(this.$t('tip.narrowScope'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteObj() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
deleteTrainingCategory(this.addModel).then(response => {
|
||||
this.$message.success(this.$t('tip.deleteProductSuccessfully'));
|
||||
this.$refs.form.resetFields();
|
||||
this.node = null;
|
||||
this.$emit('refresh');
|
||||
}).catch(error => {
|
||||
if (error.code === 500009) {
|
||||
this.$message.error(this.$t('tip.cannotDeleteProduct'));
|
||||
} else {
|
||||
this.$message.error(this.$t('tip.deleteProductFailed'));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.card-box {
|
||||
padding-top: 20px;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.steps {
|
||||
width: 980px;
|
||||
margin: 0 auto;
|
||||
|
||||
/deep/ {
|
||||
.el-step__icon.is-icon {
|
||||
width: 95px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.forms {
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
margin-top: 20px;
|
||||
|
||||
/deep/ {
|
||||
.el-select {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-textarea {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-form-item__content>.el-input {
|
||||
float: left;
|
||||
width: calc(600px);
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
float: left;
|
||||
width: calc(250px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.draft {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
margin: 20px auto;
|
||||
}
|
||||
</style>
|
58
src/views/system/product/index.vue
Normal file
58
src/views/system/product/index.vue
Normal file
@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="contnt_box">
|
||||
<div class="training-tree">
|
||||
<training-tree-operate ref="trainingTree" @loadData="loadData" />
|
||||
</div>
|
||||
<div class="training-draft">
|
||||
<edit-detail-operate ref="training" @refresh="refresh" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TrainingTreeOperate from './tree';
|
||||
import EditDetailOperate from './edit';
|
||||
|
||||
// 产品编辑
|
||||
export default {
|
||||
name: 'TrainingEditOperate',
|
||||
components: {
|
||||
EditDetailOperate,
|
||||
TrainingTreeOperate
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
loadData(node) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.training.loadData(node);
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.trainingTree.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.contnt_box{
|
||||
height: 100%;
|
||||
.training-tree {
|
||||
float: left;
|
||||
width: 420px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.training-draft {
|
||||
float: left;
|
||||
width: calc(100% - 420px);
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
130
src/views/system/product/tree.vue
Normal file
130
src/views/system/product/tree.vue
Normal file
@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="joylink-card map-list-main">
|
||||
<div class="clearfix">
|
||||
<span>{{ $t('map.productCategories') }}</span>
|
||||
</div>
|
||||
<el-input v-model="filterText" :placeholder="$t('tip.enterKeywordsFiltering')" clearable />
|
||||
<div style="height: calc(100% - 87px);">
|
||||
<el-tree
|
||||
ref="trainingTree"
|
||||
:data="treeData"
|
||||
:filter-node-method="filterNode"
|
||||
:lazy="false"
|
||||
:props="defaultProps"
|
||||
class="tree-height-max"
|
||||
expand-on-click-node
|
||||
highlight-current
|
||||
@node-click="clickEvent"
|
||||
>
|
||||
<span slot-scope="{ node }">
|
||||
<span v-if="node.data.type == 'skin'" class="el-icon-news" />
|
||||
<span v-if="node.data.type == 'prd'" class="el-icon-tickets" />
|
||||
<span v-if="node.data.type == 'trainingType'" class="el-icon-document" />
|
||||
<span v-if="node.data.type == 'trainingType'" class="el-icon-edit" />
|
||||
<span> {{ node.label }}</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getProductTree } from '@/api/management/mapprd';
|
||||
|
||||
export default {
|
||||
name: 'TreeOperate',
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
filterText: '',
|
||||
treeData: [],
|
||||
node: {},
|
||||
point: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
filterText(val) {
|
||||
this.$refs.trainingTree.filter(val);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.refresh();
|
||||
},
|
||||
methods: {
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.name.indexOf(value) !== -1;
|
||||
},
|
||||
showContextMenu(e, obj, node, vueElem) {
|
||||
e.preventDefault();
|
||||
this.point = {
|
||||
x: e.clientX,
|
||||
y: e.clientY
|
||||
};
|
||||
if (obj) {
|
||||
this.node = node;
|
||||
this.$refs.menu.show();
|
||||
}
|
||||
},
|
||||
clickEvent(obj, node, data) {
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.$emit('loadData', node);
|
||||
},
|
||||
convertTreeData(list) {
|
||||
const tree = [];
|
||||
if (list && list.length) {
|
||||
/* 去除列表的training节点*/
|
||||
list.forEach(elem => {
|
||||
elem.children = this.convertTreeData(elem.children);
|
||||
if (elem.type !== 'TrainingType') {
|
||||
tree.push(elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
return tree;
|
||||
},
|
||||
refresh() {
|
||||
getProductTree().then(response => {
|
||||
this.treeData = this.convertTreeData(response.data);
|
||||
this.$nextTick(() => { this.loading = false; });
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.refreshFailure'));
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.map-list-main{
|
||||
height: 100%;
|
||||
}
|
||||
.clearfix{
|
||||
padding: 0 20px;
|
||||
border-bottom: 1px solid #EBEEF5;
|
||||
box-sizing: border-box;
|
||||
height: 47px;
|
||||
line-height: 47px;
|
||||
}
|
||||
.tree-height-max{
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.el-tree {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.el-tree-node.is-current>.el-tree-node__content {
|
||||
background-color: #e4e3e3 !important;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user