liushengqiang 1 年之前
父节点
当前提交
3d7102755a
共有 2 个文件被更改,包括 52 次插入24 次删除
  1. 3 0
      src/pc/component/upload-to-resources/index.module.less
  2. 49 24
      src/pc/component/upload-to-resources/index.tsx

+ 3 - 0
src/pc/component/upload-to-resources/index.module.less

@@ -44,6 +44,9 @@
         .n-form-item .n-form-item-label{
             color: #666;
         }
+        .n-form-item-label.n-form-item-label--right-mark{
+            min-height: 46px;
+        }
         .n-base-selection{
             --n-height: 46px;
         }

+ 49 - 24
src/pc/component/upload-to-resources/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, nextTick, onMounted, onUnmounted, reactive, watch } from "vue";
+import { defineComponent, nextTick, onMounted, onUnmounted, reactive, ref, watch } from "vue";
 import {
 	api_musicSheetCreationWav2mp3,
 	api_musicSheetCreationSaveMusic,
@@ -147,39 +147,49 @@ export default defineComponent({
 			froms.mp3 = data;
 		};
 
-        const handleClose = () => {
-            model.saveLoading = false;
-            model.saveProgress = 0;
-        }
+		const handleClose = () => {
+			model.saveLoading = false;
+			model.saveProgress = 0;
+		};
 
 		/** 自动生成图片 */
 		const handleAutoProduct = async () => {
-            model.saveProgress = 0;
+			model.saveProgress = 0;
 			const xml = props.item.xml;
-			if (!xml) {
-				message.error("没有生成xml文件");
-                handleClose();
+			const res = await fetch(xml);
+			if (res.status > 299 || res.status < 200) {
+				message.error("xml文件不存在");
+				handleClose();
 				return;
 			}
-            const res = await fetch(xml)
-            if (res.status > 299 || res.status < 200){
-                message.error("xml文件不存在");
-                handleClose();
-                return;
-            }
 			const origin = /(localhost|192)/.test(location.host)
 				? "https://test.lexiaoya.cn"
 				: location.origin;
 			model.productIfameSrc = `${origin}/instrument/#/product-img?xmlUrl=${xml}&productXmlImg=1`;
 			model.productOpen = true;
-            setTimeout(() => {
-                model.saveProgress = 10;
-            }, 800)
+			setTimeout(() => {
+				model.saveProgress = 10;
+			}, 800);
 		};
-
+		const fromRef = ref();
 		const handleUpload = () => {
-			model.saveLoading = true;
-			handleAutoProduct();
+			fromRef.value.validate((err: any) => {
+				if (err) {
+					return;
+				}
+                if (!props.item.xml) {
+                    message.error("没有生成xml文件");
+                    handleClose();
+                    return;
+                }
+                if (!props.item.filePath) {
+                    message.error("没有生成wav文件");
+                    handleClose();
+                    return;
+                }
+				model.saveLoading = true;
+				handleAutoProduct();
+			});
 		};
 		const handleSubmit = async () => {
 			await wav2mp3();
@@ -187,7 +197,7 @@ export default defineComponent({
 			await createMusic();
 			model.saveProgress = 100;
 			emit("success");
-            message.success("上传成功");
+			message.success("上传成功");
 			setTimeout(() => {
 				model.saveLoading = false;
 				emit("update:show", false);
@@ -209,8 +219,23 @@ export default defineComponent({
 								<NIcon component={Close} size={18} />
 							</NButton>
 						</div>
-						<NForm class={styles.form} labelPlacement="left">
-							<NFormItem label="可用声部">
+						<NForm
+							ref={fromRef}
+							model={froms}
+							class={styles.form}
+							labelPlacement="left"
+							showRequireMark={false}
+						>
+							<NFormItem
+								label="可用声部"
+								path="subjectId"
+								rule={{
+									required: true,
+									type: "number",
+									message: "请选择素材可用乐器",
+									trigger: "change",
+								}}
+							>
 								<NSelect
 									to="body"
 									placeholder="请选择素材可用乐器"