瀏覽代碼

系统运维:版本升级修改

xujie 1 年之前
父節點
當前提交
f05085f07a
共有 4 個文件被更改,包括 199 次插入174 次删除
  1. 1 1
      .env.development
  2. 9 2
      src/api/system/version.js
  3. 14 0
      src/components/K-FileUpload/index.vue
  4. 175 171
      src/views/system/version/index.vue

+ 1 - 1
.env.development

@@ -20,7 +20,7 @@ ENV = 'development'
 # VUE_APP_BASE_API = 'http://10.87.23.62:8080'
 #  VUE_APP_BASE_API = 'http://localhost:8080'
 # 开发环境v
-VUE_APP_BASE_API = 'http://10.87.23.46:8081'
+VUE_APP_BASE_API = 'http://10.87.23.42:8081'
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true
 

+ 9 - 2
src/api/system/version.js

@@ -47,9 +47,16 @@ export function updateVersion(data) {
 // 版本包下载
 export function downloadFile(id,fileName) {
 	return exportFile(
-		'/system/version/download/'+id,
+		'/system/version/download/'+fileName,
 	   null,
 	   'get',
 	  fileName,null,null
 	)
-  }
+}
+
+export function getAllPackageName() {
+  return request({
+    url: '/system/version/getAllPackageName',
+    method: 'get'
+  })
+}

+ 14 - 0
src/components/K-FileUpload/index.vue

@@ -74,6 +74,11 @@ export default {
       type: Array,
       default: () => ["pdf", "jpg", "png", "bmp", "zip", "rar", "7z"],
     },
+    // 文件类型, 例如['png', 'jpg', 'jpeg']
+    packageName: {
+      type: Array,
+      default: () => [],
+    },
     // 是否显示提示
     isShowTip: {
       type: Boolean,
@@ -168,6 +173,15 @@ export default {
     handleBeforeUpload(file) {
       // 校检文件类型
       if (this.fileType) {
+        if (this.packageName.length > 0){
+          const validateFileName = file.name;
+          for (let i = 0; i < this.packageName.length; i++) {
+            if (validateFileName === this.packageName[i]){
+              this.$modal.msgError(`已存在名为 `+this.packageName[i]+` 的文件,请重新上传!`);
+              return false;
+            }
+          }
+        }
         const fileName = file.name.split('.');
         const fileExt = fileName[fileName.length - 1];
         const isTypeOk = this.fileType.indexOf(fileExt) >= 0;

+ 175 - 171
src/views/system/version/index.vue

@@ -9,16 +9,16 @@
 						style="width: 240px"
 						@keyup.enter.native="handleQuery"/>
 			</el-form-item>
-  
+
 			<el-form-item label="平台" prop="type">
 			  <el-select v-model="queryParams.type" clearable placeholder="请选择平台" style="width: 240px">
 				<el-option v-for="dict in dict.type.sys_version_type" :key="dict.value" :label="dict.label"
 						   :value="dict.value"/>
 			  </el-select>
 			</el-form-item>
-  
+
 		  </el-form>
-  
+
 		  <el-row :gutter="10">
 			<el-col :span="1.5">
 			  <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery"
@@ -30,17 +30,17 @@
 			  >重置
 			  </el-button>
 			</el-col>
-  
+
 			<el-col :span="1.5">
 			  <el-button v-hasPermi="['system:version:add']" icon="el-icon-plus" size="mini" type="primary"
 						 @click="handleAdd">新增
 			  </el-button>
 			</el-col>
-  
+
 			<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
 		  </el-row>
 		</div>
-  
+
 		<el-table
 		  v-loading="loading"
 		  :data="versionList"
@@ -93,13 +93,13 @@
 			</template>
 		  </el-table-column>
 		</el-table>
-  
+
 		<pagination v-show="total > 0" :limit.sync="queryParams.pageSize" :page.sync="queryParams.pageNum" :total="total"
 					@pagination="getList"/>
-  
+
 	  </div>
-  
-  
+
+
 	  <!-- 添加或修改版本号对话框 -->
 	  <DialogCom :title="title" :visible.sync="open" append-to-body width="750px">
 		<el-form ref="form" :model="form" :rules="rules" label-width="100px">
@@ -129,7 +129,7 @@
 			<el-form-item label="强制更新" prop="isForce">
 				<el-checkbox v-model="form.isForce"></el-checkbox>
 			</el-form-item>
-	
+
 			<el-form-item v-if="form.type!=='3'" label="上传文件" ref="files" prop="fileList">
               <K-file-upload
                 ref="upload"
@@ -137,6 +137,7 @@
                 v-model="form.fileList"
                 :limit="1"
                 :fileType="['apk']"
+                :packageName="packageNameList"
 				:fileSize="50"
                 @input="fileListChanged"
               />
@@ -157,192 +158,196 @@
 	  </DialogCom>
 	</div>
   </template>
-  
+
   <script>
   import {
-	listVersion,
-	getVersionDetail,
-	addVersion,
-	updateVersion,
-	downloadFile
+    listVersion,
+    getVersionDetail,
+    addVersion,
+    updateVersion,
+    downloadFile,
+    getAllPackageName
   } from "@/api/system/version";
   import KFileUpload from "@/components/K-FileUpload/index.vue";
   import KTextarea from "@/components/common/textarea.vue";
 
   export default {
-	name: "Version",
-	components: {KFileUpload,KTextarea},
-	dicts: ['sys_version_type','sys_true_false'],
-	data() {
-	  return {
-		// 遮罩层
-		loading: true,
-		formFileListDefualtValue: [],
-		// 选中数组
-		ids: [],
-		// 非单个停用
-		single: true,
-		// 非多个停用
-		multiple: true,
-		// 显示搜索条件
-		showSearch: true,
-		// 总条数
-		total: 0,
-		// 表数据
-		versionList: [],
-		// 弹出层标题
-		title: "",
-		// 是否显示弹出层
-		open: false,
-		// 日期范围
-		dateRange: [],
-		// 查询参数
-		queryParams: {
-		  pageNum: 1,
-		  pageSize: 10,
-		  version: null,
-		  type: null
-		},
-		// 表单参数
-		form: {},
-		defaultProps: {
-		  children: "children",
-		  label: "name"
-		},
-		// 表单校验
-		rules: {
-		  version: [
-			{required: true, message: "版本号不能为空", trigger: "blur"},
-			{validator: validatorVersion, trigger: "blur"}
-		  ],
-		  type: [
-			{required: true, message: "请选择机构类型", trigger: "blur"}
-		  ],
-		  isUse: [
-			{required: true, message: "请输入使用", trigger: "blur"}
-		  ],
-		  isForce: [
-			{required: true, message: "请输入强制更新", trigger: "blur"}
-		  ],
-		  note: [
-			{required: true, message: "请输入说明", trigger: "blur"}
-		  ]
-		},
-	  };
-	},
-	created() {
-	  this.getList();
-	},
-	methods: {
-	  fileListChanged(list) {
-        this.$refs.files.clearValidate();
+    name: "Version",
+    components: {KFileUpload,KTextarea},
+    dicts: ['sys_version_type','sys_true_false'],
+    data() {
+      return {
+      // 遮罩层
+      loading: true,
+      formFileListDefualtValue: [],
+      // 选中数组
+      ids: [],
+      // 非单个停用
+      single: true,
+      // 非多个停用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 表数据
+      versionList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 日期范围
+      dateRange: [],
+        packageNameList:[],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        version: null,
+        type: null
       },
-	  selectedType() {
-        this.$refs["form"].clearValidate(["type"]);
+      // 表单参数
+      form: {},
+      defaultProps: {
+        children: "children",
+        label: "name"
       },
-	  handleSelectionChange(selection) {
-        this.$emit('handleSelectionChange', selection)
+      // 表单校验
+      rules: {
+        version: [
+        {required: true, message: "版本号不能为空", trigger: "blur"},
+        {validator: validatorVersion, trigger: "blur"}
+        ],
+        type: [
+        {required: true, message: "请选择机构类型", trigger: "blur"}
+        ],
+        isUse: [
+        {required: true, message: "请输入使用", trigger: "blur"}
+        ],
+        isForce: [
+        {required: true, message: "请输入强制更新", trigger: "blur"}
+        ],
+        note: [
+        {required: true, message: "请输入说明", trigger: "blur"}
+        ]
       },
-	  async downloadVersionFile(row) {
-		if(row.type === 3){
-			return;
-		}
-		
-		await downloadFile(row.id,row.packageName);
+      };
+    },
+    created() {
+      this.getList();
+    },
+      methods: {
+      fileListChanged(list) {
+          this.$refs.files.clearValidate();
+        },
+      selectedType() {
+          this.$refs["form"].clearValidate(["type"]);
+        },
+      handleSelectionChange(selection) {
+          this.$emit('handleSelectionChange', selection)
+        },
+      async downloadVersionFile(row) {
+      if(row.type === 3){
+        return;
+      }
+
+		  await downloadFile(row.id,row.packageName);
 
       },
-	  getPageIndex($index) {
-		//表格序号
-		return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
-  
-	  },
-	  /** 查询角色列表 */
-	  getList() {
-		this.loading = true;
-		listVersion(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
-			this.versionList= response.rows;
-			this.total = response.total;
-			this.loading = false;
-		  }
-		);
-	  },
-	  
-	  // 取消按钮
-	  cancel() {
-		this.open = false;
-		this.reset();
-	  },
-	  // 表单重置
-	  reset() {
-		this.formFileListDefualtValue = [],
-		this.form = {
-			version: null,
-			type: null,
-			note: null,
-			isUse: false,
-			isForce: false
-		};
-		this.resetForm("form");
-	  },
-	  /** 搜索按钮操作 */
-	  handleQuery() {
-		this.queryParams.pageNum = 1;
-		this.getList();
-	  },
-	  /** 重置按钮操作 */
-	  resetQuery() {
-		this.dateRange = [];
-		this.resetForm("queryForm");
-		this.handleQuery();
-	  },
-	  /** 新增按钮操作 */
-	  handleAdd() {
-		this.reset();
-		this.open = true;
-		this.title = "新增版本号";
-	  },
-	  /** 修改按钮操作 */
-	  handleUpdate(row) {
-		this.reset();
-		const id = row.id;
-		getVersionDetail(id).then(response => {
-		  	this.form = response.data;
-		  	let file = {url:this.form.path,name:this.form.packageName};
-        	let fileList = [];
-        	fileList.push(JSON.stringify(file));
-        	this.form.fileList = fileList;
-        	this.formFileListDefualtValue = fileList;
-			this.form.type = this.form.type + '';
-		  	this.open = true;
-		  	this.title = "编辑版本号";
-		});
-	  },
-	  /** 提交按钮 */
-	  submitForm: function () {
-		this.$refs["form"].validate(valid => {
-		  if (valid) {
-			if(this.form.type !== `3` &&  this.form.fileList.length === 0){
+	    getPageIndex($index) {
+		    //表格序号
+		    return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
+	    },
+	    /** 查询角色列表 */
+	    getList() {
+		    this.loading = true;
+		    listVersion(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
+			    this.versionList= response.rows;
+			    this.total = response.total;
+			    this.loading = false;
+		    }
+		    );
+        getAllPackageName().then(response => {
+          this.packageNameList=response.data;
+        });
+	    },
+
+      // 取消按钮
+	    cancel() {
+		    this.open = false;
+		    this.reset();
+	    },
+	    // 表单重置
+	    reset() {
+		    this.formFileListDefualtValue = [],
+		    this.form = {
+          version: null,
+          type: null,
+          note: null,
+          isUse: false,
+          isForce: false
+		    };
+        this.resetForm("form");
+	    },
+	    /** 搜索按钮操作 */
+	    handleQuery() {
+		    this.queryParams.pageNum = 1;
+		    this.getList();
+	    },
+	    /** 重置按钮操作 */
+	    resetQuery() {
+        this.dateRange = [];
+        this.resetForm("queryForm");
+        this.handleQuery();
+	    },
+      /** 新增按钮操作 */
+      handleAdd() {
+        this.reset();
+        this.open = true;
+        this.title = "新增版本号";
+	    },
+      /** 修改按钮操作 */
+      handleUpdate(row) {
+        this.reset();
+        const id = row.id;
+        getVersionDetail(id).then(response => {
+          this.form = response.data;
+          let file = {url:this.form.path,name:this.form.packageName};
+            let fileList = [];
+            fileList.push(JSON.stringify(file));
+            this.form.fileList = fileList;
+            this.formFileListDefualtValue = fileList;
+			      this.form.type = this.form.type + '';
+		  	    this.open = true;
+		  	    this.title = "编辑版本号";
+		    });
+	    },
+	    /** 提交按钮 */
+	    submitForm: function () {
+		    this.$refs["form"].validate(valid => {
+		    if (valid) {
+			    if(this.form.type !== `3` &&  this.form.fileList.length === 0){
             	this.$modal.msgError("请上传文件!");
             	throw new Error("请上传文件!");
             }
-			if (this.form.type !== `3`) {
-				let file = JSON.parse(this.form.fileList[0]);
+			    if (this.form.type !== `3`) {
+				    let file = JSON.parse(this.form.fileList[0]);
             	this.form.path = file.url;
             	this.form.packageName = file.name;
-			}
-			if (this.form.id != undefined) {
+			  }
+			  if (this.form.id != undefined) {
 			  	updateVersion(this.form).then(response => {
 					this.$modal.msgSuccess("处理成功");
 					this.open = false;
 					this.getList();
 			  	});
-			} else {
+			  } else {
 			  	addVersion(this.form).then(response => {
 					this.$modal.msgSuccess("处理成功");
 					this.open = false;
 					this.getList();
 			  	});
-			}
+			  }
 		  }
 		});
 	  }
@@ -367,4 +372,3 @@
 	display: -webkit-box !important;
   }
   </style>
-