|
@@ -1,7 +1,22 @@
|
|
|
<template>
|
|
|
- <div class="admin-authorize-edit-info">
|
|
|
- <el-dialog :title="formData.titleText" v-model="formData.isShowDialog" draggable width="769px" @open="handleDialogOpen">
|
|
|
- <el-form :model="formData.editData" :rules="rules" ref="formRef" v-loading="formData.loading" size="default" label-width="120px">
|
|
|
+ <div class="layout-pd">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <div class="page-header">
|
|
|
+ <el-breadcrumb separator="/">
|
|
|
+ <el-breadcrumb-item :to="{ path: '/software-management' }">软件包管理</el-breadcrumb-item>
|
|
|
+ <el-breadcrumb-item>历史版本记录</el-breadcrumb-item>
|
|
|
+ </el-breadcrumb>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="ele-ArrowLeft"
|
|
|
+ @click="handleBack"
|
|
|
+ class="back-button"
|
|
|
+ >
|
|
|
+ 返回列表
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-form :model="formData.editData" ref="formRef" v-loading="formData.loading" size="default" label-width="120px">
|
|
|
<el-row :gutter="35">
|
|
|
<!-- 项目基本信息 -->
|
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
@@ -93,44 +108,25 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
- <template #footer>
|
|
|
- <span class="dialog-footer">
|
|
|
- <el-button @click="onCancel" size="default">取消</el-button>
|
|
|
- <el-button type="primary" @click="handleSubmit" size="default">
|
|
|
- {{formData.buttonText}}
|
|
|
- </el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { defineAsyncComponent, onMounted, reactive, ref, watch } from "vue";
|
|
|
-import { ElMessage, ElSkeleton, ElEmpty } from "element-plus";
|
|
|
+import { onMounted, reactive, ref, watch } from "vue";
|
|
|
+import { useRouter, useRoute } from "vue-router";
|
|
|
+import { ElMessage, ElEmpty, ElSkeleton, ElTimeline, ElTimelineItem, ElCard } from "element-plus";
|
|
|
import { FormRules } from "element-plus";
|
|
|
-import eventBus from "/@/utils/mitt";
|
|
|
import { HistoricalVersionRecordDto } from "/@/api/admin/productionManagement/slelistDto";
|
|
|
import { Api } from "/@/api/admin/productionManagement/slelist";
|
|
|
|
|
|
-const MyUploadFile = defineAsyncComponent(() => import('/@/components/my-upload-file/index.vue'));
|
|
|
-
|
|
|
-/** 表单操作类型 */
|
|
|
-enum FormAction {
|
|
|
- VIEW = '查看',
|
|
|
- UPDATE = '更新',
|
|
|
- ADD = '添加'
|
|
|
-}
|
|
|
+// 路由实例
|
|
|
+const router = useRouter()
|
|
|
+const route = useRoute()
|
|
|
|
|
|
/**数据对象 */
|
|
|
const formData = reactive({
|
|
|
loading: false,
|
|
|
- action: FormAction.VIEW,
|
|
|
- titleText: '查看历史版本',
|
|
|
- editIcon: 'el-icon-history',
|
|
|
- buttonText: '关闭',
|
|
|
- isShowDialog: false,
|
|
|
- softwarePackageId: null, // 软件包ID(数值类型)
|
|
|
editData: {
|
|
|
guid: 0, // 接口返回的ID(数值类型)
|
|
|
projectName: '',
|
|
@@ -149,107 +145,38 @@ const formData = reactive({
|
|
|
state: 0,
|
|
|
operatorTime: '',
|
|
|
pubDate: '',
|
|
|
+ createdTime: '',
|
|
|
+ numberOfDownloads: 0,
|
|
|
softVersions: []
|
|
|
} as HistoricalVersionRecordDto,
|
|
|
fileValue: null
|
|
|
});
|
|
|
|
|
|
-/**有效版本号选择校验*/
|
|
|
-const validateVersion = (rule: any, value: any, callback: any) => {
|
|
|
- const versionPattern: RegExp = /^\d+\.\d+\.\d+$/;
|
|
|
- if (!versionPattern.test(value)) {
|
|
|
- callback(new Error('输入的版本号格式错误,应为X.X.X格式'));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-/**表单校验规则*/
|
|
|
-const rules = reactive<FormRules>({
|
|
|
- softwareType: [{ required: true, message: '请选择软件类型', trigger: 'blur' }],
|
|
|
- equipmentType: [{ required: true, message: '请选择设备类型', trigger: 'blur' }],
|
|
|
- softwareName: [{ required: true, message: '请输入软件包名', trigger: 'blur' }],
|
|
|
- version: [
|
|
|
- { required: true, message: '请输入版本号', trigger: 'blur' },
|
|
|
- { validator: validateVersion, trigger: 'blur' }
|
|
|
- ]
|
|
|
-});
|
|
|
+/**
|
|
|
+ * 移除了不必要的表单校验规则
|
|
|
+ * 历史版本页面主要用于查看,无需校验逻辑
|
|
|
+ */
|
|
|
+const rules = reactive<FormRules>({});
|
|
|
|
|
|
/** 表单引用 */
|
|
|
const formRef = ref();
|
|
|
|
|
|
-/** 打开对话框并加载数据 */
|
|
|
-const openDialog = (softwareId: number, action: FormAction = FormAction.VIEW) => {
|
|
|
- formData.action = action;
|
|
|
- formData.editData.guid = softwareId;
|
|
|
-
|
|
|
- // 根据操作类型设置界面显示
|
|
|
- if (action === FormAction.VIEW) {
|
|
|
- formData.titleText = '查看历史版本';
|
|
|
- formData.buttonText = '关闭';
|
|
|
- formData.editIcon = 'el-icon-close';
|
|
|
- } else if (action === FormAction.UPDATE) {
|
|
|
- formData.titleText = '更新软件包';
|
|
|
- formData.buttonText = '更新';
|
|
|
- formData.editIcon = 'el-icon-refresh-right';
|
|
|
+/** 页面挂载时加载数据 */
|
|
|
+onMounted(() => {
|
|
|
+ // 从路由参数获取guid
|
|
|
+ const guid = route.query.guid
|
|
|
+ if (guid) {
|
|
|
+ formData.editData.guid = Number(guid)
|
|
|
+ fetchHistoricalVersion()
|
|
|
} else {
|
|
|
- formData.titleText = '添加软件包';
|
|
|
- formData.buttonText = '添加';
|
|
|
- formData.editIcon = 'el-icon-plus';
|
|
|
- }
|
|
|
-
|
|
|
- formData.isShowDialog = true;
|
|
|
- fetchHistoricalVersion(); // 立即加载数据
|
|
|
-};
|
|
|
-
|
|
|
-/** 对话框打开时触发 */
|
|
|
-const handleDialogOpen = () => {
|
|
|
- if (formData.softwarePackageId && formData.action === FormAction.VIEW) {
|
|
|
- fetchHistoricalVersion();
|
|
|
+ ElMessage.warning('未获取到软件包信息')
|
|
|
+ router.push('/software-management')
|
|
|
}
|
|
|
-};
|
|
|
-
|
|
|
-/** 取消操作 */
|
|
|
-const onCancel = () => {
|
|
|
- formData.editData = {
|
|
|
- guid: 0,
|
|
|
- projectName: '',
|
|
|
- projectCode: '',
|
|
|
- projectDescription: '',
|
|
|
- projectLaunchDate: '',
|
|
|
- equipmentType: '',
|
|
|
- softwareType: '',
|
|
|
- softwareName: '',
|
|
|
- version: '',
|
|
|
- explain: '',
|
|
|
- remark: '',
|
|
|
- downNum: 0,
|
|
|
- downloadUrl: '',
|
|
|
- fileName: '',
|
|
|
- state: 0,
|
|
|
- operatorTime: '',
|
|
|
- pubDate: '',
|
|
|
- softVersions: []
|
|
|
- } as HistoricalVersionRecordDto;
|
|
|
- formData.isShowDialog = false;
|
|
|
-};
|
|
|
-
|
|
|
-/***监听软件包ID变化,重新加载数据 */
|
|
|
-watch(() => formData.softwarePackageId, (newId) => {
|
|
|
- if (newId && formData.action === FormAction.VIEW) {
|
|
|
- fetchHistoricalVersion();
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-/** 文件上传处理 */
|
|
|
-const onUpload = (val) => {
|
|
|
- formData.editData.downloadUrl = val.fileUrl;
|
|
|
- formData.editData.fileName = val.fileName;
|
|
|
-};
|
|
|
+})
|
|
|
|
|
|
/** 获取历史版本数据 */
|
|
|
const fetchHistoricalVersion = async () => {
|
|
|
- if (formData.editData.guid === null || formData.editData.guid === undefined) {
|
|
|
+ if (!formData.editData.guid) {
|
|
|
ElMessage.warning('未获取到软件包ID');
|
|
|
return;
|
|
|
}
|
|
@@ -257,8 +184,6 @@ const fetchHistoricalVersion = async () => {
|
|
|
formData.loading = true;
|
|
|
try {
|
|
|
const api = new Api();
|
|
|
- // 传递formData.softwarePackageId作为ID参数
|
|
|
- console.log(formData.editData.guid)
|
|
|
const res = await api.getHistory(formData.editData.guid);
|
|
|
|
|
|
if (res.success) {
|
|
@@ -295,31 +220,44 @@ const formatDate = (dateStr: string): string => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-/** 提交处理 */
|
|
|
-const handleSubmit = () => {
|
|
|
- if (formData.action === FormAction.UPDATE || formData.action === FormAction.ADD) {
|
|
|
- formRef.value?.validate((valid: boolean) => {
|
|
|
- if (valid) {
|
|
|
- ElMessage.success(`${formData.buttonText}成功`);
|
|
|
- formData.isShowDialog = false;
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- formData.isShowDialog = false;
|
|
|
- }
|
|
|
-};
|
|
|
+/** 返回列表页 */
|
|
|
+const handleBack = () => {
|
|
|
+ router.push('/product/softwarePackageManagement')
|
|
|
+}
|
|
|
|
|
|
-defineExpose({
|
|
|
- openDialog,
|
|
|
- fetchHistoricalVersion
|
|
|
-});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
+.page-header {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ padding-bottom: 10px;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+}
|
|
|
+
|
|
|
+.back-button {
|
|
|
+ margin-top: 10px;
|
|
|
+}
|
|
|
+
|
|
|
:deep(.el-form-item__label) {
|
|
|
width: 120px !important;
|
|
|
text-align: right;
|
|
|
justify-content: flex-end;
|
|
|
padding-right: 12px;
|
|
|
}
|
|
|
-</style>
|
|
|
+
|
|
|
+.el-timeline {
|
|
|
+ margin-left: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.el-timeline-item {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.el-card {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+</style>
|