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.
moredoc/web/components/FormUpdateDocumentsCategory...

116 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="com-form-update-documents-category">
<el-form ref="form" label-position="top" label-width="80px" :model="form">
<el-form-item
label="新文档分类"
prop="category_id"
:rules="[
{ required: true, trigger: 'blur', message: '请选择新的文档分类' },
]"
>
<el-cascader
v-model="form.category_id"
:options="categoryTrees"
:filterable="true"
:props="{
checkStrictly: true,
expandTrigger: 'hover',
label: 'title',
value: 'id',
}"
clearable
placeholder="请选择新的文档分类"
></el-cascader>
</el-form-item>
<el-form-item label="文档列表" class="document-list">
<DocumentSimpleList :target="'_blank'" :docs="documents" />
</el-form-item>
<el-form-item>
<el-button
type="primary"
class="btn-block"
icon="el-icon-check"
@click="setDocumentsCategory"
></el-button
>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { setDocumentsCategory } from '~/api/document'
import { mapGetters } from 'vuex'
export default {
name: 'FormUpdateDocumentsCategory',
props: {
// 文档分类
categoryTrees: {
type: Array,
default: () => {
return []
},
},
documents: {
type: Array,
default: () => {
return []
},
},
},
data() {
return {
form: {
category_id: [],
document_id: [],
},
}
},
computed: {
...mapGetters('setting', ['settings']),
},
created() {},
methods: {
async setDocumentsCategory() {
this.$refs.form.validate(async (valid) => {
if (valid) {
this.$confirm('', '', {
confirmButtonText: '',
cancelButtonText: '',
type: 'warning',
})
.then(async () => {
this.form.document_id = this.documents.map((item) => item.id)
const res = await setDocumentsCategory(this.form)
if (res.status === 200) {
this.$message.success('')
this.$emit('success', res.data)
}
})
.catch(() => {})
}
})
},
},
}
</script>
<style lang="scss">
.com-form-update-documents-category {
.document-list {
ul,
li {
list-style: none;
margin: 0;
padding: 0;
}
ul {
max-height: 300px;
overflow: auto;
}
li {
line-height: 30px;
color: #777;
}
}
}
</style>