import SaveForm from '@/components/save-form' import Pagination from '@/components/pagination' import { DataTableRowKey, NButton, NCascader, NDataTable, NDescriptions, NDescriptionsItem, NFormItem, NIcon, NImage, NInput, NModal, NSelect, NSpace, NTag, NTooltip, useDialog, useMessage } from 'naive-ui' import {defineComponent, onMounted, onUnmounted, reactive, ref, watch} from 'vue' import { musicSheetApplicationOwnerList, musicSheetPage, musicSheetRemove, musicSheetImg, musicSheetStatusList, musicTagPage, musicSheetCategoriesQueryTree } from '../../api' import MusicOperation from '../modal/music-operation' import {subjectPage} from '@/views/system-manage/api' import MusicPreView from '../modal/musicPreView' import UseProject from '@views/music-library/music-sheet/modal/use-project' import {getMapValueByKey} from '@/utils/filters' import {appKey, musicSheetSourceType, musicSheetType} from '@/utils/constant' import {getSelectDataFromObj} from '@/utils/objectUtil' import {sysApplicationPage} from '@views/menu-manage/api' import {getOwnerName} from '@views/music-library/musicUtil' import styles from './music-list.module.less' import MusicCreateImg from '../modal/music-create-img' import TheTooltip from "@components/TheTooltip"; import { HelpCircleOutline } from '@vicons/ionicons5' export default defineComponent({ name: 'music-list', props: ['searchId', 'musicCategoryId'], setup(props, {emit}) { const dialog = useDialog() const message = useMessage() const state = reactive({ loading: false, pagination: { page: 1, rows: 10, pageTotal: 0 }, searchForm: { keyword: null, musicSheetType: null, subjectId: null, //声部ID sourceType: null, //来源类型/作者属性(PLATFORM: 平台; ORG: 机构; PERSON: 个人 composer: null, //作曲人/音乐人 userId: null, //所属人 applicationId: null, //所属人项目ID useAppId: [] as any, //适用项目ID status: null, //曲目状态(0:停用,1:启用) appAuditFlag: null, //是否审核版本 categoriesId: null, //是否审核版本 musicCategoryId: null, //曲目分类 dataCorrect: null // 数据修复 }, dataList: [] as any, subjectList: [] as any, tagList: [] as any, visiableMusic: false, musicOperation: 'add', musicData: {} as any, musicSheetCategories: [] as any, musicPreview: false, musicScore: null as any, showUseProject: false, // 适用项目 useProjectData: [] as any, // 适用项目行数据 showUseProjectId: null as any, // 适用项目行数据 detailReadonly: false, // 新增、修改、详情是否可编辑 userIdDisable: true, // 所属人 userIdData: [] as any, // 所属人数据列表 productOpen: false, productItem: {} as any }) const columns = (): any => { return [ { type: 'selection' }, { title: '曲目名称', minWidth: '200px', key: 'id', render(row: any) { return ( ) } }, { title: '封面图', key: 'titleImg', render(row: any): JSX.Element { return } }, { title: '曲目信息', minWidth: '200px', key: 'composer', render(row: any) { return ( {row.composer} {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))} ) } }, { title: '作者属性', minWidth: '250px', key: 'sourceType', render(row: any) { return ( {getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))} {getOwnerName(row.musicSheetExtend, row.sourceType)} ) } }, { title: '适用项目', key: 'projectName', render(row: any) { return ( { state.showUseProject = true state.showUseProjectId = row.id }} > ) } }, { title: '更新信息', minWidth: '250px', key: 'updateBy', render(row: any) { return ( {row.updateByName} {row.updateTime} ) } }, { title: '审核版本', minWidth: '100px', key: 'appAuditFlag', render(row: any) { return
{row.appAuditFlag ? '是' : '否'}
} }, { title: '状态', minWidth: '50px', key: 'status', render(row: any) { return ( {row.status ? '启用' : '停用'} ) } }, { title: '操作', key: 'operation', fixed: 'right', width: '300px', render(row: any) { return ( { state.musicPreview = true state.musicScore = row }} > 预览 { state.visiableMusic = true state.musicOperation = 'preview' state.musicData = row state.detailReadonly = true }} > 查看 { state.visiableMusic = true state.musicOperation = 'edit' state.musicData = row state.detailReadonly = true }} > 修改 onChangeStatus(row)} > {row.status ? '停用' : '启用'} { state.productOpen = true state.productItem = row // handleAutoProduct(row) }} > 生成图片 onRmove(row)} v-auth="musicSheet/save1751241178962984962" > 删除 ) } } ] } const checkedRowKeysRef = ref([]) const handleCheck = (rowKeys: DataTableRowKey[]) => { checkedRowKeysRef.value = rowKeys } const onChangeStatus = (row: any) => { const statusStr = row.status ? '停用' : '启用' dialog.warning({ title: '提示', content: `是否${statusStr}?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicSheetStatusList({ ids: new Array(row.id), status: !row.status }) getList() message.success(`${statusStr}成功`) } catch {} } }) } const onBatchChangeStatus = (status: boolean) => { const length = checkedRowKeysRef.value.length if (length == 0) { message.warning('未选择数据') } const statusStr = !status ? '停用' : '启用' dialog.warning({ title: '提示', content: `是否${statusStr}` + length + `条数据?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicSheetStatusList({ ids: checkedRowKeysRef.value, status: status }) getList() message.success(`${statusStr}成功`) } catch {} } }) } const updateUserIdData = async (sourceType: any) => { if (!state.searchForm.applicationId) { return } state.userIdData = [] state.searchForm.userId = null if (sourceType && sourceType !== 'PLATFORM') { const { data } = await musicSheetApplicationOwnerList({ page: 1, rows: 9999, sourceType: sourceType, applicationId: state.searchForm.applicationId }) const temp = data.rows || [] temp.forEach((next: any) => { state.userIdData.push({ ...next, label: sourceType === 'PERSON' ? next.userName : next.organizationRole, value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId }) }) } } const onRmove = (row: any): void => { dialog.warning({ title: '提示', content: `删除"${row.name}",是否继续?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicSheetRemove({ id: row.id }) getList() message.success('删除成功') } catch {} } }) } const getList = async () => { try { state.loading = true const sourceType = state.searchForm.sourceType; const userId = state.searchForm.userId let search = { ...state.searchForm, useAppId: state.searchForm.useAppId ? state.searchForm.useAppId.join(',') : state.searchForm.useAppId } as any if (sourceType) { if (sourceType == 'ORG') { search.organizationRoleId = userId search.userId = null } } const { data } = await musicSheetPage({ ...state.pagination, ...search}) state.pagination.pageTotal = Number(data.total) state.dataList = data.rows || [] } catch {} state.loading = false } // 获取标签 const getTagList = async () => { try { const { data } = await musicTagPage({ page: 1, rows: 999 }) const tempList = data.rows || [] tempList.forEach((item: any) => { item.label = item.name item.value = item.id }) state.tagList = tempList } catch {} } // 获取分类 const getMusicSheetCategorieList = async () => { try { const { data } = await musicSheetCategoriesQueryTree({}) // state.musicSheetCategories = filterPointCategory(data, 'musicSheetCategoriesList') state.musicSheetCategories = data || [] } catch (e) {} } // 获取声部 const initSubjectList = async () => { try { const { data } = await subjectPage({ page: 1, rows: 999 }) const tempList = data.rows || [] tempList.forEach((item: any) => { item.label = item.name item.value = item.id + '' }) state.subjectList = tempList } catch {} } // app列表 const initUseAppList = async () => { try { const appKeys = Object.keys(appKey) const { data } = await sysApplicationPage({ page: 1, rows: 999 }) const tempList = data.rows || [] state.useProjectData = [] const filter = tempList.filter((next: any) => { return appKeys.includes(next.appKey) }) filter.forEach((item: any) => { state.useProjectData.push({ ...item, label: item.appName, value: item.id }) }) } catch {} } const saveForm = ref() const onSubmit = () => { state.pagination.page = 1 getList() } watch( () => props.searchId, (val) => { console.log(val, 'searchId') } ) const onSearch = () => { saveForm.value?.submit() } const onBtnReset = () => { saveForm.value?.reset() } onMounted(async () => { state.loading = true // getTagList() if (props.searchId) { state.searchForm.categoriesId = props.searchId || null } if (props.musicCategoryId) { state.searchForm.musicCategoryId = props.musicCategoryId || null } initSubjectList() initUseAppList() getMusicSheetCategorieList() getList() }) return () => (
(state.searchForm = val)} > { state.userIdData = [] state.searchForm.userId = null if (value && value !== 'PLATFORM') { await updateUserIdData(value) state.userIdDisable = !state.searchForm.applicationId } else { state.userIdDisable = true } }} clearable /> { state.searchForm.applicationId = value if (value) { await updateUserIdData(state.searchForm.sourceType) state.userIdDisable = !( state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM' ) } else { state.searchForm.userId = null state.userIdDisable = true state.userIdData = [] } }} /> {{ label: () =>
所属人 {/**/} {/* {{*/} {/* default: () => '请选择作者属性和项目再选择所属人',*/} {/* trigger: () => (*/} {/* */} {/* */} {/* */} {/* */} {/* */} {/* )*/} {/* }}*/} {/**/}
, default: () => ( ) }}
搜索 重置
{ state.visiableMusic = true state.musicOperation = 'add' state.musicData = {} state.detailReadonly = true }} > 新增曲目 { onBatchChangeStatus(false) }} > 批量停用 { onBatchChangeStatus(true) }} > 批量启用 row.id} onUpdateCheckedRowKeys={handleCheck} scrollX={'1200'} >
{ if (state.musicOperation === 'add') { return '添加曲目' } else if (state.musicOperation === 'preview') { return '曲目详情' } return '修改曲目' }} style={{ width: '980px' }} > (state.visiableMusic = false)} onGetList={getList} /> (state.showUseProject = false)} onGetList={getList} /> (state.productOpen = false)} onConfirm={async (item: any) => { try { await musicSheetImg({ ...item, id: state.productItem.id }) } catch {} }} />
) } })