addMusic.tsx 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. import { defineComponent, h, onMounted, reactive, ref } from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {
  4. DataTableColumns,
  5. DataTableRowKey,
  6. NButton,
  7. NDataTable,
  8. NFormItem,
  9. NIcon,
  10. NImage,
  11. NInput,
  12. NInputNumber,
  13. NSelect,
  14. NSpace,
  15. NStep,
  16. NSteps,
  17. useDialog,
  18. useMessage
  19. } from 'naive-ui'
  20. import Pagination from '@components/pagination'
  21. import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
  22. import {
  23. appKey,
  24. musicSheetAvailableType,
  25. musicSheetPaymentType,
  26. musicSheetSourceType,
  27. musicSheetType,
  28. scoreType
  29. } from '@/utils/constant'
  30. import {
  31. musicSheetApplicationExtendSaveBatch,
  32. musicSheetApplicationExtendTagList,
  33. musicSheetApplicationOwnerList,
  34. musicSheetPage
  35. } from '@views/music-library/api'
  36. import deepClone from '@/utils/deep.clone'
  37. import { getOwnerName } from '@views/music-library/musicUtil'
  38. import TheTooltip from '@components/TheTooltip'
  39. import { sysApplicationPage } from '@views/menu-manage/api'
  40. export default defineComponent({
  41. name: 'klx-addMusic',
  42. props: {
  43. appId: {
  44. type: String,
  45. required: true
  46. },
  47. subjectList: {
  48. type: Array,
  49. default: () => []
  50. },
  51. musicSheetTagList: {
  52. type: Array,
  53. default: () => []
  54. }
  55. },
  56. emits: ['close', 'getList'],
  57. setup(props, { slots, attrs, emit }) {
  58. const dialogs = useDialog()
  59. const message = useMessage()
  60. const state = reactive({
  61. loading: false,
  62. pagination: {
  63. page: 1,
  64. rows: 5,
  65. pageTotal: 0
  66. },
  67. stepPagination: {
  68. page: 1,
  69. rows: 5,
  70. pageTotal: 0
  71. },
  72. searchForm: {
  73. keyword: null,
  74. // musicSheetType: null,
  75. subjectId: null,
  76. sourceType: null,
  77. composer: null,
  78. userId: null,
  79. applicationId: null
  80. },
  81. subjectList: [] as any,
  82. showAdd: false,
  83. currentStep: 1,
  84. dataList: [],
  85. selectRowData: [] as any, // 选择的数据列表
  86. musicSheetCategories: [] as any,
  87. musicSheetTagList: [] as any,
  88. useProjectData: [] as any, // 适用项目行数据
  89. userIdDisable: true,
  90. userIdData: [] as any,
  91. globalStartSortNum: null as any, // 排序起始值
  92. status: false as any, // 是否启用
  93. isConvertibleScore: null as any, //是否支持转简谱
  94. scoreType: null as any //默认谱面
  95. })
  96. onMounted(async () => {
  97. state.searchForm.keyword = null
  98. // state.searchForm.musicSheetType = null
  99. state.searchForm.subjectId = null
  100. state.searchForm.sourceType = null
  101. state.searchForm.composer = null
  102. state.searchForm.userId = null
  103. state.searchForm.applicationId = null
  104. state.loading = true
  105. state.subjectList = props.subjectList
  106. // state.musicSheetTagList = props.musicSheetTagList
  107. // 加载曲目标签
  108. try {
  109. const { data } = await musicSheetApplicationExtendTagList({
  110. applicationId: props.appId,
  111. enable: true
  112. })
  113. if (data && data.length > 0) {
  114. data.forEach((item: any) => {
  115. state.musicSheetTagList.push({
  116. ...item,
  117. label: item.name,
  118. value: item.id
  119. })
  120. })
  121. }
  122. } catch (err) {}
  123. await initUseAppList()
  124. await getList()
  125. })
  126. const initUseAppList = async () => {
  127. try {
  128. const appKeys = Object.keys(appKey)
  129. const { data } = await sysApplicationPage({ page: 1, rows: 999 })
  130. const tempList = data.rows || []
  131. state.useProjectData = []
  132. const filter = tempList.filter((next: any) => {
  133. return appKeys.includes(next.appKey)
  134. })
  135. filter.forEach((item: any) => {
  136. state.useProjectData.push({
  137. ...item,
  138. label: item.appName,
  139. value: item.id
  140. })
  141. })
  142. } catch {}
  143. }
  144. const getList = async () => {
  145. try {
  146. state.loading = true
  147. const search = {
  148. ...state.searchForm,
  149. userId:
  150. state.searchForm.sourceType && state.searchForm.sourceType == 'PERSON'
  151. ? state.searchForm.userId
  152. : null,
  153. organizationRoleId:
  154. state.searchForm.sourceType && state.searchForm.sourceType == 'ORG'
  155. ? state.searchForm.userId
  156. : null
  157. }
  158. const { data } = await musicSheetPage({
  159. ...state.pagination,
  160. ...search,
  161. addAppId: props.appId
  162. })
  163. state.pagination.pageTotal = Number(data.total)
  164. state.dataList = data.rows || []
  165. } catch {}
  166. state.loading = false
  167. }
  168. const saveForm = ref()
  169. const onSearch = () => {
  170. checkedRowKeysRef.value = []
  171. saveForm.value?.submit()
  172. }
  173. const onBtnReset = () => {
  174. saveForm.value?.reset()
  175. }
  176. const onSubmit = () => {
  177. state.pagination.page = 1
  178. getList()
  179. }
  180. const updateUserIdData = async (sourceType: any) => {
  181. if (!state.searchForm.applicationId) {
  182. return
  183. }
  184. state.userIdData = []
  185. state.searchForm.userId = null
  186. if (sourceType && sourceType !== 'PLATFORM') {
  187. const { data } = await musicSheetApplicationOwnerList({
  188. page: 1,
  189. rows: 9999,
  190. sourceType: sourceType,
  191. applicationId: state.searchForm.applicationId
  192. })
  193. const temp = data.rows || []
  194. temp.forEach((next: any) => {
  195. state.userIdData.push({
  196. ...next,
  197. label: sourceType === 'PERSON' ? next.userName : next.organizationRole,
  198. value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId
  199. })
  200. })
  201. }
  202. }
  203. const onSave = async () => {
  204. if (state.selectRowData.length == 0) {
  205. message.error('未选择曲目')
  206. return
  207. }
  208. const params = [] as any[]
  209. for (let i = 0; i < state.selectRowData.length; i++) {
  210. const item = state.selectRowData[i]
  211. if (item.scoreType == null) {
  212. message.error('默认谱面不能为空')
  213. return
  214. }
  215. if (item.isConvertibleScore == null) {
  216. message.error('是否支持转谱不能为空')
  217. return
  218. }
  219. params.push({
  220. ...item,
  221. musicSheetId: item.id,
  222. applicationId: props.appId,
  223. id: null
  224. })
  225. }
  226. const res = (await musicSheetApplicationExtendSaveBatch(params)) as any
  227. if (res && res.code == '200') {
  228. message.success(`添加成功`)
  229. emit('getList')
  230. emit('close')
  231. }
  232. }
  233. const columnsField = [
  234. {
  235. type: 'selection'
  236. },
  237. {
  238. title: '曲目编号',
  239. key: 'id'
  240. },
  241. {
  242. title: '封面图',
  243. key: 'titleImg',
  244. render(row: any) {
  245. return <NImage width={40} height={40} src={row.musicCover} />
  246. }
  247. },
  248. {
  249. title: '可用声部',
  250. key: 'subjectNames',
  251. render: (row: any) => {
  252. return <TheTooltip content={row.subjectNames} />
  253. }
  254. },
  255. {
  256. title: '曲目名称',
  257. key: 'name'
  258. },
  259. {
  260. title: '音乐人',
  261. key: 'composer'
  262. },
  263. // {
  264. // title: '谱面渲染',
  265. // key: 'musicSheetType',
  266. // render: (row: any) => {
  267. // return (
  268. // <div>
  269. // {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}
  270. // </div>
  271. // )
  272. // }
  273. // },
  274. {
  275. title: '曲目来源',
  276. key: 'sourceType',
  277. render(row: any) {
  278. return getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))
  279. }
  280. },
  281. {
  282. title: '所属人',
  283. key: 'userName',
  284. render: (row: any) => {
  285. return <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)} />
  286. }
  287. }
  288. ]
  289. const columns = (): any => {
  290. return columnsField
  291. }
  292. const stepColumns = (): DataTableColumns => {
  293. const field = deepClone(columnsField)
  294. field.splice(0, 1)
  295. field.push({
  296. title(column: any) {
  297. return (
  298. <NSpace>
  299. 默认谱面
  300. <NButton
  301. type="primary"
  302. size="small"
  303. text
  304. onClick={() => {
  305. dialogs.create({
  306. title: '请选择默认谱面',
  307. showIcon: false,
  308. content: () => {
  309. return h(
  310. 'div',
  311. {
  312. class: 'flex flex-col justify-center items-center text-14px'
  313. },
  314. [
  315. // icon
  316. h(NSelect, {
  317. onUpdateValue(v) {
  318. state.scoreType = v
  319. },
  320. options: getSelectDataFromObj(scoreType)
  321. })
  322. ]
  323. )
  324. },
  325. positiveText: '确定',
  326. negativeText: '取消',
  327. onPositiveClick: () => {
  328. for (let i = 0; i < state.selectRowData.length; i++) {
  329. const item = state.selectRowData[i]
  330. item.scoreType = state.scoreType
  331. }
  332. }
  333. })
  334. }}
  335. >
  336. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  337. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  338. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  339. <path
  340. 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"
  341. fill="currentColor"
  342. ></path>
  343. </svg>
  344. </NIcon>
  345. </NButton>
  346. </NSpace>
  347. )
  348. },
  349. key: 'scoreType',
  350. width: 200,
  351. render: (row: any) => {
  352. // })
  353. return (
  354. <NSelect
  355. placeholder="请选择默认谱面"
  356. value={row.scoreType}
  357. options={getSelectDataFromObj(scoreType)}
  358. onUpdateValue={(value: any) => {
  359. row.scoreType = value
  360. }}
  361. clearable
  362. />
  363. )
  364. }
  365. })
  366. field.push({
  367. title(column: any) {
  368. return (
  369. <NSpace>
  370. 是否支持转谱
  371. <NButton
  372. type="primary"
  373. size="small"
  374. text
  375. onClick={() => {
  376. dialogs.create({
  377. title: '是否支持转谱',
  378. showIcon: false,
  379. content: () => {
  380. return h(
  381. 'div',
  382. {
  383. class: 'flex flex-col justify-center items-center text-14px'
  384. },
  385. [
  386. // icon
  387. h(NSelect, {
  388. onUpdateValue(v) {
  389. state.isConvertibleScore = v
  390. },
  391. options: [
  392. {
  393. label: '是',
  394. value: true
  395. },
  396. {
  397. label: '否',
  398. value: false
  399. }
  400. ] as any
  401. })
  402. ]
  403. )
  404. },
  405. positiveText: '确定',
  406. negativeText: '取消',
  407. onPositiveClick: () => {
  408. for (let i = 0; i < state.selectRowData.length; i++) {
  409. const item = state.selectRowData[i]
  410. item.isConvertibleScore = state.isConvertibleScore
  411. }
  412. }
  413. })
  414. }}
  415. >
  416. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  417. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  418. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  419. <path
  420. 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"
  421. fill="currentColor"
  422. ></path>
  423. </svg>
  424. </NIcon>
  425. </NButton>
  426. </NSpace>
  427. )
  428. },
  429. key: 'isConvertibleScore',
  430. width: 200,
  431. render: (row: any) => {
  432. // })
  433. return (
  434. <NSelect
  435. value={row.isConvertibleScore}
  436. options={[
  437. {
  438. label: '是',
  439. value: true
  440. },
  441. {
  442. label: '否',
  443. value: false
  444. } as any
  445. ]}
  446. onUpdateValue={(value: any) => {
  447. row.isConvertibleScore = value
  448. }}
  449. filterable
  450. clearable
  451. />
  452. )
  453. }
  454. })
  455. field.push({
  456. title(column: any) {
  457. return (
  458. <NSpace>
  459. 是否启用
  460. <NButton
  461. type="primary"
  462. size="small"
  463. text
  464. onClick={() => {
  465. dialogs.create({
  466. title: '是否启用',
  467. showIcon: false,
  468. content: () => {
  469. return h(
  470. 'div',
  471. {
  472. class: 'flex flex-col justify-center items-center text-14px'
  473. },
  474. [
  475. // icon
  476. h(NSelect, {
  477. onUpdateValue(v) {
  478. state.status = v
  479. },
  480. options: [
  481. {
  482. label: '是',
  483. value: true
  484. },
  485. {
  486. label: '否',
  487. value: false
  488. }
  489. ] as any
  490. })
  491. ]
  492. )
  493. },
  494. positiveText: '确定',
  495. negativeText: '取消',
  496. onPositiveClick: () => {
  497. for (let i = 0; i < state.selectRowData.length; i++) {
  498. const item = state.selectRowData[i]
  499. item.status = state.status
  500. }
  501. }
  502. })
  503. }}
  504. >
  505. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  506. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  507. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  508. <path
  509. 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"
  510. fill="currentColor"
  511. ></path>
  512. </svg>
  513. </NIcon>
  514. </NButton>
  515. </NSpace>
  516. )
  517. },
  518. key: 'status',
  519. width: 200,
  520. render: (row: any) => {
  521. // })
  522. return (
  523. <NSelect
  524. value={row.status}
  525. options={[
  526. {
  527. label: '是',
  528. value: true
  529. },
  530. {
  531. label: '否',
  532. value: false
  533. } as any
  534. ]}
  535. onUpdateValue={(value: any) => {
  536. row.status = value
  537. }}
  538. filterable
  539. clearable
  540. />
  541. )
  542. }
  543. })
  544. field.push({
  545. title(column: any) {
  546. return (
  547. <NSpace>
  548. 排序
  549. <NButton
  550. type="primary"
  551. size="small"
  552. text
  553. onClick={() => {
  554. dialogs.create({
  555. title: '请输入排序起始值',
  556. showIcon: false,
  557. content: () => {
  558. return h(
  559. 'div',
  560. {
  561. class: 'flex flex-col justify-center items-center text-14px'
  562. },
  563. [
  564. // icon
  565. h(NInputNumber, {
  566. onUpdateValue(v) {
  567. state.globalStartSortNum = v
  568. },
  569. min: 0,
  570. max: 9999
  571. })
  572. ]
  573. )
  574. },
  575. positiveText: '确定',
  576. negativeText: '取消',
  577. onPositiveClick: () => {
  578. for (let i = 0; i < state.selectRowData.length; i++) {
  579. const item = state.selectRowData[i]
  580. item.sortNo = state.globalStartSortNum + i
  581. }
  582. }
  583. })
  584. }}
  585. >
  586. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  587. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  588. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  589. <path
  590. 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"
  591. fill="currentColor"
  592. ></path>
  593. </svg>
  594. </NIcon>
  595. </NButton>
  596. </NSpace>
  597. )
  598. },
  599. key: 'sortNo',
  600. fixed: 'right',
  601. width: 150,
  602. render: (row: any) => {
  603. return h(NInputNumber, {
  604. value: row.sortNo,
  605. min: 0,
  606. max: 9999,
  607. onUpdateValue(value: any) {
  608. row.sortNo = value
  609. }
  610. })
  611. }
  612. })
  613. field.push({
  614. title: '操作',
  615. key: 'operation',
  616. fixed: 'right',
  617. render(row: any) {
  618. return (
  619. <NSpace>
  620. <NButton
  621. type="primary"
  622. size="small"
  623. text
  624. //v-auth="musicSheet/update1602302618558099458"
  625. onClick={() => {
  626. dialogs.warning({
  627. title: '提示',
  628. content: `是否删除该数据?`,
  629. positiveText: '确定',
  630. negativeText: '取消',
  631. onPositiveClick: async () => {
  632. try {
  633. const index = state.selectRowData.findIndex((item: any) => {
  634. if (item.id == row.id) {
  635. return true
  636. }
  637. })
  638. if (index > -1) {
  639. state.selectRowData.splice(index, 1)
  640. }
  641. const index1 = checkedRowKeysRef.value.findIndex((item: any) => {
  642. if (item == row.id) {
  643. return true
  644. }
  645. })
  646. if (index1 > -1) {
  647. checkedRowKeysRef.value.splice(index, 1)
  648. }
  649. } catch {}
  650. }
  651. })
  652. }}
  653. >
  654. 移除
  655. </NButton>
  656. </NSpace>
  657. )
  658. }
  659. })
  660. return field
  661. }
  662. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  663. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  664. checkedRowKeysRef.value = rowKeys
  665. // 添加行更新值
  666. state.dataList.forEach((next: any) => {
  667. if (checkedRowKeysRef.value.includes(next.id)) {
  668. const find = state.selectRowData.find((row: any) => {
  669. return row.id === next.id
  670. })
  671. if (!find) {
  672. state.selectRowData.push({
  673. ...next,
  674. status: false,
  675. paymentType: [] as any,
  676. musicPriceDisable: false // 默认可以编辑曲目价格
  677. })
  678. }
  679. }
  680. })
  681. // 去掉行更新值
  682. state.selectRowData = state.selectRowData.filter((next: any) => {
  683. return checkedRowKeysRef.value.includes(next.id)
  684. })
  685. }
  686. return () => {
  687. return (
  688. <div class="system-menu-container">
  689. <NSpace vertical size="medium">
  690. <NSteps
  691. current={state.currentStep}
  692. // onUpdateCurrent={()=>{
  693. // state.currentStep = val
  694. // }}
  695. style={'margin-bottom: 10px;margin-top: 10px'}
  696. >
  697. <NStep title="选择曲目" description=""></NStep>
  698. <NStep title="设置曲目信息" description=""></NStep>
  699. </NSteps>
  700. </NSpace>
  701. {state.currentStep === 1 && (
  702. <div class="system-menu-container">
  703. <SaveForm
  704. ref={saveForm}
  705. model={state.searchForm}
  706. onSubmit={onSubmit}
  707. saveKey="klx-addMusic"
  708. onSetModel={(val: any) => (state.searchForm = val)}
  709. >
  710. <NFormItem label="关键词" path="keyword">
  711. <NInput
  712. v-model:value={state.searchForm.keyword}
  713. placeholder="请输入曲目名称/编号"
  714. clearable
  715. />
  716. </NFormItem>
  717. {/* <NFormItem label="谱面渲染" path="musicSheetType">
  718. <NSelect
  719. placeholder="请选择谱面渲染"
  720. v-model:value={state.searchForm.musicSheetType}
  721. options={getSelectDataFromObj(musicSheetType)}
  722. clearable
  723. />
  724. </NFormItem> */}
  725. <NFormItem label="可用声部" path="musicSubject">
  726. <NSelect
  727. placeholder="请选择可用声部"
  728. v-model:value={state.searchForm.subjectId}
  729. options={state.subjectList}
  730. clearable
  731. filterable
  732. />
  733. </NFormItem>
  734. <NFormItem label="音乐人" path="composer">
  735. <NInput
  736. placeholder="请选择音乐人"
  737. v-model:value={state.searchForm.composer}
  738. clearable
  739. />
  740. </NFormItem>
  741. <NFormItem label="曲目来源" path="sourceType">
  742. <NSelect
  743. placeholder="请选择曲目来源"
  744. v-model:value={state.searchForm.sourceType}
  745. options={getSelectDataFromObj(musicSheetSourceType)}
  746. onUpdateValue={async (value: any) => {
  747. state.userIdData = []
  748. state.searchForm.userId = null
  749. if (value && value !== 'PLATFORM') {
  750. await updateUserIdData(value)
  751. state.userIdDisable = false
  752. } else {
  753. state.userIdDisable = true
  754. }
  755. }}
  756. clearable
  757. />
  758. </NFormItem>
  759. <NFormItem label="所属项目" path="applicationId">
  760. <NSelect
  761. placeholder="请选择所属项目"
  762. v-model:value={state.searchForm.applicationId}
  763. options={state.useProjectData}
  764. clearable
  765. onUpdateValue={async (value: any) => {
  766. state.searchForm.applicationId = value
  767. if (value) {
  768. await updateUserIdData(state.searchForm.sourceType)
  769. state.userIdDisable = !(
  770. state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM'
  771. )
  772. } else {
  773. state.searchForm.userId = null
  774. state.userIdDisable = true
  775. state.userIdData = []
  776. }
  777. }}
  778. />
  779. </NFormItem>
  780. <NFormItem label="所属人" path="author">
  781. <NSelect
  782. filterable
  783. placeholder="请选择所属人"
  784. disabled={
  785. state.userIdDisable ||
  786. (!state.searchForm.applicationId && !state.searchForm.sourceType)
  787. }
  788. v-model:value={state.searchForm.userId}
  789. options={state.userIdData}
  790. clearable
  791. ></NSelect>
  792. </NFormItem>
  793. <NFormItem>
  794. <NSpace>
  795. <NButton type="primary" onClick={onSearch}>
  796. 搜索
  797. </NButton>
  798. <NButton type="default" onClick={onBtnReset}>
  799. 重置
  800. </NButton>
  801. </NSpace>
  802. </NFormItem>
  803. </SaveForm>
  804. <p style={{ paddingBottom: '12px' }}>
  805. 你选择了<span style={'color:red;padding:0 8px'}>{state.selectRowData.length}</span>
  806. 条曲目
  807. </p>
  808. <NDataTable
  809. loading={state.loading}
  810. columns={columns()}
  811. data={state.dataList}
  812. rowKey={(row: any) => row.id}
  813. onUpdateCheckedRowKeys={handleCheck}
  814. v-model:checkedRowKeys={checkedRowKeysRef.value}
  815. ></NDataTable>
  816. <Pagination
  817. v-model:page={state.pagination.page}
  818. v-model:pageSize={state.pagination.rows}
  819. v-model:pageTotal={state.pagination.pageTotal}
  820. onList={getList}
  821. sync
  822. saveKey="klx-addMusic"
  823. ></Pagination>
  824. </div>
  825. )}
  826. {state.currentStep === 2 && (
  827. <div class="system-menu-container" style={'margin-top: 15px;'}>
  828. <NDataTable
  829. loading={state.loading}
  830. columns={stepColumns()}
  831. data={state.selectRowData}
  832. rowKey={(row: any) => row.id}
  833. maxHeight={500}
  834. scrollX={2500}
  835. ></NDataTable>
  836. </div>
  837. )}
  838. <NSpace justify="end" style={'margin-top:10px'}>
  839. <NButton
  840. type="default"
  841. onClick={() => {
  842. if (state.currentStep > 1) {
  843. state.currentStep = state.currentStep - 1
  844. } else {
  845. emit('close')
  846. }
  847. }}
  848. >
  849. {state.currentStep === 1 ? '取消' : '上一步'}
  850. </NButton>
  851. <NButton
  852. type="primary"
  853. onClick={() => {
  854. if (state.currentStep < 2) {
  855. if (state.selectRowData.length == 0) {
  856. message.warning('请选择曲目')
  857. return
  858. }
  859. state.currentStep = state.currentStep + 1
  860. } else {
  861. onSave()
  862. }
  863. }}
  864. // loading={btnLoading.value}
  865. // disabled={btnLoading.value}
  866. >
  867. {state.currentStep === 2 ? '确定' : '下一步'}
  868. </NButton>
  869. </NSpace>
  870. </div>
  871. )
  872. }
  873. }
  874. })