2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-10-29 13:15:57 +08:00
|
|
|
<el-dialog
|
|
|
|
v-dialogDrag
|
|
|
|
:title="title"
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
width="25%"
|
|
|
|
:before-close="handleClose"
|
|
|
|
center
|
|
|
|
>
|
2019-08-08 15:57:36 +08:00
|
|
|
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2019-08-29 17:16:33 +08:00
|
|
|
<el-button v-loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
|
|
|
|
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
|
2019-08-08 15:57:36 +08:00
|
|
|
</span>
|
|
|
|
</el-dialog>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-08-08 15:57:36 +08:00
|
|
|
import { addTrainingRulesList } from '@/api/management/operation';
|
|
|
|
import { OperationList } from '@/scripts/OperationConfig';
|
2019-08-29 17:16:33 +08:00
|
|
|
import { getSkinCodeList } from '@/api/management/mapskin';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-08-08 15:57:36 +08:00
|
|
|
export default {
|
2019-10-29 13:15:57 +08:00
|
|
|
name: 'AddBatch',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
dialogVisible: false,
|
|
|
|
formModel: {
|
2019-10-30 19:36:29 +08:00
|
|
|
skinCode: this.$route.query.mapId
|
2019-10-29 13:15:57 +08:00
|
|
|
},
|
|
|
|
skinCodeList: [],
|
|
|
|
isShow: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
form() {
|
|
|
|
this.type === 'ADD';
|
|
|
|
const form = {
|
|
|
|
labelWidth: '120px',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
prop: 'skinCode',
|
|
|
|
label: this.$t('lesson.skinType'),
|
|
|
|
type: 'select',
|
|
|
|
required: true,
|
|
|
|
options: this.skinCodeList,
|
|
|
|
disabled: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
rules() {
|
|
|
|
const crules = {
|
|
|
|
skinCode: [
|
|
|
|
{
|
|
|
|
required: true,
|
|
|
|
message: this.$t('rules.inputSkinType'),
|
|
|
|
trigger: 'change'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
return crules;
|
|
|
|
},
|
|
|
|
title() {
|
|
|
|
return this.$t('lesson.generationOperation');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init() {
|
|
|
|
// 获取皮肤列表
|
|
|
|
this.skinCodeList = [];
|
|
|
|
getSkinCodeList().then(response => {
|
|
|
|
this.skinCodeList = response.data.map(item => {
|
|
|
|
const params = {};
|
|
|
|
params.label = item.name;
|
|
|
|
params.value = item.code;
|
|
|
|
return params;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
show(total) {
|
|
|
|
if (total) {
|
|
|
|
this.isShow = true;
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-10-29 13:15:57 +08:00
|
|
|
this.loading = false;
|
|
|
|
this.dialogVisible = true;
|
|
|
|
},
|
|
|
|
doSave() {
|
|
|
|
const self = this;
|
|
|
|
this.$refs.dataform.validateForm(() => {
|
|
|
|
if (this.isShow) {
|
|
|
|
this.$confirm(
|
|
|
|
this.$t('lesson.wellClearOperate'),
|
|
|
|
this.$t('global.tips'),
|
|
|
|
{
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.then(() => {
|
|
|
|
self.create();
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
} else {
|
|
|
|
self.create();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
create() {
|
|
|
|
const self = this;
|
|
|
|
this.loading = true;
|
|
|
|
addTrainingRulesList(
|
2019-10-30 19:36:29 +08:00
|
|
|
this.formModel.mapId,
|
|
|
|
OperationList[this.formModel.mapId].list
|
2019-10-29 13:15:57 +08:00
|
|
|
)
|
|
|
|
.then(response => {
|
|
|
|
self.loading = false;
|
|
|
|
self.$message.success(this.$t('lesson.batchCreateSuccess'));
|
|
|
|
self.handleClose();
|
|
|
|
self.$emit('reloadTable'); // 刷新列表
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
self.loading = false;
|
|
|
|
self.$message.error(
|
|
|
|
`${this.$('error.batchCreateFailed')}:${error.message}`
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleClose() {
|
|
|
|
this.formModel = {
|
2019-10-30 19:36:29 +08:00
|
|
|
skinCode: this.$route.query.mapId
|
2019-10-29 13:15:57 +08:00
|
|
|
};
|
|
|
|
this.$refs.dataform.resetForm();
|
|
|
|
this.isShow = false;
|
|
|
|
this.dialogVisible = false;
|
|
|
|
}
|
|
|
|
}
|
2019-08-08 15:57:36 +08:00
|
|
|
};
|
|
|
|
</script>
|