123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <div>
- <div>
- <el-dialog v-model="fileCollect" title="重命名" width="30%">
- <el-form :model="collectForm" label-width="120px">
- <el-form-item label="名称">
- <el-input v-model="collectForm.name" />
- </el-form-item>
- <el-form-item label="收藏标签">
- <div class="newTag" v-if="tagCollect">
- <el-input v-model="newTag" placeholder="请输入新标签" @blur="tagBlur"></el-input>
- </div>
- <el-select v-model="collectForm.folders" class="m-2" placeholder="请选择" size="large"
- @change="collectChange">
- <el-option v-for="(item, index) in collectList" :key="item.labelId" :label="item.label"
- :value="item.labelId" />
- </el-select>
- </el-form-item>
- </el-form>
- <el-button @click="createTag">新建标签</el-button>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="backColl">取消</el-button>
- <el-button type="primary" @click="getSureC">
- 确认
- </el-button>
- </span>
- </template>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { ref, onMounted, toRef } from "vue"
- import { ElMessage } from "element-plus"
- import collect from "../../../api/collect/collect"
- export default {
- props: {
- collects: {
- type: Boolean,
- required: true
- },
- copyFileName: {
- type: String,
- required: true
- },
- copyFileId:{
- type:Number,
- required:true
- }
- },
- setup(props, { emit }) {
- let { backColl, getSureC } = toRef(props)
- let result = props.collects
- let fname = props.copyFileName
- let fid = props.copyFileId
- let fileCollect = ref(false)
- let collectForm = ref({
- name: "",
- folders: "",
- })
- let tagCollect = ref(false)//添加收藏标签时显示
- let newTag = ref('')
- let sortNum = ref(0)
- let collectList = ref([])
- function inlineList() {
- fileCollect.value = result
- collectForm.value.name = fname
- }
- function tagBlur() {
- collect.addNewTag({ labelName: newTag.value, orderNum: sortNum.value + 1 }).then(res => {
- if (res.code === 200) {
- ElMessage({
- message: "新建标签成功",
- type: "success"
- })
- getAllCollect()
- }
- })
- tagCollect.value = false
- }
- function collectChange(e) {
- collectForm.value.folders = e
- }
- function getAllCollect() {
- collect.getCollect({}).then(res => {
- const maxAge = res.rows.reduce((max, obj) => (obj.orderNum > max ? obj.orderNum : max), res.rows[0].orderNum)
- sortNum.value = maxAge
- collectList.value = res.rows.map(item => {
- return {
- label: item.labelName,
- labelId: item.labelId,
- order: item.orderNum
- }
- })
- })
- }
- function createTag() {
- newTag.value = ''
- tagCollect.value = true
- }
- // 确认收藏
- function sureCollect() {
- collect.addCollect({
- "docInfo": {
- "fileId": fid - 0,
- "labelId": collectForm.value.folders - 0,
- },
- }).then(res => {
- if (res.code === 200) {
- ElMessage({
- message: "收藏成功",
- type: "success"
- })
- }
- })
- fileCollect.value = false
- emit("getCollects", fileCollect.value)
- }
- function tobacks() {
- fileCollect.value = false
- emit("getCollects", fileCollect.value)
- }
- onMounted(() => {
- inlineList()
- getAllCollect()
- })
- return {
- fileCollect,
- collectForm,
- tagCollect,
- newTag,
- inlineList,
- tagBlur,
- collectChange,
- getAllCollect,
- createTag,
- getSureC: sureCollect,
- backColl: tobacks,
- collectList,
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|