提交 aad23ec0 authored 作者: lihuihui's avatar lihuihui

update

上级 b19daa72
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
import { getVideoList, createCharacter, getCourseListSearch, getLessonList, getOtherList } from '../../api' import { getVideoList, createCharacter, getCourseListSearch, getLessonList, getOtherList } from '../../api'
import CardListItem from './CardListItem.vue' import CardListItem from './CardListItem.vue'
import { useGetCategoryList } from '@/composables/useGetCategoryList' import { useGetCategoryList } from '@/composables/useGetCategoryList'
import { ElMessage } from 'element-plus'
const appList = ref() const appList = ref()
// 资源出处 tab触发 // 资源出处 tab触发
const tabValue = ref('1') const tabValue = ref('1')
const path = ref('') const path = ref('')
let tableData: any = reactive({ let tableData: any = $ref({
list: [], list: [],
title: '', title: '',
total: '' total: ''
...@@ -121,6 +122,57 @@ if (props.btnInfo.resource_type === '2') { ...@@ -121,6 +122,57 @@ if (props.btnInfo.resource_type === '2') {
} else if (props.btnInfo.resource_type === '4') { } else if (props.btnInfo.resource_type === '4') {
path.value = '/resource/other/view' path.value = '/resource/other/view'
} }
let checkName = $ref('全选')
// 写到这了
const checkboxAll = function () {
const data = tableData.list.reduce((a: any, b: any) => {
if (b.check_status) a.push(b)
return a
}, [])
if (data.length === tableData.list.length) {
tableData.list.map((item: any) => {
item.check_status = false
return item
})
checkName = '全选'
} else {
tableData.list.map((item: any) => {
item.check_status = true
return item
})
checkName = '取消全选'
}
}
const checkboxSelect = function () {
const data = tableData.list.reduce((a: any, b: any) => {
if (b.check_status) a.push(b)
return a
}, [])
data.length !== tableData.list.length ? (checkName = '全选') : (checkName = '取消全选')
}
const addVideo = function () {
const data = tableData.list.filter((item: any) => item.check_status === true)
data.forEach((item: any, index: number) => {
const params: any = {
name: item.name,
course_id: props.course_id,
resource_type: props.btnInfo.resource_type,
parent_id: props.chapterID,
resource_id: item.id
}
createCharacter(params).then(() => {
console.log(index === data.length, 'index === data.length')
if (index === data.length - 1) {
emit('update:isShowAddDialog', false)
emit('create', item)
ElMessage.success('添加成功')
}
})
})
}
</script> </script>
<template> <template>
...@@ -152,6 +204,10 @@ if (props.btnInfo.resource_type === '2') { ...@@ -152,6 +204,10 @@ if (props.btnInfo.resource_type === '2') {
</template> </template>
<template #body="{ data }"> <template #body="{ data }">
<div class="card-list" v-if="data.length"> <div class="card-list" v-if="data.length">
<div style="display: flex; margin-bottom: 20px">
<el-button type="primary" @click="checkboxAll">{{ checkName }}</el-button>
<el-button type="primary" @click="addVideo">添加</el-button>
</div>
<div class="card-list-con"> <div class="card-list-con">
<CardListItem <CardListItem
v-for="(item, index) in data" v-for="(item, index) in data"
...@@ -161,6 +217,7 @@ if (props.btnInfo.resource_type === '2') { ...@@ -161,6 +217,7 @@ if (props.btnInfo.resource_type === '2') {
:path="path" :path="path"
@add="handleAdd" @add="handleAdd"
> >
<el-checkbox @change="checkboxSelect" v-model="item.check_status"></el-checkbox>
</CardListItem> </CardListItem>
</div> </div>
</div> </div>
......
...@@ -8,6 +8,7 @@ interface Emits { ...@@ -8,6 +8,7 @@ interface Emits {
(e: 'add', id: object): void (e: 'add', id: object): void
} }
const handleAdd = () => { const handleAdd = () => {
console.log(props.data, 'datas')
emit('add', props.data) emit('add', props.data)
} }
const bytesToSize = (bytes: number) => { const bytesToSize = (bytes: number) => {
...@@ -48,6 +49,7 @@ const bytesToSize = (bytes: number) => { ...@@ -48,6 +49,7 @@ const bytesToSize = (bytes: number) => {
</div> </div>
</div> </div>
<div class="card-item-bottom"> <div class="card-item-bottom">
<slot></slot>
<div class="item-t"> <div class="item-t">
<el-popover trigger="hover" placement="right"> <el-popover trigger="hover" placement="right">
<div v-html="props.data.created_operator_name + '/' + props.data.organ_id_name"></div> <div v-html="props.data.created_operator_name + '/' + props.data.organ_id_name"></div>
...@@ -61,7 +63,9 @@ const bytesToSize = (bytes: number) => { ...@@ -61,7 +63,9 @@ const bytesToSize = (bytes: number) => {
</div> </div>
<div class="item-b"> <div class="item-b">
<div class="time">{{ props.data.updated_time }}</div> <div class="time">{{ props.data.updated_time }}</div>
<div class="tag" v-if="tabIndex === '2'">{{ props.data.department_public === '0' ? '未共享' : '已共享' }}</div> <div class="tag" v-if="tabIndex === '2'">
{{ props.data.department_public === '0' ? '未共享' : '已共享' }}
</div>
<div class="tag" v-if="tabIndex === '3'">{{ props.data.platform_public === '0' ? '未共享' : '已共享' }}</div> <div class="tag" v-if="tabIndex === '3'">{{ props.data.platform_public === '0' ? '未共享' : '已共享' }}</div>
</div> </div>
</div> </div>
...@@ -167,7 +171,7 @@ const bytesToSize = (bytes: number) => { ...@@ -167,7 +171,7 @@ const bytesToSize = (bytes: number) => {
} }
.card-item-bottom { .card-item-bottom {
background: #fff; background: #fff;
padding: 20px 16px 30px; padding: 10px 16px 30px;
.item-t { .item-t {
display: flex; display: flex;
align-items: center; align-items: center;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论