代码调整

This commit is contained in:
joylink_cuiweidong 2022-10-27 09:58:53 +08:00
parent 1381bd8a9c
commit b63159ff08
2 changed files with 228 additions and 2 deletions

View File

@ -1,5 +1,231 @@
<template>
<div style="width: 100%;height: 100%;">
{{}}}
<QueryListPage ref="queryListPage" :card-padding="10" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</div>
</template>
<script>
import {queryMapListByUser} from '@/api/jmap/map';
import Cookies from 'js-cookie';
import ConstConfig from '@/scripts/ConstConfig';
// import { getPublishSingleList, getPublishScenesList } from '@/api/jmap/training';
import { deleteTraining, publishTraining } from '@/api/trainingManage';
import { getTrainingList, getTrainingAll } from '@/api/trainingManage';
// getPublishTrainingDetail, loadPublishTraining,
export default {
name:'TrainingManage',
data() {
return {
mapList:[],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '100px',
reset: false,
// initLoadCallback: this.initLoadCallback,
queryObject: {
mapId: {
type: 'select',
label: '地图名称',
config: {
noClear:true,
data: []
}
}
}
},
queryList:{
height: 500,
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('trainingManage.name'),
prop: 'name'
},
{
title: this.$t('trainingManage.description'),
prop: 'description'
},
{
title: this.$t('trainingManage.type'),
width: '70',
prop: 'type',
type: 'tag',
columnValue: (row) => { return this.covertData(row); },
tagType: (row) => { return ''; }
},
{
title: this.$t('trainingManage.labelJson'),
width: '200',
prop: 'labelJson',
type: 'tagMore',
columnValue: (row) => { return this.labelJsonData(row); },
tagType: (row) => { return ''; }
},
{
type: 'button',
title: this.$t('trainingManage.operate'),
width: '500',
buttons: [
{
name: this.$t('trainingManage.record'),
handleClick: this.drawUp,
type: 'success',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.modify'),
handleClick: this.handleModify,
type: 'primary',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.delete'),
handleClick: this.deleteScript,
type: 'danger',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.publish'),
handleClick: this.publishScript,
type: 'primary',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.preview'),
handleClick: this.previewScript,
type: 'primary',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.gradeRules'),
handleClick: this.gradeRules,
type: 'success',
showControl:(row) => { return row.id; }
},
{
name: this.$t('trainingManage.publishTrack'),
handleClick: this.publishTrack,
type: 'primary',
showControl:(row) => { return row.id; }
}
]
}
]
}
};
},
created() {
queryMapListByUser().then(res=>{
this.mapList = [];
res.data.forEach(element => {
this.mapList.push({label:element.name, value:element.id});
});
this.queryForm.queryObject.mapId.config.data = [...this.mapList];
// this.queryForm.queryObject.mapId.config.default = this.mapList[0].value;
});
},
methods: {
// initLoadCallback(form) {
// if (!form.trainingType) {
// form.trainingType = 'training';
// }
// // if (!form.mapId) {
// // form.mapId = this.mapList[0].value;
// // }
// },
// queryFunction(param) {
// if (param.mapId) {
// if (param.trainingType == 'training') {
// return getPublishSingleList(param.mapId);
// } else if (param.trainingType == 'scene') {
// return getPublishScenesList(param.mapId);
// }
// } else {
// return new Promise((resolve, reject)=>{
// const result = {data:[]};
// resolve(result);
// });
// }
// },
queryFunction(param) {
if (param.mapId) {
return getTrainingList(param);
} else {
return new Promise((resolve, reject)=>{
const result = {data:{list:[], total:0, pageNum:0}};
resolve(result);
});
}
},
covertData(row) {
const releaseReview = ConstConfig.ConstSelect.trainingType;
const lastData = Object.assign({}, row);
if (Cookies.get('user_lang') == 'en') {
releaseReview.forEach(function(element) {
const rolename = element.value;
if (lastData.type == rolename) {
lastData.type = element.enlabel;
}
});
} else {
releaseReview.forEach(function(element) {
const rolename = element.value;
if (lastData.type == rolename) {
lastData.type = element.label;
}
});
}
return lastData.type;
},
labelJsonData(row) {
const sList = row.labelJson ? JSON.parse(row.labelJson) : [];
const list = Object.prototype.toString.call(sList) === '[object Array]' ? sList : [sList];
return list;
},
drawUp(index, row) {
},
deleteScript(index, row) {
console.log('删除', index, row);
this.$confirm('确定删除该条实训数据?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (!row.id) { return; }
deleteTraining([row.id]).then(res => {
console.log('删除实训成功', res);
this.getListData();
}).catch(err => {
console.log('删除实训失败', err);
this.getListData();
});
}).catch(e => {});
},
handleModify(index, row) {
// console.log('', index, row);
// if (!row.id) { return; }
// this.$refs.create.doShow(row);
},
loadScript(index, data) {
},
publishScript(index, row) {
},
previewScript(index, row) {
},
gradeRules(index, row) {
},
publishTrack(index, row) {
}
}
};
</script>

View File

@ -20,7 +20,7 @@ export default {
},
queryForm: {
labelWidth: '100px',
reset: true,
reset: false,
initLoadCallback: this.initLoadCallback,
queryObject: {
mapId: {