2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-11-01 15:19:15 +08:00
|
|
|
<div class="joylink-card">
|
2019-10-31 13:56:42 +08:00
|
|
|
<div class="scriptHeader">
|
2020-05-15 14:59:53 +08:00
|
|
|
<div class="scriptList">草稿{{ $t('scriptRecord.scriptList') }}</div>
|
2019-10-31 13:56:42 +08:00
|
|
|
<el-button size="small" type="primary" class="createScript" @click="handleCreate">{{ $t('scriptRecord.scriptCreate') }}</el-button>
|
2020-10-27 17:57:59 +08:00
|
|
|
<el-button type="primary" class="uploadDemo" size="mini">
|
|
|
|
<input
|
|
|
|
id="importResults"
|
|
|
|
ref="files"
|
|
|
|
type="file"
|
|
|
|
class="file_box"
|
|
|
|
accept=".json, application/json"
|
|
|
|
@change="importScript"
|
|
|
|
>
|
|
|
|
导入剧本
|
|
|
|
</el-button>
|
2019-10-31 13:56:42 +08:00
|
|
|
</div>
|
2019-11-01 15:19:15 +08:00
|
|
|
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" style="width: 91%;margin-left:4%;margin-top:20px;" />
|
2019-10-31 13:56:42 +08:00
|
|
|
<script-publish ref="publishScript" :title="$t('scriptRecord.publishScript')" @reloadTable="reloadTable" @create="handleConfirmPublish" />
|
|
|
|
<create-script ref="createScript" :title="$t('scriptRecord.createScript')" @reloadTable="reloadTable" @create="handleConfirmCreate" />
|
|
|
|
<create-script ref="modifyScript" :title="$t('scriptRecord.modifyScript')" @reloadTable="reloadTable" @create="handleConfirmModify" />
|
2019-11-01 15:19:15 +08:00
|
|
|
</div>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-10-15 16:18:25 +08:00
|
|
|
import Cookies from 'js-cookie';
|
2019-10-14 13:10:36 +08:00
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
2020-03-30 13:07:11 +08:00
|
|
|
import { UrlConfig } from '@/scripts/ConstDic';
|
|
|
|
import { admin, superAdmin} from '@/router/index_APP_TARGET';
|
2020-10-27 17:57:59 +08:00
|
|
|
import {retractScript, publishScript, updateScript, deleteScript, getScriptPageList, createScript, postScriptImport, getScriptExport} from '@/api/script';
|
2019-09-26 10:54:07 +08:00
|
|
|
import { launchFullscreen } from '@/utils/screen';
|
2020-10-27 17:57:59 +08:00
|
|
|
import { scriptDraftRecordNotifyNew, scriptRecordNotifyNew } from '@/api/simulation';
|
2019-09-26 10:54:07 +08:00
|
|
|
import CreateScript from './create';
|
2019-10-17 13:54:41 +08:00
|
|
|
import ScriptPublish from './publish';
|
2020-09-09 10:28:56 +08:00
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
export default {
|
2019-10-31 13:56:42 +08:00
|
|
|
name: 'ScriptDraft',
|
2019-11-01 15:19:15 +08:00
|
|
|
components: {
|
2019-10-31 13:56:42 +08:00
|
|
|
CreateScript,
|
|
|
|
ScriptPublish
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pagerConfig: {
|
|
|
|
pageSize: 'pageSize',
|
|
|
|
pageIndex: 'pageNum'
|
|
|
|
},
|
|
|
|
queryForm: {
|
|
|
|
labelWidth: '100px',
|
|
|
|
reset: true,
|
|
|
|
show:false
|
|
|
|
},
|
2020-09-09 10:28:56 +08:00
|
|
|
loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts'],
|
2019-10-31 13:56:42 +08:00
|
|
|
queryList: {
|
|
|
|
query: this.queryFunction,
|
|
|
|
selectCheckShow: false,
|
|
|
|
indexShow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
title: this.$t('scriptRecord.scriptName'),
|
|
|
|
prop: 'name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('scriptRecord.scriptDescription'),
|
|
|
|
prop: 'description'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('scriptRecord.status'),
|
|
|
|
prop: 'status',
|
|
|
|
type: 'tag',
|
|
|
|
columnValue: (row) => { return this.covertData(row); },
|
|
|
|
tagType: (row) => { return ''; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('scriptRecord.revokeReason'),
|
|
|
|
prop: 'explanation'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
title: this.$t('scriptRecord.operate'),
|
2020-10-27 17:57:59 +08:00
|
|
|
width: '450',
|
2019-10-31 13:56:42 +08:00
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: this.$t('scriptRecord.scriptRecord'),
|
|
|
|
handleClick: this.drawUp,
|
|
|
|
type: 'success',
|
|
|
|
showControl:(row) => { return !(row.status == 1); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('scriptRecord.scriptModify'),
|
|
|
|
handleClick: this.handleModify,
|
|
|
|
type: 'primary',
|
|
|
|
showControl:(row) => { return !(row.status == 1); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('scriptRecord.scriptDelete'),
|
|
|
|
handleClick: this.deleteScript,
|
|
|
|
type: 'danger',
|
|
|
|
showControl:(row) => { return !(row.status == 1); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.covertButtonname(),
|
|
|
|
handleClick: this.publishScript,
|
|
|
|
type: 'primary',
|
|
|
|
showControl:(row) => { return row.status == 0; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('scriptRecord.applyRevoke'),
|
|
|
|
handleClick: this.revokeScript,
|
|
|
|
type: 'primary',
|
|
|
|
showControl:(row) => { return row.status == 1; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('scriptRecord.preview'),
|
|
|
|
handleClick: this.previewScript,
|
|
|
|
type: 'success'
|
|
|
|
// showControl:(row) => { return row.status==1},
|
2020-10-27 17:57:59 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '导出',
|
|
|
|
handleClick: this.exportScript,
|
|
|
|
type: 'primary',
|
|
|
|
showControl:(row) => { return !(row.status == 1); }
|
2019-10-31 13:56:42 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2019-10-17 10:06:52 +08:00
|
|
|
]
|
2019-10-31 13:56:42 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2020-09-09 10:28:56 +08:00
|
|
|
computed:{
|
|
|
|
project() {
|
|
|
|
return getSessionStorage('project');
|
|
|
|
}
|
|
|
|
},
|
2019-10-31 13:56:42 +08:00
|
|
|
watch: {
|
|
|
|
'$route' () {
|
|
|
|
this.reloadTable();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
queryFunction(params) {
|
2020-04-21 10:07:26 +08:00
|
|
|
return getScriptPageList(this.$route.params.mapId, params);
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
reloadTable() {
|
|
|
|
if (this.queryList && this.queryList.reload) {
|
|
|
|
this.queryList.reload();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
drawUp(index, row) {
|
2020-10-26 11:07:49 +08:00
|
|
|
scriptRecordNotifyNew(row.id).then(resp => {
|
|
|
|
const query = { mapId: row.mapId, group: resp.data, scriptId: row.id, lang:row.lang, lineCode:this.$route.query.lineCode};
|
|
|
|
this.$router.push({ path: `${UrlConfig.scriptDisplayNew}/script`, query });
|
|
|
|
launchFullscreen();
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.createSimulationFail')}: ${error.message}`);
|
|
|
|
});
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
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(() => {
|
2020-04-21 10:07:26 +08:00
|
|
|
deleteScript(row.id).then(response => {
|
2019-10-31 13:56:42 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.deleteScriptSucess'));
|
|
|
|
this.reloadTable();
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.deleteScriptFail'));
|
|
|
|
});
|
|
|
|
}).catch(() => { });
|
|
|
|
},
|
|
|
|
// 确定创建
|
|
|
|
handleConfirmCreate(data) {
|
|
|
|
if (Cookies.get('user_lang') == 'en') {
|
|
|
|
data.lang = 'en';
|
|
|
|
} else {
|
|
|
|
data.lang = 'zh';
|
|
|
|
}
|
2020-04-21 10:07:26 +08:00
|
|
|
createScript(data).then(resp => {
|
2019-10-31 13:56:42 +08:00
|
|
|
this.reloadTable();
|
|
|
|
this.$message.success(this.$t('scriptRecord.createScriptSuccess'));
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.createScriptFail')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 修改
|
|
|
|
handleModify(index, row) {
|
|
|
|
this.$refs.modifyScript.doShow(row.id);
|
|
|
|
},
|
|
|
|
// 确认修改
|
|
|
|
handleConfirmModify(data) {
|
|
|
|
if (Cookies.get('user_lang') == 'en') {
|
|
|
|
data.lang = 'en';
|
|
|
|
} else {
|
|
|
|
data.lang = 'zh';
|
|
|
|
}
|
2020-04-21 10:07:26 +08:00
|
|
|
updateScript(data.id, data).then(resp => {
|
2019-10-31 13:56:42 +08:00
|
|
|
this.reloadTable();
|
|
|
|
this.$message.success(this.$t('scriptRecord.modifyScriptSuccess'));
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.modifyScriptFail')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 创建
|
|
|
|
handleCreate() {
|
|
|
|
this.$refs.createScript.doShow(null);
|
|
|
|
},
|
|
|
|
covertData(row) {
|
|
|
|
const releaseReview = ConstConfig.ConstSelect.releaseReview;
|
|
|
|
const lastData = Object.assign({}, row);
|
|
|
|
if (Cookies.get('user_lang') == 'en') {
|
|
|
|
releaseReview.forEach(function(element) {
|
|
|
|
const rolename = element.value;
|
|
|
|
if (lastData.status == rolename) {
|
|
|
|
lastData.status = element.enlabel;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
releaseReview.forEach(function(element) {
|
|
|
|
const rolename = element.value;
|
|
|
|
if (lastData.status == rolename) {
|
|
|
|
lastData.status = element.label;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return lastData.status;
|
|
|
|
},
|
|
|
|
handleConfirmPublish(data) {
|
2020-04-21 10:07:26 +08:00
|
|
|
publishScript(data.id, {'scriptName':data.scriptName}).then(resp => {
|
2019-10-31 13:56:42 +08:00
|
|
|
this.reloadTable();
|
|
|
|
this.$message.success(this.$t('scriptRecord.publishScriptSuccess'));
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.publishScriptFailed')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
publishScript(index, row) {
|
2020-07-14 16:51:22 +08:00
|
|
|
// if (this.$store.getters.roles.indexOf(admin) >= 0 || this.$store.getters.roles.indexOf(superAdmin) >= 0) {
|
|
|
|
this.$refs.publishScript.doShow(row);
|
|
|
|
// } else {
|
|
|
|
// this.$confirm(this.$t('scriptRecord.releaseScriptTip'), this.$t('global.tips'), {
|
|
|
|
// confirmButtonText: this.$t('global.confirm'),
|
|
|
|
// cancelButtonText: this.$t('global.cancel'),
|
|
|
|
// type: 'warning'
|
|
|
|
// }).then(() => {
|
|
|
|
// publishScript(row.id, {name:''}).then(resp => {
|
|
|
|
// this.reloadTable();
|
|
|
|
// this.$message.success(this.$t('scriptRecord.releaseScriptSuccess'));
|
|
|
|
// }).catch(error => {
|
|
|
|
// this.$messageBox(`${this.$t('scriptRecord.releaseScriptFailed')}: ${error.message}`);
|
|
|
|
// });
|
|
|
|
// }).catch(() => { });
|
|
|
|
// }
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
covertButtonname() {
|
|
|
|
if (this.$store.getters.roles.indexOf(admin) >= 0 || this.$store.getters.roles.indexOf(superAdmin) >= 0) {
|
|
|
|
return this.$t('scriptRecord.publish');
|
|
|
|
} else {
|
|
|
|
return this.$t('scriptRecord.applyPublish');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
revokeScript(index, row) {
|
|
|
|
this.$confirm(this.$t('scriptRecord.revokeScriptTip'), this.$t('global.tips'), {
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
2020-04-21 10:07:26 +08:00
|
|
|
retractScript(row.id).then(resp => {
|
2019-10-31 13:56:42 +08:00
|
|
|
this.reloadTable();
|
|
|
|
this.$message.success(this.$t('approval.revokeScriptSuccess'));
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('approval.revokeScriptFailed')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
}).catch(() => { });
|
2020-07-31 15:24:44 +08:00
|
|
|
},
|
|
|
|
// 剧本预览
|
2019-10-31 13:56:42 +08:00
|
|
|
previewScript(index, row) {
|
2020-10-26 11:07:49 +08:00
|
|
|
scriptDraftRecordNotifyNew(row.id).then(resp => {
|
|
|
|
if (this.loadingProjectList.includes(this.project)) {
|
|
|
|
this.$store.dispatch('app/transitionAnimations');
|
|
|
|
}
|
|
|
|
const query = { mapId: row.mapId, group: resp.data, scriptId: row.id, try:0, lineCode:this.$route.query.lineCode};
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.displayNew}/demon`, query });
|
|
|
|
launchFullscreen();
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.createSimulationFail')}: ${error.message}`);
|
|
|
|
});
|
2020-10-27 17:57:59 +08:00
|
|
|
},
|
|
|
|
exportScript(index, row) {
|
|
|
|
getScriptExport(row.id).then(res=>{
|
|
|
|
const resultData = res.data;
|
|
|
|
if (resultData === false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const content = new Blob([JSON.stringify(resultData)]);
|
|
|
|
const urlObject = window.URL || window.webkitURL || window;
|
|
|
|
const url = urlObject.createObjectURL(content);
|
|
|
|
const el = document.createElement('a');
|
|
|
|
el.href = url;
|
|
|
|
el.download = `${resultData.name}.json`;
|
|
|
|
el.click();
|
|
|
|
urlObject.revokeObjectURL(url);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
importScript() {
|
|
|
|
const loading = this.$loading({
|
|
|
|
lock: true,
|
|
|
|
text: '正在导入中...',
|
|
|
|
spinner: 'el-icon-loading',
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
});
|
|
|
|
setTimeout(() => {
|
|
|
|
const obj = this.$refs.files;
|
|
|
|
if (!obj.files) return;
|
|
|
|
const f = obj.files[0];
|
|
|
|
const reader = new FileReader();
|
|
|
|
const that = this;
|
|
|
|
reader.readAsText(f, 'utf-8');
|
|
|
|
reader.onload = function(e) {
|
|
|
|
const data = e.target.result;
|
|
|
|
postScriptImport(that.$route.params.mapId, JSON.parse(data)).then(res => {
|
|
|
|
loading.close();
|
|
|
|
that.$message.success('导入成功!');
|
|
|
|
that.reloadTable();
|
|
|
|
loading.close();
|
|
|
|
}).catch(error => {
|
|
|
|
loading.close();
|
|
|
|
that.$message.error('导入失败' + error.message);
|
|
|
|
});
|
|
|
|
obj.value = '';
|
|
|
|
};
|
|
|
|
});
|
2019-10-31 13:56:42 +08:00
|
|
|
}
|
|
|
|
}
|
2019-09-02 15:37:57 +08:00
|
|
|
};
|
2019-08-15 09:04:17 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
2019-11-01 15:19:15 +08:00
|
|
|
.joylink-card{
|
|
|
|
height: 100%;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
2019-09-26 13:21:15 +08:00
|
|
|
.createScript{
|
2019-11-01 15:19:15 +08:00
|
|
|
float: right;
|
|
|
|
margin-right:20px;
|
2019-09-26 13:21:15 +08:00
|
|
|
}
|
|
|
|
.scriptHeader{
|
|
|
|
display:inline-block;margin-top:40px;width: 90%;margin-left:5%;
|
|
|
|
}
|
|
|
|
.scriptList{
|
|
|
|
display:inline-block;padding:7px 0px
|
|
|
|
}
|
2019-10-25 14:14:27 +08:00
|
|
|
/deep/.el-button+.el-button {
|
|
|
|
margin-left: 5px;
|
2019-10-14 13:10:36 +08:00
|
|
|
margin-top: 5px;
|
|
|
|
}
|
2020-10-27 17:57:59 +08:00
|
|
|
.uploadDemo {
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
|
|
|
float: right;
|
|
|
|
margin-right: 10px;
|
|
|
|
cursor: pointer;
|
|
|
|
padding: 10px 15px;
|
|
|
|
margin-top: 0px !important;
|
|
|
|
}
|
|
|
|
.file_box {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
opacity: 0;
|
|
|
|
cursor: pointer;
|
|
|
|
z-index: 100;
|
|
|
|
}
|
2019-08-15 09:04:17 +08:00
|
|
|
</style>
|