多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.7 KiB

3 years ago
<template>
<div class="main justify-center d-flex" style="min-height: 600px; overflow: auto">
3 years ago
<v-form ref="form" v-model="valid" @submit.prevent="renameProject">
<v-card style="width: 530px; margin-top: 100px" class="mx-auto">
3 years ago
<div
style="
position: absolute;
top: -33px;
left: -moz-calc(50% - 33px);
left: -webkit-calc(50% - 33px);
left: calc(50% - 33px);
border-radius: 15px;
"
3 years ago
class="primary"
>
<v-img class="mx-auto" width="66" height="66" :src="require('~/assets/img/icons/512x512-trans.png')" />
3 years ago
</div>
<v-container fluid class="pb-10 px-12" style="padding-top: 43px !important">
3 years ago
<!-- Edit Project -->
<h1 class="mt-4 mb-4 text-center">
{{ $t('activity.editProject') }}
</h1>
<div class="mx-auto" style="width: 350px">
3 years ago
<!-- label="Enter Project Name" -->
<!-- rule text: Required -->
<v-text-field
ref="projectTitleInput"
v-model="projectTitle"
autofocus
:full-width="false"
class="nc-metadb-project-name"
:label="$t('placeholder.projName')"
:rules="form.titleValidationRule"
/>
</div>
<div class="text-center">
<v-btn
v-t="['a:project:edit:rename']"
class="mt-3"
large
:loading="loading"
color="primary"
@click="renameProject"
>
<v-icon class="mr-1 mt-n1"> mdi-rocket-launch-outline </v-icon>
3 years ago
<!-- Edit -->
<span class="mr-1">{{ $t('general.edit') }}</span>
</v-btn>
</div>
</v-container>
</v-card>
</v-form>
</div>
</template>
<script>
import colors from '@/mixins/colors';
3 years ago
export default {
name: 'EditProject',
mixins: [colors],
data: () => ({
valid: null,
projectTitle: '',
loading: false,
projectType: 'rest',
form: {
titleValidationRule: [
v => !!v || 'Title is required',
v => (v && v.length <= 50) || 'Project name exceeds 50 characters',
3 years ago
],
},
}),
computed: {
pid() {
return this.$route.query.projectId;
3 years ago
},
},
async mounted() {
setTimeout(() => {
this.$refs.projectTitleInput.$el.querySelector('input').focus();
}, 100);
await this.getProject(this.pid);
3 years ago
},
methods: {
async getProject() {
try {
const result = await this.$api.project.read(this.pid);
this.$nextTick(() => {
this.projectTitle = result.title;
});
} catch (e) {
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
}
3 years ago
},
async renameProject() {
if (this.$refs.form.validate()) {
this.loading = true;
3 years ago
try {
await this.$api.project.update(this.pid, {
title: this.projectTitle,
});
3 years ago
await this.$store.dispatch('project/ActLoadProjectInfo');
3 years ago
this.projectReloading = false;
3 years ago
this.$router.push({
path: `/nc/${this.pid}`,
query: {
new: 1,
},
});
3 years ago
} catch (e) {
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
3 years ago
}
this.loading = false;
3 years ago
} else {
this.$toast.error('Invalid Form');
3 years ago
}
},
},
};
3 years ago
</script>
<style scoped>
/deep/ label {
font-size: 0.75rem;
3 years ago
}
.wrapper {
border: 2px solid var(--v-backgroundColor-base);
border-radius: 4px;
}
.main {
height: calc(100vh - 48px);
3 years ago
}
</style>