浏览代码

问题修改

yuanliang 1 年之前
父节点
当前提交
419a5deac4

+ 18 - 18
src/views/music-library/music-sheet/component/music-list.tsx

@@ -534,6 +534,24 @@ export default defineComponent({
               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="请选择项目"
@@ -555,24 +573,6 @@ export default defineComponent({
                 }}
             />
           </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="userId">
             <NSelect
               filterable

+ 132 - 77
src/views/music-library/music-sheet/modal/music-operation.tsx

@@ -1,15 +1,18 @@
-import type { SelectOption } from 'naive-ui'
+import type {SelectOption} from 'naive-ui'
 import {
   NAlert,
   NButton,
   NCascader,
   NCheckbox,
   NCheckboxGroup,
-  NForm, NFormItem,
+  NForm,
+  NFormItem,
   NFormItemGi,
   NGi,
   NGrid,
-  NInput, NInputGroup, NInputGroupLabel,
+  NInput,
+  NInputGroup,
+  NInputGroupLabel,
   NInputNumber,
   NModal,
   NRadio,
@@ -20,20 +23,21 @@ import {
   useDialog,
   useMessage
 } from 'naive-ui'
-import { defineComponent, onMounted, PropType, reactive, ref } from 'vue'
-import { musicSheetCategoriesQueryTree, musicSheetDetail, musicSheetSave } from '../../api'
+import {defineComponent, nextTick, onMounted, PropType, reactive, ref} from 'vue'
+import {musicSheetCategoriesQueryTree, musicSheetDetail, musicSheetSave} from '../../api'
 import UploadFile from '@/components/upload-file'
 import styles from './index.module.less'
 import deepClone from '@/utils/deep.clone'
 import axios from 'axios'
-import { appKey, clientType, musicSheetSourceType, musicSheetType } from '@/utils/constant'
-import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
-import { musicalInstrumentPage } from '@views/system-manage/subject-manage/api'
-import { subjectPage } from '@views/system-manage/api'
+import {appKey, clientType, musicSheetSourceType, musicSheetType} from '@/utils/constant'
+import {getMapValueByKey, getSelectDataFromObj} from '@/utils/objectUtil'
+import {musicalInstrumentPage} from '@views/system-manage/subject-manage/api'
+import {subjectPage} from '@views/system-manage/api'
 import MusicSheetOwnerDialog from '@views/music-library/music-sheet/modal/musicSheetOwnerDialog'
-import { sysApplicationPage } from '@views/menu-manage/api'
-import { filterPointCategory } from '@views/teaching-manage/unit-test'
+import {sysApplicationPage} from '@views/menu-manage/api'
+import {filterPointCategory} from '@views/teaching-manage/unit-test'
 import MusicCreateImg from './music-create-img'
+import {onUpdated} from "vue-demi";
 
 /**
  * 获取指定元素下一个Note元素
@@ -437,6 +441,15 @@ export default defineComponent({
       xmlRead.readAsText(file)
     }
 
+    const containOther = (track:any)=>{
+      for (let i = 0; i < state.partListNames.length; i++) {
+        if(state.partListNames[i].value == track){
+          return true
+        }
+      }
+      return false;
+    }
+
     const parseInstrumentAndSubject = (xml: any) => {
       if (!xml) return
       const xmlParse = new DOMParser().parseFromString(xml, 'text/xml')
@@ -505,15 +518,23 @@ export default defineComponent({
       //   (n: any) => n.value?.toLocaleUpperCase?.() != 'COMMON'
       // )
       const partListNames = deepClone(state.partListNames) || []
+      const multiTracksSelection = forms.multiTracksSelection;
       partListNames.forEach((item: any) => {
-        const index = forms.musicSheetSoundList.findIndex(
-          (ground: any) => item.value == ground.track
-        )
-        if (index > -1 && track == item.value) {
-          item.disabled = false
-        } else {
+        if (multiTracksSelection.includes(item.value)) {
           item.disabled = true
+        } else {
+          item.disabled = false
         }
+
+        // const index = forms.musicSheetSoundList.findIndex(
+        //   (ground: any) => item.value == ground.track
+        // )
+
+        // if (index > -1 && track == item.value) {
+        //   item.disabled = false
+        // } else {
+        //   item.disabled = true
+        // }
       })
       return partListNames || []
     }
@@ -697,7 +718,7 @@ export default defineComponent({
               }
             })
           }
-          forms.musicalInstrumentIdList = data.musicalInstrumentIds?.split(',') || []
+          forms.musicalInstrumentIdList = data.musicalInstrumentIds ? data.musicalInstrumentIds.split(',') : []
           forms.musicCategoryId = data.musicCategoryId
           data.musicSheetAccompanimentList?.forEach((next: any) => {
             state.musicSheetAccompanimentUrlList.push(next.audioFileUrl)
@@ -724,9 +745,10 @@ export default defineComponent({
               state.partListNames = getPartListNames(res?.data as any) as any
 
               // 初始化音轨和原音
-              forms.multiTracksSelection = data.multiTracksSelection?.split(',') || []
+              forms.multiTracksSelection = data.multiTracksSelection ? data.multiTracksSelection.split(',') : []
 
               const existSoundList = data.musicSheetSoundList || []
+              const tracks = [] as any
               state.partListNames.forEach((item: any) => {
                 let audioFileUrl
                 existSoundList.forEach((next: any) => {
@@ -734,9 +756,22 @@ export default defineComponent({
                     audioFileUrl = next.audioFileUrl
                   }
                 })
+                if (audioFileUrl) {
+                  forms.musicSheetSoundList.push({
+                    audioFileUrl: audioFileUrl, // 原音
+                    track: item.value // 轨道
+                  })
+                  tracks.push(item.value)
+                }
+              })
+
+              // 处理没有声轨,但有原音
+              existSoundList.filter((next: any) => {
+                return !tracks.includes(next.track)
+              }).forEach((next: any) => {
                 forms.musicSheetSoundList.push({
-                  audioFileUrl: audioFileUrl, // 原音
-                  track: item.value // 轨道
+                  audioFileUrl: next.audioFileUrl, // 原音
+                  track: next.track ? next.track : null // 轨道
                 })
               })
             }
@@ -1395,72 +1430,92 @@ export default defineComponent({
             {/* 只有播放类型为mp3时才会有原音 */}
             {forms.playMode === 'MP3' && forms.musicSheetSoundList.length > 0 && (
               <>
-                {forms.musicSheetSoundList.map((item: any, index: number) => (
-                  <>
-                    {((!item.track)||(item.track?.toLocaleUpperCase?.() != 'COMMON' && forms.multiTracksSelection.indexOf(item.track) > -1))
-                        && (
-                            <NGrid
-                                class={styles.audioSection}
-                                // v-show={forms.multiTracksSelection.indexOf(item.track) > -1}
-                            >
-                              <NFormItemGi
-                                  span={12}
-                                  label="原音"
-                                  path={`musicSheetSoundList[${index}].audioFileUrl`}
-                                  rule={[
-                                    {
-                                      // required: forms.multiTracksSelection.indexOf(forms.musicSheetSoundList[index].audioFileUrl) > -1,
-                                      required: true,
-                                      message: `请上传${
-                                          item.track ? item.track + '的' : '第' + (index + 1) + '个'
-                                      }原音`
-                                    }
-                                  ]}
-                              >
-                                <UploadFile
-                                    desc={'原音文件'}
-                                    disabled={state.previewMode}
-                                    size={100}
-                                    v-model:fileList={item.audioFileUrl}
-                                    tips="仅支持上传.mp3格式文件"
-                                    listType="image"
-                                    accept=".mp3"
-                                    bucketName="cloud-coach"
-                                />
-                              </NFormItemGi>
-                              {state.partListNames.length > 1 && (
+                {forms.musicSheetSoundList.map((item: any, index: number) => {
+                  return (
+                      <>
+                        {(!containOther(item.track) || (item.track?.toLocaleUpperCase?.() != 'COMMON' && forms.multiTracksSelection.includes(item.track)))
+                            && (
+                                <NGrid
+                                    class={styles.audioSection}
+                                    // v-show={forms.multiTracksSelection.indexOf(item.track) > -1}
+                                >
                                   <NFormItemGi
                                       span={12}
-                                      label="所属轨道"
-                                      path={`musicSheetSoundList[${index}].track`}
+                                      label="原音"
+                                      path={`musicSheetSoundList[${index}].audioFileUrl`}
                                       rule={[
                                         {
+                                          // required: forms.multiTracksSelection.indexOf(forms.musicSheetSoundList[index].audioFileUrl) > -1,
                                           required: true,
-                                          message: '请选择所属轨道'
+                                          message: `请上传${
+                                              item.track ? item.track + '的' : '第' + (index + 1) + '个'
+                                          }原音`
                                         }
                                       ]}
                                   >
-                                    <NSelect
-                                        placeholder="请选择所属轨道"
-                                        v-model:value={item.track}
-                                        options={initPartsListStatus(item.track)}
+                                    <UploadFile
+                                        desc={'原音文件'}
+                                        disabled={state.previewMode}
+                                        size={100}
+                                        v-model:fileList={item.audioFileUrl}
+                                        tips="仅支持上传.mp3格式文件"
+                                        listType="image"
+                                        accept=".mp3"
+                                        bucketName="cloud-coach"
                                     />
                                   </NFormItemGi>
-                              )}
-                              <NGi class={styles.btnRemove}>
-                                <NButton
-                                    type="primary"
-                                    text
-                                    disabled={forms.musicSheetSoundList.length === 1}
-                                    onClick={() => removeSys(index)}
-                                >
-                                  删除
-                                </NButton>
-                              </NGi>
-                            </NGrid>
-                        )}
-                  </>
-                ))}
+                                  {state.partListNames.length > 0 && (
+                                      <NFormItemGi
+                                          span={12}
+                                          label="所属轨道"
+                                          path={`musicSheetSoundList[${index}].track`}
+                                          rule={[
+                                            {
+                                              required: true,
+                                              message: '请选择所属轨道'
+                                            }
+                                          ]}
+                                      >
+                                        <NSelect
+                                            placeholder="请选择所属轨道"
+                                            value={item.track}
+                                            options={initPartsListStatus(item.track)}
+                                            onUpdateValue={(value: any) => {
+                                              const track = item.track
+                                              // 声轨交换
+                                              forms.musicSheetSoundList.forEach((next:any)=>{
+                                                if (next.track == value) {
+                                                  next.track = track
+                                                }
+                                              })
+
+                                              if (track) {
+                                                const index = forms.multiTracksSelection.indexOf(item.track)
+                                                forms.multiTracksSelection.splice(index, 1)
+                                              }
+                                              if (value && !forms.multiTracksSelection.includes(value)) {
+                                                forms.multiTracksSelection.push(value)
+                                              }
+                                              item.track = value
+                                            }}
+                                        />
+                                      </NFormItemGi>
+                                  )}
+                                  <NGi class={styles.btnRemove}>
+                                    <NButton
+                                        type="primary"
+                                        text
+                                        disabled={forms.musicSheetSoundList.length === 1}
+                                        onClick={() => removeSys(index)}
+                                    >
+                                      删除
+                                    </NButton>
+                                  </NGi>
+                                </NGrid>
+                            )}
+                      </>
+                  );
+                })}
               </>
             )}
           </NForm>

+ 23 - 19
src/views/music-library/project-music-sheet/module/gym/addMusic.tsx

@@ -157,9 +157,12 @@ export default defineComponent({
     const getList = async () => {
       try {
         state.loading = true
+        const sourceType = state.searchForm.sourceType
         const { data } = await musicSheetPage({
           ...state.pagination,
           ...state.searchForm,
+          userId: (sourceType && sourceType === 'PERSON') ? state.searchForm.userId : null,
+          organizationRoleId: (sourceType && sourceType === 'ORG') ? state.searchForm.userId : null,
           addAppId: props.appId
         })
         state.pagination.pageTotal = Number(data.total)
@@ -194,7 +197,7 @@ export default defineComponent({
           message.error('曲目分类不能为空')
           return
         }
-        if (!item.sortNo || !item.projectMusicCategoryId) {
+        if (item.sortNo === null || item.sortNo === undefined || item.sortNo === '') {
           message.error('排序号不能为空')
           return
         }
@@ -640,6 +643,24 @@ export default defineComponent({
                       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 = false
+                        } else {
+                          state.userIdDisable = true
+                        }
+                      }}
+                      clearable
+                  />
+                </NFormItem>
                 <NFormItem label="项目" path="applicationId">
                   <NSelect
                       placeholder="请选择项目"
@@ -661,24 +682,7 @@ export default defineComponent({
                       }}
                   />
                 </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 = false
-                        } else {
-                          state.userIdDisable = true
-                        }
-                      }}
-                      clearable
-                  />
-                </NFormItem>
+
                 <NFormItem label="所属人" path="author">
                   <NSelect
                       filterable

+ 74 - 25
src/views/music-library/project-music-sheet/module/gym/music-sheet-gym.tsx

@@ -23,6 +23,7 @@ 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,
@@ -79,7 +80,8 @@ export default defineComponent({
         topFlag: null, //是否置顶(0:否;1:是)
         availableType: null, //可用途径 ORG 机构 PLATFORM 平台
         appAuditFlag: null, //是否审核版本
-        detailFlag: null //是否查询详情
+        detailFlag: null, //是否查询详情
+        applicationId: null, //所属人项目ID
       },
       subjectList: [],
       dataList: [] as any[],
@@ -92,6 +94,7 @@ export default defineComponent({
       applicationId: null, //应用ID
       musicPreview: false,
       musicScore: null as any,
+      useProjectData: [] as any, // 适用项目行数据
     })
 
     onMounted(async () => {
@@ -134,10 +137,29 @@ export default defineComponent({
       } 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 = () => {
@@ -161,17 +183,11 @@ export default defineComponent({
       try {
         state.loading = true
         const sourceType = state.searchForm.sourceType
-        let userId = state.searchForm.userId
-        let organizationRoleId = null
-        if (sourceType && sourceType === 'ORG') {
-          organizationRoleId = deepClone(userId)
-          userId = null
-        }
         const { data } = await musicSheetPageByApplication({
           ...state.pagination,
           ...state.searchForm,
-          userId: userId,
-          organizationRoleId: organizationRoleId,
+          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
         })
@@ -225,6 +241,30 @@ export default defineComponent({
       })
     }
 
+    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 columns = (): any => {
       return [
         {
@@ -408,21 +448,8 @@ export default defineComponent({
                   state.userIdData = []
                   state.searchForm.userId = null
                   if (value && value !== 'PLATFORM') {
-                    const { data } = await musicSheetApplicationOwnerList({
-                      page: 1,
-                      rows: 9999,
-                      sourceType: value,
-                      applicationId: state.appId
-                    })
-                    const temp = data.rows || []
-                    temp.forEach((next: any) => {
-                      state.userIdData.push({
-                        ...next,
-                        label: value === 'PERSON' ? next.userName : next.organizationRole,
-                        value: value === 'PERSON' ? next.userId : next.organizationRoleId
-                      })
-                    })
-                    state.userIdDisable = false
+                    await updateUserIdData(value)
+                    state.userIdDisable = !state.searchForm.applicationId
                   } else {
                     state.userIdDisable = true
                   }
@@ -430,8 +457,30 @@ export default defineComponent({
                 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">
               <NSelect
+                filterable
                 placeholder="请选择所属人"
                 disabled={state.userIdDisable}
                 v-model:value={state.searchForm.userId}

+ 19 - 19
src/views/music-library/project-music-sheet/module/gyt/addMusic.tsx

@@ -194,7 +194,7 @@ export default defineComponent({
           message.error('曲目分类不能为空')
           return
         }
-        if (!item.sortNo || !item.projectMusicCategoryId) {
+        if (item.sortNo === null || item.sortNo === undefined || item.sortNo === '') {
           message.error('排序号不能为空')
           return
         }
@@ -553,6 +553,24 @@ export default defineComponent({
                       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 = false
+                        } else {
+                          state.userIdDisable = true
+                        }
+                      }}
+                      clearable
+                  />
+                </NFormItem>
                 <NFormItem label="项目" path="applicationId">
                   <NSelect
                       placeholder="请选择项目"
@@ -574,24 +592,6 @@ export default defineComponent({
                       }}
                   />
                 </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 = false
-                        } else {
-                          state.userIdDisable = true
-                        }
-                      }}
-                      clearable
-                  />
-                </NFormItem>
                 <NFormItem label="所属人" path="author">
                   <NSelect
                       filterable

+ 76 - 24
src/views/music-library/project-music-sheet/module/gyt/music-sheet-gyt.tsx

@@ -23,6 +23,7 @@ import TheTooltip from '@components/TheTooltip'
 import AddMusic from '@views/music-library/project-music-sheet/module/gyt/addMusic'
 import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
 import {
+  appKey,
   musicSheetAudioType,
   musicSheetPaymentType,
   musicSheetSourceType,
@@ -78,7 +79,8 @@ export default defineComponent({
         topFlag: null, //是否置顶(0:否;1:是)
         availableType: null, //可用途径 ORG 机构 PLATFORM 平台
         appAuditFlag: null, //是否审核版本
-        detailFlag: null //是否查询详情
+        detailFlag: null, //是否查询详情
+        applicationId: null, //所属人项目ID
       },
       subjectList: [],
       dataList: [] as any[],
@@ -91,6 +93,7 @@ export default defineComponent({
       applicationId: null, //应用ID
       musicPreview: false,
       musicScore: null as any,
+      useProjectData: [] as any, // 适用项目行数据
     })
 
     onMounted(async () => {
@@ -132,6 +135,7 @@ export default defineComponent({
 
       // 加载表格数据
 
+      initUseAppList()
       getList()
     })
 
@@ -149,6 +153,51 @@ export default defineComponent({
       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 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 checkedRowKeysRef = ref<DataTableRowKey[]>([])
     const handleCheck = (rowKeys: DataTableRowKey[]) => {
       checkedRowKeysRef.value = rowKeys
@@ -158,17 +207,11 @@ export default defineComponent({
       try {
         state.loading = true
         const sourceType = state.searchForm.sourceType
-        let userId = state.searchForm.userId
-        let organizationRoleId = null
-        if (sourceType && sourceType === 'ORG') {
-          organizationRoleId = deepClone(userId)
-          userId = null
-        }
         const { data } = await musicSheetPageByApplication({
           ...state.pagination,
           ...state.searchForm,
-          userId: userId,
-          organizationRoleId: organizationRoleId,
+          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
         })
@@ -412,21 +455,8 @@ export default defineComponent({
                   state.userIdData = []
                   state.searchForm.userId = null
                   if (value && value !== 'PLATFORM') {
-                    const { data } = await musicSheetApplicationOwnerList({
-                      page: 1,
-                      rows: 9999,
-                      sourceType: value,
-                      applicationId: state.appId
-                    })
-                    const temp = data.rows || []
-                    temp.forEach((next: any) => {
-                      state.userIdData.push({
-                        ...next,
-                        label: value === 'PERSON' ? next.userName : next.organizationRole,
-                        value: value === 'PERSON' ? next.userId : next.organizationRoleId
-                      })
-                    })
-                    state.userIdDisable = false
+                    await updateUserIdData(value)
+                    state.userIdDisable = !state.searchForm.applicationId
                   } else {
                     state.userIdDisable = true
                   }
@@ -434,8 +464,30 @@ export default defineComponent({
                 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">
               <NSelect
+                filterable
                 placeholder="请选择所属人"
                 disabled={state.userIdDisable}
                 v-model:value={state.searchForm.userId}

+ 18 - 18
src/views/music-library/project-music-sheet/module/klx/addMusic.tsx

@@ -1013,6 +1013,24 @@ export default defineComponent({
                       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 = false
+                      } else {
+                        state.userIdDisable = true
+                      }
+                    }}
+                    clearable
+                  />
+                </NFormItem>
                 <NFormItem label="项目" path="applicationId">
                   <NSelect
                       placeholder="请选择项目"
@@ -1034,24 +1052,6 @@ export default defineComponent({
                       }}
                   />
                 </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 = false
-                      } else {
-                        state.userIdDisable = true
-                      }
-                    }}
-                    clearable
-                  />
-                </NFormItem>
                 <NFormItem label="所属人" path="author">
                   <NSelect
                       filterable

+ 87 - 31
src/views/music-library/project-music-sheet/module/klx/music-sheet-klx.tsx

@@ -22,6 +22,7 @@ import TheTooltip from '@components/TheTooltip'
 import AddMusic from '@views/music-library/project-music-sheet/module/klx/addMusic'
 import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
 import {
+  appKey,
   musicSheetAudioType,
   musicSheetAvailableType,
   musicSheetPaymentType,
@@ -78,7 +79,8 @@ export default defineComponent({
         availableType: null, //可用途径 ORG 机构 PLATFORM 平台
         appAuditFlag: null, //是否审核版本
         detailFlag: null, //是否查询详情
-        musicTagIds: [] as any //曲目标签
+        musicTagIds: [] as any,//曲目标签
+        applicationId: null, //所属人项目ID
       },
       subjectList: [],
       dataList: [] as any[],
@@ -91,6 +93,7 @@ export default defineComponent({
       applicationId: null, //应用ID
       musicPreview: false,
       musicScore: null as any,
+      useProjectData: [] as any, // 适用项目行数据
     })
 
     onMounted(async () => {
@@ -137,7 +140,7 @@ export default defineComponent({
       } catch (err) {}
 
       // 加载表格数据
-
+      initUseAppList()
       getList()
     })
 
@@ -155,6 +158,25 @@ export default defineComponent({
       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 checkedRowKeysRef = ref<DataTableRowKey[]>([])
     const handleCheck = (rowKeys: DataTableRowKey[]) => {
       checkedRowKeysRef.value = rowKeys
@@ -173,8 +195,8 @@ export default defineComponent({
         const { data } = await musicSheetPageByApplication({
           ...state.pagination,
           ...state.searchForm,
-          userId: userId,
-          organizationRoleId: organizationRoleId,
+          userId: (sourceType && sourceType === 'PERSON') ? state.searchForm.userId : null,
+          organizationRoleId: (sourceType && sourceType === 'ORG') ? state.searchForm.userId : null,
           musicTagIds: state.searchForm.musicTagIds?.join(','),
           ...filterTimes(state.searchForm.times, ['startTime', 'endTime']),
           applicationId: state.applicationId
@@ -243,6 +265,31 @@ export default defineComponent({
       return paymentTypeName.join(',')
     }
 
+    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 columns = (): any => {
       return [
         {
@@ -447,37 +494,46 @@ export default defineComponent({
             </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') {
-                    const { data } = await musicSheetApplicationOwnerList({
-                      page: 1,
-                      rows: 9999,
-                      sourceType: value,
-                      applicationId: state.appId
-                    })
-                    const temp = data.rows || []
-                    temp.forEach((next: any) => {
-                      state.userIdData.push({
-                        ...next,
-                        label: value === 'PERSON' ? next.userName : next.organizationRole,
-                        value: value === 'PERSON' ? next.userId : next.organizationRoleId
-                      })
-                    })
-                    state.userIdDisable = false
-                  } else {
-                    state.userIdDisable = true
-                  }
-                }}
-                clearable
+                  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">
               <NSelect
+                filterable
                 placeholder="请选择所属人"
                 disabled={state.userIdDisable}
                 v-model:value={state.searchForm.userId}

+ 18 - 18
src/views/music-library/project-music-sheet/module/kt/addMusic.tsx

@@ -560,6 +560,24 @@ export default defineComponent({
                       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 = false
+                        } else {
+                          state.userIdDisable = true
+                        }
+                      }}
+                      clearable
+                  />
+                </NFormItem>
                 <NFormItem label="项目" path="applicationId">
                   <NSelect
                       placeholder="请选择项目"
@@ -581,24 +599,6 @@ export default defineComponent({
                       }}
                   />
                 </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 = false
-                        } else {
-                          state.userIdDisable = true
-                        }
-                      }}
-                      clearable
-                  />
-                </NFormItem>
                 <NFormItem label="所属人" path="author">
                   <NSelect
                       filterable

+ 87 - 37
src/views/music-library/project-music-sheet/module/kt/music-sheet-kt.tsx

@@ -29,7 +29,7 @@ import {
   musicSheetPageByApplication
 } from '@views/music-library/api'
 import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
-import { musicSheetAudioType, musicSheetSourceType, musicSheetType } from '@/utils/constant'
+import {appKey, musicSheetAudioType, musicSheetSourceType, musicSheetType} from '@/utils/constant'
 import { sysApplicationPage } from '@views/menu-manage/api'
 import { musicSheetApplicationExtendSubjectList } from '@views/system-manage/api'
 import { filterTimes } from '@/utils/dateUtil'
@@ -76,7 +76,8 @@ export default defineComponent({
         topFlag: null, //是否置顶(0:否;1:是)
         availableType: null, //可用途径 ORG 机构 PLATFORM 平台
         appAuditFlag: null, //是否审核版本
-        detailFlag: null //是否查询详情
+        detailFlag: null, //是否查询详情
+        applicationId: null, //所属人项目ID
       },
       subjectList: [],
       dataList: [] as any[],
@@ -89,6 +90,7 @@ export default defineComponent({
       applicationId: null, //应用ID
       musicPreview: false,
       musicScore: null as any,
+      useProjectData: [] as any, // 适用项目行数据
     })
 
     onMounted(async () => {
@@ -127,9 +129,30 @@ export default defineComponent({
         }
       } 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 = () => {
@@ -153,17 +176,11 @@ export default defineComponent({
       state.loading = true
       try {
         const sourceType = state.searchForm.sourceType
-        let userId = state.searchForm.userId
-        let organizationRoleId = null
-        if (sourceType && sourceType === 'ORG') {
-          organizationRoleId = deepClone(userId)
-          userId = null
-        }
         const { data } = await musicSheetPageByApplication({
           ...state.pagination,
           ...state.searchForm,
-          userId: userId,
-          organizationRoleId: organizationRoleId,
+          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
         })
@@ -217,6 +234,31 @@ export default defineComponent({
       })
     }
 
+    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 columns = (): any => {
       return [
         {
@@ -396,33 +438,41 @@ export default defineComponent({
             </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') {
-                    const { data } = await musicSheetApplicationOwnerList({
-                      page: 1,
-                      rows: 9999,
-                      sourceType: value,
-                      applicationId: state.appId
-                    })
-                    const temp = data.rows || []
-                    temp.forEach((next: any) => {
-                      state.userIdData.push({
-                        ...next,
-                        label: value === 'PERSON' ? next.userName : next.organizationRole,
-                        value: value === 'PERSON' ? next.userId : next.organizationRoleId
-                      })
-                    })
-                    state.userIdDisable = false
-                  } else {
-                    state.userIdDisable = true
-                  }
-                }}
-                clearable
+                  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">