rt-sim-training-client/src/views/scriptManage/home.vue

322 lines
10 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<el-card :style="{height: height+'px'}">
2019-09-26 13:21:15 +08:00
<div class="scriptHeader">
<div class="scriptList">{{$t('scriptRecord.scriptList')}}</div>
<el-button size="small" type="primary" @click="handleCreate" class="createScript">{{$t('scriptRecord.scriptCreate')}}</el-button>
</div>
2019-09-26 09:07:19 +08:00
<el-table
:data="tableData"
stripe
border
2019-09-26 13:21:15 +08:00
style="width: 90%;margin-left:5%;margin-top:20px;display: inline-block;">
2019-09-26 09:07:19 +08:00
<el-table-column
type="index"
width="150">
</el-table-column>
<el-table-column
prop="name"
:label="$t('scriptRecord.scriptName')"
2019-10-14 13:10:36 +08:00
>
2019-09-26 09:07:19 +08:00
</el-table-column>
<el-table-column
prop="description"
:label="$t('scriptRecord.scriptDescription')"
2019-10-14 13:10:36 +08:00
>
</el-table-column>
<el-table-column
:label="$t('scriptRecord.status')"
>
<template slot-scope="scope">
<div>{{covertData(scope.row)}}</div>
</template>
2019-09-26 09:07:19 +08:00
</el-table-column>
2019-10-14 13:58:26 +08:00
<el-table-column
prop="explanation"
:label="$t('scriptRecord.revokeReason')"
>
</el-table-column>
2019-09-26 09:07:19 +08:00
<el-table-column
2019-09-26 13:21:15 +08:00
:label="$t('scriptRecord.operate')"
2019-10-14 13:10:36 +08:00
width="400"
2019-09-26 09:07:19 +08:00
>
2019-09-26 10:54:07 +08:00
<template slot-scope="scope">
2019-10-14 13:58:26 +08:00
<el-button size="small" type="success" @click="drawUp(scope.$index, scope.row)" v-if="!(scope.row.status==1)">{{$t('scriptRecord.scriptRecord')}}</el-button>
<el-button size="small" type="primary" @click="handleModify(scope.$index, scope.row)" v-if="!(scope.row.status==1)">{{$t('scriptRecord.scriptModify')}}</el-button>
<el-button size="small" type="danger" @click="deleteScript(scope.$index, scope.row)" v-if="!(scope.row.status==1)">{{$t('scriptRecord.scriptDelete')}}</el-button>
<el-button size="small" type="primary" @click="publishScript(scope.$index, scope.row)" v-if="scope.row.status==0" v-html="covertButtonname()"></el-button>
<el-button size="small" type="primary" @click="revokeScript(scope.$index, scope.row)" v-if="scope.row.status==1">{{$t('scriptRecord.applyRevoke')}}</el-button>
2019-10-14 13:10:36 +08:00
<el-button size="small" type="success" @click="previewScript(scope.$index, scope.row)" v-if="scope.row.status==1">{{$t('scriptRecord.preview')}}</el-button>
2019-09-26 10:54:07 +08:00
</template>
2019-09-26 09:07:19 +08:00
</el-table-column>
</el-table>
2019-09-26 10:54:07 +08:00
<create-script ref='createScript' @reloadTable="reloadTable" @create="handleConfirmCreate" :title="$t('scriptRecord.createScript')">
</create-script>
<create-script ref='modifyScript' @reloadTable="reloadTable" @create="handleConfirmModify" :title="$t('scriptRecord.modifyScript')">
2019-09-26 09:07:19 +08:00
</create-script>
<!-- <div class="home-box">
<el-card class="box-card">
2019-09-10 16:14:54 +08:00
<div id="scriptTitle">{{ $t('scriptRecord.createScript') }}</div>
<div id="sciptForm">
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
2019-08-15 14:06:53 +08:00
</div>
<div id="btnList">
<span slot="footer" class="btn-footer">
2019-09-10 16:14:54 +08:00
<el-button type="primary" :loading="loading" @click="doCreate">{{$t('scriptRecord.submit')}}</el-button>
</span>
</div>
</el-card>
2019-09-26 09:07:19 +08:00
</div> -->
</el-card>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-10-14 13:10:36 +08:00
import ConstConfig from '@/scripts/ConstConfig';
import { UrlConfig } from '@/router/index';
2019-10-14 13:10:36 +08:00
import { mapGetters } from 'vuex';
import { admin, superAdmin} from '@/router';
2019-09-26 09:07:19 +08:00
// import {listPublishMap} from '@/api/jmap/map';
2019-10-14 13:10:36 +08:00
import {releaseScript,publishScript} from '@/api/designPlatform';
2019-09-26 09:07:19 +08:00
import { getQuestPageList,createQuest,deleteQuest,updateQuest} from '@/api/quest';
2019-09-26 10:54:07 +08:00
import { launchFullscreen } from '@/utils/screen';
import { scriptRecordNotify } from '@/api/simulation';
import CreateScript from './create';
2019-09-26 09:07:19 +08:00
// import {createQuest} from '@/api/quest';
2019-07-26 13:32:43 +08:00
export default {
name: 'ScriptDraft',
2019-09-26 10:54:07 +08:00
components: {
CreateScript,
},
data() {
return {
2019-09-26 09:07:19 +08:00
tableData:[],
// queryList: {
// actions: [
// { text: '创建', btnCode: 'employee_insert', handler: this.handleCreate }
// ]
// },
// loading: false,
// mapList: [],
// taskStatusList: [],
// disabled: true,
// formModel: {
// name: '',
// mapId: '',
// description: ''
// },
// isShow: false
};
},
computed: {
2019-10-14 13:10:36 +08:00
...mapGetters([
'roles',
]),
height() {
return this.$store.state.app.height - 50;
}
},
watch: {
2019-09-26 09:07:19 +08:00
// '$store.state.scriptRecord.scriptId': function (val) {
// this.formModel.mapId=val;
// }
2019-10-12 17:15:25 +08:00
'$route' () {
this.loadInitData();
}
},
mounted() {
this.loadInitData();
},
methods: {
2019-09-26 09:07:19 +08:00
loadInitData(){
2019-09-30 10:46:29 +08:00
this.getQuestPageList(this.$route.params.mapId)
},
2019-09-26 09:07:19 +08:00
async getQuestPageList(id){
let response=await getQuestPageList(id);
this.tableData=response.data;
2019-09-26 10:54:07 +08:00
},
drawUp(index,row) {
scriptRecordNotify(row.id).then(resp => {
const query = { mapId: row.mapId, group: resp.data, scriptId: row.id };
this.$router.push({ path: `${UrlConfig.scriptDisplay}/script`, query });
launchFullscreen();
}).catch(error => {
this.$messageBox(`${this.$t('scriptRecord.createSimulationFail')}: ${error.message}`);
});
},
deleteScript(index,row) {
this.$confirm(this.$t('scriptRecord.deleteScriptTip'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteQuest(row.id).then(response => {
this.$message.success(this.$t('scriptRecord.deleteScriptSucess'));
this.loadInitData();
}).catch(() => {
this.$messageBox(this.$t('scriptRecord.deleteScriptFail'));
});
}).catch(() => { });
},
// 确定创建
handleConfirmCreate(data) {
createQuest(data).then(resp => {
this.reloadTable();
this.$message.success('创建剧本成功');
}).catch(error => {
this.$messageBox(`创建剧本失败: ${error.message}`);
})
},
//修改
handleModify(index, row){
this.$refs.modifyScript.doShow(row.id);
},
//确认修改
handleConfirmModify(data){
updateQuest(data.id,data).then(resp => {
this.reloadTable();
this.$message.success('修改剧本成功');
}).catch(error => {
this.$messageBox(`修改剧本失败: ${error.message}`);
})
},
// 创建
handleCreate() {
this.$refs.createScript.doShow(null);
},
reloadTable() {
this.loadInitData();
2019-10-14 13:10:36 +08:00
},
covertData(row){
let releaseReview=ConstConfig.ConstSelect.releaseReview;
let lastData=Object.assign({}, row) ;
releaseReview.forEach(function(element){
let rolename=element.value;
if(lastData.status==rolename){
lastData.status=element.label;
}
});
2019-10-14 13:58:26 +08:00
return lastData.status;
// let explanation=lastData.explanation?'{ 说明:'+lastData.explanation+'}':'';
// return lastData.status+explanation;
2019-10-14 13:10:36 +08:00
},
publishScript(index,row){
if(this.roles.indexOf(admin) >= 0 || this.roles.indexOf(superAdmin) >= 0){
publishScript(row.id,{'scriptName':row.name}).then(resp => {
this.reloadTable();
this.$message.success(this.$t('approval.releaseScriptSuccess'));
}).catch(error => {
this.$messageBox(`${this.$t('approval.releaseScriptFailed')}: ${error.message}`);
});
2019-10-14 13:58:26 +08:00
}else{
2019-10-14 13:10:36 +08:00
releaseScript(row.id,1).then(resp => {
this.reloadTable();
this.$message.success(this.$t('approval.releaseScriptSuccess'));
}).catch(error => {
this.$messageBox(`${this.$t('approval.releaseScriptFailed')}: ${error.message}`);
});
}
2019-10-14 13:58:26 +08:00
},
covertButtonname(){
if(this.roles.indexOf(admin) >= 0 || this.roles.indexOf(superAdmin) >= 0){
return this.$t('scriptRecord.publish');
}else{
return this.$t('scriptRecord.applyPublish');
}
},
revokeScript(index,row){
releaseScript(row.id,0).then(resp => {
this.reloadTable();
this.$message.success(this.$t('approval.revokeScriptSuccess'));
}).catch(error => {
this.$messageBox(`${this.$t('approval.revokeScriptFailed')}: ${error.message}`);
});
},
previewScript(index,row){
2019-10-15 13:41:23 +08:00
scriptRecordNotify(row.id).then(resp => {
2019-10-16 09:18:26 +08:00
const query = { mapId: row.mapId, group: resp.data, scriptId: row.id,skinCode:this.$route.query.skinCode,try:0};
this.$router.push({ path: `${UrlConfig.design.display}/demon`, query });
2019-10-15 13:41:23 +08:00
launchFullscreen();
}).catch(error => {
this.$messageBox(`${this.$t('scriptRecord.createSimulationFail')}: ${error.message}`);
});
// skinCode=02&group=16-128-757&prdType=02&mapId=18&code=JLFZZX-1&goodsId=&try=0
2019-09-26 10:54:07 +08:00
}
2019-09-26 09:07:19 +08:00
// loadInitData() {
// this.mapList = [];
// listPublishMap().then(response => {
// this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name }; });
// this.formModel.mapId=this.$store.state.scriptRecord.scriptId|| this.mapList[0].value;
// });
// },
// doCreate() {
// const self = this;
// if (!this.loading) {
// this.$refs.dataform.validateForm(() => {
// this.loading=true;
// const data=this.formModel;
// createQuest(data).then(resp => {
// const data={mapId: self.formModel.mapId, scriptId: resp.data};
// this.$emit('refresh', data);
// this.$message.success(this.$t('scriptRecord.createScriptSuccess'));
2019-09-10 17:32:41 +08:00
2019-09-26 09:07:19 +08:00
// this.formModel={};
// this.loading=false;
// this.$router.push({ path: `${UrlConfig.script.detail}/${resp.data}` });
// }).catch(error => {
// this.loading=false;
// this.$messageBox(`${$t('scriptRecord.createScriptFail')}${error.message}`);
// });
// });
// }
// }
}
};
2019-08-15 09:04:17 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
2019-09-26 13:21:15 +08:00
// .home-box {
// padding: 20px 100px;
// float: left;
// width: 100%;
// font-family: 'Microsoft YaHei';
// }
// .box-card {
// width:800px;
// margin: 0 auto;
// margin-top: 20px;
// padding-bottom: 50px;
// }
// #scriptTitle{
// padding: 30px 40px;
// }
// #sciptForm{
// margin-top: 10px;
// padding: 0px 130px 0px 100px;
// }
// #btnList{
// margin: 0px 100px;
// }
// .btn-footer{
// margin-left: 100px;
// margin-top: 10px;
// display: inline-block;
// }
.createScript{
display:inline-block;float:right;margin-right:20px;
}
.scriptHeader{
display:inline-block;margin-top:40px;width: 90%;margin-left:5%;
}
.scriptList{
display:inline-block;padding:7px 0px
}
2019-10-14 13:10:36 +08:00
.el-button+.el-button {
margin-left: 10px;
margin-top: 5px;
}
2019-08-15 09:04:17 +08:00
</style>