123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818 |
- 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 (
- <NDescriptions labelPlacement="left" column={1}>
- <NDescriptionsItem label="名称">
- <TheTooltip content={row.name}/>
- </NDescriptionsItem>
- <NDescriptionsItem label="编号"><TheTooltip content={row.id}/></NDescriptionsItem>
- </NDescriptions>
- )
- }
- },
- {
- title: '封面图',
- key: 'titleImg',
- render(row: any): JSX.Element {
- return <NImage width={60} height={60} src={row.musicCover}/>
- }
- },
- {
- title: '曲目信息',
- minWidth: '200px',
- key: 'composer',
- render(row: any) {
- return (
- <NDescriptions labelPlacement="left" column={1}>
- <NDescriptionsItem label="音乐人">{row.composer}</NDescriptionsItem>
- <NDescriptionsItem label="多声轨渲染">{getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}</NDescriptionsItem>
- <NDescriptionsItem label="分类"><TheTooltip content={row.musicCategoryName}/></NDescriptionsItem>
- <NDescriptionsItem label="可用声部"><TheTooltip content={row.subjectNames}/></NDescriptionsItem>
- </NDescriptions>
- )
- }
- },
- {
- title: '作者属性',
- minWidth: '250px',
- key: 'sourceType',
- render(row: any) {
- return (
- <NDescriptions labelPlacement="left" column={1}>
- <NDescriptionsItem label="属性">{getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))}</NDescriptionsItem>
- <NDescriptionsItem label="所属人">{getOwnerName(row.musicSheetExtend, row.sourceType)}</NDescriptionsItem>
- </NDescriptions>
- )
- }
- },
- {
- title: '适用项目',
- key: 'projectName',
- render(row: any) {
- return (
- <NSpace>
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- state.showUseProject = true
- state.showUseProjectId = row.id
- }}
- >
- <TheTooltip content={row.musicSheetExtend && row.musicSheetExtend.useApplicationNames
- ? row.musicSheetExtend.useApplicationNames
- : ''}/>
- <NIcon size={15} style="padding-left: 9px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- }
- },
- {
- title: '更新信息',
- minWidth: '250px',
- key: 'updateBy',
- render(row: any) {
- return (
- <NDescriptions labelPlacement="left" column={1}>
- <NDescriptionsItem label="更新人">{row.updateByName}</NDescriptionsItem>
- <NDescriptionsItem label="更新时间">{row.updateTime}</NDescriptionsItem>
- </NDescriptions>
- )
- }
- },
- {
- title: '审核版本',
- minWidth: '100px',
- key: 'appAuditFlag',
- render(row: any) {
- return <div>{row.appAuditFlag ? '是' : '否'}</div>
- }
- },
- {
- title: '状态',
- minWidth: '50px',
- key: 'status',
- render(row: any) {
- return (
- <NTag type={row.status ? 'primary' : 'default'}>{row.status ? '启用' : '停用'}</NTag>
- )
- }
- },
- {
- title: '操作',
- key: 'operation',
- fixed: 'right',
- width: '300px',
- render(row: any) {
- return (
- <NSpace>
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- state.musicPreview = true
- state.musicScore = row
- }}
- >
- 预览
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- v-auth="musicSheet/detail1751241103201271810"
- onClick={() => {
- state.visiableMusic = true
- state.musicOperation = 'preview'
- state.musicData = row
- state.detailReadonly = true
- }}
- >
- 查看
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- v-auth="musicSheet/save1751241178962984962"
- onClick={() => {
- state.visiableMusic = true
- state.musicOperation = 'edit'
- state.musicData = row
- state.detailReadonly = true
- }}
- >
- 修改
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- v-auth="musicSheet/statusList1751241653309407234"
- onClick={() => onChangeStatus(row)}
- >
- {row.status ? '停用' : '启用'}
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- v-auth="musicSheet/img1751240591299051522"
- onClick={() => {
- state.productOpen = true
- state.productItem = row
- // handleAutoProduct(row)
- }}
- >
- 生成图片
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- disabled={!!row.status}
- onClick={() => onRmove(row)}
- v-auth="musicSheet/save1751241178962984962"
- >
- 删除
- </NButton>
- </NSpace>
- )
- }
- }
- ]
- }
- const checkedRowKeysRef = ref<DataTableRowKey[]>([])
- 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 () => (
- <div class="system-menu-container">
- <SaveForm
- ref={saveForm}
- model={state.searchForm}
- onSubmit={onSubmit}
- saveKey="music-list"
- onSetModel={(val: any) => (state.searchForm = val)}
- >
- <NFormItem label="关键词" path="keyword">
- <NInput
- placeholder="曲目编号/名称"
- v-model:value={state.searchForm.keyword}
- clearable
- />
- </NFormItem>
- <NFormItem label="多声轨渲染" path="musicSheetType">
- <NSelect
- placeholder="请选择多声轨渲染"
- v-model:value={state.searchForm.musicSheetType}
- options={getSelectDataFromObj(musicSheetType)}
- clearable
- />
- </NFormItem>
- <NFormItem label="曲目分类" path="musicCategoryId">
- <NCascader
- valueField="id"
- labelField="name"
- children-field="musicSheetCategoriesList"
- placeholder="请选择曲目分类"
- v-model:value={state.searchForm.musicCategoryId}
- options={state.musicSheetCategories}
- clearable
- />
- </NFormItem>
- <NFormItem label="可用声部" path="musicSubject">
- <NSelect
- placeholder="请选择可用声部"
- v-model:value={state.searchForm.subjectId}
- options={state.subjectList}
- clearable
- />
- </NFormItem>
- <NFormItem label="音乐人" path="composer">
- <NInput
- placeholder="请选择音乐人"
- v-model:value={state.searchForm.composer}
- clearable
- />
- </NFormItem>
- <NFormItem label="作者属性" path="sourceType">
- <NSelect
- placeholder="请选择作者属性"
- v-model:value={state.searchForm.sourceType}
- options={getSelectDataFromObj(musicSheetSourceType)}
- onUpdateValue={async (value: any) => {
- state.userIdData = []
- state.searchForm.userId = null
- if (value && value !== 'PLATFORM') {
- await updateUserIdData(value)
- state.userIdDisable = !state.searchForm.applicationId
- } else {
- state.userIdDisable = true
- }
- }}
- clearable
- />
- </NFormItem>
- <NFormItem label="项目" path="applicationId">
- <NSelect
- placeholder="请选择项目"
- v-model:value={state.searchForm.applicationId}
- options={state.useProjectData}
- clearable
- onUpdateValue={async (value: any) => {
- 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 = []
- }
- }}
- />
- </NFormItem>
- <NFormItem label="所属人" path="userId">
- {{
- label: () =>
- <div>
- 所属人
- {/*<NTooltip style={"padding-left: 10px"}>*/}
- {/* {{*/}
- {/* default: () => '请选择作者属性和项目再选择所属人',*/}
- {/* trigger: () => (*/}
- {/* <span>*/}
- {/* <NIcon size="20">*/}
- {/* <HelpCircleOutline/>*/}
- {/* </NIcon>*/}
- {/* </span>*/}
- {/* )*/}
- {/* }}*/}
- {/*</NTooltip>*/}
- </div>
- ,
- default: () => (
- <NSelect
- filterable
- placeholder="请选择所属人"
- disabled={state.userIdDisable || (!state.searchForm.applicationId && !state.searchForm.sourceType)}
- v-model:value={state.searchForm.userId}
- options={state.userIdData}
- clearable
- ></NSelect>
- )
- }}
- </NFormItem>
- <NFormItem label="适用项目" path="useAppId">
- <NSelect
- placeholder="请选择适用项目"
- v-model:value={state.searchForm.useAppId}
- options={state.useProjectData}
- multiple
- maxTagCount={1}
- />
- </NFormItem>
- <NFormItem label="状态" path="status">
- <NSelect
- v-model={[state.searchForm.status, 'value']}
- placeholder="请选择状态"
- clearable
- options={
- [
- {
- label: '启用',
- value: true
- },
- {
- label: '停用',
- value: false
- }
- ] as any
- }
- />
- </NFormItem>
- <NFormItem label="审核版本" path="appAuditFlag">
- <NSelect
- v-model={[state.searchForm.appAuditFlag, 'value']}
- placeholder="请选择审核版本"
- clearable
- options={
- [
- {
- label: '是',
- value: 1
- },
- {
- label: '否',
- value: 0
- }
- ] as any
- }
- />
- </NFormItem>
- <NFormItem label="数据修复" path="dataCorrect">
- <NSelect
- v-model={[state.searchForm.dataCorrect, 'value']}
- placeholder="请选择数据修复"
- clearable
- options={
- [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- }
- />
- </NFormItem>
- <NFormItem>
- <NSpace>
- <NButton type="primary" onClick={onSearch}>
- 搜索
- </NButton>
- <NButton type="default" onClick={onBtnReset}>
- 重置
- </NButton>
- </NSpace>
- </NFormItem>
- </SaveForm>
- <div class={['section-container']}>
- <NSpace style={{ paddingBottom: '12px' }}>
- <NButton
- type="primary"
- v-auth="musicSheet/save1751241178962984962"
- onClick={() => {
- state.visiableMusic = true
- state.musicOperation = 'add'
- state.musicData = {}
- state.detailReadonly = true
- }}
- >
- 新增曲目
- </NButton>
- <NButton
- disabled={checkedRowKeysRef.value.length == 0}
- v-auth="musicSheet/statusList1751241653309407234"
- onClick={() => {
- onBatchChangeStatus(false)
- }}
- >
- 批量停用
- </NButton>
- <NButton
- disabled={checkedRowKeysRef.value.length == 0}
- v-auth="musicSheet/statusList1751241653309407234"
- onClick={() => {
- onBatchChangeStatus(true)
- }}
- >
- 批量启用
- </NButton>
- </NSpace>
- <NDataTable
- loading={state.loading}
- columns={columns()}
- data={state.dataList}
- rowKey={(row: any) => row.id}
- onUpdateCheckedRowKeys={handleCheck}
- scrollX={'1200'}
- ></NDataTable>
- <Pagination
- v-model:page={state.pagination.page}
- v-model:pageSize={state.pagination.rows}
- v-model:pageTotal={state.pagination.pageTotal}
- onList={getList}
- sync
- saveKey="music-list"
- ></Pagination>
- </div>
- <NModal
- v-model:show={state.visiableMusic}
- preset="dialog"
- showIcon={false}
- maskClosable={false}
- title={() => {
- if (state.musicOperation === 'add') {
- return '添加曲目'
- } else if (state.musicOperation === 'preview') {
- return '曲目详情'
- }
- return '修改曲目'
- }}
- style={{ width: '980px' }}
- >
- <MusicOperation
- type={state.musicOperation}
- data={state.musicData}
- subjectList={state.subjectList}
- // musicSheetCategories={state.musicSheetCategories}
- // tagList={state.tagList}
- onClose={() => (state.visiableMusic = false)}
- onGetList={getList}
- />
- </NModal>
- <NModal
- blockScroll={true}
- v-model:show={state.musicPreview}
- preset="dialog"
- showIcon={false}
- title={'曲目预览'}
- style={{ width: 'auto' }}
- >
- <MusicPreView item={state.musicScore} isMove={1}/>
- </NModal>
- <NModal
- blockScroll={true}
- v-model:show={state.showUseProject}
- preset="dialog"
- showIcon={false}
- title={'适用项目'}
- style={{ width: '500px' }}
- >
- <UseProject
- id={state.showUseProjectId}
- useProject={state.useProjectData}
- onClose={() => (state.showUseProject = false)}
- onGetList={getList}
- />
- </NModal>
- <NModal
- class={styles.productModal}
- title="自动生成曲谱图片"
- v-model:show={state.productOpen}
- preset="dialog"
- closeOnEsc={false}
- maskClosable={false}
- showIcon={false}
- >
- <MusicCreateImg
- xmlFileUrl={state.productItem.xmlFileUrl}
- onClose={() => (state.productOpen = false)}
- onConfirm={async (item: any) => {
- try {
- await musicSheetImg({
- ...item,
- id: state.productItem.id
- })
- } catch {}
- }}
- />
- </NModal>
- </div>
- )
- }
- })
|