yuanliang 1 год назад
Родитель
Сommit
23ce8427f6

+ 15 - 3
src/views/music-library/api.ts

@@ -124,6 +124,18 @@ export const musicSheetStatusList = (params?: any) => {
   } as any)
 }
 
+/**
+ *  @description: 查询分页(不同应用) 项目曲目
+ * @param params
+ */
+export const musicSheetPageByApplication = (params?: any) => {
+  return request({
+    url: '/cbs-app/musicSheet/pageByApplication',
+    method: 'post',
+    data: params
+  } as any)
+}
+
 
 //---
 
@@ -258,12 +270,12 @@ export const musicSheetApplicationExtendCategoryApplicationExtendInfo = (params?
 }
 
 /**
- *  @description: 查询分页(不同应用) 项目曲目
+ *  @description: 曲目应用拓展表 批量保存
  * @param params
  */
-export const musicSheetPageByApplication = (params?: any) => {
+export const musicSheetApplicationExtendSaveBatch = (params?: any) => {
   return request({
-    url: '/cbs-app/musicSheet/pageByApplication',
+    url: '/cbs-app/musicSheetApplicationExtend/saveBatch',
     method: 'post',
     data: params
   } as any)

+ 1 - 1
src/views/music-library/music-sheet/modal/use-project.tsx

@@ -91,7 +91,7 @@ export default defineComponent({
 
       // 加载不同项目的曲目分类列表
       const projectIdArr = [] as any
-      const appIdCodeMap = new Map<number, string>
+      const appIdCodeMap = new Map<number, string>;
       props.useProject.forEach((project: any) => {
         projectIdArr.push(project.id)
         appIdCodeMap.set(project.id, project.appKey)

+ 121 - 31
src/views/music-library/project-music-sheet/module/cooleshow-edu/addMusic.tsx

@@ -1,29 +1,11 @@
-import {h, defineComponent, onMounted, reactive, ref} from "vue";
+import {defineComponent, h, onMounted, reactive, ref} from "vue";
 import SaveForm from "@components/save-form";
-import {
-  DataTableColumns,
-  DataTableRowKey,
-  NButton,
-  NCascader,
-  NDataTable,
-  NDescriptions,
-  NDescriptionsItem,
-  NFormItem,
-  NIcon,
-  NImage,
-  NInput,
-  NInputNumber,
-  NSelect,
-  NSpace,
-  NStep,
-  NSteps, useDialog
-} from "naive-ui";
+import {DataTableColumns, DataTableRowKey, NButton, NCascader, NDataTable, NFormItem, NIcon, NImage, NInput, NInputNumber, NSelect, NSpace, NStep, NSteps, useDialog, useMessage} from "naive-ui";
 import Pagination from "@components/pagination";
 import {getMapValueByKey, getSelectDataFromObj} from "@/utils/objectUtil";
 import {musicSheetSourceType, musicSheetType} from "@/utils/constant";
-import {musicSheetPage} from "@views/music-library/api";
+import {musicSheetApplicationExtendSaveBatch, musicSheetPage} from "@views/music-library/api";
 import deepClone from "@/utils/deep.clone";
-import {helpCenterCatalogRemove} from "@views/content-manage/api";
 
 export default defineComponent({
   name: 'project-music-sheet-mec',
@@ -41,8 +23,10 @@ export default defineComponent({
       default: () => []
     }
   },
+  emits: ['close', 'getList'],
   setup(props, {slots, attrs, emit}) {
     const dialogs = useDialog()
+    const message = useMessage()
     const state = reactive({
       loading: false,
       pagination: {
@@ -68,6 +52,7 @@ export default defineComponent({
       selectRowData: [] as any,// 选择的数据列表
       musicSheetCategories: [] as any,
       startSortNum: null as any,// 排序起始值
+      projectMusicCategoryId: null as any,// 曲目分类ID
     })
 
     onMounted(() => {
@@ -105,6 +90,40 @@ export default defineComponent({
       getList()
     }
 
+    const onSave = async () => {
+      if (state.selectRowData.length == 0) {
+        message.error('未选择曲目');
+        return;
+      }
+      const params = [] as any[];
+      for (let i = 0; i < state.selectRowData.length; i++) {
+        const item = state.selectRowData[i];
+        if (!item.projectMusicCategoryId) {
+          message.error('曲目分类不能为空')
+          return;
+        }
+        if (!item.sortNo || !item.projectMusicCategoryId) {
+          message.error('排序号不能为空')
+          return;
+        }
+        params.push({
+          ...item,
+          musicSheetId: item.id,
+          musicSheetCategoryId: item.projectMusicCategoryId,
+          applicationId: props.appId,
+          id: null
+        })
+      }
+      const res = await musicSheetApplicationExtendSaveBatch(params) as any
+      if (res && res.code == '200') {
+        message.success(`添加成功`)
+        emit('getList')
+        emit('close')
+      }
+
+
+    }
+
     const columnsField = [
       {
         type: 'selection'
@@ -163,7 +182,61 @@ export default defineComponent({
       const field = deepClone(columnsField);
       field.splice(0, 1)
       field.push({
-        title: '曲目分类',
+        title(column: any) {
+          return (
+              <NSpace>
+                曲目分类
+                <NButton type="primary"
+                         size="small"
+                         text
+                         onClick={() => {
+                           dialogs.create({
+                             title: "请选择曲目分类",
+                             showIcon: false,
+                             content: () => {
+                               return h(
+                                   "div",
+                                   {
+                                     class: "flex flex-col justify-center items-center text-14px",
+                                   },
+                                   [
+                                     // icon
+                                     h(NCascader, {
+                                       onUpdateValue(v) {
+                                         state.projectMusicCategoryId = v
+                                       },
+                                       valueField: 'id',
+                                       labelField: "name",
+                                       childrenField: 'children',
+                                       placeholderField: '请选择曲目分类',
+                                       options: state.musicSheetCategories
+                                     }),
+                                   ]
+                               )
+                             },
+                             positiveText: "确定",
+                             negativeText: '取消',
+                             onPositiveClick: () => {
+                               for (let i = 0; i < state.selectRowData.length; i++) {
+                                 const item = state.selectRowData[i];
+                                 item.projectMusicCategoryId = state.projectMusicCategoryId
+                               }
+                             },
+                           })
+                         }
+                         }
+                >
+                  <NIcon size={15} style="padding-left: 5px;margin-top:4px">
+                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+                      <path d="M2 26h28v2H2z" fill="currentColor"></path>
+                      <path d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z" fill="currentColor"></path>
+                    </svg>
+                  </NIcon>
+                </NButton>
+              </NSpace>
+          )
+
+        },
         key: 'projectMusicCategoryId',
         fixed: 'right',
         width: 200,
@@ -208,7 +281,9 @@ export default defineComponent({
                                      h(NInputNumber, {
                                        onUpdateValue(v) {
                                          state.startSortNum = v
-                                       }
+                                       },
+                                       min: 0,
+                                       max: 9999,
                                      }),
                                    ]
                                )
@@ -227,7 +302,7 @@ export default defineComponent({
                          }
                          }
                 >
-                  <NIcon size={15} style="padding-left: 9px">
+                  <NIcon size={15} style="padding-left: 5px;margin-top:4px">
                     <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
                       <path d="M2 26h28v2H2z" fill="currentColor"></path>
                       <path d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z" fill="currentColor"></path>
@@ -244,9 +319,10 @@ export default defineComponent({
         render: (row: any) => {
           return h(NInputNumber, {
             value: row.sortNo,
+            min: 0,
+            max: 9999,
             onUpdateValue(value: any) {
               row.sortNo = value
-              console.log(state.selectRowData)
             }
           })
         }
@@ -279,6 +355,14 @@ export default defineComponent({
                             if (index > -1) {
                               state.selectRowData.splice(index, 1)
                             }
+                            const index1 = checkedRowKeysRef.value.findIndex((item: any) => {
+                              if (item == row.id) {
+                                return true
+                              }
+                            })
+                            if (index1 > -1) {
+                              checkedRowKeysRef.value.splice(index, 1)
+                            }
                           } catch {
                           }
                         }
@@ -294,10 +378,6 @@ export default defineComponent({
       return field;
     }
 
-    const updateCurrent = (val: any) => {
-      state.currentStep = val
-    }
-
     const checkedRowKeysRef = ref<DataTableRowKey[]>([])
     const handleCheck = (rowKeys: DataTableRowKey[]) => {
       checkedRowKeysRef.value = rowKeys
@@ -323,7 +403,13 @@ export default defineComponent({
       return (
           <div class="system-menu-container">
             <NSpace vertical size="medium">
-              <NSteps current={state.currentStep} onUpdateCurrent={updateCurrent} style={"margin-bottom: 10px;margin-top: 10px"}>
+              <NSteps
+                  current={state.currentStep}
+                  // onUpdateCurrent={()=>{
+                  //   state.currentStep = val
+                  // }}
+                  style={"margin-bottom: 10px;margin-top: 10px"}
+              >
                 <NStep
                     title="选择曲目"
                     description=""
@@ -431,9 +517,13 @@ export default defineComponent({
                   type="primary"
                   onClick={() => {
                     if (state.currentStep < 2) {
+                      if (state.selectRowData.length == 0) {
+                        message.warning("请选择曲目")
+                        return
+                      }
                       state.currentStep = state.currentStep + 1;
                     } else {
-                      onSubmit()
+                      onSave()
                     }
                   }}
                   // loading={btnLoading.value}

+ 5 - 0
src/views/music-library/project-music-sheet/module/cooleshow-edu/cooleshow-edu.tsx

@@ -487,6 +487,11 @@ export default defineComponent({
                 style={{width: '1200px'}}
             >
               <AddMusic
+                  onClose={() => (state.showAdd = false)}
+                  onGetList={() => {
+                    state.pagination.page = 1
+                    getList()
+                  }}
                   subjectList={state.subjectList}
                   appId={state.appId}
                   musicSheetCategories={state.musicSheetCategories}