|
@@ -1,19 +1,24 @@
|
|
|
<template>
|
|
|
- <el-form ref="form" label-width="120px" class="cameraVersion-from">
|
|
|
+ <el-form
|
|
|
+ :model="data"
|
|
|
+ ref="form"
|
|
|
+ label-width="120px"
|
|
|
+ class="cameraVersion-from"
|
|
|
+ >
|
|
|
<el-form-item label="设备类型" class="mandatory">
|
|
|
{{ cameraTypeDesc[data.type] }}
|
|
|
</el-form-item>
|
|
|
<el-form-item label="版本号" class="mandatory">
|
|
|
<el-input
|
|
|
maxlength="30"
|
|
|
- v-model="data.version"
|
|
|
+ v-model.trim="data.version"
|
|
|
placeholder="请输入最新版本号"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="最低版本号" class="mandatory">
|
|
|
+ <el-form-item label="最低版本号">
|
|
|
<el-input
|
|
|
maxlength="30"
|
|
|
- v-model="data.minVersion"
|
|
|
+ v-model.trim="data.minVersion"
|
|
|
placeholder="请输入最低版本(低于此版本号强制更新)"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
@@ -23,7 +28,7 @@
|
|
|
maxlength="200"
|
|
|
type="textarea"
|
|
|
:autosize="{ minRows: 4, maxRows: 10 }"
|
|
|
- v-model="data.description"
|
|
|
+ v-model.trim="data.description"
|
|
|
placeholder="请输入版本更新说明"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
@@ -43,9 +48,9 @@
|
|
|
<el-button type="primary" :disabled="!!data.file">
|
|
|
<el-icon><Upload /></el-icon>上传
|
|
|
</el-button>
|
|
|
- <!-- <template v-slot:tip>
|
|
|
- <div class="el-upload__tip">注:可上传{{ size }}以内的{{ formatDesc }}</div>
|
|
|
- </template> -->
|
|
|
+ <template v-slot:tip>
|
|
|
+ <div class="el-upload__tip">注:可上传{{ size }}以内的文件</div>
|
|
|
+ </template>
|
|
|
<!-- <template v-slot:file="{ file }: { file: UploadFile }">
|
|
|
<div class="file" @click.stop="previewFile()">
|
|
|
<div>
|
|
@@ -62,14 +67,14 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { computed, ref, watchEffect } from "vue";
|
|
|
-// import { ElMessage } from "element-plus";
|
|
|
import { QuiskExpose } from "@/helper/mount";
|
|
|
import { CameraVersionEntity } from "@/store/cameraVersion";
|
|
|
import { useUpload } from "@/hook/upload";
|
|
|
import { maxFileSize } from "@/constant/caseFile";
|
|
|
import { CameraType } from "@/store/camera";
|
|
|
import { cameraTypeDesc } from "@/constant/camera";
|
|
|
-import { uploadFile } from "@/store/cameraVersion";
|
|
|
+import { addCameraVersion, CameraVersionType } from "@/store/cameraVersion";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
|
|
|
const cameraTypes = [CameraType.SWKJ, CameraType.SWSS1, CameraType.SWSS2];
|
|
|
const props = defineProps<{
|
|
@@ -84,14 +89,16 @@ const data = ref<CameraVersionEntity>({
|
|
|
file: undefined,
|
|
|
});
|
|
|
|
|
|
+const form = ref();
|
|
|
+
|
|
|
const isAdd = computed(() => !props.entity?.id);
|
|
|
|
|
|
const httpsApi = async ({ file }) => {
|
|
|
console.log("httpsApi", file);
|
|
|
- let fileUrl = await uploadFile(file);
|
|
|
-
|
|
|
- file.url = fileUrl;
|
|
|
- console.log("httpsApi", file, fileUrl);
|
|
|
+ // let fileUrl = await uploadFile(file);
|
|
|
+ data.value.file = file;
|
|
|
+ // file.url = fileUrl;
|
|
|
+ // console.log("httpsApi", file, fileUrl);
|
|
|
};
|
|
|
|
|
|
const { size, fileList, upload, removeFile, previewFile, file, accept } =
|
|
@@ -100,7 +107,23 @@ const { size, fileList, upload, removeFile, previewFile, file, accept } =
|
|
|
formats: [".jpg", ".jpeg"],
|
|
|
});
|
|
|
defineExpose<QuiskExpose>({
|
|
|
- async submit() {},
|
|
|
+ async submit() {
|
|
|
+ if (!data.value.version) {
|
|
|
+ ElMessage.error("版本号不能为空!");
|
|
|
+ throw "版本号不能为空!";
|
|
|
+ }
|
|
|
+ if (!data.value.file) {
|
|
|
+ ElMessage.error("文件不能为空!");
|
|
|
+ throw "文件不能为空!";
|
|
|
+ }
|
|
|
+ if (!data.value.description) {
|
|
|
+ ElMessage.error("版本更新说明不能为空!");
|
|
|
+ throw "版本更新说明不能为空!";
|
|
|
+ }
|
|
|
+ const res = await addCameraVersion(data.value as any as CameraVersionType);
|
|
|
+ console.log("res", res);
|
|
|
+ ElMessage.success("添加成功!");
|
|
|
+ },
|
|
|
});
|
|
|
</script>
|
|
|
|