import { defineComponent, onMounted, reactive, ref } from 'vue' import SaveForm from '@components/save-form' import { DataTableRowKey, NButton, NCascader, NDataTable, NDatePicker, NDescriptions, NDescriptionsItem, NFormItem, NIcon, NImage, NInput, NModal, NSelect, NSpace, NTag, NTooltip, useDialog, useMessage } from 'naive-ui' import Pagination from '@components/pagination' import TheTooltip from '@components/TheTooltip' import AddMusic from '@views/music-library/project-music-sheet/module/gym/addMusic' import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil' import { appKey, musicSheetAudioType, musicSheetPaymentType, musicSheetSourceType, musicSheetType } from '@/utils/constant' import { musicSheetApplicationExtendCategoryList, musicSheetApplicationExtendDel, musicSheetApplicationExtendStatus, musicSheetApplicationOwnerList, musicSheetPageByApplication, musicSheetStatusList } from '@views/music-library/api' import UpdateMusic from '@views/music-library/project-music-sheet/module/gym/updateMusic' import { subjectPage, sysApplicationPage } from '@views/system-manage/api' import { filterTimes } from '@/utils/dateUtil' import deepClone from '@/utils/deep.clone' import { getOwnerName } from '@views/music-library/musicUtil' import MusicPreView from '@views/music-library/music-sheet/modal/musicPreView' import { HelpCircleOutline } from '@vicons/ionicons5' export default defineComponent({ name: 'project-music-sheet-mec', props: { appKey: { type: String, default: 'GYT' } }, setup(props) { const dialog = useDialog() const message = useMessage() const state = reactive({ loading: false, appId: null as any, pagination: { page: 1, rows: 10, pageTotal: 0 }, searchForm: { keyword: null, musicSheetType: null, //曲目类型(SINGLE:单曲 CONCERT:合奏) subjectId: null, //声部ID subjectIds: null, //曲目声部ID集合 musicCategoryIds: null, //曲目分类ID status: null, //曲目状态(0:停用,1:启用) sourceType: null, //来源类型/作者属性(PLATFORM: 平台; ORG: 机构; PERSON: 个人) paymentType: null, //收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费) userId: null, //所属人 musicCategoryId: null, //曲目分类ID times: null, // 上传时间 audioType: null, //音频类型(HOMEMODE: 自制 COMMON: 普通) exquisiteFlag: null, //精品标志 topFlag: null, //是否置顶(0:否;1:是) availableType: null, //可用途径 ORG 机构 PLATFORM 平台 appAuditFlag: null, //是否审核版本 detailFlag: null, //是否查询详情 applicationId: null, //所属人项目ID extendApplicationId: null //所属人项目ID }, subjectList: [], dataList: [] as any[], musicSheetCategories: [], showAddDialog: false, showEditDialog: false, userIdDisable: true, userIdData: [] as any, updateRow: {} as any, // 修改选择的行 applicationId: null, //应用ID musicPreview: false, musicScore: null as any, useProjectData: [] as any // 适用项目行数据 }) onMounted(async () => { state.loading = true // 获取应用APP信息 try { const { data } = await sysApplicationPage({ page: 1, rows: 1, appKey: props.appKey }) const tempList = data.rows || [] if (!tempList || tempList.length == 0) { state.loading = false message.error('加载项目信息失败') return } state.appId = tempList[0].id state.applicationId = tempList[0].id } catch {} // 加载声部 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 {} //加载曲目分类列表 try { const { data } = await musicSheetApplicationExtendCategoryList({ applicationIds: state.appId }) if (data && data.length > 0) { state.musicSheetCategories = data[0].musicSheetCategories } } catch {} // 加载表格数据 initUseAppList() getList() }) 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 onSearch = () => { checkedRowKeysRef.value = [] saveForm.value?.submit() } const onBtnReset = () => { saveForm.value?.reset() } const onSubmit = () => { state.pagination.page = 1 getList() } const checkedRowKeysRef = ref([]) const handleCheck = (rowKeys: DataTableRowKey[]) => { checkedRowKeysRef.value = rowKeys } const getList = async () => { try { state.loading = true const sourceType = state.searchForm.sourceType const { data } = await musicSheetPageByApplication({ ...state.pagination, ...state.searchForm, userId: sourceType && sourceType === 'PERSON' ? state.searchForm.userId : null, organizationRoleId: sourceType && sourceType === 'ORG' ? state.searchForm.userId : null, ...filterTimes(state.searchForm.times, ['startTime', 'endTime']), applicationId: state.applicationId }) state.pagination.pageTotal = Number(data.total) state.dataList = data.rows || [] } catch {} state.loading = false } const onChangeStatus = (row: any) => { const statusStr = row.status ? '停用' : '启用' dialog.warning({ title: '提示', content: `是否${statusStr}?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicSheetApplicationExtendStatus({ ids: row.applicationExtendId, 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 musicSheetApplicationExtendStatus({ ids: checkedRowKeysRef.value.join(','), status: status }) getList() message.success(`${statusStr}成功`) } catch {} } }) } const updateUserIdData = async (sourceType: any) => { if (!state.searchForm.extendApplicationId) { return } state.userIdData = [] state.searchForm.userId = null if (sourceType && sourceType !== 'PLATFORM') { const { data } = await musicSheetApplicationOwnerList({ page: 1, rows: 9999, sourceType: sourceType, applicationId: state.searchForm.extendApplicationId }) 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: `删除曲目,是否继续?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicSheetApplicationExtendDel(row.applicationExtendId) getList() message.success('删除成功') } catch {} } }) } const columns = (): any => { return [ { type: 'selection' }, { title: '曲目名称', key: 'id', render: (row: any) => ( <> {' '} {' '} ) }, { title: '封面图', key: 'musicCover', render(row: any): JSX.Element { return } }, // { // title: '可用声部', // key: 'subjectNames', // render: (row: any) => { // return // } // }, { title: '曲目信息', key: 'musicSheetCategoriesName', render: (row: any) => ( <> {getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))} {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))} ) }, { title: '伴奏类型', key: 'audioType', render: (row: any) => { return (
{getMapValueByKey(row.audioType, new Map(Object.entries(musicSheetAudioType)))}
) } }, { title: '曲目分类', key: 'musicSheetCategoryName' }, { title: '收费方式', key: 'paymentType', render: (row: any) => { return (
{getMapValueByKey(row.paymentType, new Map(Object.entries(musicSheetPaymentType)))}
) } }, { title: '上传人', minWidth: '150px', key: 'composer', render(row: any) { return ( {row.createByName} {row.createTime} ) } }, { title: '状态', key: 'status', render(row: any) { return ( {row.status ? '启用' : '停用'} ) } }, { title: '操作', key: 'operation', fixed: 'right', render(row: any) { return ( { state.musicPreview = true state.musicScore = row }} > 预览 onChangeStatus(row)} > {row.status ? '停用' : '启用'} { state.showEditDialog = true state.updateRow = row }} > 修改 onRmove(row)} v-auth="musicSheetApplicationExtend/del1770708555010191362" > 删除 ) } } ] } return () => { return (
(state.searchForm = val)} > { state.userIdData = [] state.searchForm.userId = null if (value && value !== 'PLATFORM') { await updateUserIdData(value) state.userIdDisable = !state.searchForm.extendApplicationId } else { state.userIdDisable = true } }} clearable /> { state.searchForm.extendApplicationId = 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 = [] } }} /> {/**/} {/* */} {/* */} {/**/} 搜索 重置
{ state.showAddDialog = true }} > 添加曲目 { onBatchChangeStatus(false) }} > 批量停用 { onBatchChangeStatus(true) }} > 批量启用 row.applicationExtendId} v-model:checkedRowKeys={checkedRowKeysRef.value} scrollX={'1400'} >
(state.showAddDialog = false)} onGetList={() => { state.pagination.page = 1 getList() }} subjectList={state.subjectList} appId={state.appId} musicSheetCategories={state.musicSheetCategories} /> (state.showEditDialog = false)} onGetList={() => { state.pagination.page = 1 getList() }} rowData={state.updateRow} appId={state.appId} musicSheetCategories={state.musicSheetCategories} />
) } } })