music-sheet-gyt.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. import { defineComponent, onMounted, reactive, ref } from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {
  4. DataTableRowKey,
  5. NButton,
  6. NCascader,
  7. NDataTable,
  8. NDatePicker,
  9. NDescriptions,
  10. NDescriptionsItem,
  11. NFormItem,
  12. NImage,
  13. NInput,
  14. NModal,
  15. NSelect,
  16. NSpace,
  17. NTag,
  18. useDialog,
  19. useMessage
  20. } from 'naive-ui'
  21. import Pagination from '@components/pagination'
  22. import TheTooltip from '@components/TheTooltip'
  23. import AddMusic from '@views/music-library/project-music-sheet/module/gyt/addMusic'
  24. import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
  25. import {
  26. appKey,
  27. musicSheetAudioType,
  28. musicSheetPaymentType,
  29. musicSheetSourceType,
  30. musicSheetType
  31. } from '@/utils/constant'
  32. import {
  33. musicSheetApplicationExtendCategoryList,
  34. musicSheetApplicationExtendStatus,
  35. musicSheetApplicationOwnerList,
  36. musicSheetPageByApplication
  37. } from '@views/music-library/api'
  38. import { subjectPage, sysApplicationPage } from '@views/system-manage/api'
  39. import { filterTimes } from '@/utils/dateUtil'
  40. import deepClone from '@/utils/deep.clone'
  41. import { getOwnerName } from '@views/music-library/musicUtil'
  42. import UpdateMusic from '@views/music-library/project-music-sheet/module/gyt/updateMusic'
  43. import MusicPreView from "@views/music-library/music-sheet/modal/musicPreView";
  44. export default defineComponent({
  45. name: 'project-music-sheet-gyt',
  46. props: {
  47. appKey: {
  48. type: String,
  49. default: 'GYT'
  50. }
  51. },
  52. setup(props) {
  53. const dialog = useDialog()
  54. const message = useMessage()
  55. const state = reactive({
  56. loading: false,
  57. appId: null as any,
  58. pagination: {
  59. page: 1,
  60. rows: 10,
  61. pageTotal: 0
  62. },
  63. searchForm: {
  64. keyword: null,
  65. musicSheetType: null, //曲目类型(SINGLE:单曲 CONCERT:合奏)
  66. subjectId: null, //声部ID
  67. subjectIds: null, //曲目声部ID集合
  68. musicCategoryIds: null, //曲目分类ID
  69. status: null, //曲目状态(0:停用,1:启用)
  70. sourceType: null, //来源类型/作者属性(PLATFORM: 平台; ORG: 机构; PERSON: 个人)
  71. paymentType: null, //收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费)
  72. userId: null, //所属人
  73. musicCategoryId: null, //曲目分类ID
  74. times: null, // 上传时间
  75. audioType: null, //音频类型(HOMEMODE: 自制 COMMON: 普通)
  76. exquisiteFlag: null, //精品标志
  77. topFlag: null, //是否置顶(0:否;1:是)
  78. availableType: null, //可用途径 ORG 机构 PLATFORM 平台
  79. appAuditFlag: null, //是否审核版本
  80. detailFlag: null, //是否查询详情
  81. applicationId: null, //所属人项目ID
  82. extendApplicationId: null, //所属人项目ID
  83. },
  84. subjectList: [],
  85. dataList: [] as any[],
  86. musicSheetCategories: [],
  87. showAddDialog: false,
  88. showEditDialog: false,
  89. userIdDisable: true,
  90. userIdData: [] as any,
  91. updateRow: {} as any, // 修改选择的行
  92. applicationId: null, //应用ID
  93. musicPreview: false,
  94. musicScore: null as any,
  95. useProjectData: [] as any, // 适用项目行数据
  96. })
  97. onMounted(async () => {
  98. state.loading = true
  99. // 获取应用APP信息
  100. try {
  101. const { data } = await sysApplicationPage({ page: 1, rows: 1, appKey: props.appKey })
  102. const tempList = data.rows || []
  103. if (!tempList || tempList.length == 0) {
  104. state.loading = false
  105. message.error('加载项目信息失败')
  106. return
  107. }
  108. state.appId = tempList[0].id
  109. state.applicationId = tempList[0].id
  110. } catch {}
  111. // 加载声部
  112. try {
  113. const { data } = await subjectPage({ page: 1, rows: 999 })
  114. const tempList = data.rows || []
  115. tempList.forEach((item: any) => {
  116. item.label = item.name
  117. item.value = item.id + ''
  118. })
  119. state.subjectList = tempList
  120. } catch {}
  121. try {
  122. //加载曲目分类列表
  123. const { data } = await musicSheetApplicationExtendCategoryList({
  124. applicationIds: state.appId
  125. })
  126. if (data && data.length > 0) {
  127. state.musicSheetCategories = data[0].musicSheetCategories
  128. }
  129. } catch {}
  130. // 加载表格数据
  131. initUseAppList()
  132. getList()
  133. })
  134. const saveForm = ref()
  135. const onSearch = () => {
  136. saveForm.value?.submit()
  137. }
  138. const onBtnReset = () => {
  139. saveForm.value?.reset()
  140. }
  141. const onSubmit = () => {
  142. state.pagination.page = 1
  143. getList()
  144. }
  145. const initUseAppList = async () => {
  146. try {
  147. const appKeys = Object.keys(appKey)
  148. const { data } = await sysApplicationPage({ page: 1, rows: 999 })
  149. const tempList = data.rows || []
  150. state.useProjectData = []
  151. const filter = tempList.filter((next: any) => {
  152. return appKeys.includes(next.appKey)
  153. })
  154. filter.forEach((item: any) => {
  155. state.useProjectData.push({
  156. ...item,
  157. label: item.appName,
  158. value: item.id
  159. })
  160. })
  161. } catch {}
  162. }
  163. const updateUserIdData = async (sourceType: any) => {
  164. if (!state.searchForm.extendApplicationId) {
  165. return
  166. }
  167. state.userIdData = []
  168. state.searchForm.userId = null
  169. if (sourceType && sourceType !== 'PLATFORM') {
  170. const { data } = await musicSheetApplicationOwnerList({
  171. page: 1,
  172. rows: 9999,
  173. sourceType: sourceType,
  174. applicationId: state.searchForm.extendApplicationId
  175. })
  176. const temp = data.rows || []
  177. temp.forEach((next: any) => {
  178. state.userIdData.push({
  179. ...next,
  180. label: sourceType === 'PERSON' ? next.userName : next.organizationRole,
  181. value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId
  182. })
  183. })
  184. }
  185. }
  186. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  187. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  188. checkedRowKeysRef.value = rowKeys
  189. }
  190. const getList = async () => {
  191. try {
  192. state.loading = true
  193. const sourceType = state.searchForm.sourceType
  194. const { data } = await musicSheetPageByApplication({
  195. ...state.pagination,
  196. ...state.searchForm,
  197. userId: (sourceType && sourceType === 'PERSON') ? state.searchForm.userId : null,
  198. organizationRoleId: (sourceType && sourceType === 'ORG') ? state.searchForm.userId : null,
  199. ...filterTimes(state.searchForm.times, ['startTime', 'endTime']),
  200. applicationId: state.applicationId
  201. })
  202. state.pagination.pageTotal = Number(data.total)
  203. state.dataList = data.rows || []
  204. } catch {}
  205. state.loading = false
  206. }
  207. const onChangeStatus = (row: any) => {
  208. const statusStr = row.status ? '停用' : '启用'
  209. dialog.warning({
  210. title: '提示',
  211. content: `是否${statusStr}?`,
  212. positiveText: '确定',
  213. negativeText: '取消',
  214. onPositiveClick: async () => {
  215. try {
  216. await musicSheetApplicationExtendStatus({
  217. ids: row.applicationExtendId,
  218. status: !row.status
  219. })
  220. getList()
  221. message.success(`${statusStr}成功`)
  222. } catch {}
  223. }
  224. })
  225. }
  226. const onBatchChangeStatus = (status: boolean) => {
  227. const length = checkedRowKeysRef.value.length
  228. if (length == 0) {
  229. message.warning('未选择数据')
  230. }
  231. const statusStr = !status ? '停用' : '启用'
  232. dialog.warning({
  233. title: '提示',
  234. content: `是否${statusStr}` + length + `条数据?`,
  235. positiveText: '确定',
  236. negativeText: '取消',
  237. onPositiveClick: async () => {
  238. try {
  239. await musicSheetApplicationExtendStatus({
  240. ids: checkedRowKeysRef.value.join(','),
  241. status: status
  242. })
  243. getList()
  244. message.success(`${statusStr}成功`)
  245. } catch {}
  246. }
  247. })
  248. }
  249. const columns = (): any => {
  250. return [
  251. {
  252. type: 'selection'
  253. },
  254. {
  255. title: '曲目名称',
  256. key: 'id',
  257. render: (row: any) => (
  258. <>
  259. <NDescriptions labelPlacement="left" column={1}>
  260. <NDescriptionsItem label="曲目名称">
  261. <TheTooltip content={row.name} />{' '}
  262. </NDescriptionsItem>
  263. <NDescriptionsItem label="曲目编号"><TheTooltip content={row.id} />{' '}</NDescriptionsItem>
  264. </NDescriptions>
  265. </>
  266. )
  267. },
  268. {
  269. title: '封面图',
  270. key: 'musicCover',
  271. render(row: any): JSX.Element {
  272. return <NImage width={60} height={60} src={row.musicCover} />
  273. }
  274. },
  275. // {
  276. // title: '可用声部',
  277. // key: 'subjectNames',
  278. // render: (row: any) => {
  279. // return <TheTooltip content={row.subjectNames}/>
  280. // }
  281. // },
  282. {
  283. title: '曲目信息',
  284. key: 'musicSheetCategoriesName',
  285. render: (row: any) => (
  286. <>
  287. <NDescriptions labelPlacement="left" column={1}>
  288. <NDescriptionsItem label="曲目来源">
  289. {getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))}
  290. </NDescriptionsItem>
  291. <NDescriptionsItem label="多声轨渲染">{getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}</NDescriptionsItem>
  292. <NDescriptionsItem label="所属人">
  293. <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)}/>
  294. </NDescriptionsItem>
  295. <NDescriptionsItem label="可用声部">
  296. <TheTooltip content={row.subjectNames}/>
  297. </NDescriptionsItem>
  298. </NDescriptions>
  299. </>
  300. )
  301. },
  302. {
  303. title: '伴奏类型',
  304. key: 'audioType',
  305. render: (row: any) => {
  306. return (
  307. <div>
  308. {getMapValueByKey(row.audioType, new Map(Object.entries(musicSheetAudioType)))}
  309. </div>
  310. )
  311. }
  312. },
  313. {
  314. title: '曲目分类',
  315. key: 'musicSheetCategoryName'
  316. },
  317. // {
  318. // title: '可用途径',
  319. // key: 'availableType',
  320. // render: (row: any) => {
  321. // return <div>{getMapValueByKey(row.availableType, new Map(Object.entries(musicSheetAvailableType)))}</div>
  322. // }
  323. // },
  324. // {
  325. // title: '收费方式',
  326. // key: 'paymentType',
  327. // render: (row: any) => {
  328. // return (
  329. // <div>
  330. // {getMapValueByKey(row.paymentType, new Map(Object.entries(musicSheetPaymentType)))}
  331. // </div>
  332. // )
  333. // }
  334. // },
  335. {
  336. title: '上传人',
  337. minWidth: '150px',
  338. key: 'composer',
  339. render(row: any) {
  340. return (
  341. <NDescriptions labelPlacement="left" column={1}>
  342. <NDescriptionsItem label="上传人">{row.createByName}</NDescriptionsItem>
  343. <NDescriptionsItem label="上传时间">{row.createTime}</NDescriptionsItem>
  344. </NDescriptions>
  345. )
  346. }
  347. },
  348. {
  349. title: '状态',
  350. key: 'status',
  351. render(row: any) {
  352. return (
  353. <NTag type={row.status ? 'primary' : 'default'}>{row.status ? '启用' : '停用'}</NTag>
  354. )
  355. }
  356. },
  357. {
  358. title: '操作',
  359. key: 'operation',
  360. fixed: 'right',
  361. render(row: any) {
  362. return (
  363. <NSpace>
  364. <NButton
  365. type="primary"
  366. size="small"
  367. text
  368. onClick={() => {
  369. state.musicPreview = true
  370. state.musicScore = row
  371. }}
  372. >
  373. 预览
  374. </NButton>
  375. <NButton
  376. type="primary"
  377. size="small"
  378. text
  379. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  380. onClick={() => onChangeStatus(row)}
  381. >
  382. {row.status ? '停用' : '启用'}
  383. </NButton>
  384. <NButton
  385. type="primary"
  386. size="small"
  387. text
  388. v-auth="musicSheetApplicationExtend/update1751235625503162370"
  389. onClick={() => {
  390. state.showEditDialog = true
  391. state.updateRow = row
  392. }}
  393. >
  394. 修改
  395. </NButton>
  396. </NSpace>
  397. )
  398. }
  399. }
  400. ]
  401. }
  402. return () => {
  403. return (
  404. <div class="system-menu-container">
  405. <SaveForm
  406. ref={saveForm}
  407. model={state.searchForm}
  408. onSubmit={onSubmit}
  409. saveKey="music-sheet-gyt"
  410. onSetModel={(val: any) => (state.searchForm = val)}
  411. >
  412. <NFormItem label="关键词" path="keyword">
  413. <NInput
  414. placeholder="请输入曲目名称/编号"
  415. v-model:value={state.searchForm.keyword}
  416. clearable
  417. />
  418. </NFormItem>
  419. <NFormItem label="曲目来源" path="sourceType">
  420. <NSelect
  421. placeholder="请选择曲目来源"
  422. v-model:value={state.searchForm.sourceType}
  423. options={getSelectDataFromObj(musicSheetSourceType)}
  424. onUpdateValue={async (value: any) => {
  425. state.userIdData = []
  426. state.searchForm.userId = null
  427. if (value && value !== 'PLATFORM') {
  428. await updateUserIdData(value)
  429. state.userIdDisable = !state.searchForm.extendApplicationId
  430. } else {
  431. state.userIdDisable = true
  432. }
  433. }}
  434. clearable
  435. />
  436. </NFormItem>
  437. <NFormItem label="项目" path="applicationId">
  438. <NSelect
  439. placeholder="请选择项目"
  440. v-model:value={state.searchForm.extendApplicationId}
  441. options={state.useProjectData}
  442. clearable
  443. onUpdateValue={async (value: any) => {
  444. state.searchForm.extendApplicationId = value
  445. if (value) {
  446. await updateUserIdData(state.searchForm.sourceType)
  447. state.userIdDisable = !(
  448. state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM'
  449. )
  450. } else {
  451. state.searchForm.userId = null
  452. state.userIdDisable = true
  453. state.userIdData = []
  454. }
  455. }}
  456. />
  457. </NFormItem>
  458. <NFormItem label="所属人" path="userId">
  459. <NSelect
  460. filterable
  461. placeholder="请选择所属人"
  462. disabled={state.userIdDisable}
  463. v-model:value={state.searchForm.userId}
  464. options={state.userIdData}
  465. clearable
  466. ></NSelect>
  467. </NFormItem>
  468. <NFormItem label="多声轨渲染" path="subjectType">
  469. <NSelect
  470. placeholder="请选多声轨渲染"
  471. v-model:value={state.searchForm.musicSheetType}
  472. options={getSelectDataFromObj(musicSheetType)}
  473. clearable
  474. />
  475. </NFormItem>
  476. <NFormItem label="伴奏类型" path="audioType">
  477. <NSelect
  478. placeholder="请选择伴奏类型"
  479. v-model:value={state.searchForm.audioType}
  480. options={getSelectDataFromObj(musicSheetAudioType)}
  481. clearable
  482. />
  483. </NFormItem>
  484. <NFormItem label="可用声部" path="subjectId">
  485. <NSelect
  486. placeholder="请选择可用声部"
  487. v-model:value={state.searchForm.subjectId}
  488. options={state.subjectList}
  489. clearable
  490. />
  491. </NFormItem>
  492. <NFormItem label="曲目分类" path="musicCategoryId">
  493. <NCascader
  494. valueField="id"
  495. labelField="name"
  496. children-field="children"
  497. placeholder="请选择曲目分类"
  498. v-model:value={state.searchForm.musicCategoryId}
  499. options={state.musicSheetCategories}
  500. clearable
  501. />
  502. </NFormItem>
  503. {/*<NFormItem*/}
  504. {/* label="可用途径"*/}
  505. {/* path="availableType"*/}
  506. {/*>*/}
  507. {/* <NSelect*/}
  508. {/* placeholder="请选择可用途径"*/}
  509. {/* v-model:value={state.searchForm.availableType}*/}
  510. {/* options={getSelectDataFromObj(musicSheetAvailableType)}*/}
  511. {/* clearable*/}
  512. {/* >*/}
  513. {/* </NSelect>*/}
  514. {/*</NFormItem>*/}
  515. {/*<NFormItem label="收费方式" path="paymentType">*/}
  516. {/* <NSelect*/}
  517. {/* placeholder="请选择收费方式"*/}
  518. {/* v-model:value={state.searchForm.paymentType}*/}
  519. {/* options={getSelectDataFromObj(musicSheetPaymentType)}*/}
  520. {/* clearable*/}
  521. {/* ></NSelect>*/}
  522. {/*</NFormItem>*/}
  523. <NFormItem label="状态" path="status">
  524. <NSelect
  525. v-model:value={state.searchForm.status}
  526. placeholder="请选择状态"
  527. options={
  528. [
  529. {
  530. label: '启用',
  531. value: true
  532. },
  533. {
  534. label: '停用',
  535. value: false
  536. }
  537. ] as any
  538. }
  539. clearable
  540. />
  541. </NFormItem>
  542. <NFormItem label="上传时间" path="authorFrom">
  543. <NDatePicker
  544. v-model:value={state.searchForm.times}
  545. type="daterange"
  546. clearable
  547. value-format="yyyy.MM.dd"
  548. startPlaceholder="开始时间"
  549. endPlaceholder="结束时间"
  550. />
  551. </NFormItem>
  552. <NFormItem>
  553. <NSpace>
  554. <NButton type="primary" onClick={onSearch}>
  555. 搜索
  556. </NButton>
  557. <NButton type="default" onClick={onBtnReset}>
  558. 重置
  559. </NButton>
  560. </NSpace>
  561. </NFormItem>
  562. </SaveForm>
  563. <div class={['section-container']}>
  564. <NSpace style={{ paddingBottom: '12px' }}>
  565. <NButton
  566. type="primary"
  567. v-auth="musicSheetApplicationExtend/saveBatch1751234383880126466"
  568. onClick={() => {
  569. state.showAddDialog = true
  570. }}
  571. >
  572. 添加曲目
  573. </NButton>
  574. <NButton
  575. disabled={checkedRowKeysRef.value.length == 0}
  576. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  577. onClick={() => {
  578. onBatchChangeStatus(false)
  579. }}
  580. >
  581. 批量停用
  582. </NButton>
  583. <NButton
  584. disabled={checkedRowKeysRef.value.length == 0}
  585. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  586. onClick={() => {
  587. onBatchChangeStatus(true)
  588. }}
  589. >
  590. 批量启用
  591. </NButton>
  592. </NSpace>
  593. <NDataTable
  594. loading={state.loading}
  595. columns={columns()}
  596. data={state.dataList}
  597. rowKey={(row: any) => row.applicationExtendId}
  598. onUpdateCheckedRowKeys={handleCheck}
  599. scrollX={'1200'}
  600. ></NDataTable>
  601. <Pagination
  602. v-model:page={state.pagination.page}
  603. v-model:pageSize={state.pagination.rows}
  604. v-model:pageTotal={state.pagination.pageTotal}
  605. onList={getList}
  606. sync
  607. saveKey="music-sheet-gyt"
  608. ></Pagination>
  609. </div>
  610. <NModal
  611. v-model:show={state.showAddDialog}
  612. preset="dialog"
  613. showIcon={false}
  614. title={'添加曲目'}
  615. style={{ width: '1300px' }}
  616. >
  617. <AddMusic
  618. onClose={() => (state.showAddDialog = false)}
  619. onGetList={() => {
  620. state.pagination.page = 1
  621. getList()
  622. }}
  623. subjectList={state.subjectList}
  624. appId={state.appId}
  625. musicSheetCategories={state.musicSheetCategories}
  626. />
  627. </NModal>
  628. <NModal
  629. v-model:show={state.showEditDialog}
  630. preset="dialog"
  631. showIcon={false}
  632. title={'修改曲目'}
  633. style={{ width: '500px' }}
  634. >
  635. <UpdateMusic
  636. onClose={() => (state.showEditDialog = false)}
  637. onGetList={() => {
  638. state.pagination.page = 1
  639. getList()
  640. }}
  641. rowData={state.updateRow}
  642. appId={state.appId}
  643. musicSheetCategories={state.musicSheetCategories}
  644. />
  645. </NModal>
  646. <NModal
  647. blockScroll={true}
  648. v-model:show={state.musicPreview}
  649. preset="dialog"
  650. showIcon={false}
  651. title={'曲目预览'}
  652. style={{ width: 'auto' }}
  653. >
  654. <MusicPreView item={state.musicScore} />
  655. </NModal>
  656. </div>
  657. )
  658. }
  659. }
  660. })