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

238 lines
7.2 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')"
width="300">
</el-table-column>
<el-table-column
prop="description"
:label="$t('scriptRecord.scriptDescription')"
width="400">
</el-table-column>
<el-table-column
2019-09-26 13:21:15 +08:00
:label="$t('scriptRecord.operate')"
2019-09-26 09:07:19 +08:00
>
2019-09-26 10:54:07 +08:00
<template slot-scope="scope">
<el-button size="small" type="success" @click="drawUp(scope.$index, scope.row)">{{$t('scriptRecord.scriptRecord')}}</el-button>
<el-button size="small" type="primary" @click="handleModify(scope.$index, scope.row)">{{$t('scriptRecord.scriptModify')}}</el-button>
<el-button size="small" type="danger" @click="deleteScript(scope.$index, scope.row)">{{$t('scriptRecord.scriptDelete')}}</el-button>
<el-button size="small" type="primary" @click="publishScript(scope.$index, scope.row)">{{$t('scriptRecord.applyPublish')}}</el-button>
<el-button size="small" type="success" @click="previewScript(scope.$index, scope.row)">{{$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>
import { UrlConfig } from '@/router/index';
2019-09-26 09:07:19 +08:00
// import {listPublishMap} from '@/api/jmap/map';
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: {
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;
// }
},
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-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-08-15 09:04:17 +08:00
</style>