Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
00b4b533a8
@ -32,6 +32,14 @@ export function updateTraining(data) {
|
||||
data
|
||||
});
|
||||
}
|
||||
/** 更新实训标签 */
|
||||
export function updateTrainingLabel(data) {
|
||||
return request({
|
||||
url: `/api/v2/training/published/update/label`,
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
/** 查询步骤列表 */
|
||||
export function getTrainingStepList(trainingId) {
|
||||
return request({
|
||||
|
206
src/views/organization/trainingManage/editTraining.vue
Normal file
206
src/views/organization/trainingManage/editTraining.vue
Normal file
@ -0,0 +1,206 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-dialogDrag
|
||||
:visible.sync="dialogVisible"
|
||||
width="50%"
|
||||
:title="title"
|
||||
:modal="false"
|
||||
:show-close="false"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:before-close="doClose"
|
||||
>
|
||||
<div>
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<el-form ref="form" :model="tagForm" size="small" label-width="90px" :rules="formRules">
|
||||
<el-form-item v-if="formModel.type === 'SINGLE'" label="客户端" prop="client">
|
||||
<el-select v-model="tagForm.client" placeholder="请选择客户端" disabled>
|
||||
<el-option label="行调客户端" value="dispatchWork" />
|
||||
<el-option label="现地客户端" value="localWork" />
|
||||
<el-option label="轨道详览" value="troDetailWork" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标签" prop="dynamicTags">
|
||||
<el-tag
|
||||
v-for="tag in tagForm.dynamicTags"
|
||||
:key="tag"
|
||||
closable
|
||||
:disable-transitions="false"
|
||||
@close="handleClose(tag)"
|
||||
>
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-input
|
||||
v-if="inputVisible"
|
||||
ref="saveTagInput"
|
||||
v-model="inputValue"
|
||||
class="input-new-tag"
|
||||
size="small"
|
||||
@keyup.enter.native="handleInputConfirm"
|
||||
@blur="handleInputConfirm"
|
||||
/>
|
||||
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ New Tag</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="doClose">取 消</el-button>
|
||||
<el-button type="primary" @click="doSave">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateTrainingLabel } from '@/api/trainingManage';
|
||||
import ConstConfig from '@/scripts/ConstConfig';
|
||||
|
||||
export default {
|
||||
name: 'Create',
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
formModel: {
|
||||
name: '',
|
||||
mapId: '',
|
||||
description:'',
|
||||
type: '',
|
||||
client: ''
|
||||
},
|
||||
inputVisible: false,
|
||||
inputValue: '',
|
||||
tagForm: {
|
||||
client: '',
|
||||
dynamicTags: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
const t = '编辑标签';
|
||||
return t;
|
||||
},
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '90px',
|
||||
items: [
|
||||
{ prop: 'name', label: '名称', type: 'text', required: true, disabled: true },
|
||||
{ prop: 'description', label: '描述', type: 'textarea', isAutoSize: true, required: true, disabled: true },
|
||||
{ prop: 'type', label: '类型', type: 'select', options: ConstConfig.ConstSelect.trainingType, required: true, disabled: true }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const crules = {
|
||||
name: [
|
||||
{ required: true, validator: this.validateName, trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ required: true, validator: this.validateDescription, trigger: 'blur' }
|
||||
],
|
||||
type: [
|
||||
{ required: true, message: '请选择实训类型', trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
formRules() {
|
||||
return {
|
||||
client: [{ required: true, message: '请选择客户端', trigger: 'blur' }]
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClose(tag) {
|
||||
this.tagForm.dynamicTags.splice(this.tagForm.dynamicTags.indexOf(tag), 1);
|
||||
},
|
||||
showInput() {
|
||||
this.inputVisible = true;
|
||||
this.$nextTick(_ => {
|
||||
this.$refs.saveTagInput.$refs.input.focus();
|
||||
});
|
||||
},
|
||||
handleInputConfirm() {
|
||||
const inputValue = this.inputValue;
|
||||
if (inputValue) {
|
||||
this.tagForm.dynamicTags.push(inputValue);
|
||||
}
|
||||
this.inputVisible = false;
|
||||
this.inputValue = '';
|
||||
},
|
||||
validateName(rule, value, callback) {
|
||||
if (value.trim().length == 0) {
|
||||
this.formModel.name = this.formModel.name.replace(/\s/g, '');
|
||||
return callback(new Error('请输入实训名称'));
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
},
|
||||
validateDescription(rule, value, callback) {
|
||||
if (value.trim().length == 0) {
|
||||
this.formModel.description = this.formModel.description.replace(/\s/g, '');
|
||||
return callback(new Error('请输入实训描述'));
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
},
|
||||
doShow(data) {
|
||||
if (data) {
|
||||
this.dialogVisible = true;
|
||||
this.formModel = {...data};
|
||||
Object.keys(this.formModel).forEach(key => {
|
||||
this.formModel[key] = data[key];
|
||||
});
|
||||
this.tagForm.dynamicTags = data.labelJson ? JSON.parse(data.labelJson) : [];
|
||||
this.tagForm.client = data.client;
|
||||
}
|
||||
},
|
||||
doSave() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
const cpData = Object.assign({}, this.formModel);
|
||||
cpData.client = this.formModel.type === 'SINGLE' ? this.tagForm.client : '';
|
||||
cpData.labelJson = JSON.stringify(this.tagForm.dynamicTags);
|
||||
const api = updateTrainingLabel;
|
||||
const mes = '编辑标签';
|
||||
api(cpData).then(res => {
|
||||
this.$message.success(`${mes}成功!`);
|
||||
this.$emit('editLabel');
|
||||
this.doClose();
|
||||
}).catch(err => {
|
||||
this.$message.error(`${mes}失败!,${err.message}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
doClose() {
|
||||
this.$refs.dataform && this.$refs.dataform.resetForm();
|
||||
this.$refs.form && this.$refs.form.resetFields();
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/deep/ .el-dialog--center .el-dialog__body{
|
||||
padding: 25px 65px 30px 10px;
|
||||
}
|
||||
.el-tag + .el-tag {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.button-new-tag {
|
||||
margin-left: 10px;
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.input-new-tag {
|
||||
width: 90px;
|
||||
margin-left: 10px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
</style>
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div style="width: 100%;height: 100%;">
|
||||
<QueryListPage v-if="showList" ref="queryListPage" :card-padding="10" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
|
||||
<editTraining ref="editTraining" @editLabel="editLabel" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -10,9 +11,14 @@ import { createSimulation } from '@/api/simulation';
|
||||
import ConstConfig from '@/scripts/ConstConfig';
|
||||
import { getSessionStorage } from '@/utils/auth';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import editTraining from './editTraining';
|
||||
import { superAdmin, admin } from '@/router/index';
|
||||
import { getAllPublishTrainingList, getManageTrainingListInOrg, publishTrainingPutOn, publishTrainingPutOff, publishTrainingDelete } from '@/api/jmap/training';
|
||||
export default {
|
||||
name:'TrainingManage',
|
||||
components: {
|
||||
editTraining
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts', 'hlsdrts', 'designhlsdrts', 'teaching', 'designteaching'],
|
||||
@ -93,7 +99,7 @@ export default {
|
||||
{
|
||||
type: 'button',
|
||||
title: this.$t('trainingManage.operate'),
|
||||
width: '200',
|
||||
width: '240',
|
||||
buttons: [
|
||||
// {
|
||||
// name: '加载',
|
||||
@ -101,6 +107,12 @@ export default {
|
||||
// type: 'primary',
|
||||
// showControl:(row) => { return row.mapSystem; }
|
||||
// }
|
||||
{
|
||||
name: '修改标签',
|
||||
handleClick: this.handlerEditLabel,
|
||||
type: 'primary',
|
||||
showControl: row => { return this.isAdmin; }
|
||||
},
|
||||
{
|
||||
name: '上架',
|
||||
handleClick: this.handlerShelf,
|
||||
@ -131,6 +143,9 @@ export default {
|
||||
},
|
||||
orgId() {
|
||||
return this.$store.state.user.companyId;
|
||||
},
|
||||
isAdmin() {
|
||||
return this.$store.state.user.roles.includes(superAdmin) || this.$store.state.user.roles.includes(admin);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -149,6 +164,12 @@ export default {
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
editLabel() {
|
||||
this.queryList.reload();
|
||||
},
|
||||
handlerEditLabel(index, data) {
|
||||
this.$refs.editTraining.doShow(data);
|
||||
},
|
||||
handlerShelf(index, data) {
|
||||
publishTrainingPutOn({ids: [data.id]}).then(resp=>{
|
||||
this.queryList.reload();
|
||||
|
Loading…
Reference in New Issue
Block a user