修改接口
This commit is contained in:
parent
72c1f1d4ca
commit
6343a79f81
@ -1,313 +1,320 @@
|
||||
<template>
|
||||
<el-card v-loading="loading">
|
||||
<div slot="header" style="text-align: center;">
|
||||
<span v-if="hasProduct"><b>仿真名称: {{ courseModel.name }}</b></span>
|
||||
<span v-else>无仿真产品</span>
|
||||
</div>
|
||||
<el-tabs type="border-card" @tab-click="handleLeave" :value="currentPrdCode"
|
||||
:style="{ height: height-50 +'px' }">
|
||||
<el-tab-pane v-for="item in productList" :key="item.code" :name="item.code" :label="item.name"
|
||||
style="padding: 5px" :style="{ height: height-160 +'px' }">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{ height: height-170 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">产品说明:</span>
|
||||
<span class="list-elem">{{ courseModel.remarks }}</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">权限列表:</span>
|
||||
</p>
|
||||
<limit-list :ref="`limit_${item.code}`" :courseModel="courseModel" @initLoadPage="initLoadPage">
|
||||
</limit-list>
|
||||
</el-scrollbar>
|
||||
</el-tab-pane>
|
||||
<div class="btn-buy" v-if="hasProduct">
|
||||
<el-button type="success" @click="buy">购买</el-button>
|
||||
<el-button type="primary" @click="distribute" v-if="hasPermssion">权限分发</el-button>
|
||||
<el-button type="primary" @click="transfer" v-if="hasPermssion">权限转赠</el-button>
|
||||
<el-button type="primary" @click="start" v-show="isStartDemon">开始仿真</el-button>
|
||||
<el-button type="primary" @click="start" v-show="isCreateRoom">创建房间</el-button>
|
||||
<el-button type="primary" @click="joinRoom" v-show="isInRoom">进入房间</el-button>
|
||||
</div>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
<el-card v-loading="loading">
|
||||
<div slot="header" style="text-align: center;">
|
||||
<span v-if="hasProduct"><b>仿真名称: {{ courseModel.name }}</b></span>
|
||||
<span v-else>无仿真产品</span>
|
||||
</div>
|
||||
<el-tabs
|
||||
type="border-card"
|
||||
:value="currentPrdCode"
|
||||
:style="{ height: height-50 +'px' }"
|
||||
@tab-click="handleLeave"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in productList"
|
||||
:key="item.code"
|
||||
:name="item.code"
|
||||
:label="item.name"
|
||||
style="padding: 5px"
|
||||
:style="{ height: height-160 +'px' }"
|
||||
>
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: height-170 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">产品说明:</span>
|
||||
<span class="list-elem">{{ courseModel.remarks }}</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">权限列表:</span>
|
||||
</p>
|
||||
<limit-list :ref="`limit_${item.code}`" :course-model="courseModel" @initLoadPage="initLoadPage" />
|
||||
</el-scrollbar>
|
||||
</el-tab-pane>
|
||||
<div v-if="hasProduct" class="btn-buy">
|
||||
<el-button type="success" @click="buy">购买</el-button>
|
||||
<el-button v-if="hasPermssion" type="primary" @click="distribute">权限分发</el-button>
|
||||
<el-button v-if="hasPermssion" type="primary" @click="transfer">权限转赠</el-button>
|
||||
<el-button v-show="isStartDemon" type="primary" @click="start">开始仿真</el-button>
|
||||
<el-button v-show="isCreateRoom" type="primary" @click="start">创建房间</el-button>
|
||||
<el-button v-show="isInRoom" type="primary" @click="joinRoom">进入房间</el-button>
|
||||
</div>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
</template>
|
||||
<script>
|
||||
import { getCourseLessonTree } from '@/api/management/exam';
|
||||
import { getProductList, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getGoodsTryUse } from '@/api/management/goods';
|
||||
import { getCommodityMapProduct, getMapProductDetail } from '@/api/management/mapprd';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import { queryPermissionSimulation } from '@/api/management/author';
|
||||
import { postCreateRoom, getjointTraining, checkRoomExist } from '@/api/chat';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { simulationNotify } from '@/api/simulation';
|
||||
import localStore from 'storejs';
|
||||
import LimitList from "@/views/components/limits/index";
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getGoodsTryUse } from '@/api/management/goods';
|
||||
import { getCommodityMapProduct, getMapProductDetail } from '@/api/management/mapprd';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import { queryPermissionSimulation } from '@/api/management/author';
|
||||
import { postCreateRoom, getjointTraining, checkRoomExist } from '@/api/chat';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { simulationNotify } from '@/api/simulation';
|
||||
import localStore from 'storejs';
|
||||
import LimitList from '@/views/components/limits/index';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
|
||||
export default {
|
||||
name: 'ExamDetailList',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
components: {
|
||||
LimitList
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
tryTime: 0,
|
||||
goodsId: '',
|
||||
tryUser: 0,
|
||||
loading: true,
|
||||
currentLessonId: '',
|
||||
currentPrdCode: '',
|
||||
productList: [],
|
||||
courseModel: {
|
||||
id: '',
|
||||
name: '',
|
||||
mapId: '',
|
||||
skinCode: '',
|
||||
remarks: '',
|
||||
prdType: '',
|
||||
prdCode: '',
|
||||
pmsList: [],
|
||||
},
|
||||
EffectiveTypeList: [],
|
||||
jointShow: false,
|
||||
jointGroup: '',
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
setTime(val) {
|
||||
if (val <= 1) {
|
||||
return `0分钟`;
|
||||
} else if (1 < val && val <= 60) {
|
||||
return '1分钟';
|
||||
} else if (val > 60) {
|
||||
let time = parseInt(val / 60);
|
||||
return `${time}分钟`;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hasProduct() {
|
||||
return this.productList.length;
|
||||
},
|
||||
hasPermssion() {
|
||||
let isShow = false;
|
||||
if (this.courseModel.pmsList.length) {
|
||||
isShow = true;
|
||||
}
|
||||
return isShow;
|
||||
},
|
||||
isStartDemon() {
|
||||
return this.courseModel.prdType !== '03' && (this.hasPermssion || this.tryTime > 0);
|
||||
},
|
||||
isCreateRoom() {
|
||||
return this.courseModel.prdType === '03' && this.hasPermssion && !this.jointShow
|
||||
},
|
||||
isInRoom() {
|
||||
return this.courseModel.prdType == '03' && this.hasPermssion && this.jointShow
|
||||
},
|
||||
mapId() {
|
||||
return this.$route.params.mapId;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route': function (val) {
|
||||
this.loadInitData();
|
||||
},
|
||||
'currentPrdCode': function (code) {
|
||||
this.initLoadPage({ id: this.mapId, code: code });
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.loadInitData();
|
||||
},
|
||||
methods: {
|
||||
async loadInitData() {
|
||||
this.$Dictionary.effectiveType().then(list => {
|
||||
this.EffectiveTypeList = list;
|
||||
});
|
||||
export default {
|
||||
name: 'ExamDetailList',
|
||||
components: {
|
||||
LimitList
|
||||
},
|
||||
filters: {
|
||||
setTime(val) {
|
||||
if (val <= 1) {
|
||||
return `0分钟`;
|
||||
} else if (val > 1 && val <= 60) {
|
||||
return '1分钟';
|
||||
} else if (val > 60) {
|
||||
const time = parseInt(val / 60);
|
||||
return `${time}分钟`;
|
||||
}
|
||||
}
|
||||
},
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
tryTime: 0,
|
||||
goodsId: '',
|
||||
tryUser: 0,
|
||||
loading: true,
|
||||
currentLessonId: '',
|
||||
currentPrdCode: '',
|
||||
productList: [],
|
||||
courseModel: {
|
||||
id: '',
|
||||
name: '',
|
||||
mapId: '',
|
||||
skinCode: '',
|
||||
remarks: '',
|
||||
prdType: '',
|
||||
prdCode: '',
|
||||
pmsList: []
|
||||
},
|
||||
EffectiveTypeList: [],
|
||||
jointShow: false,
|
||||
jointGroup: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
hasProduct() {
|
||||
return this.productList.length;
|
||||
},
|
||||
hasPermssion() {
|
||||
let isShow = false;
|
||||
if (this.courseModel.pmsList.length) {
|
||||
isShow = true;
|
||||
}
|
||||
return isShow;
|
||||
},
|
||||
isStartDemon() {
|
||||
return this.courseModel.prdType !== '03' && (this.hasPermssion || this.tryTime > 0);
|
||||
},
|
||||
isCreateRoom() {
|
||||
return this.courseModel.prdType === '03' && this.hasPermssion && !this.jointShow;
|
||||
},
|
||||
isInRoom() {
|
||||
return this.courseModel.prdType == '03' && this.hasPermssion && this.jointShow;
|
||||
},
|
||||
mapId() {
|
||||
return this.$route.params.mapId;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route': function (val) {
|
||||
this.loadInitData();
|
||||
},
|
||||
'currentPrdCode': function (code) {
|
||||
this.initLoadPage({ id: this.mapId, code: code });
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.loadInitData();
|
||||
},
|
||||
methods: {
|
||||
async loadInitData() {
|
||||
this.$Dictionary.effectiveType().then(list => {
|
||||
this.EffectiveTypeList = list;
|
||||
});
|
||||
|
||||
this.currentPrdCode = '';
|
||||
this.productList = [];
|
||||
try {
|
||||
if (parseInt(this.mapId)) {
|
||||
this.getJointTrainingList();
|
||||
let rest = await getPublishMapInfo(this.mapId);
|
||||
if (rest && rest.code == 200) {
|
||||
let resp = await getCommodityMapProduct(rest.data.skinCode);
|
||||
if (resp.data && resp.data.length) {
|
||||
this.productList = resp.data.sort((a, b) => {
|
||||
return Number(b.prdType) - Number(a.prdType);
|
||||
})
|
||||
this.currentPrdCode = '';
|
||||
this.productList = [];
|
||||
try {
|
||||
if (parseInt(this.mapId)) {
|
||||
this.getJointTrainingList();
|
||||
const rest = await getPublishMapInfo(this.mapId);
|
||||
if (rest && rest.code == 200) {
|
||||
const resp = await getCommodityMapProduct(rest.data.skinCode);
|
||||
if (resp.data && resp.data.length) {
|
||||
this.productList = resp.data.sort((a, b) => {
|
||||
return Number(b.prdType) - Number(a.prdType);
|
||||
});
|
||||
|
||||
this.currentPrdCode = localStore.get(this.$route.path) || this.productList[0].code;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (e) {
|
||||
this.$messageBox('获取产品列表失败');
|
||||
}
|
||||
},
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
async getJointTrainingList() {
|
||||
try {
|
||||
if (this.mapId) {
|
||||
let res = await checkRoomExist({ mapId: this.mapId });
|
||||
this.jointGroup = res.data;
|
||||
this.jointShow = false;
|
||||
if (res.data) {
|
||||
this.jointShow = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error, '获取是否拥有综合演练房间');
|
||||
}
|
||||
},
|
||||
async handleLeave(tab) {
|
||||
this.currentPrdCode = tab.name;
|
||||
localStore.set(this.$route.path, this.currentPrdCode);
|
||||
},
|
||||
async initLoadPage(data) {
|
||||
this.loading = true
|
||||
if (data && parseInt(data.id) && data.code) {
|
||||
try {
|
||||
let resp = await getMapProductDetail(data.code);
|
||||
this.tryUser = 0;
|
||||
this.loading = false;
|
||||
this.courseModel = {
|
||||
id: resp.data.id,
|
||||
name: resp.data.name,
|
||||
mapId: data.id,
|
||||
skinCode: resp.data.skinCode,
|
||||
remarks: resp.data.remarks,
|
||||
prdType: resp.data.prdType,
|
||||
prdCode: resp.data.code,
|
||||
pmsList: resp.data.pmsList || [],
|
||||
PermissionType: PermissionType.SIMULATION
|
||||
};
|
||||
this.currentPrdCode = localStore.get(this.$route.path) || this.productList[0].code;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (e) {
|
||||
this.$messageBox('获取产品列表失败');
|
||||
}
|
||||
},
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
async getJointTrainingList() {
|
||||
try {
|
||||
if (this.mapId) {
|
||||
const res = await checkRoomExist({ mapId: this.mapId });
|
||||
this.jointGroup = res.data;
|
||||
this.jointShow = false;
|
||||
if (res.data) {
|
||||
this.jointShow = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error, '获取是否拥有综合演练房间');
|
||||
}
|
||||
},
|
||||
async handleLeave(tab) {
|
||||
this.currentPrdCode = tab.name;
|
||||
localStore.set(this.$route.path, this.currentPrdCode);
|
||||
},
|
||||
async initLoadPage(data) {
|
||||
this.loading = true;
|
||||
if (data && parseInt(data.id) && data.code) {
|
||||
try {
|
||||
const resp = await getMapProductDetail(data.code);
|
||||
this.tryUser = 0;
|
||||
this.loading = false;
|
||||
this.courseModel = {
|
||||
id: resp.data.id,
|
||||
name: resp.data.name,
|
||||
mapId: data.id,
|
||||
skinCode: resp.data.skinCode,
|
||||
remarks: resp.data.remarks,
|
||||
prdType: resp.data.prdType,
|
||||
prdCode: resp.data.code,
|
||||
pmsList: resp.data.pmsList || [],
|
||||
PermissionType: PermissionType.SIMULATION
|
||||
};
|
||||
|
||||
let rest = await queryPermissionSimulation({ mapId: this.courseModel.mapId, prdCode: this.courseModel.prdCode });
|
||||
this.courseModel.pmsList = rest.data;
|
||||
if (!this.courseModel.pmsList.length) {
|
||||
this.tryUser = 1;
|
||||
let paras = {
|
||||
mapId: data.id,
|
||||
mapProductCode: data.code,
|
||||
productType: PermissionType.SIMULATION
|
||||
};
|
||||
const rest = await queryPermissionSimulation({ mapId: this.courseModel.mapId, prdCode: this.courseModel.prdCode });
|
||||
this.courseModel.pmsList = rest.data;
|
||||
if (!this.courseModel.pmsList.length) {
|
||||
this.tryUser = 1;
|
||||
const paras = {
|
||||
mapId: data.id,
|
||||
mapProductCode: data.code,
|
||||
productType: PermissionType.SIMULATION
|
||||
};
|
||||
|
||||
try {
|
||||
let resr = await getGoodsTryUse(paras);
|
||||
if (resr.data.tryTime <= 0) {
|
||||
this.tryTime = 0;
|
||||
} else {
|
||||
this.tryTime = resr.data.tryTime;
|
||||
this.goodsId = resr.data.goodsId;
|
||||
}
|
||||
} catch (error) {
|
||||
this.tryTime = 0;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
this.$messageBox('刷新失败');
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async joinRoom() {
|
||||
await getjointTraining(this.jointGroup);
|
||||
let query = { skinCode: this.courseModel.skinCode, group: this.jointGroup };
|
||||
this.$router.push({ path: `/trainroom`, query: query });
|
||||
},
|
||||
async start() {
|
||||
if (this.courseModel.prdType == '03') {
|
||||
try {
|
||||
let param = {
|
||||
mapId: Number(this.mapId),
|
||||
prdCode: this.courseModel.prdCode,
|
||||
}
|
||||
let res = await postCreateRoom(param);
|
||||
if (res && res.code == 200) {
|
||||
let query = { skinCode: this.courseModel.skinCode, group: res.data };
|
||||
this.$router.push({ path: `/trainroom`, query: query });
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code == 20001) {
|
||||
this.$confirm(`每个用户只能创建一个综合演练房间, 是否进入房间`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => { }).catch(() => { })
|
||||
}
|
||||
if (error.code == 500009) {
|
||||
this.$messageBox(error.message);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
if (this.courseModel.pmsList.length) {
|
||||
this.jump();
|
||||
} else {
|
||||
if (this.tryTime <= 1) {
|
||||
this.loading.close();
|
||||
this.$confirm('您没有权限,请前往购买产品', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.buy();
|
||||
}).catch(() => { })
|
||||
} else {
|
||||
this.jump();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
jump() {
|
||||
let data = { mapId: this.courseModel.mapId, code: this.currentPrdCode }
|
||||
simulationNotify(data).then(resp => {
|
||||
// try 0 有权限不走试用
|
||||
let query = { skinCode: this.courseModel.skinCode, group: resp.data, prdType: this.courseModel.prdType, mapId: this.courseModel.mapId, code: this.currentPrdCode, goodsId: this.goodsId, try: this.tryUser };
|
||||
this.$router.push({ path: `${UrlConfig.display}/demon`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
})
|
||||
},
|
||||
buy() {
|
||||
this.$router.push({
|
||||
path: `${UrlConfig.demonstration.pay}/${this.courseModel.id}`,
|
||||
query: { permissionType: PermissionType.SIMULATION, prdCode: this.courseModel.prdCode, mapId: this.courseModel.mapId }
|
||||
});
|
||||
},
|
||||
transfer() {
|
||||
if (this.$refs) {
|
||||
this.$refs[`limit_${this.currentPrdCode}`][0].transfer(this.courseModel);
|
||||
}
|
||||
},
|
||||
distribute() {
|
||||
if (this.$refs) {
|
||||
this.$refs[`limit_${this.currentPrdCode}`][0].distribute(this.courseModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
const resr = await getGoodsTryUse(paras);
|
||||
if (resr.data.tryTime <= 0) {
|
||||
this.tryTime = 0;
|
||||
} else {
|
||||
this.tryTime = resr.data.tryTime;
|
||||
this.goodsId = resr.data.goodsId;
|
||||
}
|
||||
} catch (error) {
|
||||
this.tryTime = 0;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
this.$messageBox('刷新失败');
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async joinRoom() {
|
||||
await getjointTraining(this.jointGroup);
|
||||
const query = { skinCode: this.courseModel.skinCode, group: this.jointGroup };
|
||||
this.$router.push({ path: `/trainroom`, query: query });
|
||||
},
|
||||
async start() {
|
||||
if (this.courseModel.prdType == '03') {
|
||||
try {
|
||||
const param = {
|
||||
mapId: Number(this.mapId),
|
||||
prdCode: this.courseModel.prdCode
|
||||
};
|
||||
const res = await postCreateRoom(param);
|
||||
if (res && res.code == 200) {
|
||||
const query = { skinCode: this.courseModel.skinCode, group: res.data };
|
||||
this.$router.push({ path: `/trainroom`, query: query });
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code == 20001) {
|
||||
this.$confirm(`每个用户只能创建一个综合演练房间, 是否进入房间`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => { }).catch(() => { });
|
||||
}
|
||||
if (error.code == 500009) {
|
||||
this.$messageBox(error.message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
if (this.courseModel.pmsList.length) {
|
||||
this.jump();
|
||||
} else {
|
||||
if (this.tryTime <= 1) {
|
||||
this.loading.close();
|
||||
this.$confirm('您没有权限,请前往购买产品', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.buy();
|
||||
}).catch(() => { });
|
||||
} else {
|
||||
this.jump();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
jump() {
|
||||
const data = { mapId: this.courseModel.mapId, code: this.currentPrdCode };
|
||||
simulationNotify(data).then(resp => {
|
||||
// try 0 有权限不走试用
|
||||
const query = { skinCode: this.courseModel.skinCode, group: resp.data, prdType: this.courseModel.prdType, mapId: this.courseModel.mapId, code: this.currentPrdCode, goodsId: this.goodsId, try: this.tryUser };
|
||||
this.$router.push({ path: `${UrlConfig.display}/demon`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
});
|
||||
},
|
||||
buy() {
|
||||
this.$router.push({
|
||||
path: `${UrlConfig.demonstration.pay}/${this.courseModel.id}`,
|
||||
query: { permissionType: PermissionType.SIMULATION, prdCode: this.courseModel.prdCode, mapId: this.courseModel.mapId }
|
||||
});
|
||||
},
|
||||
transfer() {
|
||||
if (this.$refs) {
|
||||
this.$refs[`limit_${this.currentPrdCode}`][0].transfer(this.courseModel);
|
||||
}
|
||||
},
|
||||
distribute() {
|
||||
if (this.$refs) {
|
||||
this.$refs[`limit_${this.currentPrdCode}`][0].distribute(this.courseModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
::-webkit-scrollbar {
|
||||
|
@ -43,10 +43,8 @@
|
||||
<menu-system-time ref="menuSystemTime" :offset="offset" :group="group" />
|
||||
</div>
|
||||
|
||||
<Three-Test v-show="simulationShow" :panelShow="simulationShow" ref="ThreeTest" @showpanel="showpanel">
|
||||
</Three-Test>
|
||||
<Jl3d-Simulation v-show="drivingShow" :panelShow="drivingShow" ref="Jl3dSimulation" @showdriving="showdriving">
|
||||
</Jl3d-Simulation>
|
||||
<Three-Test v-show="simulationShow" ref="ThreeTest" :panel-show="simulationShow" @showpanel="showpanel" />
|
||||
<Jl3d-Simulation v-show="drivingShow" ref="Jl3dSimulation" :panel-show="drivingShow" @showdriving="showdriving" />
|
||||
|
||||
<fault-choose ref="faultChoose" :group="group" />
|
||||
<run-plan-Load ref="runPlanLoad" :group="group" />
|
||||
@ -79,7 +77,7 @@ import { runDiagramQuit, loadQuest, getSimulationInfo } from '@/api/simulation';
|
||||
import { OperateMode, TrainingMode } from '@/scripts/ConstDic';
|
||||
import { checkLoginLine } from '@/api/login';
|
||||
// import { isFullscreen } from '@/utils/screen';
|
||||
import { loadMapData,loadMapDataById } from '@/utils/loaddata';
|
||||
import { loadMapData, loadMapDataById } from '@/utils/loaddata';
|
||||
import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
// import { handleToken } from '@/utils/auth';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
@ -89,7 +87,6 @@ import Vue from 'vue';
|
||||
import ThreeTest from '@/views/jlmap3d/index';
|
||||
import Jl3dSimulation from '@/views/jlmap3d/simulation/jl3dsimulation';
|
||||
|
||||
|
||||
export default {
|
||||
name: 'DisplayDraft',
|
||||
components: {
|
||||
@ -197,13 +194,13 @@ export default {
|
||||
},
|
||||
async created() {
|
||||
this.group = this.$route.query.group || '';
|
||||
const loading = this.$loading({
|
||||
lock: true ,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
loading.close();
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.loading.close();
|
||||
},
|
||||
async mounted() {
|
||||
this.mode = this.$route.params.mode;
|
||||
@ -450,12 +447,12 @@ export default {
|
||||
},
|
||||
// 选择脚本
|
||||
async selectQuest(row, id) {
|
||||
let res = await loadQuest(row.id, id, this.group);
|
||||
const res = await loadQuest(row.id, id, this.group);
|
||||
if (res && res.code == 200) {
|
||||
this.questId = parseInt(row.id);
|
||||
if(res.data && res.data.mapLocation) {
|
||||
let mapLocation={"offsetX":res.data.mapLocation.x,"offsetY":res.data.mapLocation.y,"scaleRate":res.data.mapLocation.scale};
|
||||
Vue.prototype.$jlmap.setOptions(mapLocation)
|
||||
if (res.data && res.data.mapLocation) {
|
||||
const mapLocation={'offsetX': res.data.mapLocation.x, 'offsetY': res.data.mapLocation.y, 'scaleRate': res.data.mapLocation.scale};
|
||||
Vue.prototype.$jlmap.setOptions(mapLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,8 +480,7 @@ export default {
|
||||
},
|
||||
|
||||
// 通过id加载地图数据
|
||||
async loadMapDataById(mapId)
|
||||
{
|
||||
async loadMapDataById(mapId) {
|
||||
try {
|
||||
await loadMapDataById(mapId);
|
||||
await this.$store.dispatch('training/setMapDefaultState');
|
||||
|
@ -1,230 +1,226 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<div slot="header" style="text-align: center;">
|
||||
<b>试卷名称: {{ examDetails.name }}</b>
|
||||
</div>
|
||||
<div style="margin:50px; overflow-y: auto;">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{ height: height - 190 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试时间:</span>
|
||||
<span class="list-elem" v-if="examDetails.startTime">
|
||||
{{ examDetails.startTime }} - {{examDetails.endTime }}</span>
|
||||
<span class="list-elem" v-else>随时都可以考试</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试说明:</span>
|
||||
<span class="list-elem">{{ examDetails.remarks }}</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试时长:</span>
|
||||
<span class="list-elem">{{ parseInt(examDetails.duration) / 60 }}分钟</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试满分:</span>
|
||||
<span class="list-elem">{{ examDetails.fullPoint }}分</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试及格分:</span>
|
||||
<span class="list-elem">{{ examDetails.passingPoint }}分</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试规则:</span>
|
||||
<span class="list-elem">
|
||||
<p class="list-table">
|
||||
<el-table :data="examDetails.examDefinitionRulesVOList" border show-summary>
|
||||
<el-table-column prop="name" label="实训类型" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="num" label="题数">
|
||||
</el-table-column>
|
||||
<el-table-column prop="point" label="分值">
|
||||
</el-table-column>
|
||||
<el-table-column prop="chapterIdLong" label="总分">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</p>
|
||||
</span>
|
||||
</p>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="btn-start">
|
||||
<el-button type="primary" @click="exmaStart">开始考试</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div slot="header" style="text-align: center;">
|
||||
<b>试卷名称: {{ examDetails.name }}</b>
|
||||
</div>
|
||||
<div style="margin:50px; overflow-y: auto;">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: height - 190 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试时间:</span>
|
||||
<span v-if="examDetails.startTime" class="list-elem">
|
||||
{{ examDetails.startTime }} - {{ examDetails.endTime }}</span>
|
||||
<span v-else class="list-elem">随时都可以考试</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试说明:</span>
|
||||
<span class="list-elem">{{ examDetails.remarks }}</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试时长:</span>
|
||||
<span class="list-elem">{{ parseInt(examDetails.duration) / 60 }}分钟</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试满分:</span>
|
||||
<span class="list-elem">{{ examDetails.fullPoint }}分</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试及格分:</span>
|
||||
<span class="list-elem">{{ examDetails.passingPoint }}分</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">考试规则:</span>
|
||||
<span class="list-elem">
|
||||
<p class="list-table">
|
||||
<el-table :data="examDetails.examDefinitionRulesVOList" border show-summary>
|
||||
<el-table-column prop="name" label="实训类型" width="180" />
|
||||
<el-table-column prop="num" label="题数" />
|
||||
<el-table-column prop="point" label="分值" />
|
||||
<el-table-column prop="chapterIdLong" label="总分" />
|
||||
</el-table>
|
||||
</p>
|
||||
</span>
|
||||
</p>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="btn-start">
|
||||
<el-button type="primary" @click="exmaStart">开始考试</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
<script>
|
||||
import { examNotify } from '@/api/simulation';
|
||||
import { getExamLessonDetail } from '@/api/management/exam';
|
||||
import { generateExamList } from '@/api/management/userexam';
|
||||
import { getPublishLessonDetail } from "@/api/jmap/lesson";
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { getDetailList } from '@/api/management/dictionary';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import { examNotify } from '@/api/simulation';
|
||||
import { getExamLessonDetail } from '@/api/management/exam';
|
||||
import { generateExamList } from '@/api/management/userexam';
|
||||
import { getPublishLessonDetail } from '@/api/jmap/lesson';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { getDetailList } from '@/api/management/dictionary';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
|
||||
export default {
|
||||
name: 'ExamDetailView',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
examDetails: {
|
||||
lessonId: '',
|
||||
name: '',
|
||||
remarks: '',
|
||||
examDefinitionRulesVOList: [],
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
fullPoint: '',
|
||||
passingPoint: '',
|
||||
duration: '',
|
||||
type: '',
|
||||
},
|
||||
typeList: [],
|
||||
examList: [],
|
||||
trainingOperateTypeMap: {},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route.params.examId': function (val) {
|
||||
this.loadInitPage(val);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('trainingList', [
|
||||
'trainingList'
|
||||
]),
|
||||
},
|
||||
async mounted() {
|
||||
this.trainingOperateTypeMap = {};
|
||||
this.$Dictionary.stationControl().then(list => {
|
||||
this.trainingOperateTypeMap['01'] = list; //控制权实训
|
||||
});
|
||||
this.$Dictionary.signalOperation().then(list => {
|
||||
this.trainingOperateTypeMap['02'] = list; //信号机实训
|
||||
});
|
||||
this.$Dictionary.switchOperation().then(list => {
|
||||
this.trainingOperateTypeMap['03'] = list; //道岔实训
|
||||
});
|
||||
this.$Dictionary.sectionOperation().then(list => {
|
||||
this.trainingOperateTypeMap['04'] = list; //区段实训
|
||||
});
|
||||
this.$Dictionary.stationStandOperation().then(list => {
|
||||
this.trainingOperateTypeMap['05'] = list; //站台实训
|
||||
});
|
||||
this.$Dictionary.trainPlanOperation().then(list => {
|
||||
this.trainingOperateTypeMap['06'] = list; //行车计划实训
|
||||
});
|
||||
this.$Dictionary.trainOperation().then(list => {
|
||||
this.trainingOperateTypeMap['07'] = list; //列车实训
|
||||
});
|
||||
await this.getList();
|
||||
this.loadInitPage(this.$route.params.examId);
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
async getList() {
|
||||
this.typeList = [];
|
||||
await getDetailList('training_type').then(res => {
|
||||
this.typeList = res.data;
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
},
|
||||
async loadInitPage(examId) {
|
||||
if (examId) {
|
||||
let res = await getExamLessonDetail(examId);
|
||||
this.examDetails = res.data
|
||||
this.examDetails.examDefinitionRulesVOList.forEach((res, index) => {
|
||||
res.chapterIdLong = Number(res.num) * Number(res.point)
|
||||
this.typeList.forEach(v => {
|
||||
if (res.trainingType == v.code) {
|
||||
this.examDetails.examDefinitionRulesVOList[index].name = v.name;
|
||||
if (res.operateType) {
|
||||
this.trainingOperateTypeMap[res.trainingType].forEach(item => {
|
||||
if (item.code == res.operateType) {
|
||||
this.examDetails.examDefinitionRulesVOList[index].name = `${this.examDetails.examDefinitionRulesVOList[index].name}-${item.name}`;
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
let resp = await generateExamList(this.examDetails.id)
|
||||
this.examList = resp.data.userExamQuestionsVOs;
|
||||
this.userExam = resp.data;
|
||||
}
|
||||
},
|
||||
buy() {
|
||||
getPublishLessonDetail({ id: this.examDetails.lessonId }).then((res) => {
|
||||
this.$router.push({
|
||||
path: `${UrlConfig.exam.pay}/${this.examDetails.lessonId}`,
|
||||
query: { permissionType: PermissionType.EXAM, prdCode: res.data.prdCode, mapId: res.data.mapId }
|
||||
});
|
||||
})
|
||||
export default {
|
||||
name: 'ExamDetailView',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
examDetails: {
|
||||
lessonId: '',
|
||||
name: '',
|
||||
remarks: '',
|
||||
examDefinitionRulesVOList: [],
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
fullPoint: '',
|
||||
passingPoint: '',
|
||||
duration: '',
|
||||
type: ''
|
||||
},
|
||||
typeList: [],
|
||||
examList: [],
|
||||
trainingOperateTypeMap: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'$route.params.examId': function (val) {
|
||||
this.loadInitPage(val);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('trainingList', [
|
||||
'trainingList'
|
||||
])
|
||||
},
|
||||
async mounted() {
|
||||
this.trainingOperateTypeMap = {};
|
||||
this.$Dictionary.stationControl().then(list => {
|
||||
this.trainingOperateTypeMap['01'] = list; // 控制权实训
|
||||
});
|
||||
this.$Dictionary.signalOperation().then(list => {
|
||||
this.trainingOperateTypeMap['02'] = list; // 信号机实训
|
||||
});
|
||||
this.$Dictionary.switchOperation().then(list => {
|
||||
this.trainingOperateTypeMap['03'] = list; // 道岔实训
|
||||
});
|
||||
this.$Dictionary.sectionOperation().then(list => {
|
||||
this.trainingOperateTypeMap['04'] = list; // 区段实训
|
||||
});
|
||||
this.$Dictionary.stationStandOperation().then(list => {
|
||||
this.trainingOperateTypeMap['05'] = list; // 站台实训
|
||||
});
|
||||
this.$Dictionary.trainPlanOperation().then(list => {
|
||||
this.trainingOperateTypeMap['06'] = list; // 行车计划实训
|
||||
});
|
||||
this.$Dictionary.trainOperation().then(list => {
|
||||
this.trainingOperateTypeMap['07'] = list; // 列车实训
|
||||
});
|
||||
await this.getList();
|
||||
this.loadInitPage(this.$route.params.examId);
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
async getList() {
|
||||
this.typeList = [];
|
||||
await getDetailList('training_type').then(res => {
|
||||
this.typeList = res.data;
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
},
|
||||
async loadInitPage(examId) {
|
||||
if (examId) {
|
||||
const res = await getExamLessonDetail(examId);
|
||||
this.examDetails = res.data;
|
||||
this.examDetails.examDefinitionRulesVOList.forEach((res, index) => {
|
||||
res.chapterIdLong = Number(res.num) * Number(res.point);
|
||||
this.typeList.forEach(v => {
|
||||
if (res.trainingType == v.code) {
|
||||
this.examDetails.examDefinitionRulesVOList[index].name = v.name;
|
||||
if (res.operateType) {
|
||||
this.trainingOperateTypeMap[res.trainingType].forEach(item => {
|
||||
if (item.code == res.operateType) {
|
||||
this.examDetails.examDefinitionRulesVOList[index].name = `${this.examDetails.examDefinitionRulesVOList[index].name}-${item.name}`;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
const resp = await generateExamList(this.examDetails.id);
|
||||
this.examList = resp.data.userExamQuestionsVOs;
|
||||
this.userExam = resp.data;
|
||||
}
|
||||
},
|
||||
buy() {
|
||||
getPublishLessonDetail({ id: this.examDetails.lessonId }).then((res) => {
|
||||
this.$router.push({
|
||||
path: `${UrlConfig.exam.pay}/${this.examDetails.lessonId}`,
|
||||
query: { permissionType: PermissionType.EXAM, prdCode: res.data.prdCode, mapId: res.data.mapId }
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
async examDetail() {
|
||||
let data = this.examDetails
|
||||
try {
|
||||
let response = await generateExamList(data.id)
|
||||
this.userExam = response.data;
|
||||
let list = response.data.userExamQuestionsVOs;
|
||||
await this.$store.dispatch('exam/start')
|
||||
await this.$store.dispatch('exam/setUsedTime', this.userExam.usedTime);
|
||||
await this.$store.dispatch('exam/setTotalTime', this.userExam.duration);
|
||||
await this.$store.dispatch('trainingList/setTrainingList', list);
|
||||
} catch (error) {
|
||||
this.loading.close();
|
||||
//判断是否有考试权限,如果没有权限则跳到购买页面,否则报错
|
||||
if (error.code === 500004) {
|
||||
this.$confirm('无此课程的考试权限,请前往购买!', '提示', {
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
center: true
|
||||
}).then(() => {
|
||||
this.buy();
|
||||
}).catch(() => { });
|
||||
} else if (error.code === 500005) {
|
||||
this.$messageBox('不在考试范围之内');
|
||||
} else {
|
||||
this.$messageBox(`${error.message}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
exmaStart() {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.examDetail();
|
||||
if (this.examList.length) {
|
||||
examNotify({ examId: this.$route.params.examId }).then(resp => {
|
||||
let query = {
|
||||
group: resp.data,
|
||||
trainingId: this.examList[0].trainingId,
|
||||
userExamId: this.userExam.id,
|
||||
examQuestionId: this.examList[0].id
|
||||
};
|
||||
this.$router.push({ path: `${UrlConfig.display}/exam`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
this.loading.close();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async examDetail() {
|
||||
const data = this.examDetails;
|
||||
try {
|
||||
const response = await generateExamList(data.id);
|
||||
this.userExam = response.data;
|
||||
const list = response.data.userExamQuestionsVOs;
|
||||
await this.$store.dispatch('exam/start');
|
||||
await this.$store.dispatch('exam/setUsedTime', this.userExam.usedTime);
|
||||
await this.$store.dispatch('exam/setTotalTime', this.userExam.duration);
|
||||
await this.$store.dispatch('trainingList/setTrainingList', list);
|
||||
} catch (error) {
|
||||
this.loading.close();
|
||||
// 判断是否有考试权限,如果没有权限则跳到购买页面,否则报错
|
||||
if (error.code === 500004) {
|
||||
this.$confirm('无此课程的考试权限,请前往购买!', '提示', {
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
center: true
|
||||
}).then(() => {
|
||||
this.buy();
|
||||
}).catch(() => { });
|
||||
} else if (error.code === 500005) {
|
||||
this.$messageBox('不在考试范围之内');
|
||||
} else {
|
||||
this.$messageBox(`${error.message}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
exmaStart() {
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.examDetail();
|
||||
if (this.examList.length) {
|
||||
examNotify({ examId: this.$route.params.examId }).then(resp => {
|
||||
const query = {
|
||||
group: resp.data,
|
||||
trainingId: this.examList[0].trainingId,
|
||||
userExamId: this.userExam.id,
|
||||
examQuestionId: this.examList[0].id
|
||||
};
|
||||
this.$router.push({ path: `${UrlConfig.display}/exam`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
this.loading.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
@ -1,279 +1,300 @@
|
||||
<template>
|
||||
<el-card class="map-list-main" v-loading="loading">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>草稿地图列表</span>
|
||||
<el-button type="text" @click="createMap" style="float: right; padding: 3px 0">新建</el-button>
|
||||
<!-- <el-button type="text" v-if="$route.params.mapId != 0" @click="doExportFront" style="float: right; padding: 3px 0; margin-right: 9px;">导出地图</el-button> -->
|
||||
<el-button type="text" class="uploadDemo">
|
||||
<input type="file" @change="importf" ref="files" class="file_box"
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
|
||||
导入地图
|
||||
</el-button>
|
||||
</div>
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{height: height + 'px'}">
|
||||
<el-tree ref="tree" :data="mapList" node-key="id" highlight-current :props="defaultProps"
|
||||
@node-click="handleNodeClick" @node-contextmenu="showContextMenu" class="tree-height-max">
|
||||
<span slot-scope="{ node, data }">
|
||||
<span v-if="node.data.type == 'skin'" class="el-icon-news"> {{ node.label }}</span>
|
||||
<span v-if="node.data.type == 'map'" class="el-icon-edit-outline"> {{ node.label }}</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</el-scrollbar>
|
||||
<map-create ref="mapCreate" @refresh="refresh" :skinCode="skinCode" @editmap="handleNodeClick"></map-create>
|
||||
<map-operate-menu ref="menu" :point="point" :editModel="editModel" @editRoute="editRoute" @setSwitch="setSwitch"
|
||||
@editMap="handleNodeClick" @pathUnit="pathUnit" @refresh="refresh"></map-operate-menu>
|
||||
<el-card v-loading="loading" class="map-list-main">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>草稿地图列表</span>
|
||||
<el-button type="text" style="float: right; padding: 3px 0" @click="createMap">新建</el-button>
|
||||
<!-- <el-button type="text" v-if="$route.params.mapId != 0" @click="doExportFront" style="float: right; padding: 3px 0; margin-right: 9px;">导出地图</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"
|
||||
>
|
||||
导入地图
|
||||
</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, data }">
|
||||
<span v-if="node.data.type == 'skin'" class="el-icon-news"> {{ node.label }}</span>
|
||||
<span v-if="node.data.type == 'map'" class="el-icon-edit-outline"> {{ 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"
|
||||
@editRoute="editRoute"
|
||||
@setSwitch="setSwitch"
|
||||
@editMap="handleNodeClick"
|
||||
@pathUnit="pathUnit"
|
||||
@refresh="refresh"
|
||||
/>
|
||||
|
||||
</el-card>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { DeviceMenu } from '@/scripts/ConstDic';
|
||||
import { deleteMap, listMap, getMapTree, newMap, publishMap, editMap, saveAsMap, getMapDetail, postBuildMapImport } from '@/api/jmap/mapdraft'
|
||||
import PopMenu from '@/components/PopMenu';
|
||||
import MapOperateMenu from './operateMenu';
|
||||
import MapCreate from './create';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import XLSX from 'xlsx';
|
||||
import { translate, translateSheetTitle } from '@/scripts/translate';
|
||||
import { sheet_to_json } from '@/utils/Export2Excel';
|
||||
import localStore from 'storejs';
|
||||
import { DeviceMenu } from '@/scripts/ConstDic';
|
||||
import { deleteMap, listMap, getMapTree, newMap, publishMap, editMap, saveAsMap, getMapDetail, postBuildMapImport } from '@/api/jmap/mapdraft';
|
||||
import PopMenu from '@/components/PopMenu';
|
||||
import MapOperateMenu from './operateMenu';
|
||||
import MapCreate from './create';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import XLSX from 'xlsx';
|
||||
import { translate, translateSheetTitle } from '@/scripts/translate';
|
||||
import { sheet_to_json } from '@/utils/Export2Excel';
|
||||
import localStore from 'storejs';
|
||||
|
||||
export default {
|
||||
name: 'MapListDraft',
|
||||
components: {
|
||||
PopMenu,
|
||||
MapCreate,
|
||||
MapOperateMenu
|
||||
},
|
||||
mixins: [WindowResizeHandler],
|
||||
data() {
|
||||
return {
|
||||
height: 0,
|
||||
loading: true,
|
||||
activeName: 'first',
|
||||
mapList: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
editModel: {},
|
||||
skinCode: '',
|
||||
point: {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.refresh();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler() {
|
||||
this.height = this._clientHeight - 115;
|
||||
},
|
||||
getSkinStyle(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();
|
||||
let menu = DeviceMenu.Map;
|
||||
export default {
|
||||
name: 'MapListDraft',
|
||||
components: {
|
||||
PopMenu,
|
||||
MapCreate,
|
||||
MapOperateMenu
|
||||
},
|
||||
mixins: [WindowResizeHandler],
|
||||
data() {
|
||||
return {
|
||||
height: 0,
|
||||
loading: true,
|
||||
activeName: 'first',
|
||||
mapList: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
editModel: {},
|
||||
skinCode: '',
|
||||
point: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.refresh();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler() {
|
||||
this.height = this._clientHeight - 115;
|
||||
},
|
||||
getSkinStyle(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.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
|
||||
}
|
||||
},
|
||||
handleNodeClick(obj, node) {
|
||||
this.getSkinStyle(node);
|
||||
if (obj && obj.type == 'map') {
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.$emit('mapSelected', { mapInfo: obj, view: 'draft' });
|
||||
}
|
||||
},
|
||||
editRoute() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'route' });
|
||||
},
|
||||
setSwitch() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'swtich' });
|
||||
},
|
||||
pathUnit() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'path' });
|
||||
},
|
||||
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;
|
||||
})
|
||||
},
|
||||
this.point = {
|
||||
x: e.clientX,
|
||||
y: e.clientY
|
||||
};
|
||||
this.editModel = obj;
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
|
||||
}
|
||||
},
|
||||
handleNodeClick(obj, node) {
|
||||
this.getSkinStyle(node);
|
||||
if (obj && obj.type == 'map') {
|
||||
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
|
||||
this.$emit('mapSelected', { mapInfo: obj, view: 'draft' });
|
||||
}
|
||||
},
|
||||
editRoute() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'route' });
|
||||
},
|
||||
setSwitch() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'swtich' });
|
||||
},
|
||||
pathUnit() {
|
||||
this.$emit('mapSelected', { mapInfo: this.editModel, view: 'path' });
|
||||
},
|
||||
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)'
|
||||
});
|
||||
let obj = this.$refs.files;
|
||||
let wb;
|
||||
if (!obj.files) return;
|
||||
let f = obj.files[0];
|
||||
let reader = new FileReader();
|
||||
const that = this;
|
||||
reader.onload = function (e) {
|
||||
let data = e.target.result;
|
||||
if (that.rABS) {
|
||||
wb = XLSX.read(btoa(that.fixdata(data)), {//手动转化
|
||||
type: 'base64'
|
||||
});
|
||||
} else {
|
||||
wb = XLSX.read(data, {
|
||||
type: 'binary'
|
||||
});
|
||||
}
|
||||
let resultJSONData = { 'devices': {} };
|
||||
for (let index in wb.Sheets) {
|
||||
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) {
|
||||
|
||||
let titleNum = that.formatSheetTitle(index);
|
||||
let key = translateSheetTitle.sheetName[titleNum];
|
||||
const titleNum = that.formatSheetTitle(index);
|
||||
const key = translateSheetTitle.sheetName[titleNum];
|
||||
|
||||
let filterVal = that.handelData(key);
|
||||
let jsonData = sheet_to_json(wb.Sheets[index])
|
||||
let 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);
|
||||
}
|
||||
},
|
||||
// 转换数据格式
|
||||
handelData(key) {
|
||||
let tHeader = [];
|
||||
let tHeaderF = [];
|
||||
if (translate[key]) {
|
||||
translate[key].columns.forEach(item => {
|
||||
tHeader.push(item.tHeader);
|
||||
tHeaderF.push(item.key);
|
||||
});
|
||||
}
|
||||
let filterVal = {
|
||||
tHeader: tHeader,
|
||||
tHeaderF: tHeaderF,
|
||||
};
|
||||
return filterVal;
|
||||
},
|
||||
//文件流转BinaryString
|
||||
fixdata(data) {
|
||||
var o = "",
|
||||
l = 0,
|
||||
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) => {
|
||||
let 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;
|
||||
},
|
||||
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);
|
||||
}
|
||||
},
|
||||
// 转换数据格式
|
||||
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() {
|
||||
let res = await getMapDetail(this.$route.params.mapId);
|
||||
let resultData = res.data;
|
||||
if (resultData === false) {
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// 前端方式导出
|
||||
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);
|
||||
self.queryExportData(resultData).then(data => {
|
||||
excel.export_json_excel(data, resultData.name);
|
||||
|
||||
}).catch(error => {
|
||||
self.$message.error('导出执行异常:' + error.message);
|
||||
});
|
||||
}).catch(error => {
|
||||
self.$message.error('导出执行异常:' + error.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 格式化数据列表
|
||||
queryExportData(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let result = {
|
||||
base: [],
|
||||
};
|
||||
let obj = {};
|
||||
for (let 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 格式化数据列表
|
||||
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 {
|
||||
|
@ -1,213 +1,223 @@
|
||||
<template>
|
||||
<div class="card-box">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step :title="title" icon="el-icon-edit-outline"></el-step>
|
||||
<el-step title="" icon="el-icon-upload"></el-step>
|
||||
</el-steps>
|
||||
<el-card class="forms">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{height:height-160 + 'px'}" style="padding-top: 40px">
|
||||
<el-form ref="form" :model="courseModel" :rules="rules" label-width="135px">
|
||||
<el-form-item label="课程名称:" prop="name">
|
||||
<el-input v-model="courseModel.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联皮肤:" prop="skinCode">
|
||||
<el-select v-model="courseModel.skinCode" placeholder="请选择" :disabled="true">
|
||||
<el-option v-for="(item,index) in skinStyleList" :key="index" :label="item.name"
|
||||
:value="item.code"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联产品:" prop="prdCode">
|
||||
<el-select v-model="courseModel.prdCode" placeholder="请选择" :disabled="isEdit">
|
||||
<el-option v-for="(item,index) in productList" :key="index" :label="item.name"
|
||||
:value="item.code"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="课程说明:" prop="remarks">
|
||||
<el-input type="textarea" :autosize="{ minRows: 6, maxRows: 6}" placeholder="请输入内容"
|
||||
v-model="courseModel.remarks">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<template v-if="!isEdit">
|
||||
<el-button type="primary" @click="create" v-if="courseModel.skinCode">创建</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button type="primary" @click="update">更新</el-button>
|
||||
<el-button type="primary" @click="publish">发布</el-button>
|
||||
<el-button type="danger" @click="deleteLesson">删除</el-button>
|
||||
</template>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<publish-lesson ref="publishLesson"></publish-lesson>
|
||||
<div 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-160 + 'px'}" style="padding-top: 40px">
|
||||
<el-form ref="form" :model="courseModel" :rules="rules" label-width="135px">
|
||||
<el-form-item label="课程名称:" prop="name">
|
||||
<el-input v-model="courseModel.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联皮肤:" prop="skinCode">
|
||||
<el-select v-model="courseModel.skinCode" placeholder="请选择" :disabled="true">
|
||||
<el-option
|
||||
v-for="(item,index) in skinStyleList"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联产品:" prop="prdCode">
|
||||
<el-select v-model="courseModel.prdCode" placeholder="请选择" :disabled="isEdit">
|
||||
<el-option
|
||||
v-for="(item,index) in productList"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="课程说明:" prop="remarks">
|
||||
<el-input
|
||||
v-model="courseModel.remarks"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 6, maxRows: 6}"
|
||||
placeholder="请输入内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<template v-if="!isEdit">
|
||||
<el-button v-if="courseModel.skinCode" type="primary" @click="create">创建</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button type="primary" @click="update">更新</el-button>
|
||||
<el-button type="primary" @click="publish">发布</el-button>
|
||||
<el-button type="danger" @click="deleteLesson">删除</el-button>
|
||||
</template>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<publish-lesson ref="publishLesson" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createLesson, updateLesson, getLessonDetail, delLesson } from '@/api/jmap/lessondraft'
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getSkinStyleList } from '@/api/management/mapskin';
|
||||
import localStore from 'storejs';
|
||||
import PublishLesson from './publish';
|
||||
import { createLesson, updateLesson, getLessonDetail, delLesson } from '@/api/jmap/lessondraft';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { getSkinStyleList } from '@/api/management/mapskin';
|
||||
import PublishLesson from './publish';
|
||||
|
||||
export default {
|
||||
name: 'courseEdit',
|
||||
props: {
|
||||
height: {
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
components: {
|
||||
PublishLesson
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isEdit: false,
|
||||
display: 1,
|
||||
productList: [],
|
||||
skinStyleList: [],
|
||||
courseModel: {
|
||||
id: '',
|
||||
prdCode: '',
|
||||
product: [],
|
||||
skinCode: '',
|
||||
name: '',
|
||||
remarks: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.isEdit ? '编辑课程' : '创建课程';
|
||||
},
|
||||
rules() {
|
||||
let baseRules = {
|
||||
name: [
|
||||
{ required: true, message: '请输入课程名称', trigger: 'change' }
|
||||
],
|
||||
skinCode: [
|
||||
{ required: true, message: '请选择皮肤类型', trigger: 'change' }
|
||||
],
|
||||
prdCode: [
|
||||
{ required: true, message: '请选择关联产品', trigger: 'change' }
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: '请输入课程说明', trigger: 'change' }
|
||||
],
|
||||
}
|
||||
return baseRules;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.skinStyleList = [];
|
||||
getSkinStyleList().then(response => {
|
||||
this.skinStyleList = response.data;
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
initData(isNew, node) {
|
||||
this.isEdit = !isNew;
|
||||
this.clearForm();
|
||||
if (!isNew) {
|
||||
this.refresh(node);
|
||||
} else {
|
||||
this.courseModel.skinCode = node.data.id;
|
||||
}
|
||||
export default {
|
||||
name: 'CourseEdit',
|
||||
components: {
|
||||
PublishLesson
|
||||
},
|
||||
props: {
|
||||
height: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isEdit: false,
|
||||
display: 1,
|
||||
productList: [],
|
||||
skinStyleList: [],
|
||||
courseModel: {
|
||||
id: '',
|
||||
prdCode: '',
|
||||
product: [],
|
||||
skinCode: '',
|
||||
name: '',
|
||||
remarks: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.isEdit ? '编辑课程' : '创建课程';
|
||||
},
|
||||
rules() {
|
||||
const baseRules = {
|
||||
name: [
|
||||
{ required: true, message: '请输入课程名称', trigger: 'change' }
|
||||
],
|
||||
skinCode: [
|
||||
{ required: true, message: '请选择皮肤类型', trigger: 'change' }
|
||||
],
|
||||
prdCode: [
|
||||
{ required: true, message: '请选择关联产品', trigger: 'change' }
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: '请输入课程说明', trigger: 'change' }
|
||||
]
|
||||
};
|
||||
return baseRules;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.skinStyleList = [];
|
||||
getSkinStyleList().then(response => {
|
||||
this.skinStyleList = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
initData(isNew, node) {
|
||||
this.isEdit = !isNew;
|
||||
this.clearForm();
|
||||
if (!isNew) {
|
||||
this.refresh(node);
|
||||
} else {
|
||||
this.courseModel.skinCode = node.data.id;
|
||||
}
|
||||
|
||||
this.productList = [];
|
||||
getCommodityMapProduct(this.getParentSkin(node)).then(response => {
|
||||
this.productList = response.data || [];
|
||||
this.productList = this.productList.filter(elem => { return elem.prdType != '03' })
|
||||
})
|
||||
this.productList = [];
|
||||
getCommodityMapProduct(this.getParentSkin(node)).then(response => {
|
||||
this.productList = response.data || [];
|
||||
this.productList = this.productList.filter(elem => { return elem.prdType != '03'; });
|
||||
});
|
||||
|
||||
},
|
||||
clearForm() {
|
||||
this.courseModel.id = '';
|
||||
this.$refs.form.resetFields();
|
||||
},
|
||||
create() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
let model = {
|
||||
skinCode: this.courseModel.skinCode,
|
||||
prdCode: this.courseModel.prdCode,
|
||||
name: this.courseModel.name,
|
||||
remarks: this.courseModel.remarks
|
||||
}
|
||||
createLesson(model).then(response => {
|
||||
this.$emit('refresh');
|
||||
this.$message.success('创建成功');
|
||||
}).catch(error => {
|
||||
this.$messageBox('创建失败')
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
let model = {
|
||||
id: this.courseModel.id,
|
||||
skinCode: this.courseModel.skinCode,
|
||||
prdCode: this.courseModel.prdCode,
|
||||
name: this.courseModel.name,
|
||||
remarks: this.courseModel.remarks
|
||||
}
|
||||
updateLesson(model).then(response => {
|
||||
this.$emit('refresh');
|
||||
this.$message.success('更新成功');
|
||||
}).catch(error => {
|
||||
this.$messageBox('更新失败')
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
publish() {
|
||||
this.$refs.publishLesson.doShow(this.courseModel);
|
||||
},
|
||||
deleteLesson() {
|
||||
delLesson(this.courseModel).then(response => {
|
||||
this.$message.success('删除成功');
|
||||
this.$refs.form.resetFields();
|
||||
this.isEdit = false,
|
||||
this.$emit('refresh');
|
||||
}).catch(error => {
|
||||
this.$messageBox('删除失败');
|
||||
});
|
||||
},
|
||||
getParentSkin(node) {
|
||||
let next = node;
|
||||
let skinCode = '';
|
||||
while (next) {
|
||||
if (next.data && next.data.type == 'skin') {
|
||||
skinCode = next.data.id;
|
||||
}
|
||||
next = next.parent;
|
||||
}
|
||||
return skinCode;
|
||||
},
|
||||
refresh(node) {
|
||||
if (node && node.data) {
|
||||
getLessonDetail(node.data).then(response => {
|
||||
let data = response.data;
|
||||
this.courseModel = {
|
||||
id: data.id,
|
||||
skinCode: this.getParentSkin(node),
|
||||
prdCode: data.prdCode,
|
||||
name: data.name,
|
||||
remarks: data.remarks,
|
||||
};
|
||||
}).catch(error => {
|
||||
this.$messageBox('获取课程信息失败')
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForm() {
|
||||
this.courseModel.id = '';
|
||||
this.$refs.form.resetFields();
|
||||
},
|
||||
create() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const model = {
|
||||
skinCode: this.courseModel.skinCode,
|
||||
prdCode: this.courseModel.prdCode,
|
||||
name: this.courseModel.name,
|
||||
remarks: this.courseModel.remarks
|
||||
};
|
||||
createLesson(model).then(response => {
|
||||
this.$emit('refresh');
|
||||
this.$message.success('创建成功');
|
||||
}).catch(error => {
|
||||
this.$messageBox('创建失败');
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const model = {
|
||||
id: this.courseModel.id,
|
||||
skinCode: this.courseModel.skinCode,
|
||||
prdCode: this.courseModel.prdCode,
|
||||
name: this.courseModel.name,
|
||||
remarks: this.courseModel.remarks
|
||||
};
|
||||
updateLesson(model).then(response => {
|
||||
this.$emit('refresh');
|
||||
this.$message.success('更新成功');
|
||||
}).catch(error => {
|
||||
this.$messageBox('更新失败');
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
publish() {
|
||||
this.$refs.publishLesson.doShow(this.courseModel);
|
||||
},
|
||||
deleteLesson() {
|
||||
delLesson(this.courseModel).then(response => {
|
||||
this.$message.success('删除成功');
|
||||
this.$refs.form.resetFields();
|
||||
this.isEdit = false,
|
||||
this.$emit('refresh');
|
||||
}).catch(error => {
|
||||
this.$messageBox('删除失败');
|
||||
});
|
||||
},
|
||||
getParentSkin(node) {
|
||||
let next = node;
|
||||
let skinCode = '';
|
||||
while (next) {
|
||||
if (next.data && next.data.type == 'skin') {
|
||||
skinCode = next.data.id;
|
||||
}
|
||||
next = next.parent;
|
||||
}
|
||||
return skinCode;
|
||||
},
|
||||
refresh(node) {
|
||||
if (node && node.data) {
|
||||
getLessonDetail(node.data).then(response => {
|
||||
const data = response.data;
|
||||
this.courseModel = {
|
||||
id: data.id,
|
||||
skinCode: this.getParentSkin(node),
|
||||
prdCode: data.prdCode,
|
||||
name: data.name,
|
||||
remarks: data.remarks
|
||||
};
|
||||
}).catch(error => {
|
||||
this.$messageBox('获取课程信息失败');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@ -263,4 +273,4 @@
|
||||
text-align: center;
|
||||
margin: 20px auto;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -1,317 +1,327 @@
|
||||
<template>
|
||||
<el-dialog :title="operation.title" :visible.sync="dialogShow" width="500px" :before-close="close">
|
||||
<el-form ref="form" :model="operateModel" label-width="100px" :rules="rules" size="mini">
|
||||
<el-form-item label="皮肤类型:" prop="skinCode">
|
||||
<el-select v-model="operateModel.skinCode" @change="skinStyleChoose">
|
||||
<el-option v-for="option in skinStyleList" :key="option.code" :label="option.name"
|
||||
:value="option.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品类型:" prop="prdCode">
|
||||
<el-select v-model="operateModel.prdCode" @change="prdChange">
|
||||
<el-option v-for="option in productList" :key="option.code" :label="option.name"
|
||||
:value="option.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="实训类型:" prop="type">
|
||||
<el-select v-model="operateModel.type" @change="typeChange">
|
||||
<el-option v-for="option in trainingTypeLists" :key="option.code" :label="option.name"
|
||||
:value="option.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作类型:" prop="operateType">
|
||||
<el-select v-model="operateModel.operateType" multiple>
|
||||
<el-option v-for="option in trainingTypeMap[operateModel.type]" :key="option.code"
|
||||
:label="option.name" :value="option.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="最小用时:" prop="minDuration" v-if="isUpdate">
|
||||
<el-input-number v-model="operateModel.minDuration" :min="0" :max="10000"></el-input-number>s
|
||||
</el-form-item>
|
||||
<el-form-item label="最大用时:" prop="maxDuration" v-if="isUpdate">
|
||||
<el-input-number v-model="operateModel.maxDuration" :min="0" :max="10000"></el-input-number>s
|
||||
</el-form-item>
|
||||
<el-form-item label="实训描述:" prop="remarks" v-if="isUpdate">
|
||||
<el-input type="textarea" v-model="operateModel.remarks"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose">取 消</el-button>
|
||||
<el-button type="primary" @click="handleDeal" :loading="loading">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog :title="operation.title" :visible.sync="dialogShow" width="500px" :before-close="close">
|
||||
<el-form ref="form" :model="operateModel" label-width="100px" :rules="rules" size="mini">
|
||||
<el-form-item label="皮肤类型:" prop="skinCode">
|
||||
<el-select v-model="operateModel.skinCode" @change="skinStyleChoose">
|
||||
<el-option
|
||||
v-for="option in skinStyleList"
|
||||
:key="option.code"
|
||||
:label="option.name"
|
||||
:value="option.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品类型:" prop="prdCode">
|
||||
<el-select v-model="operateModel.prdCode" @change="prdChange">
|
||||
<el-option
|
||||
v-for="option in productList"
|
||||
:key="option.code"
|
||||
:label="option.name"
|
||||
:value="option.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="实训类型:" prop="type">
|
||||
<el-select v-model="operateModel.type" @change="typeChange">
|
||||
<el-option
|
||||
v-for="option in trainingTypeLists"
|
||||
:key="option.code"
|
||||
:label="option.name"
|
||||
:value="option.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作类型:" prop="operateType">
|
||||
<el-select v-model="operateModel.operateType" multiple>
|
||||
<el-option
|
||||
v-for="option in trainingTypeMap[operateModel.type]"
|
||||
:key="option.code"
|
||||
:label="option.name"
|
||||
:value="option.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isUpdate" label="最小用时:" prop="minDuration">
|
||||
<el-input-number v-model="operateModel.minDuration" :min="0" :max="10000" />s
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isUpdate" label="最大用时:" prop="maxDuration">
|
||||
<el-input-number v-model="operateModel.maxDuration" :min="0" :max="10000" />s
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isUpdate" label="实训描述:" prop="remarks">
|
||||
<el-input v-model="operateModel.remarks" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="handleDeal">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { addAutoTraining, updateAutoTraining, deleteAutoTraining } from '@/api/jmap/training';
|
||||
import { getOperateTrainingList } from '@/api/management/operation';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import localStore from 'storejs';
|
||||
import { addAutoTraining, updateAutoTraining, deleteAutoTraining } from '@/api/jmap/training';
|
||||
import { getOperateTrainingList } from '@/api/management/operation';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
|
||||
export default {
|
||||
name: 'TrainingAdd',
|
||||
props: {
|
||||
skinStyleList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
trainingTypeList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
trainingOperateTypeMap: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
var minDurations = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入标准用时'));
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (!Number.isInteger(value)) {
|
||||
callback(new Error('请输入数字值'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
var maxDurations = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入标准用时'));
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (!Number.isInteger(value)) {
|
||||
callback(new Error('请输入数字值'));
|
||||
} else {
|
||||
if (value < this.operateModel.minDuration) {
|
||||
callback(new Error('必须大于最小时间'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
export default {
|
||||
name: 'TrainingAdd',
|
||||
props: {
|
||||
skinStyleList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
trainingTypeList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
trainingOperateTypeMap: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
var minDurations = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入标准用时'));
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (!Number.isInteger(value)) {
|
||||
callback(new Error('请输入数字值'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
var maxDurations = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入标准用时'));
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (!Number.isInteger(value)) {
|
||||
callback(new Error('请输入数字值'));
|
||||
} else {
|
||||
if (value < this.operateModel.minDuration) {
|
||||
callback(new Error('必须大于最小时间'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
var checkOperateType = (rule, value, callback) => {
|
||||
if (value.length <= 0) {
|
||||
return callback(new Error('请选择实训类型'));
|
||||
} else if (this.operation.event == '02' && value.length !== 1) {
|
||||
return callback(new Error('只能选择一个实训类型'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
var checkOperateType = (rule, value, callback) => {
|
||||
if (value.length <= 0) {
|
||||
return callback(new Error('请选择实训类型'));
|
||||
} else if (this.operation.event == '02' && value.length !== 1) {
|
||||
return callback(new Error('只能选择一个实训类型'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
var checkRemarks = (rule, value, callback) => {
|
||||
if (this.operation.event == '02' && !value) {
|
||||
return callback(new Error('请输入实训描述'));
|
||||
}
|
||||
callback();
|
||||
};
|
||||
// var checkRemarks = (rule, value, callback) => {
|
||||
// if (this.operation.event == '02' && !value) {
|
||||
// return callback(new Error('请输入实训描述'));
|
||||
// }
|
||||
// callback();
|
||||
// };
|
||||
|
||||
return {
|
||||
dialogShow: false,
|
||||
productTypesList: [],
|
||||
trainTypesList: [],
|
||||
productList: [],
|
||||
checkList: [],
|
||||
operateModel: {
|
||||
name: '',
|
||||
type: '',
|
||||
skinCode: '',
|
||||
prdCode: '',
|
||||
operateType: [],
|
||||
maxDuration: 0,
|
||||
minDuration: 0,
|
||||
remarks: '',
|
||||
},
|
||||
loading: false,
|
||||
trainingTypeLists: [],
|
||||
trainingTypeMap: {},
|
||||
operation: {
|
||||
event: '',
|
||||
title: '',
|
||||
},
|
||||
rules: {
|
||||
skinCode: [
|
||||
{ required: true, message: '请输入地图名称', trigger: 'change' }
|
||||
],
|
||||
prdCode: [
|
||||
{ required: true, message: '请输入产品类型', trigger: 'change' }
|
||||
],
|
||||
type: [
|
||||
{ required: true, message: '请输入实训类型', trigger: 'change' }
|
||||
],
|
||||
operateType: [
|
||||
{ required: true, validator: checkOperateType, trigger: 'change' }
|
||||
],
|
||||
minDuration: [
|
||||
{ required: true, validator: minDurations, trigger: 'blur' }
|
||||
],
|
||||
maxDuration: [
|
||||
{ required: true, validator: maxDurations, trigger: 'blur' }
|
||||
],
|
||||
// remarks: [
|
||||
// { required: true, validator: checkRemarks, trigger: 'blur' }
|
||||
// ]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isUpdate() {
|
||||
return this.operation.event == '02';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
show(data) {
|
||||
this.operation = {
|
||||
event: data.event,
|
||||
title: data.title
|
||||
}
|
||||
this.dialogShow = true;
|
||||
},
|
||||
close() {
|
||||
this.dialogShow = false;
|
||||
this.loading = false;
|
||||
},
|
||||
skinStyleChoose(skinCode) {
|
||||
this.operateModel.prdCode = '';
|
||||
this.productList = [];
|
||||
if (skinCode) {
|
||||
getCommodityMapProduct(skinCode).then((response) => {
|
||||
this.productList = response.data;
|
||||
this.productList = this.productList.filter(elem => { return elem.prdType != '03'; })
|
||||
})
|
||||
}
|
||||
},
|
||||
async prdChange(prdCode) {
|
||||
this.trainingTypeMap = {};
|
||||
this.operateModel.operateType = [];
|
||||
return {
|
||||
dialogShow: false,
|
||||
productTypesList: [],
|
||||
trainTypesList: [],
|
||||
productList: [],
|
||||
checkList: [],
|
||||
operateModel: {
|
||||
name: '',
|
||||
type: '',
|
||||
skinCode: '',
|
||||
prdCode: '',
|
||||
operateType: [],
|
||||
maxDuration: 0,
|
||||
minDuration: 0,
|
||||
remarks: ''
|
||||
},
|
||||
loading: false,
|
||||
trainingTypeLists: [],
|
||||
trainingTypeMap: {},
|
||||
operation: {
|
||||
event: '',
|
||||
title: ''
|
||||
},
|
||||
rules: {
|
||||
skinCode: [
|
||||
{ required: true, message: '请输入地图名称', trigger: 'change' }
|
||||
],
|
||||
prdCode: [
|
||||
{ required: true, message: '请输入产品类型', trigger: 'change' }
|
||||
],
|
||||
type: [
|
||||
{ required: true, message: '请输入实训类型', trigger: 'change' }
|
||||
],
|
||||
operateType: [
|
||||
{ required: true, validator: checkOperateType, trigger: 'change' }
|
||||
],
|
||||
minDuration: [
|
||||
{ required: true, validator: minDurations, trigger: 'blur' }
|
||||
],
|
||||
maxDuration: [
|
||||
{ required: true, validator: maxDurations, trigger: 'blur' }
|
||||
]
|
||||
// remarks: [
|
||||
// { required: true, validator: checkRemarks, trigger: 'blur' }
|
||||
// ]
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isUpdate() {
|
||||
return this.operation.event == '02';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
show(data) {
|
||||
this.operation = {
|
||||
event: data.event,
|
||||
title: data.title
|
||||
};
|
||||
this.dialogShow = true;
|
||||
},
|
||||
close() {
|
||||
this.dialogShow = false;
|
||||
this.loading = false;
|
||||
},
|
||||
skinStyleChoose(skinCode) {
|
||||
this.operateModel.prdCode = '';
|
||||
this.productList = [];
|
||||
if (skinCode) {
|
||||
getCommodityMapProduct(skinCode).then((response) => {
|
||||
this.productList = response.data;
|
||||
this.productList = this.productList.filter(elem => { return elem.prdType != '03'; });
|
||||
});
|
||||
}
|
||||
},
|
||||
async prdChange(prdCode) {
|
||||
this.trainingTypeMap = {};
|
||||
this.operateModel.operateType = [];
|
||||
|
||||
let skinStyleObj = this.skinStyleList.find(elem => { return elem.code === this.operateModel.skinCode }) || {};
|
||||
let prdTypeObj = this.productList.find(elem => { return elem.code === prdCode }) || {};
|
||||
let res = await getOperateTrainingList({ skinCode: skinStyleObj.code, productType: prdTypeObj.prdType });
|
||||
if (res && res.code == 200) {
|
||||
this.trainingTypeLists = res.data;
|
||||
this.trainingTypeList.forEach(elem => {
|
||||
this.trainingTypeLists.forEach(item => {
|
||||
if (item.id == elem.code) {
|
||||
item.name = elem.name;
|
||||
item.code = elem.code;
|
||||
}
|
||||
const skinStyleObj = this.skinStyleList.find(elem => { return elem.code === this.operateModel.skinCode; }) || {};
|
||||
const prdTypeObj = this.productList.find(elem => { return elem.code === prdCode; }) || {};
|
||||
const res = await getOperateTrainingList({ skinCode: skinStyleObj.code, productType: prdTypeObj.prdType });
|
||||
if (res && res.code == 200) {
|
||||
this.trainingTypeLists = res.data;
|
||||
this.trainingTypeList.forEach(elem => {
|
||||
this.trainingTypeLists.forEach(item => {
|
||||
if (item.id == elem.code) {
|
||||
item.name = elem.name;
|
||||
item.code = elem.code;
|
||||
}
|
||||
|
||||
this.trainingOperateTypeMap[item.id].forEach(i => {
|
||||
item.children.forEach(v => {
|
||||
if (i.code == v.id) {
|
||||
v.name = i.name;
|
||||
v.code = i.code;
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
})
|
||||
this.trainingOperateTypeMap[item.id].forEach(i => {
|
||||
item.children.forEach(v => {
|
||||
if (i.code == v.id) {
|
||||
v.name = i.name;
|
||||
v.code = i.code;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.trainingTypeLists.forEach(item => {
|
||||
item.children.forEach(v => {
|
||||
if (!this.trainingTypeMap[item.id]) {
|
||||
this.trainingTypeMap[item.id] = [];
|
||||
}
|
||||
this.trainingTypeLists.forEach(item => {
|
||||
item.children.forEach(v => {
|
||||
if (!this.trainingTypeMap[item.id]) {
|
||||
this.trainingTypeMap[item.id] = [];
|
||||
}
|
||||
|
||||
this.trainingTypeMap[item.id].push({
|
||||
name: v.name,
|
||||
code: v.code,
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
typeChange(type) {
|
||||
this.operateModel.operateType = [];
|
||||
this.trainTypesList = this.trainingOperateTypeMap[type] || []
|
||||
},
|
||||
// 取消
|
||||
handleClose() {
|
||||
this.dialogShow = false;
|
||||
},
|
||||
// 确定
|
||||
handleDeal() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
if (this.operation.event == '01') { //add
|
||||
//创建实训
|
||||
let data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: this.operateModel.type,
|
||||
operateType: this.operateModel.operateType
|
||||
}
|
||||
this.trainingTypeMap[item.id].push({
|
||||
name: v.name,
|
||||
code: v.code
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
typeChange(type) {
|
||||
this.operateModel.operateType = [];
|
||||
this.trainTypesList = this.trainingOperateTypeMap[type] || [];
|
||||
},
|
||||
// 取消
|
||||
handleClose() {
|
||||
this.dialogShow = false;
|
||||
},
|
||||
// 确定
|
||||
handleDeal() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
if (this.operation.event == '01') { // add
|
||||
// 创建实训
|
||||
const data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: this.operateModel.type,
|
||||
operateType: this.operateModel.operateType
|
||||
};
|
||||
|
||||
addAutoTraining(data).then(response => {
|
||||
this.$message.success('自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(error => {
|
||||
this.$messageBox('生成实训失败');
|
||||
this.loading = false;
|
||||
});
|
||||
} else if (this.operation.event == '02') { //edit
|
||||
//更新实训
|
||||
let data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: this.operateModel.type,
|
||||
operateType: this.operateModel.operateType,
|
||||
remarks: this.operateModel.remarks,
|
||||
minDuration: this.operateModel.minDuration,
|
||||
maxDuration: this.operateModel.maxDuration
|
||||
}
|
||||
addAutoTraining(data).then(response => {
|
||||
this.$message.success('自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(() => {
|
||||
this.$messageBox('生成实训失败');
|
||||
this.loading = false;
|
||||
});
|
||||
} else if (this.operation.event == '02') { // edit
|
||||
// 更新实训
|
||||
const data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: this.operateModel.type,
|
||||
operateType: this.operateModel.operateType,
|
||||
remarks: this.operateModel.remarks,
|
||||
minDuration: this.operateModel.minDuration,
|
||||
maxDuration: this.operateModel.maxDuration
|
||||
};
|
||||
|
||||
updateAutoTraining(data).then(response => {
|
||||
this.$message.success('更新自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(error => {
|
||||
this.$messageBox('更新自动生成实训失败');
|
||||
this.loading = false;
|
||||
})
|
||||
} else if (this.operation.event == '03') { //delete
|
||||
//删除实训
|
||||
let data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: `${this.operateModel.type}`,
|
||||
operateType: `${this.operateModel.operateType.join(',')}`,
|
||||
}
|
||||
updateAutoTraining(data).then(response => {
|
||||
this.$message.success('更新自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(() => {
|
||||
this.$messageBox('更新自动生成实训失败');
|
||||
this.loading = false;
|
||||
});
|
||||
} else if (this.operation.event == '03') { // delete
|
||||
// 删除实训
|
||||
const data = {
|
||||
skinCode: this.operateModel.skinCode,
|
||||
name: this.operateModel.name,
|
||||
prdCode: this.operateModel.prdCode,
|
||||
trainingType: `${this.operateModel.type}`,
|
||||
operateType: `${this.operateModel.operateType.join(',')}`
|
||||
};
|
||||
|
||||
deleteAutoTraining(data).then(response => {
|
||||
this.$message.success('删除自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(error => {
|
||||
this.$messageBox('删除自动生成实训失败');
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
deleteAutoTraining(data).then(response => {
|
||||
this.$message.success('删除自动生成实训成功!');
|
||||
this.$emit('refresh');
|
||||
this.close();
|
||||
}).catch(() => {
|
||||
this.$messageBox('删除自动生成实训失败');
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-checkbox {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -12,8 +12,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { listPublishMap, putMapProductOnLine, putMapProductOffLine } from '@/api/jmap/mapdraft';
|
||||
// import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { pageQueryTraining } from '@/api/jmap/training';
|
||||
import { trainingNotify } from '@/api/simulation';
|
||||
import { getCommodityMapProduct, getProductList } from '@/api/management/mapprd';
|
||||
|
@ -1,346 +1,342 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- <turnback-bar :title="turnbackBarTitle"></turnback-bar> -->
|
||||
<div class="card-box">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step :title="title" icon="el-icon-edit-outline"></el-step>
|
||||
<el-step title="" icon="el-icon-upload"></el-step>
|
||||
</el-steps>
|
||||
<el-card class="forms">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{height:height -70 + 'px'}"
|
||||
style="padding-top: 40px">
|
||||
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button type="primary" @click="create" v-if="isAdd">{{$t('global.create')}}</el-button>
|
||||
<el-button type="warning" @click="update" v-if="isEdit">{{$t('global.update')}}</el-button>
|
||||
<el-button type="primary" @click="turnback">{{$t('global.return')}}</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<!-- <turnback-bar :title="turnbackBarTitle"></turnback-bar> -->
|
||||
<div 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 -70 + 'px'}"
|
||||
style="padding-top: 40px"
|
||||
>
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
</el-scrollbar>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button v-if="isAdd" type="primary" @click="create">{{ $t('global.create') }}</el-button>
|
||||
<el-button v-if="isEdit" type="warning" @click="update">{{ $t('global.update') }}</el-button>
|
||||
<el-button type="primary" @click="turnback">{{ $t('global.return') }}</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getOrderDetail, updateOrder } from '@/api/management/order';
|
||||
import { addOrganization } from '@/api/management/organization';
|
||||
import { getOrderCharge } from '@/api/management/order';
|
||||
import { getMapLesson } from '@/api/management/dictionary';
|
||||
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { saveCommodityList, getCommodityDetailById, updataCommodityList } from '@/api/management/goods';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { getCommodityProductLesson } from '@/api/jmap/lesson';
|
||||
import { validateCharCode } from '@/utils/validate';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { saveCommodityList, getCommodityDetailById, updataCommodityList } from '@/api/management/goods';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { getCommodityProductLesson } from '@/api/jmap/lesson';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
|
||||
export default {
|
||||
name: 'DictionaryDetailEdit',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
type: '',
|
||||
height: '',
|
||||
display: 1,
|
||||
foreverInitData: false,
|
||||
dataLesson: [],
|
||||
productList: [],
|
||||
mapIdList: [],
|
||||
productTypeList: [],
|
||||
mapProductCodeList: [],
|
||||
mapProductCodeListFilter: [],
|
||||
lessonIdList: [],
|
||||
TimeStyleList: [],
|
||||
TimeStyleDict: {},
|
||||
formModel: {
|
||||
name: '',
|
||||
skinCode: '',
|
||||
productType: '01',
|
||||
mapId: '',
|
||||
mapProductCode: '',
|
||||
lessonId: '',
|
||||
forever: false,
|
||||
tryUseTime: 0,
|
||||
tryUseTimeUnit: '05',
|
||||
price: 0,
|
||||
remarks: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// turnbackBarTitle() {
|
||||
// return '';
|
||||
// },
|
||||
isAdd() {
|
||||
return this.type === 'ADD';
|
||||
},
|
||||
isEdit() {
|
||||
return (this.type === 'EDIT') && !isNaN(Number(this.$route.params.commodityId));;
|
||||
},
|
||||
title() {
|
||||
return this.isAdd ? this.$t('orderAuthor.addGoods') : (this.isEdit ? this.$t('orderAuthor.addGoods') : this.$t('orderAuthor.unknownRouter'));
|
||||
},
|
||||
isShowLesson() {
|
||||
return this.formModel.productType === '01' || this.formModel.productType === '02'; // 教学类型,考试类型
|
||||
},
|
||||
isShowSimulation() {
|
||||
return this.formModel.productType === '03'; // 仿真类型
|
||||
},
|
||||
isShowScreen() {
|
||||
return this.formModel.productType === '04'; // 大屏类型
|
||||
},
|
||||
isShowForever() {
|
||||
return this.formModel.forever;
|
||||
},
|
||||
isDisabled() {
|
||||
return this.isEdit
|
||||
},
|
||||
foreverIsDisabled() {
|
||||
return this.foreverInitData
|
||||
},
|
||||
payTypeIsDisabled() {
|
||||
return this.isEdit
|
||||
},
|
||||
export default {
|
||||
name: 'DictionaryDetailEdit',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
type: '',
|
||||
height: '',
|
||||
display: 1,
|
||||
foreverInitData: false,
|
||||
dataLesson: [],
|
||||
productList: [],
|
||||
mapIdList: [],
|
||||
productTypeList: [],
|
||||
mapProductCodeList: [],
|
||||
mapProductCodeListFilter: [],
|
||||
lessonIdList: [],
|
||||
TimeStyleList: [],
|
||||
TimeStyleDict: {},
|
||||
formModel: {
|
||||
name: '',
|
||||
skinCode: '',
|
||||
productType: '01',
|
||||
mapId: '',
|
||||
mapProductCode: '',
|
||||
lessonId: '',
|
||||
forever: false,
|
||||
tryUseTime: 0,
|
||||
tryUseTimeUnit: '05',
|
||||
price: 0,
|
||||
remarks: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// turnbackBarTitle() {
|
||||
// return '';
|
||||
// },
|
||||
isAdd() {
|
||||
return this.type === 'ADD';
|
||||
},
|
||||
isEdit() {
|
||||
return (this.type === 'EDIT') && !isNaN(Number(this.$route.params.commodityId));
|
||||
},
|
||||
title() {
|
||||
return this.isAdd ? this.$t('orderAuthor.addGoods') : (this.isEdit ? this.$t('orderAuthor.addGoods') : this.$t('orderAuthor.unknownRouter'));
|
||||
},
|
||||
isShowLesson() {
|
||||
return this.formModel.productType === '01' || this.formModel.productType === '02'; // 教学类型,考试类型
|
||||
},
|
||||
isShowSimulation() {
|
||||
return this.formModel.productType === '03'; // 仿真类型
|
||||
},
|
||||
isShowScreen() {
|
||||
return this.formModel.productType === '04'; // 大屏类型
|
||||
},
|
||||
isShowForever() {
|
||||
return this.formModel.forever;
|
||||
},
|
||||
isDisabled() {
|
||||
return this.isEdit;
|
||||
},
|
||||
foreverIsDisabled() {
|
||||
return this.foreverInitData;
|
||||
},
|
||||
payTypeIsDisabled() {
|
||||
return this.isEdit;
|
||||
},
|
||||
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '135px',
|
||||
items: [
|
||||
{ prop: 'name', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false },
|
||||
{ prop: 'productType', label: this.$t('orderAuthor.productType'), type: 'select', required: false, disabled: this.isDisabled, options: this.productTypeList, change: true, onChange: this.typeChange },
|
||||
{ prop: 'mapId', label: this.$t('orderAuthor.map'), type: 'select', required: false, disabled: this.isDisabled, options: this.mapIdList, show: this.isShowLesson || this.isShowSimulation, change: true, onChange: this.mapChange },
|
||||
{ prop: 'mapProductCode', label: this.$t('orderAuthor.productName'), type: 'select', required: false, disabled: this.isDisabled, options: this.mapProductCodeListFilter, show: this.isShowLesson || this.isShowSimulation, change: true, onChange: this.productChange },
|
||||
{ prop: 'lessonId', label: this.$t('orderAuthor.lesson'), type: 'select', required: false, disabled: this.isDisabled, options: this.lessonIdList, show: this.isShowLesson },
|
||||
{ prop: 'forever', label: this.$t('orderAuthor.whetherTrial'), type: 'radio', required: false, options: this.$ConstSelect.Whether, disabled: this.foreverIsDisabled },
|
||||
{ prop: 'tryUseTimeUnit', label: this.$t('orderAuthor.unitOfTime'), type: 'select', required: false, disabled: this.foreverIsDisabled, show: this.isShowForever, options: this.TimeStyleList },
|
||||
{ prop: 'tryUseTime', label: this.$t('orderAuthor.trialTime'), type: 'number', required: false, disabled: this.foreverIsDisabled, show: this.isShowForever, message: `${this.TimeStyleDict[this.formModel.tryUseTimeUnit]}` },
|
||||
{ prop: 'price', label: this.$t('orderAuthor.price'), type: 'number', required: false, min: 0.01, message: this.$t('global.yuan') },
|
||||
{ prop: 'remarks', label: this.$t('orderAuthor.describtion'), type: 'textarea', required: false }
|
||||
]
|
||||
|
||||
form() {
|
||||
let form = {
|
||||
labelWidth: '135px',
|
||||
items: [
|
||||
{ prop: 'name', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false },
|
||||
{ prop: 'productType', label: this.$t('orderAuthor.productType'), type: 'select', required: false, disabled: this.isDisabled, options: this.productTypeList, change: true, onChange: this.typeChange },
|
||||
{ prop: 'mapId', label: this.$t('orderAuthor.map'), type: 'select', required: false, disabled: this.isDisabled, options: this.mapIdList, show: this.isShowLesson || this.isShowSimulation, change: true, onChange: this.mapChange },
|
||||
{ prop: 'mapProductCode', label: this.$t('orderAuthor.productName'), type: 'select', required: false, disabled: this.isDisabled, options: this.mapProductCodeListFilter, show: this.isShowLesson || this.isShowSimulation, change: true, onChange: this.productChange },
|
||||
{ prop: 'lessonId', label: this.$t('orderAuthor.lesson'), type: 'select', required: false, disabled: this.isDisabled, options: this.lessonIdList, show: this.isShowLesson },
|
||||
{ prop: 'forever', label: this.$t('orderAuthor.whetherTrial'), type: 'radio', required: false, options: this.$ConstSelect.Whether, disabled: this.foreverIsDisabled },
|
||||
{ prop: 'tryUseTimeUnit', label: this.$t('orderAuthor.unitOfTime'), type: 'select', required: false, disabled: this.foreverIsDisabled, show: this.isShowForever, options: this.TimeStyleList },
|
||||
{ prop: 'tryUseTime', label: this.$t('orderAuthor.trialTime'), type: 'number', required: false, disabled: this.foreverIsDisabled, show: this.isShowForever, message: `${this.TimeStyleDict[this.formModel.tryUseTimeUnit]}` },
|
||||
{ prop: 'price', label: this.$t('orderAuthor.price'), type: 'number', required: false, min: 0.01, message: this.$t('global.yuan') },
|
||||
{ prop: 'remarks', label: this.$t('orderAuthor.describtion'), type: 'textarea', required: false, },
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
|
||||
}
|
||||
return form
|
||||
},
|
||||
rules() {
|
||||
const baseRules = {
|
||||
name: [
|
||||
{ required: true, message: this.$t('orderAuthor.goodsNameInput'), trigger: 'blur' }
|
||||
],
|
||||
productType: [
|
||||
{ required: true, message: this.$t('orderAuthor.productTypeInput'), trigger: 'change' }
|
||||
],
|
||||
mapId: [
|
||||
{ required: true, message: this.$t('orderAuthor.mapInput'), trigger: 'change' }
|
||||
],
|
||||
mapProductCode: [
|
||||
{ required: true, message: this.$t('orderAuthor.productInput'), trigger: 'change' }
|
||||
],
|
||||
lessonId: [
|
||||
{ required: true, message: this.$t('orderAuthor.lessonInput'), trigger: 'change' }
|
||||
],
|
||||
forever: [
|
||||
{ required: true, message: this.$t('orderAuthor.foreverRadio'), trigger: 'change' }
|
||||
],
|
||||
tryUseTime: [
|
||||
{ required: true, message: this.$t('orderAuthor.trialTimeInput'), trigger: 'change' }
|
||||
],
|
||||
tryUseTimeUnit: [
|
||||
{ required: true, message: this.$t('orderAuthor.unitOfTimeRadio'), trigger: 'change' }
|
||||
],
|
||||
price: [
|
||||
{ required: true, message: this.$t('orderAuthor.totalPriceInput'), trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number(value) >= 0) {
|
||||
if (String(value).split('.')[1] && String(value).split('.')[1].length > 2) {
|
||||
callback(new Error(this.$t('orderAuthor.totalPriceInputError1')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
callback(new Error(this.$t('orderAuthor.totalPriceInputError2')));
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: this.$t('orderAuthor.goodsDescribtionInput'), trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
|
||||
rules() {
|
||||
let baseRules = {
|
||||
name: [
|
||||
{ required: true, message: this.$t('orderAuthor.goodsNameInput'), trigger: 'blur' }
|
||||
],
|
||||
productType: [
|
||||
{ required: true, message: this.$t('orderAuthor.productTypeInput'), trigger: 'change' }
|
||||
],
|
||||
mapId: [
|
||||
{ required: true, message: this.$t('orderAuthor.mapInput'), trigger: 'change' }
|
||||
],
|
||||
mapProductCode: [
|
||||
{ required: true, message: this.$t('orderAuthor.productInput'), trigger: 'change' }
|
||||
],
|
||||
lessonId: [
|
||||
{ required: true, message: this.$t('orderAuthor.lessonInput'), trigger: 'change' }
|
||||
],
|
||||
forever: [
|
||||
{ required: true, message: this.$t('orderAuthor.foreverRadio'), trigger: 'change' }
|
||||
],
|
||||
tryUseTime: [
|
||||
{ required: true, message: this.$t('orderAuthor.trialTimeInput'), trigger: 'change' }
|
||||
],
|
||||
tryUseTimeUnit: [
|
||||
{ required: true, message: this.$t('orderAuthor.unitOfTimeRadio'), trigger: 'change' }
|
||||
],
|
||||
price: [
|
||||
{ required: true, message: this.$t('orderAuthor.totalPriceInput'), trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number(value) >= 0) {
|
||||
if (String(value).split('.')[1] && String(value).split('.')[1].length > 2) {
|
||||
callback(new Error(this.$t('orderAuthor.totalPriceInputError1')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
callback(new Error(this.$t('orderAuthor.totalPriceInputError2')));
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
}
|
||||
],
|
||||
remarks: [
|
||||
{ required: true, message: this.$t('orderAuthor.goodsDescribtionInput'), trigger: 'blur' }
|
||||
],
|
||||
}
|
||||
// 清空表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.dataform.clearValidate();
|
||||
});
|
||||
|
||||
//清空表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.dataform.clearValidate();
|
||||
});
|
||||
return baseRules;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initLoadPage();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight - 170;
|
||||
},
|
||||
async initLoadPage() {
|
||||
// 加载字典数据
|
||||
// 加载地图,产品,课程
|
||||
this.mapIdList.length = 0;
|
||||
try {
|
||||
const response = await listPublishMap();
|
||||
// this.dataLesson = response.data;
|
||||
const data = response.data;
|
||||
if (data && data.length) {
|
||||
data.forEach(elem => {
|
||||
this.mapIdList.push({ value: elem.id, label: elem.name });
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this.$messageBox(this.$t('error.getItemListFailed'));
|
||||
}
|
||||
// 产品类型
|
||||
this.$Dictionary.productType().then(list => {
|
||||
this.$convertList(list, this.productTypeList, elem => {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
return baseRules;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initLoadPage();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight - 170;
|
||||
},
|
||||
async initLoadPage() {
|
||||
// 加载字典数据
|
||||
// 加载地图,产品,课程
|
||||
this.mapIdList.length = 0;
|
||||
try {
|
||||
let response = await listPublishMap();
|
||||
// this.dataLesson = response.data;
|
||||
let data = response.data;
|
||||
if (data && data.length) {
|
||||
data.forEach(elem => {
|
||||
this.mapIdList.push({ value: elem.id, label: elem.name });
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
this.$messageBox(this.$t('error.getItemListFailed'));
|
||||
}
|
||||
// 产品类型
|
||||
this.$Dictionary.productType().then(list => {
|
||||
this.$convertList(list, this.productTypeList, elem => {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
// 时间类型
|
||||
this.TimeStyleDict = {};
|
||||
this.$Dictionary.timeStyleType().then(list => {
|
||||
this.$convertList(list, this.TimeStyleList, elem => {
|
||||
return true;
|
||||
});
|
||||
list.forEach(elem => {
|
||||
this.TimeStyleDict[elem.code] = elem.name;
|
||||
});
|
||||
});
|
||||
|
||||
// 时间类型
|
||||
this.TimeStyleDict = {};
|
||||
this.$Dictionary.timeStyleType().then(list => {
|
||||
this.$convertList(list, this.TimeStyleList, elem => {
|
||||
return true;
|
||||
});
|
||||
list.forEach(elem => {
|
||||
this.TimeStyleDict[elem.code] = elem.name;
|
||||
})
|
||||
});
|
||||
// 清空数据
|
||||
this.$refs.dataform.resetForm();
|
||||
|
||||
//清空数据
|
||||
this.$refs.dataform.resetForm();
|
||||
|
||||
//获取操作模式
|
||||
this.type = String(this.$route.params.mode).toUpperCase();
|
||||
if (this.type === 'EDIT') {
|
||||
try {
|
||||
let res = await getCommodityDetailById(this.$route.params.commodityId);
|
||||
this.mapChange(res.data.mapId);
|
||||
this.productChange(res.data.mapProductCode);
|
||||
this.formModel = {
|
||||
name: res.data.name,
|
||||
productType: res.data.productType,
|
||||
mapId: res.data.mapId,
|
||||
mapProductCode: res.data.mapProductCode,
|
||||
lessonId: res.data.lessonId,
|
||||
forever: res.data.tryUse,
|
||||
tryUseTime: res.data.tryUseTime,
|
||||
tryUseTimeUnit: res.data.tryUseTimeUnit || '05',
|
||||
price: res.data.price,
|
||||
remarks: res.data.remarks,
|
||||
id: res.data.id,
|
||||
};
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getItemListFailed'));
|
||||
}
|
||||
}
|
||||
//清空表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.dataform.clearValidate();
|
||||
});
|
||||
},
|
||||
typeChange(type) {
|
||||
this.mapProductCodeListFilter = this.mapProductCodeList.filter(elem => {
|
||||
if (type != '03') { //不是仿真时,过滤综合演练
|
||||
return elem.prdType != '03';
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
},
|
||||
async mapChange(mapId) {
|
||||
this.mapProductCodeList = [];
|
||||
this.formModel.mapProductCode = '';
|
||||
this.lessonIdList = [];
|
||||
this.formModel.lessonId = '';
|
||||
try {
|
||||
let rest = await getPublishMapInfo(mapId);
|
||||
if (rest && rest.code == 200) {
|
||||
let resp = await getCommodityMapProduct(rest.data.skinCode);
|
||||
if (resp && resp.code == 200) {
|
||||
resp.data.forEach(ele => {
|
||||
this.mapProductCodeList.push({ value: ele.code, label: ele.name, prdType: ele.prdType });
|
||||
this.typeChange(this.formModel.productType);
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getMapProductListFailed'));
|
||||
}
|
||||
},
|
||||
async productChange(productId) {
|
||||
this.formModel.lessonId = '';
|
||||
this.lessonIdList = [];
|
||||
try {
|
||||
let rest = await getCommodityProductLesson(productId);
|
||||
if (rest && rest.code == 200) {
|
||||
rest.data.forEach(ele => {
|
||||
this.lessonIdList.push({ value: ele.id, label: ele.name });
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getLessonListFailed'));
|
||||
}
|
||||
},
|
||||
buildModel() {
|
||||
//构造基础数据
|
||||
let model = {
|
||||
name: this.formModel.name,
|
||||
productType: this.formModel.productType,
|
||||
mapId: this.formModel.mapId,
|
||||
mapProductCode: this.formModel.mapProductCode,
|
||||
lessonId: this.formModel.lessonId,
|
||||
tryUse: this.formModel.forever,
|
||||
tryUseTime: this.formModel.tryUseTime,
|
||||
tryUseTimeUnit: this.formModel.tryUseTimeUnit,
|
||||
price: this.formModel.price,
|
||||
remarks: this.formModel.remarks,
|
||||
id: this.formModel.id,
|
||||
}
|
||||
return model;
|
||||
},
|
||||
create() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
saveCommodityList(this.buildModel()).then(response => {
|
||||
this.turnback();
|
||||
this.$message.success(this.$t('tip.creatingSuccessful'));
|
||||
}).catch(error => {
|
||||
this.$messageBox(this.$t('tip.creatingFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
updataCommodityList(this.buildModel()).then(response => {
|
||||
this.turnback();
|
||||
this.$message.success(this.$t('tip.updateSuccessfully'));
|
||||
}).catch(error => {
|
||||
this.$messageBox(this.$t('tip.updateFailed'))
|
||||
});
|
||||
})
|
||||
},
|
||||
turnback() {
|
||||
this.$router.go(-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取操作模式
|
||||
this.type = String(this.$route.params.mode).toUpperCase();
|
||||
if (this.type === 'EDIT') {
|
||||
try {
|
||||
const res = await getCommodityDetailById(this.$route.params.commodityId);
|
||||
this.mapChange(res.data.mapId);
|
||||
this.productChange(res.data.mapProductCode);
|
||||
this.formModel = {
|
||||
name: res.data.name,
|
||||
productType: res.data.productType,
|
||||
mapId: res.data.mapId,
|
||||
mapProductCode: res.data.mapProductCode,
|
||||
lessonId: res.data.lessonId,
|
||||
forever: res.data.tryUse,
|
||||
tryUseTime: res.data.tryUseTime,
|
||||
tryUseTimeUnit: res.data.tryUseTimeUnit || '05',
|
||||
price: res.data.price,
|
||||
remarks: res.data.remarks,
|
||||
id: res.data.id
|
||||
};
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getItemListFailed'));
|
||||
}
|
||||
}
|
||||
// 清空表单验证提示信息
|
||||
this.$nextTick(function () {
|
||||
this.$refs.dataform.clearValidate();
|
||||
});
|
||||
},
|
||||
typeChange(type) {
|
||||
this.mapProductCodeListFilter = this.mapProductCodeList.filter(elem => {
|
||||
if (type != '03') { // 不是仿真时,过滤综合演练
|
||||
return elem.prdType != '03';
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
async mapChange(mapId) {
|
||||
this.mapProductCodeList = [];
|
||||
this.formModel.mapProductCode = '';
|
||||
this.lessonIdList = [];
|
||||
this.formModel.lessonId = '';
|
||||
try {
|
||||
const rest = await getPublishMapInfo(mapId);
|
||||
if (rest && rest.code == 200) {
|
||||
const resp = await getCommodityMapProduct(rest.data.skinCode);
|
||||
if (resp && resp.code == 200) {
|
||||
resp.data.forEach(ele => {
|
||||
this.mapProductCodeList.push({ value: ele.code, label: ele.name, prdType: ele.prdType });
|
||||
this.typeChange(this.formModel.productType);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getMapProductListFailed'));
|
||||
}
|
||||
},
|
||||
async productChange(productId) {
|
||||
this.formModel.lessonId = '';
|
||||
this.lessonIdList = [];
|
||||
try {
|
||||
const rest = await getCommodityProductLesson(productId);
|
||||
if (rest && rest.code == 200) {
|
||||
rest.data.forEach(ele => {
|
||||
this.lessonIdList.push({ value: ele.id, label: ele.name });
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
this.$messageBox(this.$t('error.getLessonListFailed'));
|
||||
}
|
||||
},
|
||||
buildModel() {
|
||||
// 构造基础数据
|
||||
const model = {
|
||||
name: this.formModel.name,
|
||||
productType: this.formModel.productType,
|
||||
mapId: this.formModel.mapId,
|
||||
mapProductCode: this.formModel.mapProductCode,
|
||||
lessonId: this.formModel.lessonId,
|
||||
tryUse: this.formModel.forever,
|
||||
tryUseTime: this.formModel.tryUseTime,
|
||||
tryUseTimeUnit: this.formModel.tryUseTimeUnit,
|
||||
price: this.formModel.price,
|
||||
remarks: this.formModel.remarks,
|
||||
id: this.formModel.id
|
||||
};
|
||||
return model;
|
||||
},
|
||||
create() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
saveCommodityList(this.buildModel()).then(response => {
|
||||
this.turnback();
|
||||
this.$message.success(this.$t('tip.creatingSuccessful'));
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.creatingFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
updataCommodityList(this.buildModel()).then(response => {
|
||||
this.turnback();
|
||||
this.$message.success(this.$t('tip.updateSuccessfully'));
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.updateFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
turnback() {
|
||||
this.$router.go(-1);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
|
@ -1,313 +1,305 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="show" width="800px" :before-close="doClose" center>
|
||||
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="draftRule" :disabled="disabled">{{ isAdd? '添加': '修改'}}
|
||||
</el-button>
|
||||
<el-button @click="doClose">取 消</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog :title="title" :visible.sync="show" width="800px" :before-close="doClose" center>
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" :disabled="disabled" @click="draftRule">{{ isAdd? '添加': '修改' }}
|
||||
</el-button>
|
||||
<el-button @click="doClose">取 消</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { OperatorModel, PermissionType } from '@/scripts/ConstDic';
|
||||
import { getTotalRemains } from '@/api/management/author';
|
||||
import { superAdmin } from '@/router';
|
||||
import { getDimUserList } from '@/api/management/user';
|
||||
import { getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { OperatorModel, PermissionType } from '@/scripts/ConstDic';
|
||||
import { getTotalRemains } from '@/api/management/author';
|
||||
import { superAdmin } from '@/router';
|
||||
import { getDimUserList } from '@/api/management/user';
|
||||
|
||||
export default {
|
||||
name: 'EditRule',
|
||||
props: {
|
||||
PermissionTypeList: {
|
||||
type: Array
|
||||
},
|
||||
PublishMapList: {
|
||||
type: Array
|
||||
},
|
||||
PublisLessonList: {
|
||||
type: Array
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
type: '',
|
||||
mapProductList: [],
|
||||
filterPublisLessonList: [],
|
||||
formModel: {
|
||||
permissionType: '',
|
||||
mapId: '',
|
||||
lessonId: '',
|
||||
mapProductCode: '',
|
||||
date: '',
|
||||
amount: 0,
|
||||
ownerId: '',
|
||||
roleName: '',
|
||||
},
|
||||
DatePicker: {
|
||||
shortcuts: [{
|
||||
text: '今天',
|
||||
onClick(picker) {
|
||||
picker.$emit('pick', new Date());
|
||||
}
|
||||
}]
|
||||
},
|
||||
numberMessage: '',
|
||||
}
|
||||
},
|
||||
export default {
|
||||
name: 'EditRule',
|
||||
props: {
|
||||
permissionTypeList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
publishMapList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
publisLessonList: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
type: '',
|
||||
mapProductList: [],
|
||||
filterPublisLessonList: [],
|
||||
formModel: {
|
||||
permissionType: '',
|
||||
mapId: '',
|
||||
lessonId: '',
|
||||
mapProductCode: '',
|
||||
date: '',
|
||||
amount: 0,
|
||||
ownerId: '',
|
||||
roleName: ''
|
||||
},
|
||||
DatePicker: {
|
||||
shortcuts: [{
|
||||
text: '今天',
|
||||
onClick(picker) {
|
||||
picker.$emit('pick', new Date());
|
||||
}
|
||||
}]
|
||||
},
|
||||
numberMessage: ''
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
form() {
|
||||
let form = {
|
||||
labelWidth: '120px',
|
||||
items: [
|
||||
{ prop: 'permissionType', label: '权限类型', type: 'select', required: false, disabled: !this.isAdd, options: this.PermissionTypeList, change: true, onChange: this.permissionTypeChange },
|
||||
{ prop: 'mapId', label: '地图名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMap, options: this.PublishMapList, change: true, onChange: this.mapChange },
|
||||
{ prop: 'mapProductCode', label: '地图产品名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
|
||||
{ prop: 'lessonId', label: '课程名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowLesson, options: this.filterPublisLessonList },
|
||||
{ prop: 'roleName', label: '选择权限所有者', type: 'complete', required: false, disabled: !this.isAdd, show: this.isShowRole, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: '请输入昵称/名字/手机号' },
|
||||
{ prop: 'date', label: '选择时间', type: 'daterange', required: false, viewFormat: "yyyy-MM-dd HH:mm:ss", valueFormat: "yyyy-MM-dd HH:mm:ss" },
|
||||
{ prop: 'amount', label: '权限个数', type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage },
|
||||
]
|
||||
}
|
||||
return form
|
||||
},
|
||||
rules() {
|
||||
let crules = {
|
||||
permissionType: [
|
||||
{ required: true, message: '请选择权限类型', trigger: 'change' }
|
||||
],
|
||||
mapId: [
|
||||
{ required: true, message: '请选择地图名称', trigger: 'change' }
|
||||
],
|
||||
mapProductCode: [
|
||||
{ required: true, message: '请选择地图产品名称', trigger: 'change' }
|
||||
],
|
||||
lessonId: [
|
||||
{ required: true, message: '请选择课程', trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: '请输入时间', trigger: 'blur' }
|
||||
],
|
||||
amount: [
|
||||
{ required: true, message: '请输入权限个数', trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number.isInteger(Number(value)) && Number(value) > 0) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error("权限个数必须大于0"));
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
}
|
||||
]
|
||||
}
|
||||
return crules
|
||||
},
|
||||
title() {
|
||||
if (this.isAdd) {
|
||||
return '增加权限打包规则';
|
||||
} else {
|
||||
return '编辑权限打包规则';
|
||||
}
|
||||
},
|
||||
disabled() {
|
||||
return this.formModel.amount > this.maxTotal || this.formModel.amount <= 0;
|
||||
},
|
||||
isAdd() {
|
||||
return this.type == 'add';
|
||||
},
|
||||
isShowMap() {
|
||||
if (this.formModel.permissionType !== '04') {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
isShowRole() {
|
||||
if (this.$store.state.user.roles.indexOf(superAdmin) != -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
isShowMapProduct() {
|
||||
if (this.formModel.permissionType !== '04') {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
isShowLesson() {
|
||||
if (this.formModel.permissionType != '04' && this.formModel.permissionType != '03') {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
formModel: {
|
||||
handler: function (val, old) {
|
||||
this.setTotalMax();
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
computed: {
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '120px',
|
||||
items: [
|
||||
{ prop: 'permissionType', label: '权限类型', type: 'select', required: false, disabled: !this.isAdd, options: this.PermissionTypeList, change: true, onChange: this.permissionTypeChange },
|
||||
{ prop: 'mapId', label: '地图名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMap, options: this.PublishMapList, change: true, onChange: this.mapChange },
|
||||
{ prop: 'mapProductCode', label: '地图产品名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
|
||||
{ prop: 'lessonId', label: '课程名称', type: 'select', required: false, disabled: !this.isAdd, show: this.isShowLesson, options: this.filterPublisLessonList },
|
||||
{ prop: 'roleName', label: '选择权限所有者', type: 'complete', required: false, disabled: !this.isAdd, show: this.isShowRole, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: '请输入昵称/名字/手机号' },
|
||||
{ prop: 'date', label: '选择时间', type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss' },
|
||||
{ prop: 'amount', label: '权限个数', type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const crules = {
|
||||
permissionType: [
|
||||
{ required: true, message: '请选择权限类型', trigger: 'change' }
|
||||
],
|
||||
mapId: [
|
||||
{ required: true, message: '请选择地图名称', trigger: 'change' }
|
||||
],
|
||||
mapProductCode: [
|
||||
{ required: true, message: '请选择地图产品名称', trigger: 'change' }
|
||||
],
|
||||
lessonId: [
|
||||
{ required: true, message: '请选择课程', trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: '请输入时间', trigger: 'blur' }
|
||||
],
|
||||
amount: [
|
||||
{ required: true, message: '请输入权限个数', trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number.isInteger(Number(value)) && Number(value) > 0) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error('权限个数必须大于0'));
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
title() {
|
||||
if (this.isAdd) {
|
||||
return '增加权限打包规则';
|
||||
} else {
|
||||
return '编辑权限打包规则';
|
||||
}
|
||||
},
|
||||
disabled() {
|
||||
return this.formModel.amount > this.maxTotal || this.formModel.amount <= 0;
|
||||
},
|
||||
isAdd() {
|
||||
return this.type == 'add';
|
||||
},
|
||||
isShowMap() {
|
||||
return this.formModel.permissionType !== '04';
|
||||
|
||||
var validator = {}
|
||||
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode };
|
||||
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode };
|
||||
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.mapProductCode };
|
||||
validator[PermissionType.SCREEN] = () => { return true };
|
||||
},
|
||||
isShowRole() {
|
||||
return this.$store.state.user.roles.indexOf(superAdmin) != -1;
|
||||
},
|
||||
isShowMapProduct() {
|
||||
return this.formModel.permissionType !== '04';
|
||||
},
|
||||
isShowLesson() {
|
||||
return this.formModel.permissionType != '04' && this.formModel.permissionType != '03';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
formModel: {
|
||||
handler: function (val, old) {
|
||||
this.setTotalMax();
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
|
||||
var validator = {};
|
||||
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode; };
|
||||
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode; };
|
||||
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.mapProductCode; };
|
||||
validator[PermissionType.SCREEN] = () => { return true; };
|
||||
|
||||
if (endTime && startTime && this.formModel.permissionType && validator[this.formModel.permissionType]()) {
|
||||
let model = {
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
type: this.formModel.permissionType,
|
||||
ownerId: this.formModel.ownerId,
|
||||
}
|
||||
if (endTime && startTime && this.formModel.permissionType && validator[this.formModel.permissionType]()) {
|
||||
const model = {
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
type: this.formModel.permissionType,
|
||||
ownerId: this.formModel.ownerId
|
||||
};
|
||||
|
||||
if (this.formModel.permissionType == PermissionType.LESSON || this.formModel.permissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.formModel.mapId;
|
||||
model['mapProductCode'] = this.formModel.mapProductCode;
|
||||
} else if (this.formModel.permissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.formModel.mapId;
|
||||
model['mapProductCode'] = this.formModel.mapProductCode;
|
||||
}
|
||||
if (this.formModel.permissionType == PermissionType.LESSON || this.formModel.permissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.formModel.mapId;
|
||||
model['mapProductCode'] = this.formModel.mapProductCode;
|
||||
} else if (this.formModel.permissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.formModel.mapId;
|
||||
model['mapProductCode'] = this.formModel.mapProductCode;
|
||||
}
|
||||
|
||||
getTotalRemains(model).then(response => {
|
||||
this.maxTotal = response.data;
|
||||
this.numberMessage = `(剩余最大权限个数:${this.maxTotal})`
|
||||
}).catch(error => {
|
||||
this.numberMessage = '';
|
||||
})
|
||||
getTotalRemains(model).then(response => {
|
||||
this.maxTotal = response.data;
|
||||
this.numberMessage = `(剩余最大权限个数:${this.maxTotal})`;
|
||||
}).catch(() => {
|
||||
this.numberMessage = '';
|
||||
});
|
||||
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
permissionTypeChange() {
|
||||
this.formModel.mapId = '';
|
||||
this.formModel.mapProductCode = '';
|
||||
this.formModel.lessonId = '';
|
||||
},
|
||||
mapChange(mapId) {
|
||||
this.formModel.mapProductCode = '';
|
||||
this.formModel.lessonId = '';
|
||||
this.mapProductList = [];
|
||||
getPublishMapInfo(mapId).then(resp => {
|
||||
getCommodityMapProduct(resp.data.skinCode).then(rest => {
|
||||
let list = rest.data || [];
|
||||
this.mapProductList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name };
|
||||
})
|
||||
});
|
||||
})
|
||||
},
|
||||
mapProductChange(mapProductCode) {
|
||||
this.formModel.lessonId = '';
|
||||
this.filterPublisLessonList = this.PublisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.mapProductCode });
|
||||
},
|
||||
// 搜索查询input
|
||||
async querySearchAsync(queryString, cb) {
|
||||
// 根据queryString 查询用户 并显示
|
||||
let results = [];
|
||||
if (queryString) {
|
||||
try {
|
||||
let params = {
|
||||
fuzzyParam: queryString,
|
||||
};
|
||||
let res = await getDimUserList(params);
|
||||
let list = res.data;
|
||||
list.forEach(item => {
|
||||
let value = {
|
||||
id: item.id,
|
||||
value: `${item.nickname}(${item.name})${item.mobile}`
|
||||
}
|
||||
results.push(value);
|
||||
})
|
||||
cb(results);
|
||||
} catch (error) {
|
||||
console.error(error, '查询用户list');
|
||||
cb(results);
|
||||
}
|
||||
} else {
|
||||
cb(results);
|
||||
}
|
||||
},
|
||||
prdSelect(item) {
|
||||
this.formModel.ownerId = item.id;
|
||||
},
|
||||
doShow(data) {
|
||||
this.show = true
|
||||
this.type = data.type;
|
||||
if (!this.isAdd) {
|
||||
let model = data.item;
|
||||
this.formModel = {
|
||||
permissionType: model.permissionType,
|
||||
mapId: model.mapId,
|
||||
lessonId: model.lessonId,
|
||||
mapProductCode: model.mapProductCode,
|
||||
date: [model.startTime, model.endTime],
|
||||
amount: model.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
permissionTypeChange() {
|
||||
this.formModel.mapId = '';
|
||||
this.formModel.mapProductCode = '';
|
||||
this.formModel.lessonId = '';
|
||||
},
|
||||
mapChange(mapId) {
|
||||
this.formModel.mapProductCode = '';
|
||||
this.formModel.lessonId = '';
|
||||
this.mapProductList = [];
|
||||
getPublishMapInfo(mapId).then(resp => {
|
||||
getCommodityMapProduct(resp.data.skinCode).then(rest => {
|
||||
const list = rest.data || [];
|
||||
this.mapProductList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name };
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
mapProductChange(mapProductCode) {
|
||||
this.formModel.lessonId = '';
|
||||
this.filterPublisLessonList = this.PublisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.mapProductCode; });
|
||||
},
|
||||
// 搜索查询input
|
||||
async querySearchAsync(queryString, cb) {
|
||||
// 根据queryString 查询用户 并显示
|
||||
const results = [];
|
||||
if (queryString) {
|
||||
try {
|
||||
const params = {
|
||||
fuzzyParam: queryString
|
||||
};
|
||||
const res = await getDimUserList(params);
|
||||
const list = res.data;
|
||||
list.forEach(item => {
|
||||
const value = {
|
||||
id: item.id,
|
||||
value: `${item.nickname}(${item.name})${item.mobile}`
|
||||
};
|
||||
results.push(value);
|
||||
});
|
||||
cb(results);
|
||||
} catch (error) {
|
||||
console.error(error, '查询用户list');
|
||||
cb(results);
|
||||
}
|
||||
} else {
|
||||
cb(results);
|
||||
}
|
||||
},
|
||||
prdSelect(item) {
|
||||
this.formModel.ownerId = item.id;
|
||||
},
|
||||
doShow(data) {
|
||||
this.show = true;
|
||||
this.type = data.type;
|
||||
if (!this.isAdd) {
|
||||
const model = data.item;
|
||||
this.formModel = {
|
||||
permissionType: model.permissionType,
|
||||
mapId: model.mapId,
|
||||
lessonId: model.lessonId,
|
||||
mapProductCode: model.mapProductCode,
|
||||
date: [model.startTime, model.endTime],
|
||||
amount: model.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName
|
||||
};
|
||||
}
|
||||
|
||||
this.formModel.amount = 0;
|
||||
},
|
||||
doClose() {
|
||||
this.show = false;
|
||||
},
|
||||
draftRule() {
|
||||
if (this.formModel.amount <= this.maxTotal && this.formModel.amount) {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
if (this.isAdd) {
|
||||
this.$emit('addRuleForm', {
|
||||
operator: OperatorModel.TRANSFER,
|
||||
permissionType: this.formModel.permissionType,
|
||||
mapId: this.isShowMap ? this.formModel.mapId : '',
|
||||
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
|
||||
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
amount: this.formModel.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName,
|
||||
})
|
||||
} else {
|
||||
this.$emit('editRuleForm', {
|
||||
operator: OperatorModel.TRANSFER,
|
||||
permissionType: this.formModel.permissionType,
|
||||
mapId: this.isShowMap ? this.formModel.mapId : '',
|
||||
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
|
||||
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
amount: this.formModel.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName,
|
||||
})
|
||||
}
|
||||
this.doClose();
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
this.formModel.amount = 0;
|
||||
},
|
||||
doClose() {
|
||||
this.show = false;
|
||||
},
|
||||
draftRule() {
|
||||
if (this.formModel.amount <= this.maxTotal && this.formModel.amount) {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
if (this.isAdd) {
|
||||
this.$emit('addRuleForm', {
|
||||
operator: OperatorModel.TRANSFER,
|
||||
permissionType: this.formModel.permissionType,
|
||||
mapId: this.isShowMap ? this.formModel.mapId : '',
|
||||
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
|
||||
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
amount: this.formModel.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName
|
||||
});
|
||||
} else {
|
||||
this.$emit('editRuleForm', {
|
||||
operator: OperatorModel.TRANSFER,
|
||||
permissionType: this.formModel.permissionType,
|
||||
mapId: this.isShowMap ? this.formModel.mapId : '',
|
||||
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
|
||||
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
amount: this.formModel.amount,
|
||||
ownerId: this.formModel.ownerId,
|
||||
roleName: this.formModel.roleName
|
||||
});
|
||||
}
|
||||
this.doClose();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
/deep/ {
|
||||
.el-select {
|
||||
@ -325,4 +317,4 @@
|
||||
width: calc(250px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -1,254 +1,261 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<div class="pack-box" :style="{ height: height +'px' }">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" style="">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step title="制定打包规则" icon="el-icon-edit"></el-step>
|
||||
<el-step icon="el-icon-setting"></el-step>
|
||||
</el-steps>
|
||||
<el-card class="forms pack-rule">
|
||||
<el-button class="addList" @click="dialogAdd" size="small">添加规则</el-button>
|
||||
<el-table :data="ruleList" border show-summary :summary-method="getSummaries" style="width: 100%"
|
||||
:height="height-300">
|
||||
<el-table-column prop="permissionType" label="权限类型" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{computedName(PermissionTypeList, scope.row.permissionType)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="mapId" label="地图名称">
|
||||
<template slot-scope="scope">
|
||||
{{computedName(PublishMapList, scope.row.mapId)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="mapProductCode" label="产品名称" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.mapProductCode}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="lessonId" label="课程名称">
|
||||
<template slot-scope="scope">
|
||||
{{computedName(PublisLessonList, scope.row.lessonId)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="startTime" label="起始时间" width="80">
|
||||
</el-table-column>
|
||||
<el-table-column prop="endTime" label="结束时间" width="80">
|
||||
</el-table-column>
|
||||
<el-table-column prop="amount" label="分配权限数量" width="110">
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="dialogEdit(scope.row)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteForm(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button type="primary" @click="packForm" v-if="!urlInfo.url">打包</el-button>
|
||||
<el-button type="primary" @click="QrCodeShow" v-if="urlInfo.url">获取二维码</el-button>
|
||||
<el-button type="primary" @click="turnback">返回</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<edit-rule ref="addRule" :PermissionTypeList="PermissionTypeList" :PublisLessonList="PublisLessonList"
|
||||
:PublishMapList="PublishMapList" @editRuleForm="editRuleForm" @addRuleForm="addRuleForm">
|
||||
</edit-rule>
|
||||
</el-scrollbar>
|
||||
<el-card>
|
||||
<div class="pack-box" :style="{ height: height +'px' }">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" style="">
|
||||
<el-steps class="steps" :active="display">
|
||||
<el-step title="制定打包规则" icon="el-icon-edit" />
|
||||
<el-step icon="el-icon-setting" />
|
||||
</el-steps>
|
||||
<el-card class="forms pack-rule">
|
||||
<el-button class="addList" size="small" @click="dialogAdd">添加规则</el-button>
|
||||
<el-table
|
||||
:data="ruleList"
|
||||
border
|
||||
show-summary
|
||||
:summary-method="getSummaries"
|
||||
style="width: 100%"
|
||||
:height="height-300"
|
||||
>
|
||||
<el-table-column prop="permissionType" label="权限类型" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ computedName(PermissionTypeList, scope.row.permissionType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="mapId" label="地图名称">
|
||||
<template slot-scope="scope">
|
||||
{{ computedName(PublishMapList, scope.row.mapId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="mapProductCode" label="产品名称" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.mapProductCode }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="lessonId" label="课程名称">
|
||||
<template slot-scope="scope">
|
||||
{{ computedName(PublisLessonList, scope.row.lessonId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="startTime" label="起始时间" width="80" />
|
||||
<el-table-column prop="endTime" label="结束时间" width="80" />
|
||||
<el-table-column prop="amount" label="分配权限数量" width="110" />
|
||||
<el-table-column label="操作" width="90">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="dialogEdit(scope.row)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteForm(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<div class="draft">
|
||||
<el-button-group>
|
||||
<el-button v-if="!urlInfo.url" type="primary" @click="packForm">打包</el-button>
|
||||
<el-button v-if="urlInfo.url" type="primary" @click="qrcodeShow">获取二维码</el-button>
|
||||
<el-button type="primary" @click="turnback">返回</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<qr-code ref="qrCode"></qr-code>
|
||||
<can-transfer ref="canDistribute" @distribute="distribute"></can-transfer>
|
||||
</el-card>
|
||||
<edit-rule
|
||||
ref="addRule"
|
||||
:permission-type-list="PermissionTypeList"
|
||||
:publis-lesson-list="PublisLessonList"
|
||||
:publish-map-list="PublishMapList"
|
||||
@editRuleForm="editRuleForm"
|
||||
@addRuleForm="addRuleForm"
|
||||
/>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<qr-code ref="qrCode" />
|
||||
<can-transfer ref="canDistribute" @distribute="distribute" />
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getPublishLessonList } from '@/api/jmap/lesson';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { packagePermissionDistribute } from '@/api/management/distribute';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import QrCode from "@/components/QrCode";
|
||||
import EditRule from './editRule';
|
||||
import CanTransfer from './canDistribute';
|
||||
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
|
||||
import { getPublishLessonList } from '@/api/jmap/lesson';
|
||||
import { getCommodityMapProduct } from '@/api/management/mapprd';
|
||||
import { packagePermissionDistribute } from '@/api/management/distribute';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
import QrCode from '@/components/QrCode';
|
||||
import EditRule from './editRule';
|
||||
import CanTransfer from './canDistribute';
|
||||
|
||||
export default {
|
||||
name: 'packRule',
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
components: {
|
||||
EditRule,
|
||||
QrCode,
|
||||
CanTransfer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
display: 1,
|
||||
height: 0,
|
||||
urlInfo: {},
|
||||
PermissionTypeList: [],
|
||||
PublisLessonList: [],
|
||||
PublishMapList: [],
|
||||
ruleList: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadInitData();
|
||||
},
|
||||
methods: {
|
||||
getSummaries(param) {
|
||||
const { columns, data } = param;
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '总数';
|
||||
return;
|
||||
}
|
||||
export default {
|
||||
name: 'PackRule',
|
||||
components: {
|
||||
EditRule,
|
||||
QrCode,
|
||||
CanTransfer
|
||||
},
|
||||
mixins: [
|
||||
WindowResizeHandler
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
display: 1,
|
||||
height: 0,
|
||||
urlInfo: {},
|
||||
PermissionTypeList: [],
|
||||
PublisLessonList: [],
|
||||
PublishMapList: [],
|
||||
ruleList: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.loadInitData();
|
||||
},
|
||||
methods: {
|
||||
getSummaries(param) {
|
||||
const { columns, data } = param;
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '总数';
|
||||
return;
|
||||
}
|
||||
|
||||
if (index === 6) {
|
||||
const values = data.map(item => Number(item[column.property]));
|
||||
if (!values.every(value => isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (index === 6) {
|
||||
const values = data.map(item => Number(item[column.property]));
|
||||
if (!values.every(value => isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return sums;
|
||||
},
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight - 63;
|
||||
},
|
||||
computedName(list, code) {
|
||||
let name = '';
|
||||
list.forEach(elem => {
|
||||
if (elem.value == code) {
|
||||
name = elem.label;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
},
|
||||
async computedMapProduct(item) {
|
||||
let name = '';
|
||||
let resp = await getPublishMapInfo(item.mapId);
|
||||
let rest = await getCommodityMapProduct(resp.data.skinCode);
|
||||
let list = rest.data || [];
|
||||
list.forEach(elem => {
|
||||
if (elem.id = item.mapProductCode) {
|
||||
name = elem.name;
|
||||
return;
|
||||
}
|
||||
})
|
||||
return name;
|
||||
},
|
||||
loadInitData() {
|
||||
this.PermissionTypeList = [];
|
||||
this.$Dictionary.permissionType().then(list => {
|
||||
this.PermissionTypeList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name }
|
||||
})
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight - 63;
|
||||
},
|
||||
computedName(list, code) {
|
||||
let name = '';
|
||||
list.forEach(elem => {
|
||||
if (elem.value == code) {
|
||||
name = elem.label;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
},
|
||||
async computedMapProduct(item) {
|
||||
let name = '';
|
||||
const resp = await getPublishMapInfo(item.mapId);
|
||||
const rest = await getCommodityMapProduct(resp.data.skinCode);
|
||||
const list = rest.data || [];
|
||||
list.forEach(elem => {
|
||||
if (elem.id == item.mapProductCode) {
|
||||
name = elem.name;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
},
|
||||
loadInitData() {
|
||||
this.PermissionTypeList = [];
|
||||
this.$Dictionary.permissionType().then(list => {
|
||||
this.PermissionTypeList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name };
|
||||
});
|
||||
});
|
||||
|
||||
this.EffectiveTypeList = [];
|
||||
this.$Dictionary.effectiveType().then(list => {
|
||||
this.EffectiveTypeList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name }
|
||||
})
|
||||
});
|
||||
this.EffectiveTypeList = [];
|
||||
this.$Dictionary.effectiveType().then(list => {
|
||||
this.EffectiveTypeList = list.map(elem => {
|
||||
return { value: elem.code, label: elem.name };
|
||||
});
|
||||
});
|
||||
|
||||
this.PublishMapList = [];
|
||||
listPublishMap().then(response => {
|
||||
let list = response.data || [];
|
||||
this.PublishMapList = list.map(elem => {
|
||||
return { value: elem.id, label: elem.name }
|
||||
})
|
||||
})
|
||||
this.PublishMapList = [];
|
||||
listPublishMap().then(response => {
|
||||
const list = response.data || [];
|
||||
this.PublishMapList = list.map(elem => {
|
||||
return { value: elem.id, label: elem.name };
|
||||
});
|
||||
});
|
||||
|
||||
this.PublisLessonList = [];
|
||||
getPublishLessonList().then(response => {
|
||||
let list = response.data || [];
|
||||
this.PublisLessonList = list.map(elem => {
|
||||
return { value: elem.id, label: elem.name, mapId: elem.mapId, prdCode: elem.prdCode }
|
||||
})
|
||||
})
|
||||
},
|
||||
turnback() {
|
||||
this.$router.go(-1)
|
||||
},
|
||||
dialogAdd() {
|
||||
this.$refs.addRule.doShow({ type: 'add' });
|
||||
},
|
||||
dialogEdit(item) {
|
||||
this.$refs.addRule.doShow({ type: 'edit', item: item });
|
||||
},
|
||||
deleteForm(item) {
|
||||
var index = this.ruleList.indexOf(item)
|
||||
if (index >= 0) {
|
||||
this.ruleList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
addRuleForm(item) {
|
||||
let index = this.ruleList.findIndex(elem => {
|
||||
return item.mapId == elem.mapId &&
|
||||
this.PublisLessonList = [];
|
||||
getPublishLessonList().then(response => {
|
||||
const list = response.data || [];
|
||||
this.PublisLessonList = list.map(elem => {
|
||||
return { value: elem.id, label: elem.name, mapId: elem.mapId, prdCode: elem.prdCode };
|
||||
});
|
||||
});
|
||||
},
|
||||
turnback() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
dialogAdd() {
|
||||
this.$refs.addRule.doShow({ type: 'add' });
|
||||
},
|
||||
dialogEdit(item) {
|
||||
this.$refs.addRule.doShow({ type: 'edit', item: item });
|
||||
},
|
||||
deleteForm(item) {
|
||||
var index = this.ruleList.indexOf(item);
|
||||
if (index >= 0) {
|
||||
this.ruleList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
addRuleForm(item) {
|
||||
const index = this.ruleList.findIndex(elem => {
|
||||
return item.mapId == elem.mapId &&
|
||||
item.lessonId == elem.lessonId &&
|
||||
item.mapProductCode == elem.mapProductCode &&
|
||||
item.permissionType == elem.permissionType
|
||||
})
|
||||
item.permissionType == elem.permissionType;
|
||||
});
|
||||
|
||||
if (index < 0) {
|
||||
this.ruleList.push(item);
|
||||
} else {
|
||||
this.$message.warning('已存在此类型规则');
|
||||
}
|
||||
},
|
||||
editRuleForm(item) {
|
||||
let index = this.ruleList.findIndex(elem => {
|
||||
return item.mapId == elem.mapId &&
|
||||
if (index < 0) {
|
||||
this.ruleList.push(item);
|
||||
} else {
|
||||
this.$message.warning('已存在此类型规则');
|
||||
}
|
||||
},
|
||||
editRuleForm(item) {
|
||||
const index = this.ruleList.findIndex(elem => {
|
||||
return item.mapId == elem.mapId &&
|
||||
item.lessonId == elem.lessonId &&
|
||||
item.mapProductCode == elem.mapProductCode &&
|
||||
item.permissionType == elem.permissionType
|
||||
});
|
||||
item.permissionType == elem.permissionType;
|
||||
});
|
||||
|
||||
if (index >= 0) {
|
||||
Object.assign(this.ruleList[index], item);
|
||||
}
|
||||
},
|
||||
packForm() {
|
||||
if (this.ruleList.length) {
|
||||
this.$refs.canDistribute.doShow();
|
||||
} else {
|
||||
this.$messageBox('请添加规则');
|
||||
}
|
||||
},
|
||||
distribute(data) {
|
||||
this.url = '';
|
||||
this.ruleList.forEach(item => {
|
||||
item.canDistribute = data.canDistribute;
|
||||
});
|
||||
packagePermissionDistribute(this.ruleList).then(resp => {
|
||||
this.urlInfo = {
|
||||
url: resp.data,
|
||||
title: '权限分发二维码'
|
||||
};
|
||||
this.QrCodeShow();
|
||||
}).catch(error => {
|
||||
this.$messageBox('打包权限失败');
|
||||
})
|
||||
},
|
||||
QrCodeShow() {
|
||||
if (this.$refs) {
|
||||
this.$refs.qrCode.doShow(this.urlInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index >= 0) {
|
||||
Object.assign(this.ruleList[index], item);
|
||||
}
|
||||
},
|
||||
packForm() {
|
||||
if (this.ruleList.length) {
|
||||
this.$refs.canDistribute.doShow();
|
||||
} else {
|
||||
this.$messageBox('请添加规则');
|
||||
}
|
||||
},
|
||||
distribute(data) {
|
||||
this.url = '';
|
||||
this.ruleList.forEach(item => {
|
||||
item.canDistribute = data.canDistribute;
|
||||
});
|
||||
packagePermissionDistribute(this.ruleList).then(resp => {
|
||||
this.urlInfo = {
|
||||
url: resp.data,
|
||||
title: '权限分发二维码'
|
||||
};
|
||||
this.qrcodeShow();
|
||||
}).catch(() => {
|
||||
this.$messageBox('打包权限失败');
|
||||
});
|
||||
},
|
||||
qrcodeShow() {
|
||||
if (this.$refs) {
|
||||
this.$refs.qrCode.doShow(this.urlInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.pack-box {
|
||||
@ -307,4 +314,4 @@
|
||||
text-align: center;
|
||||
margin: 20px auto;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -1,112 +1,112 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<div slot="header" style="text-align: center;">
|
||||
<b>实训名称: {{ courseModel.name }}</b>
|
||||
</div>
|
||||
<div style="margin:50px">
|
||||
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{ height: height - 190 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">完成实训最佳用时:</span>
|
||||
<span class="list-elem"> {{ courseModel.minDuration | setTime}} 秒</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">完成实训最大用时:</span>
|
||||
<span class="list-elem">{{ courseModel.maxDuration | setTime}} 秒</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">实训说明:</span>
|
||||
<span class="list-elem">{{ courseModel.remarks }}</span>
|
||||
</p>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="btn-start">
|
||||
<el-button type="primary" @click="start">开始实训</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div slot="header" style="text-align: center;">
|
||||
<b>实训名称: {{ courseModel.name }}</b>
|
||||
</div>
|
||||
<div style="margin:50px">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: height - 190 +'px' }">
|
||||
<p class="list-item">
|
||||
<span class="list-label">完成实训最佳用时:</span>
|
||||
<span class="list-elem"> {{ courseModel.minDuration | setTime }} 秒</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">完成实训最大用时:</span>
|
||||
<span class="list-elem">{{ courseModel.maxDuration | setTime }} 秒</span>
|
||||
</p>
|
||||
<p class="list-item">
|
||||
<span class="list-label">实训说明:</span>
|
||||
<span class="list-elem">{{ courseModel.remarks }}</span>
|
||||
</p>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="btn-start">
|
||||
<el-button type="primary" @click="start">开始实训</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import { getTrainingDetail, } from "@/api/jmap/training";
|
||||
import { trainingNotify } from '@/api/simulation';
|
||||
import { PermissionType } from "@/scripts/ConstDic";
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import WindowResizeHandler from "@/mixin/WindowResizeHandler";
|
||||
import { mapGetters } from 'vuex';
|
||||
import { getTrainingDetail } from '@/api/jmap/training';
|
||||
import { trainingNotify } from '@/api/simulation';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||
|
||||
export default {
|
||||
name: "LessonPracticalDetail",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
height: "",
|
||||
courseModel: {
|
||||
id: "",
|
||||
name: "",
|
||||
maxDuration: "",
|
||||
minDuration: "",
|
||||
remarks: "",
|
||||
updateTime: ""
|
||||
}
|
||||
};
|
||||
},
|
||||
mixins: [WindowResizeHandler],
|
||||
filters: {
|
||||
setTime(val) {
|
||||
return val;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route(newVal) {
|
||||
this.initLoadPage();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initLoadPage();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
initLoadPage() {
|
||||
let data = { id: this.$route.params.trainingId };
|
||||
if (parseInt(data.id)) {
|
||||
getTrainingDetail(data)
|
||||
.then(res => {
|
||||
this.courseModel = {
|
||||
id: res.data.id,
|
||||
name: res.data.name,
|
||||
maxDuration: res.data.maxDuration,
|
||||
remarks: res.data.remarks,
|
||||
minDuration: res.data.minDuration,
|
||||
updateTime: res.data.updateTime
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
this.$message.error("获取课程信息失败:" + error.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
start() {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
trainingNotify({ trainingId: this.$route.params.trainingId }).then(resp => {
|
||||
let query = {
|
||||
group: resp.data, trainingId: this.$route.params.trainingId, lessonId: this.$route.params.lessonId
|
||||
};
|
||||
this.$router.push({ path: `${UrlConfig.display}/teach`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
loading.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
export default {
|
||||
name: 'LessonPracticalDetail',
|
||||
components: {},
|
||||
filters: {
|
||||
setTime(val) {
|
||||
return val;
|
||||
}
|
||||
},
|
||||
mixins: [WindowResizeHandler],
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
courseModel: {
|
||||
id: '',
|
||||
name: '',
|
||||
maxDuration: '',
|
||||
minDuration: '',
|
||||
remarks: '',
|
||||
updateTime: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
$route(newVal) {
|
||||
this.initLoadPage();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initLoadPage();
|
||||
},
|
||||
methods: {
|
||||
resizeHandler: function () {
|
||||
this.height = this._clientHeight;
|
||||
},
|
||||
initLoadPage() {
|
||||
const data = { id: this.$route.params.trainingId };
|
||||
if (parseInt(data.id)) {
|
||||
getTrainingDetail(data)
|
||||
.then(res => {
|
||||
this.courseModel = {
|
||||
id: res.data.id,
|
||||
name: res.data.name,
|
||||
maxDuration: res.data.maxDuration,
|
||||
remarks: res.data.remarks,
|
||||
minDuration: res.data.minDuration,
|
||||
updateTime: res.data.updateTime
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
this.$message.error('获取课程信息失败:' + error.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
start() {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
trainingNotify({ trainingId: this.$route.params.trainingId }).then(resp => {
|
||||
const query = {
|
||||
group: resp.data, trainingId: this.$route.params.trainingId, lessonId: this.$route.params.lessonId
|
||||
};
|
||||
this.$router.push({ path: `${UrlConfig.display}/teach`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
this.$messageBox(`创建仿真失败: ${error.message}`);
|
||||
loading.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
Loading…
Reference in New Issue
Block a user