提交 a0ed7c21 authored 作者: 王鹏飞's avatar 王鹏飞

refactor: 移除 Vue 宏转换并改造相关响应式写法

上级 66db47db
{ {
"globals": { "globals": {
"$": true,
"$$": true,
"$computed": true,
"$customRef": true,
"$ref": true,
"$shallowRef": true,
"$toRef": true,
"EffectScope": true, "EffectScope": true,
"asyncComputed": true, "asyncComputed": true,
"autoResetRef": true, "autoResetRef": true,
......
// Generated by 'unplugin-auto-import' // Generated by 'unplugin-auto-import'
export {} export {}
declare global { declare global {
const $$: typeof import('vue/macros')['$$']
const $: typeof import('vue/macros')['$']
const $computed: typeof import('vue/macros')['$computed']
const $customRef: typeof import('vue/macros')['$customRef']
const $ref: typeof import('vue/macros')['$ref']
const $shallowRef: typeof import('vue/macros')['$shallowRef']
const $toRef: typeof import('vue/macros')['$toRef']
const EffectScope: typeof import('vue')['EffectScope'] const EffectScope: typeof import('vue')['EffectScope']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
......
...@@ -34,7 +34,7 @@ onMounted(() => { ...@@ -34,7 +34,7 @@ onMounted(() => {
//设置配置 //设置配置
myEcharts.setOption(option) myEcharts.setOption(option)
}) })
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
columns: [ columns: [
{ label: '访问时间', prop: 'created_at', align: 'center' }, { label: '访问时间', prop: 'created_at', align: 'center' },
......
...@@ -10,13 +10,13 @@ import type { IMenuItem } from '@/types' ...@@ -10,13 +10,13 @@ import type { IMenuItem } from '@/types'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const menuList = $computed<IMenuItem[]>(() => { const menuList = computed<IMenuItem[]>(() => {
const found = menus.find(item => route.fullPath.includes(item.path)) const found = menus.find(item => route.fullPath.includes(item.path))
return found?.children || [] return found?.children || []
}) })
const defaultActive = computed(() => { const defaultActive = computed(() => {
// 扁平菜单 // 扁平菜单
const flatMenuList: IMenuItem[] = menuList.reduce((result: IMenuItem[], item) => { const flatMenuList: IMenuItem[] = menuList.value.reduce((result: IMenuItem[], item) => {
result.push(item) result.push(item)
if (item.children) { if (item.children) {
result = result.concat(item.children) result = result.concat(item.children)
......
...@@ -6,7 +6,7 @@ import { ElMessage, ElMessageBox } from 'element-plus' ...@@ -6,7 +6,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { checkPermission } from '@/utils/permission' import { checkPermission } from '@/utils/permission'
import AddDialog from '../components/AddDialog.vue' import AddDialog from '../components/AddDialog.vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
const appList = $ref<null | InstanceType<typeof AppList>>(null) const appList = ref<null | InstanceType<typeof AppList>>(null)
const prevCategoryName = ref('') const prevCategoryName = ref('')
const title = ref('') const title = ref('')
...@@ -23,7 +23,7 @@ interface ICategory { ...@@ -23,7 +23,7 @@ interface ICategory {
status_name: string status_name: string
children?: ICategory[] children?: ICategory[]
} }
let tableData = $ref<ICategory[]>([]) const tableData = ref<ICategory[]>([])
const editData = ref({}) const editData = ref({})
const isEdit = ref(false) const isEdit = ref(false)
const handleEdit = (row: ICategory) => { const handleEdit = (row: ICategory) => {
...@@ -32,7 +32,7 @@ const handleEdit = (row: ICategory) => { ...@@ -32,7 +32,7 @@ const handleEdit = (row: ICategory) => {
dialogVisible.value = true dialogVisible.value = true
editData.value = row editData.value = row
if (row.depth > '0') { if (row.depth > '0') {
prevCategoryName.value = getParent(row.id, tableData[0]).category_name prevCategoryName.value = getParent(row.id, tableData.value[0]).category_name
} else { } else {
prevCategoryName.value = '' prevCategoryName.value = ''
} }
...@@ -64,8 +64,8 @@ const handleAddCategory = () => { ...@@ -64,8 +64,8 @@ const handleAddCategory = () => {
isEdit.value = false isEdit.value = false
dialogVisible.value = true dialogVisible.value = true
title.value = '新增类别' title.value = '新增类别'
editData.value = tableData[0] editData.value = tableData.value[0]
prevCategoryName.value = tableData[0].category_name prevCategoryName.value = tableData.value[0].category_name
} }
// 获取上级类别 // 获取上级类别
const getParent = (node: string, tree: any) => { const getParent = (node: string, tree: any) => {
...@@ -86,11 +86,11 @@ const getParent = (node: string, tree: any) => { ...@@ -86,11 +86,11 @@ const getParent = (node: string, tree: any) => {
// 获取分类列表 // 获取分类列表
const handleUpdate = () => { const handleUpdate = () => {
appList?.refetch() appList.value?.refetch()
} }
// 扁平列表数据 // 扁平列表数据
let tableDataList = $ref<ICategory[]>([]) const tableDataList = ref<ICategory[]>([])
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
...@@ -99,19 +99,19 @@ const listOptions = computed(() => { ...@@ -99,19 +99,19 @@ const listOptions = computed(() => {
params: { type: 'tree', category_name: '' }, params: { type: 'tree', category_name: '' },
callback(data: ICategory[], params: any) { callback(data: ICategory[], params: any) {
const list = rebuildData(params.category_name, data) const list = rebuildData(params.category_name, data)
tableData = list tableData.value = list
tableDataList = flatten(list) tableDataList.value = flatten(list)
return { list } return { list }
} },
}, },
filters: [{ type: 'input', prop: 'category_name', label: '类别名称:', placeholder: '请输入类别名称' }], filters: [{ type: 'input', prop: 'category_name', label: '类别名称:', placeholder: '请输入类别名称' }],
columns: [ columns: [
{ label: '类别名称', prop: 'category_name', align: 'center' }, { label: '类别名称', prop: 'category_name' },
{ label: '层级', prop: 'depth', align: 'center' }, { label: '层级', prop: 'depth', align: 'center' },
{ label: '状态', prop: 'status_name', align: 'center' }, { label: '状态', prop: 'status_name', align: 'center' },
{ label: '操作', slots: 'table-operate', width: 230, align: 'center', fixed: 'right' } { label: '操作', slots: 'table-operate', width: 230, align: 'center', fixed: 'right' },
], ],
data: tableData data: tableData.value,
} }
}) })
// 数据扁平化 // 数据扁平化
...@@ -127,7 +127,7 @@ function flatten(data: any[], pid = '0') { ...@@ -127,7 +127,7 @@ function flatten(data: any[], pid = '0') {
} }
// 拖拽 // 拖拽
function useSortable() { function useSortable() {
const el = appList?.$el.querySelector('.el-table__body-wrapper tbody') const el = appList.value?.$el.querySelector('.el-table__body-wrapper tbody')
if (!el) return if (!el) return
Sortable.create(el, { Sortable.create(el, {
...@@ -145,30 +145,30 @@ function useSortable() { ...@@ -145,30 +145,30 @@ function useSortable() {
onEnd(evt: SortableEvent) { onEnd(evt: SortableEvent) {
const { oldIndex, newIndex } = evt const { oldIndex, newIndex } = evt
if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) return if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) return
const draggedRow = tableDataList[oldIndex] const draggedRow = tableDataList.value[oldIndex]
const relatedRow = tableDataList[newIndex] const relatedRow = tableDataList.value[newIndex]
moveCategory({ moveCategory({
id: draggedRow.id, id: draggedRow.id,
brother_id: relatedRow.id, brother_id: relatedRow.id,
type: newIndex > oldIndex ? 'after' : 'before' type: newIndex > oldIndex ? 'after' : 'before',
}).then(() => { }).then(() => {
// 修复拖拽后数据顺序不对的问题 // 修复拖拽后数据顺序不对的问题
if (oldIndex < newIndex) { if (oldIndex < newIndex) {
tableData = [] tableData.value = []
} }
handleUpdate() handleUpdate()
}) })
} },
}) })
} }
// 展开行 // 展开行
let expandRowKeys = $ref<string[]>([]) const expandRowKeys = ref<string[]>([])
function onExpandChange(row: ICategory, expanded: boolean) { function onExpandChange(row: ICategory, expanded: boolean) {
if (expanded) { if (expanded) {
expandRowKeys.push(row.id) expandRowKeys.value.push(row.id)
} else { } else {
expandRowKeys = expandRowKeys.filter(id => id !== row.id) expandRowKeys.value = expandRowKeys.value.filter((id) => id !== row.id)
} }
} }
...@@ -188,7 +188,7 @@ const rebuildData = (value: any, arr: any) => { ...@@ -188,7 +188,7 @@ const rebuildData = (value: any, arr: any) => {
const ab = rebuildData(value, element.children) const ab = rebuildData(value, element.children)
const obj = { const obj = {
...element, ...element,
children: ab children: ab,
} }
newArr.push(obj) newArr.push(obj)
} else { } else {
...@@ -197,7 +197,7 @@ const rebuildData = (value: any, arr: any) => { ...@@ -197,7 +197,7 @@ const rebuildData = (value: any, arr: any) => {
const ab = rebuildData(value, element.children) const ab = rebuildData(value, element.children)
const obj = { const obj = {
...element, ...element,
children: ab children: ab,
} }
if (ab && ab.length > 0) { if (ab && ab.length > 0) {
newArr.push(obj) newArr.push(obj)
...@@ -222,8 +222,7 @@ onMounted(() => { ...@@ -222,8 +222,7 @@ onMounted(() => {
:expand-row-keys="expandRowKeys" :expand-row-keys="expandRowKeys"
@expand-change="onExpandChange" @expand-change="onExpandChange"
border border
stripe stripe>
>
<el-button <el-button
type="primary" type="primary"
@click="handleAddCategory" @click="handleAddCategory"
...@@ -257,6 +256,5 @@ onMounted(() => { ...@@ -257,6 +256,5 @@ onMounted(() => {
:isEdit="isEdit" :isEdit="isEdit"
:title="title" :title="title"
:prevCategoryName="prevCategoryName" :prevCategoryName="prevCategoryName"
v-if="dialogVisible" v-if="dialogVisible" />
/>
</template> </template>
...@@ -18,7 +18,7 @@ interface Emits { ...@@ -18,7 +18,7 @@ interface Emits {
const classInfo: any = ref({}) // 班级信息 const classInfo: any = ref({}) // 班级信息
const multiSelection = ref([]) const multiSelection = ref([])
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getRelationClassStuList, httpRequest: getRelationClassStuList,
......
...@@ -21,7 +21,7 @@ const isShowAddDialog = ref(false) ...@@ -21,7 +21,7 @@ const isShowAddDialog = ref(false)
const title = ref('') const title = ref('')
const id = ref('') const id = ref('')
const classInfo: any = ref({}) const classInfo: any = ref({})
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getClassStuList, httpRequest: getClassStuList,
......
...@@ -24,7 +24,7 @@ const props = defineProps({ ...@@ -24,7 +24,7 @@ const props = defineProps({
interface Emits { interface Emits {
(e: 'update:isRelatingDialog', isRelatingDialog: boolean): void (e: 'update:isRelatingDialog', isRelatingDialog: boolean): void
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getClassSemList, httpRequest: getClassSemList,
......
...@@ -21,7 +21,7 @@ const isEdit = ref('') ...@@ -21,7 +21,7 @@ const isEdit = ref('')
const isShowClassDialog = ref(false) const isShowClassDialog = ref(false)
const isShowClassStuDialog = ref(false) const isShowClassStuDialog = ref(false)
const isRelatingDialog = ref(false) const isRelatingDialog = ref(false)
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { httpRequest: getClassList, params: { name: '', organ_id: '' } }, remote: { httpRequest: getClassList, params: { name: '', organ_id: '' } },
filters: [ filters: [
......
...@@ -12,7 +12,7 @@ const title = ref('') ...@@ -12,7 +12,7 @@ const title = ref('')
const id = ref('') const id = ref('')
const isEdit = ref('') const isEdit = ref('')
const isShowProDialog = ref(false) const isShowProDialog = ref(false)
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { httpRequest: getProList, params: { name: '' } }, remote: { httpRequest: getProList, params: { name: '' } },
filters: [{ type: 'input', prop: 'name', label: '专业名称:', placeholder: '专业名称' }], filters: [{ type: 'input', prop: 'name', label: '专业名称:', placeholder: '专业名称' }],
......
...@@ -24,7 +24,7 @@ const multiSelection = ref([]) ...@@ -24,7 +24,7 @@ const multiSelection = ref([])
let { list: selectTree }: any = useGetCategoryList() let { list: selectTree }: any = useGetCategoryList()
const defaultProps = { children: 'children', label: 'category_name', value: 'id' } const defaultProps = { children: 'children', label: 'category_name', value: 'id' }
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getRelationSemCourse, httpRequest: getRelationSemCourse,
......
...@@ -19,7 +19,7 @@ const appList = ref() ...@@ -19,7 +19,7 @@ const appList = ref()
const id: any = ref('') const id: any = ref('')
const isShowCourse = ref(false) const isShowCourse = ref(false)
const semInfo: any = ref({}) const semInfo: any = ref({})
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getSemCourse, httpRequest: getSemCourse,
......
...@@ -16,7 +16,7 @@ const id = ref('') ...@@ -16,7 +16,7 @@ const id = ref('')
const isEdit = ref('') const isEdit = ref('')
const isShowAddSemDialog = ref(false) const isShowAddSemDialog = ref(false)
const isShowSemCourseDialog = ref(false) const isShowSemCourseDialog = ref(false)
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { httpRequest: getSemList, params: { name: '', organ_id: '' } }, remote: { httpRequest: getSemList, params: { name: '', organ_id: '' } },
filters: [ filters: [
......
...@@ -20,7 +20,7 @@ const title = ref('') // 弹框标题 ...@@ -20,7 +20,7 @@ const title = ref('') // 弹框标题
const isEdit = ref('') const isEdit = ref('')
const id = ref('') const id = ref('')
const isShowStaffDialog = ref(false) const isShowStaffDialog = ref(false)
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getStaffList, httpRequest: getStaffList,
......
...@@ -10,10 +10,10 @@ const store = useMapStore() ...@@ -10,10 +10,10 @@ const store = useMapStore()
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const appList = ref() const appList = ref()
const levelList = $computed(() => { const levelList = computed(() => {
return store.getMapValuesByKey('teacher_level') return store.getMapValuesByKey('teacher_level')
}) })
const imgDefault = $ref('https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png') const imgDefault = 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png'
const courseList = ref([]) const courseList = ref([])
const id = route.query.id as string const id = route.query.id as string
const title = route.query.title as string const title = route.query.title as string
......
...@@ -5,7 +5,7 @@ import { useMapStore } from '@/stores/map' ...@@ -5,7 +5,7 @@ import { useMapStore } from '@/stores/map'
const store = useMapStore() const store = useMapStore()
const router = useRouter() const router = useRouter()
const appList = ref() const appList = ref()
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getTeacherList, httpRequest: getTeacherList,
......
...@@ -29,7 +29,7 @@ const changeCover = () => { ...@@ -29,7 +29,7 @@ const changeCover = () => {
// 封面 // 封面
const courseCover = ref('') const courseCover = ref('')
// 课程封面图轮播 // 课程封面图轮播
let swiperCovers: [{ id: string; url: string }[]] = $ref([[]]) const swiperCovers = ref<{ id: string; url: string }[][]>([[]])
// 获取swiper 自定义左右切换按钮 // 获取swiper 自定义左右切换按钮
let swiper = ref() let swiper = ref()
const swiperChange = (type?: string) => { const swiperChange = (type?: string) => {
...@@ -40,21 +40,21 @@ getCoverList({ type: '2' }).then(res => { ...@@ -40,21 +40,21 @@ getCoverList({ type: '2' }).then(res => {
const filtersData = res.data.list const filtersData = res.data.list
let index = 0 let index = 0
while (index < filtersData.length) { while (index < filtersData.length) {
swiperCovers.push(filtersData.slice(index, (index += 8))) swiperCovers.value.push(filtersData.slice(index, (index += 8)))
} }
swiperCovers.forEach((item: any, index: number) => { swiperCovers.value.forEach((item: any, index: number) => {
if (item.length === 0) { if (item.length === 0) {
swiperCovers.splice(index, 1) swiperCovers.value.splice(index, 1)
} }
}) })
}) })
let isSwiperBtn = $ref(0) const isSwiperBtn = ref(0)
const watchSwiper = (index: number) => { const watchSwiper = (index: number) => {
if (!index) { if (!index) {
isSwiperBtn = 0 isSwiperBtn.value = 0
} else { } else {
swiperCovers.length === index + 1 ? (isSwiperBtn = 1) : (isSwiperBtn = 2) swiperCovers.value.length === index + 1 ? (isSwiperBtn.value = 1) : (isSwiperBtn.value = 2)
} }
} }
......
...@@ -43,7 +43,7 @@ const handleAdd = (val: any) => { ...@@ -43,7 +43,7 @@ const handleAdd = (val: any) => {
dataList.value.push({ id: val.id, name: val.name, can_download: val.can_download, url: val.url, type: val.type }) dataList.value.push({ id: val.id, name: val.name, can_download: val.can_download, url: val.url, type: val.type })
emit('information', dataList.value) emit('information', dataList.value)
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
columns: [ columns: [
{ label: '资料名称', prop: 'name', slots: 'table-name' }, { label: '资料名称', prop: 'name', slots: 'table-name' },
......
...@@ -44,7 +44,7 @@ const handleAdd = (val: any) => { ...@@ -44,7 +44,7 @@ const handleAdd = (val: any) => {
dataList.value = [val] dataList.value = [val]
emit('information', dataList.value) emit('information', dataList.value)
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
columns: [ columns: [
{ label: '数字教材名称', prop: 'name' }, { label: '数字教材名称', prop: 'name' },
......
...@@ -5,7 +5,9 @@ import type { UploadProps, UploadUserFile } from 'element-plus' ...@@ -5,7 +5,9 @@ import type { UploadProps, UploadUserFile } from 'element-plus'
import md5 from 'blueimp-md5' import md5 from 'blueimp-md5'
import { getSignature } from '@/api/base' import { getSignature } from '@/api/base'
const props = withDefaults(defineProps<{ modelValue: string | []; prefix?: string }>(), { type UploadFileItem = { name: string; url: string }
const props = withDefaults(defineProps<{ modelValue: string | UploadFileItem[]; prefix?: string }>(), {
prefix: 'upload/admin/' prefix: 'upload/admin/'
}) })
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
......
...@@ -9,7 +9,7 @@ const appList = ref() ...@@ -9,7 +9,7 @@ const appList = ref()
// 资源出处 tab触发 // 资源出处 tab触发
const tabValue = ref('1') const tabValue = ref('1')
const path = ref('') const path = ref('')
let tableData: any = $ref({ const tableData = ref<any>({
list: [], list: [],
title: '', title: '',
total: '', total: '',
...@@ -75,7 +75,7 @@ const listOptions = computed(() => { ...@@ -75,7 +75,7 @@ const listOptions = computed(() => {
}, },
callback(data: any) { callback(data: any) {
data.list.forEach((item: any) => (item.check_status = false)) data.list.forEach((item: any) => (item.check_status = false))
tableData = data tableData.value = data
return { list: data.list, total: data.total } return { list: data.list, total: data.total }
}, },
params: { tab: tabValue, status: '1', authorized: '', name: '', course_id: props.course_id || '' }, params: { tab: tabValue, status: '1', authorized: '', name: '', course_id: props.course_id || '' },
...@@ -103,7 +103,7 @@ const listOptions = computed(() => { ...@@ -103,7 +103,7 @@ const listOptions = computed(() => {
{ label: '更新人部门', prop: 'organ_id_name', align: 'center' }, { label: '更新人部门', prop: 'organ_id_name', align: 'center' },
{ label: '更新日期', prop: 'updated_time', align: 'center' }, { label: '更新日期', prop: 'updated_time', align: 'center' },
], ],
data: tableData.list, data: tableData.value.list,
} }
}) })
// tab切换 // tab切换
...@@ -143,38 +143,38 @@ if (props.btnInfo.resource_type === '2') { ...@@ -143,38 +143,38 @@ if (props.btnInfo.resource_type === '2') {
path.value = '/resource/other/view' path.value = '/resource/other/view'
} }
let checkName = $ref('全选') const checkName = ref('全选')
// 写到这了 // 写到这了
const checkboxAll = function () { const checkboxAll = function () {
const data = tableData.list.reduce((a: any, b: any) => { const data = tableData.value.list.reduce((a: any, b: any) => {
if (b.check_status) a.push(b) if (b.check_status) a.push(b)
return a return a
}, []) }, [])
if (data.length === tableData.list.length) { if (data.length === tableData.value.list.length) {
tableData.list.map((item: any) => { tableData.value.list.map((item: any) => {
item.check_status = false item.check_status = false
return item return item
}) })
checkName = '全选' checkName.value = '全选'
} else { } else {
tableData.list.map((item: any) => { tableData.value.list.map((item: any) => {
item.check_status = true item.check_status = true
return item return item
}) })
checkName = '取消全选' checkName.value = '取消全选'
} }
} }
const checkboxSelect = function () { const checkboxSelect = function () {
const data = tableData.list.reduce((a: any, b: any) => { const data = tableData.value.list.reduce((a: any, b: any) => {
if (b.check_status) a.push(b) if (b.check_status) a.push(b)
return a return a
}, []) }, [])
data.length !== tableData.list.length ? (checkName = '全选') : (checkName = '取消全选') data.length !== tableData.value.list.length ? (checkName.value = '全选') : (checkName.value = '取消全选')
} }
const addVideo = function () { const addVideo = function () {
const data = tableData.list.filter((item: any) => item.check_status === true) const data = tableData.value.list.filter((item: any) => item.check_status === true)
data.forEach((item: any, index: number) => { data.forEach((item: any, index: number) => {
addRequest(item, index, data) addRequest(item, index, data)
}) })
...@@ -208,14 +208,14 @@ const changeCard = () => { ...@@ -208,14 +208,14 @@ const changeCard = () => {
isCard.value = !isCard.value isCard.value = !isCard.value
} }
let checkBox = $ref([]) const checkBox = ref<any[]>([])
const select = function (row: any) { const select = function (row: any) {
checkBox = row checkBox.value = row
} }
const addVideoList = function () { const addVideoList = function () {
checkBox.forEach((item: any, index: number) => { checkBox.value.forEach((item: any, index: number) => {
addRequest(item, index, checkBox) addRequest(item, index, checkBox.value)
}) })
} }
</script> </script>
......
...@@ -33,7 +33,7 @@ const majorList: any = ref([]) ...@@ -33,7 +33,7 @@ const majorList: any = ref([])
const allMajorList: any = ref([]) const allMajorList: any = ref([])
// is 编辑 新建 // is 编辑 新建
const isUpdate = $computed(() => { const isUpdate = computed(() => {
return !!route.query.id return !!route.query.id
}) })
...@@ -42,8 +42,8 @@ interface ICourseList { ...@@ -42,8 +42,8 @@ interface ICourseList {
value: string value: string
} }
const ruleFormRef = $ref<FormInstance>() const ruleFormRef = ref<FormInstance>()
const ruleFormRef2 = $ref<FormInstance>() const ruleFormRef2 = ref<FormInstance>()
// 课程类型 // 课程类型
const courseType = computed<ICourseList[]>(() => { const courseType = computed<ICourseList[]>(() => {
...@@ -118,9 +118,9 @@ const information: any = ref([]) ...@@ -118,9 +118,9 @@ const information: any = ref([])
const textbookInfo: any = ref([]) const textbookInfo: any = ref([])
// 获取详情 // 获取详情
let loading = $ref<boolean>(false) const loading = ref<boolean>(false)
function fetchDetail() { function fetchDetail() {
loading = true loading.value = true
getCourseDetails({ id }).then((res: any) => { getCourseDetails({ id }).then((res: any) => {
Object.assign(form, res.data) Object.assign(form, res.data)
examList.value = res.data.examinations examList.value = res.data.examinations
...@@ -137,11 +137,13 @@ function fetchDetail() { ...@@ -137,11 +137,13 @@ function fetchDetail() {
}) })
// res.data.books[0]?.book_id // res.data.books[0]?.book_id
} }
loading = false loading.value = false
}) })
} }
onMounted(() => { onMounted(() => {
isUpdate && fetchDetail() if (isUpdate.value) {
fetchDetail()
}
}) })
watchEffect(() => { watchEffect(() => {
...@@ -153,7 +155,7 @@ watchEffect(() => { ...@@ -153,7 +155,7 @@ watchEffect(() => {
watch( watch(
() => form.lecturer_id, () => form.lecturer_id,
() => { () => {
ruleFormRef?.validateField('lecturer_id') ruleFormRef.value?.validateField('lecturer_id')
} }
) )
...@@ -163,9 +165,9 @@ function setDefaultData(data: any[] = []) { ...@@ -163,9 +165,9 @@ function setDefaultData(data: any[] = []) {
// 提交 // 提交
function handleSubmit() { function handleSubmit() {
Promise.all([ruleFormRef.validate(), ruleFormRef2.validate()]) Promise.all([ruleFormRef.value!.validate(), ruleFormRef2.value!.validate()])
.then(() => { .then(() => {
isUpdate ? handleUpdate() : handleCreate() isUpdate.value ? handleUpdate() : handleCreate()
}) })
.catch(() => { .catch(() => {
ElMessage.error('请检查表单是否填写完整') ElMessage.error('请检查表单是否填写完整')
......
...@@ -26,7 +26,7 @@ const getResourceData = (id: string) => { ...@@ -26,7 +26,7 @@ const getResourceData = (id: string) => {
} }
// 切换视频 // 切换视频
let videoIndex = $ref(0) const videoIndex = ref(0)
const videoOptions = computed(() => { const videoOptions = computed(() => {
return { return {
...@@ -39,13 +39,15 @@ const videoOptions = computed(() => { ...@@ -39,13 +39,15 @@ const videoOptions = computed(() => {
] ]
} }
}) })
const video = $computed<{ id: string }>(() => { const video = computed<{ id: string }>(() => {
return props.data[videoIndex] return props.data[videoIndex.value]
}) })
watch( watch(
() => videoIndex, videoIndex,
() => { () => {
getResourceData(video.id) if (video.value?.id) {
getResourceData(video.value.id)
}
}, },
{ immediate: true } { immediate: true }
) )
...@@ -55,15 +57,17 @@ watch( ...@@ -55,15 +57,17 @@ watch(
() => { () => {
if (route.query.type === '2') { if (route.query.type === '2') {
const index = props.data.findIndex((item: any) => item.id === route.query.resid) const index = props.data.findIndex((item: any) => item.id === route.query.resid)
videoIndex = index !== -1 ? index : 0 videoIndex.value = index !== -1 ? index : 0
}
if (video.value?.id) {
getResourceData(video.value.id)
} }
getResourceData(video.id)
}, },
{ immediate: true } { immediate: true }
) )
const changeVideo = (index: number) => { const changeVideo = (index: number) => {
videoIndex = index videoIndex.value = index
} }
const chapterHeight: any = ref(0) const chapterHeight: any = ref(0)
const chapterWidth: any = ref(0) const chapterWidth: any = ref(0)
......
...@@ -13,7 +13,7 @@ const id = route.query.id as string ...@@ -13,7 +13,7 @@ const id = route.query.id as string
const courseDetails: any = ref({}) const courseDetails: any = ref({})
let chapters = $ref([]) const chapters = ref<any[]>([])
onMounted(() => { onMounted(() => {
// 课程详情 // 课程详情
handleGetViewCourseDetails() handleGetViewCourseDetails()
...@@ -22,7 +22,7 @@ const handleGetViewCourseDetails = () => { ...@@ -22,7 +22,7 @@ const handleGetViewCourseDetails = () => {
getViewCourseDetails({ id: id }).then((res: any) => { getViewCourseDetails({ id: id }).then((res: any) => {
courseDetails.value = res.data courseDetails.value = res.data
if (courseDetails.value.chapters[0]?.children) { if (courseDetails.value.chapters[0]?.children) {
chapters = courseDetails.value.chapters[0].children.reduce((a: any, b: any) => { chapters.value = courseDetails.value.chapters[0].children.reduce((a: any, b: any) => {
b.children.map((item: any, index: number) => { b.children.map((item: any, index: number) => {
index === 0 ? (item.show = true) : (item.show = false) index === 0 ? (item.show = true) : (item.show = false)
return item return item
......
...@@ -38,7 +38,7 @@ const tabChange = () => { ...@@ -38,7 +38,7 @@ const tabChange = () => {
appList.value.refetch() appList.value.refetch()
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
const columns = [ const columns = [
{ {
label: '课件标题', label: '课件标题',
......
...@@ -13,14 +13,25 @@ const route = useRoute() ...@@ -13,14 +13,25 @@ const route = useRoute()
const id = route.query.id as string const id = route.query.id as string
// is 编辑 新建 // is 编辑 新建
const isUpdate = $computed(() => { const isUpdate = computed(() => {
return !!route.query.id return !!route.query.id
}) })
const form: any = reactive({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 编辑数据回显 // 编辑数据回显
if (isUpdate) { if (isUpdate.value) {
getCourseDetails({ id: id }).then((res: any) => { getCourseDetails({ id: id }).then((res: any) => {
form = res.data Object.assign(form, res.data)
form.file = [ form.file = [
{ {
name: res.data.name, name: res.data.name,
...@@ -38,18 +49,6 @@ const defaultProps = { ...@@ -38,18 +49,6 @@ const defaultProps = {
value: 'id' value: 'id'
} }
// form表单
let form: any = $ref({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 监听文件上传 // 监听文件上传
watch( watch(
() => form.file, () => form.file,
...@@ -86,7 +85,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { ...@@ -86,7 +85,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
form.size = size form.size = size
const params = Object.assign({}, form) const params = Object.assign({}, form)
delete params.file delete params.file
if (isUpdate) { if (isUpdate.value) {
params.id = id params.id = id
updateResources(params) updateResources(params)
} else { } else {
......
...@@ -4,7 +4,7 @@ import Newest from '../components/Newest.vue' ...@@ -4,7 +4,7 @@ import Newest from '../components/Newest.vue'
import Hottest from '../components/Hottest.vue' import Hottest from '../components/Hottest.vue'
import RecentLearning from '../components/RecentLearning.vue' import RecentLearning from '../components/RecentLearning.vue'
import { getUtilData } from '../api' import { getUtilData } from '../api'
let flag = $ref(false) const flag = ref(false)
const data = reactive<{ statistics: object[]; latest: object[]; hot: object[]; learn: object[] }>({ const data = reactive<{ statistics: object[]; latest: object[]; hot: object[]; learn: object[] }>({
statistics: [], statistics: [],
latest: [], latest: [],
...@@ -14,7 +14,7 @@ const data = reactive<{ statistics: object[]; latest: object[]; hot: object[]; l ...@@ -14,7 +14,7 @@ const data = reactive<{ statistics: object[]; latest: object[]; hot: object[]; l
// 所有数据 // 所有数据
getUtilData().then(res => { getUtilData().then(res => {
flag = true flag.value = true
let { latest = [], hot = [], learn = [] }: { latest: object[]; hot: object[]; learn: object[] } = res.data let { latest = [], hot = [], learn = [] }: { latest: object[]; hot: object[]; learn: object[] } = res.data
if (learn === null) learn = [] if (learn === null) learn = []
// 统计资源数据整合 // 统计资源数据整合
......
...@@ -38,7 +38,7 @@ const tabChange = () => { ...@@ -38,7 +38,7 @@ const tabChange = () => {
appList.value.refetch() appList.value.refetch()
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
const columns = [ const columns = [
{ {
label: '教案标题', label: '教案标题',
......
...@@ -13,14 +13,25 @@ const route = useRoute() ...@@ -13,14 +13,25 @@ const route = useRoute()
const id = route.query.id as string const id = route.query.id as string
// is 编辑 新建 // is 编辑 新建
const isUpdate = $computed(() => { const isUpdate = computed(() => {
return !!route.query.id return !!route.query.id
}) })
const form: any = reactive({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 编辑数据回显 // 编辑数据回显
if (isUpdate) { if (isUpdate.value) {
getLessonDetails({ id: id }).then((res: any) => { getLessonDetails({ id: id }).then((res: any) => {
form = res.data Object.assign(form, res.data)
form.file = [ form.file = [
{ {
name: res.data.name, name: res.data.name,
...@@ -38,18 +49,6 @@ const defaultProps = { ...@@ -38,18 +49,6 @@ const defaultProps = {
value: 'id' value: 'id'
} }
// form表单
let form: any = $ref({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 监听文件上传 // 监听文件上传
watch( watch(
() => form.file, () => form.file,
...@@ -87,7 +86,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { ...@@ -87,7 +86,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
form.size = size form.size = size
const params = Object.assign({}, form) const params = Object.assign({}, form)
delete params.file delete params.file
if (isUpdate) { if (isUpdate.value) {
params.id = id params.id = id
updateResources(params) updateResources(params)
} else { } else {
......
...@@ -39,7 +39,7 @@ const defaultProps = { ...@@ -39,7 +39,7 @@ const defaultProps = {
value: 'id', value: 'id',
} }
const listOptions = $computed(() => { const listOptions = computed(() => {
const columns = [ const columns = [
{ {
label: '其他标题', label: '其他标题',
......
...@@ -13,14 +13,25 @@ const route = useRoute() ...@@ -13,14 +13,25 @@ const route = useRoute()
const id = route.query.id as string const id = route.query.id as string
// is 编辑 新建 // is 编辑 新建
const isUpdate = $computed(() => { const isUpdate = computed(() => {
return !!route.query.id return !!route.query.id
}) })
const form: any = reactive({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 编辑数据回显 // 编辑数据回显
if (isUpdate) { if (isUpdate.value) {
getOtherDetails({ id: id }).then((res: any) => { getOtherDetails({ id: id }).then((res: any) => {
form = res.data Object.assign(form, res.data)
form.file = [ form.file = [
{ {
name: res.data.name, name: res.data.name,
...@@ -38,18 +49,6 @@ const defaultProps = { ...@@ -38,18 +49,6 @@ const defaultProps = {
value: 'id' value: 'id'
} }
// form表单
let form: any = $ref({
file: [],
name: '',
source: '2',
classification: '',
knowledge_points: '',
url: '',
type: '',
size: ''
})
// 监听文件上传 // 监听文件上传
watch( watch(
() => form.file, () => form.file,
...@@ -89,7 +88,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { ...@@ -89,7 +88,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
form.size = size form.size = size
const params = Object.assign({}, form) const params = Object.assign({}, form)
delete params.file delete params.file
if (isUpdate) { if (isUpdate.value) {
params.id = id params.id = id
updateResources(params) updateResources(params)
} else { } else {
......
...@@ -17,13 +17,13 @@ interface Emits { ...@@ -17,13 +17,13 @@ interface Emits {
(e: 'update:modelValue', modelValue: boolean): void (e: 'update:modelValue', modelValue: boolean): void
(e: 'update'): void (e: 'update'): void
} }
const uploadMultipleVideoRef = $ref<InstanceType<typeof UploadMultipleVideo> | null>(null) const uploadMultipleVideoRef = ref<InstanceType<typeof UploadMultipleVideo> | null>(null)
const handleConfirm = () => { const handleConfirm = () => {
emit('update:modelValue', false) emit('update:modelValue', false)
emit('update') emit('update')
} }
const handleCancel = () => { const handleCancel = () => {
const fileList = uploadMultipleVideoRef?.uploader?._uploadList || [] const fileList = uploadMultipleVideoRef.value?.uploader?._uploadList || []
if (fileList.length) { if (fileList.length) {
for (const item of fileList) { for (const item of fileList) {
if (item.state === 'Uploading') { if (item.state === 'Uploading') {
......
...@@ -5,7 +5,9 @@ import type { UploadProps, UploadUserFile } from 'element-plus' ...@@ -5,7 +5,9 @@ import type { UploadProps, UploadUserFile } from 'element-plus'
import md5 from 'blueimp-md5' import md5 from 'blueimp-md5'
import { getSignature } from '@/api/base' import { getSignature } from '@/api/base'
const props = withDefaults(defineProps<{ modelValue: string | []; prefix?: string }>(), { type UploadFileItem = { name: string; url: string }
const props = withDefaults(defineProps<{ modelValue: string | UploadFileItem[]; prefix?: string }>(), {
prefix: 'upload/admin/' prefix: 'upload/admin/'
}) })
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
......
...@@ -27,7 +27,7 @@ interface UploadInfo { ...@@ -27,7 +27,7 @@ interface UploadInfo {
const emit = defineEmits(['upload', 'canClose']) const emit = defineEmits(['upload', 'canClose'])
let uploader = createUploader() let uploader = createUploader()
let fileList = $ref<UploadInfo[]>([]) const fileList = ref<UploadInfo[]>([])
const fileChange = (event: Event) => { const fileChange = (event: Event) => {
const element = event.currentTarget as HTMLInputElement const element = event.currentTarget as HTMLInputElement
...@@ -35,18 +35,18 @@ const fileChange = (event: Event) => { ...@@ -35,18 +35,18 @@ const fileChange = (event: Event) => {
if (!files) return if (!files) return
for (const file of files) { for (const file of files) {
// 是否重复上传 // 是否重复上传
const hasRepeat = !!fileList.find( const hasRepeat = !!fileList.value.find(
item => item =>
item.file.name === file.name && item.file.size === file.size && item.file.lastModified === file.lastModified item.file.name === file.name && item.file.size === file.size && item.file.lastModified === file.lastModified
) )
!hasRepeat && uploader.addFile(file, null, null, null, '{"Vod":{}}') !hasRepeat && uploader.addFile(file, null, null, null, '{"Vod":{}}')
} }
uploader.startUpload() uploader.startUpload()
fileList = uploader._uploadList fileList.value = uploader._uploadList
} }
function updateFileList(uploadInfo: UploadInfo) { function updateFileList(uploadInfo: UploadInfo) {
if (!uploadInfo) return if (!uploadInfo) return
fileList = fileList.map(item => { fileList.value = fileList.value.map(item => {
if (item.ri === uploadInfo.ri) { if (item.ri === uploadInfo.ri) {
return { ...item, ...uploadInfo } return { ...item, ...uploadInfo }
} }
...@@ -134,10 +134,10 @@ function percentage(value: number) { ...@@ -134,10 +134,10 @@ function percentage(value: number) {
// 删除上传文件 // 删除上传文件
const deleteFile = function (index: number) { const deleteFile = function (index: number) {
console.log(index, 'deleteFile', fileList) console.log(index, 'deleteFile', fileList)
fileList.splice(index, 1) fileList.value.splice(index, 1)
uploader.deleteFile(index) uploader.deleteFile(index)
} }
defineExpose({ uploader, fileList: $$(fileList) }) defineExpose({ uploader, fileList })
</script> </script>
<template> <template>
<div class="upload-video" style="display: flex; flex-direction: column; align-items: flex-start"> <div class="upload-video" style="display: flex; flex-direction: column; align-items: flex-start">
......
...@@ -12,7 +12,7 @@ interface IUpload { ...@@ -12,7 +12,7 @@ interface IUpload {
progress?: number progress?: number
videoId?: string videoId?: string
} }
let uploadData = $ref<IUpload>({ code: -1 }) const uploadData = ref<IUpload>({ code: -1 })
const emit = defineEmits(['upload']) const emit = defineEmits(['upload'])
const form: any = reactive({ const form: any = reactive({
...@@ -92,7 +92,7 @@ const createUploader: any = () => { ...@@ -92,7 +92,7 @@ const createUploader: any = () => {
}) })
} }
} }
uploadData = { uploadData.value = {
code: 1, code: 1,
name: uploadInfo.file.name, name: uploadInfo.file.name,
msg: '开始上传' msg: '开始上传'
...@@ -101,7 +101,7 @@ const createUploader: any = () => { ...@@ -101,7 +101,7 @@ const createUploader: any = () => {
// 文件上传成功 // 文件上传成功
onUploadSucceed: function (uploadInfo: any) { onUploadSucceed: function (uploadInfo: any) {
const fileData = window.localStorage.fileData ? JSON.parse(window.localStorage.fileData) : {} const fileData = window.localStorage.fileData ? JSON.parse(window.localStorage.fileData) : {}
uploadData = { uploadData.value = {
code: 0, code: 0,
name: uploadInfo.file.name, name: uploadInfo.file.name,
videoId: fileData.videoId, videoId: fileData.videoId,
...@@ -112,7 +112,7 @@ const createUploader: any = () => { ...@@ -112,7 +112,7 @@ const createUploader: any = () => {
// 文件上传失败 // 文件上传失败
// code:any, message:any // code:any, message:any
onUploadFailed: function (uploadInfo: any) { onUploadFailed: function (uploadInfo: any) {
uploadData = { uploadData.value = {
code: 2, code: 2,
name: uploadInfo.file.name, name: uploadInfo.file.name,
msg: '文件上传失败' msg: '文件上传失败'
...@@ -122,7 +122,7 @@ const createUploader: any = () => { ...@@ -122,7 +122,7 @@ const createUploader: any = () => {
onUploadProgress: function (uploadInfo: any, totalSize: any, progress: any) { onUploadProgress: function (uploadInfo: any, totalSize: any, progress: any) {
let progressPercent = Math.ceil(progress * 100) let progressPercent = Math.ceil(progress * 100)
form.authProgress = progressPercent form.authProgress = progressPercent
uploadData.progress = progressPercent uploadData.value.progress = progressPercent
}, },
// 上传凭证超时 // 上传凭证超时
onUploadTokenExpired: function (uploadInfo: any) { onUploadTokenExpired: function (uploadInfo: any) {
......
<script setup lang="ts"> <script setup lang="ts">
import AppVideoPlayer from '@/components/base/AppVideoPlayer.vue' import AppVideoPlayer from '@/components/base/AppVideoPlayer.vue'
const props = defineProps(['data']) const props = defineProps(['data'])
const videoOptions = $computed(() => { const videoOptions = computed(() => {
return { return {
sources: [ sources: [
{ {
......
...@@ -21,7 +21,7 @@ const form = reactive({ ...@@ -21,7 +21,7 @@ const form = reactive({
// (e: 'update:modelValue', modelValue: boolean): void // (e: 'update:modelValue', modelValue: boolean): void
// (e: 'update'): void // (e: 'update'): void
// } // }
const uploadMultipleVideoRef = $ref<InstanceType<typeof UploadMultipleVideo> | null>(null) const uploadMultipleVideoRef = ref<InstanceType<typeof UploadMultipleVideo> | null>(null)
// const handleConfirm = () => { // const handleConfirm = () => {
// emit('update:modelValue', false) // emit('update:modelValue', false)
// emit('update') // emit('update')
......
...@@ -11,19 +11,19 @@ const appList = ref() ...@@ -11,19 +11,19 @@ const appList = ref()
const id = router.currentRoute.value.query.id as string const id = router.currentRoute.value.query.id as string
// 获取视频详情、课件列表 // 获取视频详情、课件列表
let videoDetails:any = $ref({}) const videoDetails = ref<any>({})
let videoPpt:any = $ref([]) const videoPpt = ref<any[]>([])
const listDetail = () => { const listDetail = () => {
getVideoPpt({ id: id }).then(res => { getVideoPpt({ id: id }).then(res => {
videoDetails = res.data.video videoDetails.value = res.data.video
videoPpt = res.data.ppts videoPpt.value = res.data.ppts
}) })
} }
listDetail() listDetail()
// 视频课件列表 // 视频课件列表
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
columns: [ columns: [
{ label: '课程图片', slots: 'table-cover', align: 'center' }, { label: '课程图片', slots: 'table-cover', align: 'center' },
...@@ -31,18 +31,18 @@ const listOptions = $computed(() => { ...@@ -31,18 +31,18 @@ const listOptions = $computed(() => {
{ label: '时码', prop: 'point', align: 'center' }, { label: '时码', prop: 'point', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center', fixed: 'right' } { label: '操作', slots: 'table-operate', align: 'center', fixed: 'right' }
], ],
data: videoPpt data: videoPpt.value
} }
}) })
// 新增弹窗 // 新增弹窗
const dialogFormVisible = ref(false) const dialogFormVisible = ref(false)
const covers:any = $ref([]) const covers = ref<any[]>([])
const coverList: any = $ref([]) const coverList = ref<any[]>([])
const coverRemove: any = [] const coverRemove: any = []
// 监听图片上传后 组合成table所用的数据 // 监听图片上传后 组合成table所用的数据
watch( watch(
() => covers, covers,
value => { value => {
coverRemove.map((item: any) => { coverRemove.map((item: any) => {
const index = value.findIndex((i:any) => i.url === item ) const index = value.findIndex((i:any) => i.url === item )
...@@ -51,9 +51,9 @@ watch( ...@@ -51,9 +51,9 @@ watch(
} }
}) })
value.forEach((item: any, index: number) => { value.forEach((item: any, index: number) => {
const findItem = coverList.find((i:any) => i.url === item.url) const findItem = coverList.value.find((i:any) => i.url === item.url)
if (!findItem) { if (!findItem) {
coverList.push({ coverList.value.push({
name: item.name, name: item.name,
url: item.url, url: item.url,
point: '', point: '',
...@@ -64,7 +64,7 @@ watch( ...@@ -64,7 +64,7 @@ watch(
} }
) )
// 添加课程的列表 // 添加课程的列表
const uploadList = $computed(() => { const uploadList = computed(() => {
return { return {
columns: [ columns: [
{ label: '课程图片', slots: 'table-cover', align: 'center' }, { label: '课程图片', slots: 'table-cover', align: 'center' },
...@@ -72,13 +72,13 @@ const uploadList = $computed(() => { ...@@ -72,13 +72,13 @@ const uploadList = $computed(() => {
{ label: '时码', slots: 'table-input', align: 'center' }, { label: '时码', slots: 'table-input', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center', fixed: 'right' } { label: '操作', slots: 'table-operate', align: 'center', fixed: 'right' }
], ],
data: coverList data: coverList.value
} }
}) })
// 提交课程列表 // 提交课程列表
const submitCourseList = () => { const submitCourseList = () => {
let flag = false let flag = false
coverList.forEach((item: any) => { coverList.value.forEach((item: any) => {
if (item.point === '') { if (item.point === '') {
ElMessage('时间码不能为空') ElMessage('时间码不能为空')
flag = true flag = true
...@@ -86,7 +86,7 @@ const submitCourseList = () => { ...@@ -86,7 +86,7 @@ const submitCourseList = () => {
} }
}) })
if (!flag) { if (!flag) {
createPpt({ id: id, ppts: JSON.stringify(coverList) }).then((res:any) => { createPpt({ id: id, ppts: JSON.stringify(coverList.value) }).then((res:any) => {
if (res.code === 0) { if (res.code === 0) {
listDetail() listDetail()
ElMessage({ ElMessage({
...@@ -101,7 +101,7 @@ const submitCourseList = () => { ...@@ -101,7 +101,7 @@ const submitCourseList = () => {
// 删除上传的列表 // 删除上传的列表
const deleteUploadList = (index: number, url: string) => { const deleteUploadList = (index: number, url: string) => {
coverRemove.push(url) coverRemove.push(url)
coverList.splice(index, 1) coverList.value.splice(index, 1)
} }
// 修改时间码 // 修改时间码
......
...@@ -37,7 +37,7 @@ const tabChange = () => { ...@@ -37,7 +37,7 @@ const tabChange = () => {
// 列表切换 // 列表切换
const isCard = useStorage('isCard', true) const isCard = useStorage('isCard', true)
// table 数据 // table 数据
const listOptions = $computed(() => { const listOptions = computed(() => {
const columns = [ const columns = [
{ {
label: '视频标题', label: '视频标题',
......
...@@ -15,12 +15,12 @@ const route = useRoute() ...@@ -15,12 +15,12 @@ const route = useRoute()
const id = route.query.id as string const id = route.query.id as string
// is 编辑 新建 // is 编辑 新建
const isUpdate = $computed(() => { const isUpdate = computed(() => {
return !!route.query.id return !!route.query.id
}) })
// 编辑数据回显 // 编辑数据回显
if (isUpdate) { if (isUpdate.value) {
getVideoDetails({ id: id }).then((res: any) => { getVideoDetails({ id: id }).then((res: any) => {
form.data = res.data form.data = res.data
}) })
...@@ -35,17 +35,17 @@ const defaultProps = { ...@@ -35,17 +35,17 @@ const defaultProps = {
} }
// 视频封面图轮播 // 视频封面图轮播
let swiperCovers: [{ id: string; url: string }[]] = $ref([[]]) const swiperCovers = ref<{ id: string; url: string }[][]>([[]])
// 获取封面 // 获取封面
getCoverList().then(res => { getCoverList().then(res => {
const filtersData = res.data.list.filter((i: any) => i.type === '1') const filtersData = res.data.list.filter((i: any) => i.type === '1')
let index = 0 let index = 0
while (index < filtersData.length) { while (index < filtersData.length) {
swiperCovers.push(filtersData.slice(index, (index += 8))) swiperCovers.value.push(filtersData.slice(index, (index += 8)))
} }
swiperCovers.forEach((item: any, index: number) => { swiperCovers.value.forEach((item: any, index: number) => {
if (item.length === 0) { if (item.length === 0) {
swiperCovers.splice(index, 1) swiperCovers.value.splice(index, 1)
} }
}) })
}) })
...@@ -81,7 +81,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { ...@@ -81,7 +81,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
ElMessage('请勾选用户协议') ElMessage('请勾选用户协议')
return return
} }
if (isUpdate) { if (isUpdate.value) {
updateResources() updateResources()
} else { } else {
createResources() createResources()
...@@ -144,12 +144,12 @@ const uploadVideo = (data: any) => { ...@@ -144,12 +144,12 @@ const uploadVideo = (data: any) => {
form.data.name = name.slice(0, name.lastIndexOf('.')) form.data.name = name.slice(0, name.lastIndexOf('.'))
} }
let isSwiperBtn = $ref(0) const isSwiperBtn = ref(0)
const watchSwiper = (index: number) => { const watchSwiper = (index: number) => {
if (!index) { if (!index) {
isSwiperBtn = 0 isSwiperBtn.value = 0
} else { } else {
swiperCovers.length === index + 1 ? (isSwiperBtn = 1) : (isSwiperBtn = 2) swiperCovers.value.length === index + 1 ? (isSwiperBtn.value = 1) : (isSwiperBtn.value = 2)
} }
} }
......
...@@ -8,7 +8,7 @@ const appList = ref() ...@@ -8,7 +8,7 @@ const appList = ref()
const isShowDialog = ref(false) const isShowDialog = ref(false)
const isEdit = ref(false) const isEdit = ref(false)
const editData = ref({}) const editData = ref({})
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getCoverList, httpRequest: getCoverList,
......
...@@ -13,7 +13,7 @@ const store = useMapStore() ...@@ -13,7 +13,7 @@ const store = useMapStore()
// 状态 // 状态
//表单每行数据 //表单每行数据
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getDictionaryList, httpRequest: getDictionaryList,
......
...@@ -8,7 +8,7 @@ const status = ref('') ...@@ -8,7 +8,7 @@ const status = ref('')
// const userList: any = ref([]) // const userList: any = ref([])
// 状态 // 状态
//表单每行数据 //表单每行数据
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getSuggestionList, httpRequest: getSuggestionList,
......
...@@ -24,8 +24,7 @@ const props = defineProps({ ...@@ -24,8 +24,7 @@ const props = defineProps({
}) })
const showComment = ref(false) // 评论框显示状态 const showComment = ref(false) // 评论框显示状态
const reviews = ref('') // 评语 const reviews = ref('') // 评语
let questionData: any = $ref({}) // 题目数据 const questionData: any = reactive(Object.assign({}, props.question)) // 题目数据
questionData = Object.assign({}, props.question)
// 题目类型 // 题目类型
const questionType = computed(() => { const questionType = computed(() => {
// 1单选,2多选,3简答,5案例题, 6判断, 7实操,8情景 // 1单选,2多选,3简答,5案例题, 6判断, 7实操,8情景
......
...@@ -4,7 +4,7 @@ import { getPaperList, getSearchList } from '../api' ...@@ -4,7 +4,7 @@ import { getPaperList, getSearchList } from '../api'
const router = useRouter() const router = useRouter()
const appList = ref() const appList = ref()
const courseListCategory: any = ref([]) const courseListCategory: any = ref([])
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { httpRequest: getPaperList, params: { course_id: '', paper_name: '' } }, remote: { httpRequest: getPaperList, params: { course_id: '', paper_name: '' } },
filters: [ filters: [
......
...@@ -8,7 +8,7 @@ const appList = ref() ...@@ -8,7 +8,7 @@ const appList = ref()
const classId = ref('') const classId = ref('')
const classList: any = ref([]) const classList: any = ref([])
const stuList: any = ref([]) const stuList: any = ref([])
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getPaperStuList, httpRequest: getPaperStuList,
......
...@@ -169,10 +169,10 @@ const handleChangeCourse = () => { ...@@ -169,10 +169,10 @@ const handleChangeCourse = () => {
form.chapter_id = '' form.chapter_id = ''
chapterList.value = [] chapterList.value = []
} }
const videoLimit = $computed(() => { const videoLimit = computed(() => {
return form.files.filter((item: any) => item.url.includes('.mp4')) return form.files.filter((item: any) => item.url.includes('.mp4'))
}) })
const imgLimit = $computed(() => { const imgLimit = computed(() => {
return form.files.filter( return form.files.filter(
(item: any) => item.url.includes('.png') || item.url.includes('.jpg') || item.url.includes('.jpeg') (item: any) => item.url.includes('.png') || item.url.includes('.jpg') || item.url.includes('.jpeg')
) )
...@@ -187,11 +187,11 @@ const beforeUploadFiles = (file: any) => { ...@@ -187,11 +187,11 @@ const beforeUploadFiles = (file: any) => {
ElMessage.warning('图片大小不能超过2MB') ElMessage.warning('图片大小不能超过2MB')
return false return false
} }
if (imgLimit.length >= 10 && (file.url.includes('.png') || file.url.includes('.jpg') || file.url.includes('.jpeg'))) { if (imgLimit.value.length >= 10 && (file.url.includes('.png') || file.url.includes('.jpg') || file.url.includes('.jpeg'))) {
ElMessage.warning('最多只能上传10张图片') ElMessage.warning('最多只能上传10张图片')
return false return false
} }
if (videoLimit.length >= 1 && file.url.includes('.mp4')) { if (videoLimit.value.length >= 1 && file.url.includes('.mp4')) {
ElMessage.warning('最多只能上传1个视频') ElMessage.warning('最多只能上传1个视频')
return false return false
} }
......
...@@ -28,10 +28,10 @@ const rules = reactive<FormRules>({ ...@@ -28,10 +28,10 @@ const rules = reactive<FormRules>({
content: [{ required: true, message: '请填写正文内容', trigger: 'blur' }] content: [{ required: true, message: '请填写正文内容', trigger: 'blur' }]
}) })
const videoLimit = $computed(() => { const videoLimit = computed(() => {
return form.files.filter((item: any) => item.url.includes('.mp4')) return form.files.filter((item: any) => item.url.includes('.mp4'))
}) })
const imgLimit = $computed(() => { const imgLimit = computed(() => {
return form.files.filter( return form.files.filter(
(item: any) => item.url.includes('.png') || item.url.includes('.jpg') || item.url.includes('.jpeg') (item: any) => item.url.includes('.png') || item.url.includes('.jpg') || item.url.includes('.jpeg')
) )
...@@ -47,11 +47,11 @@ const beforeUploadFiles = (file: any) => { ...@@ -47,11 +47,11 @@ const beforeUploadFiles = (file: any) => {
ElMessage.warning('图片大小不能超过2MB') ElMessage.warning('图片大小不能超过2MB')
return false return false
} }
if (imgLimit.length >= 10 && (file.url.includes('.png') || file.url.includes('.jpg') || file.url.includes('.jpeg'))) { if (imgLimit.value.length >= 10 && (file.url.includes('.png') || file.url.includes('.jpg') || file.url.includes('.jpeg'))) {
ElMessage.warning('最多只能上传10张图片') ElMessage.warning('最多只能上传10张图片')
return false return false
} }
if (videoLimit.length >= 1 && file.url.includes('.mp4')) { if (videoLimit.value.length >= 1 && file.url.includes('.mp4')) {
ElMessage.warning('最多只能上传1个视频') ElMessage.warning('最多只能上传1个视频')
return false return false
} }
......
...@@ -20,7 +20,7 @@ const semesterList: any = ref([]) ...@@ -20,7 +20,7 @@ const semesterList: any = ref([])
const classList: any = ref([]) const classList: any = ref([])
const courseList: any = ref([]) const courseList: any = ref([])
const chapterList: any = ref([]) const chapterList: any = ref([])
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
params: { params: {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import ReplyDialog from '../components/ReplyDialog.vue' import ReplyDialog from '../components/ReplyDialog.vue'
const appList = ref() const appList = ref()
const isShowReplyDialog = ref(false) const isShowReplyDialog = ref(false)
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
// remote: { httpRequest: getProList, params: { name: '' } }, // remote: { httpRequest: getProList, params: { name: '' } },
filters: [ filters: [
......
...@@ -9,7 +9,7 @@ const course_id = ref('') ...@@ -9,7 +9,7 @@ const course_id = ref('')
const searchCourseList: any = ref([]) const searchCourseList: any = ref([])
const searchClassList: any = ref([]) const searchClassList: any = ref([])
const listOptions = $computed(() => { const listOptions = computed(() => {
return { return {
remote: { remote: {
httpRequest: getWorkList, httpRequest: getWorkList,
......
...@@ -11,9 +11,9 @@ import mkcert from 'vite-plugin-mkcert' ...@@ -11,9 +11,9 @@ import mkcert from 'vite-plugin-mkcert'
export default defineConfig(({ mode }) => ({ export default defineConfig(({ mode }) => ({
base: mode === 'prod' ? 'https://webapp-pub.ezijing.com/website/prod/center-resource/' : '/', base: mode === 'prod' ? 'https://webapp-pub.ezijing.com/website/prod/center-resource/' : '/',
plugins: [ plugins: [
vue({ reactivityTransform: true }), vue(),
AutoImport({ AutoImport({
imports: ['vue', 'vue/macros', 'vue-router', '@vueuse/core'], imports: ['vue', 'vue-router', '@vueuse/core'],
dts: true, dts: true,
eslintrc: { enabled: true } eslintrc: { enabled: true }
}), }),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论