Add Chatdoc feature (#40)
This commit is contained in:
1 parent
60752af1fb
commit
811a2bca09
51 files changed
+2742
-25
No files matched your search
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" width="500px">
|
||||
<el-form ref="form" label-width="60px">
|
||||
<el-form-item :label="$t('chatdoc.field.name')" :prop="form.name">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chatdoc.field.description')" :prop="form.description">
|
||||
<el-input v-model="form.description" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit">{{ $t('common.button.create') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
<button class="btn btn-create" @click="dialogVisible = true">
|
||||
<font-awesome-icon :icon="['fas', 'plus']" />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton, ElDialog, ElMessage, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
interface IData {
|
||||
dialogVisible: boolean;
|
||||
creating: boolean;
|
||||
form: {
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UploadDocument',
|
||||
components: {
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
creating: false,
|
||||
form: {
|
||||
name: '',
|
||||
description: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
async onSubmit() {
|
||||
if (!this.form.name) {
|
||||
ElMessage.error(this.$t('chatdoc.message.nameRequired'));
|
||||
return;
|
||||
}
|
||||
this.creating = true;
|
||||
this.$store
|
||||
.dispatch('chatdoc/createRepository', {
|
||||
name: this.form.name,
|
||||
description: this.form.description
|
||||
})
|
||||
.then(() => {
|
||||
this.creating = false;
|
||||
ElMessage.success(this.$t('chatdoc.message.createDocumentSuccess'));
|
||||
this.dialogVisible = false;
|
||||
this.$store.dispatch('chatdoc/getRepositories');
|
||||
})
|
||||
.catch(() => {
|
||||
this.creating = false;
|
||||
ElMessage.error(this.$t('chatdoc.message.createRepositoryFailed'));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.btn.btn-create {
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
margin-top: 5px;
|
||||
background-color: #eee;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
border-radius: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user