Ver código fonte

主干版本切换新增

zhangjie 2 anos atrás
pai
commit
10e5258d20

+ 3 - 0
src/modules/admin/api.js

@@ -70,6 +70,9 @@ export const appModuleEnable = ({ id, enable }) => {
 export const appVersionList = datas => {
   return $postParam("/api/admin/version/query", datas);
 };
+export const appSetMasterVersion = ({ appId, versionId }) => {
+  return $postParam("/api/admin/app/master_version", { id: appId, versionId });
+};
 export const appVersionInsertOrUpdate = datas => {
   if (datas.id) {
     return $post("/api/admin/version/update", datas);

+ 17 - 14
src/modules/admin/components/AppModuleManage.vue

@@ -172,21 +172,24 @@ export default {
       this.curRow = { ...row, appId: this.app.id };
       this.$refs.ModifyAppModule.open();
     },
-    toEnable(row) {
+    async toEnable(row) {
       const action = row.enable ? "禁用" : "启用";
-      this.$confirm(`确定要${action}模块【${row.name}】吗?`, "提示", {
-        type: "warning"
-      })
-        .then(async () => {
-          const enable = !row.enable;
-          await appModuleEnable({
-            id: row.id,
-            enable
-          });
-          row.enable = enable;
-          this.$message.success("操作成功!");
-        })
-        .catch(() => {});
+      const confirm = await this.$confirm(
+        `确定要${action}模块【${row.name}】吗?`,
+        "提示",
+        {
+          type: "warning"
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      const enable = !row.enable;
+      await appModuleEnable({
+        id: row.id,
+        enable
+      });
+      row.enable = enable;
+      this.$message.success("操作成功!");
     }
   }
 };

+ 60 - 16
src/modules/admin/components/AppVersionManage.vue

@@ -47,6 +47,16 @@
         <el-table ref="TableList" :data="dataList">
           <el-table-column prop="id" label="ID" width="80"></el-table-column>
           <el-table-column prop="name" label="名称"> </el-table-column>
+          <el-table-column prop="archived" label="是否为主干版本" width="80">
+            <template slot-scope="scope">
+              <span
+                :class="{
+                  'color-success': scope.row.id === curMasterVersionId
+                }"
+              ></span>
+              {{ scope.row.id === curMasterVersionId ? "主干版本" : "" }}
+            </template>
+          </el-table-column>
           <el-table-column prop="archived" label="状态" width="80">
             <template slot-scope="scope">
               <span
@@ -73,6 +83,13 @@
                 @click="toEdit(scope.row)"
                 >编辑</el-button
               >
+              <el-button
+                class="btn-primary"
+                type="text"
+                :disabled="scope.row.id === curMasterVersionId"
+                @click="toSetMaster(scope.row)"
+                >设置为主干版本</el-button
+              >
               <el-button
                 :class="scope.row.archived ? 'btn-danger' : 'btn-primary'"
                 type="text"
@@ -106,7 +123,11 @@
 </template>
 
 <script>
-import { appVersionList, appVersionInsertOrUpdate } from "../api";
+import {
+  appVersionList,
+  appVersionInsertOrUpdate,
+  appSetMasterVersion
+} from "../api";
 import { ARCHIVED_TYPE } from "../../../constants/enumerate";
 import ModifyAppVersion from "../components/ModifyAppVersion.vue";
 
@@ -132,11 +153,13 @@ export default {
       size: this.GLOBAL.pageSize,
       total: 0,
       dataList: [],
-      curRow: {}
+      curRow: {},
+      curMasterVersionId: null
     };
   },
   methods: {
     visibleChange() {
+      this.curMasterVersionId = this.app.masterVertionId;
       // this.toPage(1);
     },
     cancel() {
@@ -170,21 +193,42 @@ export default {
       this.curRow = { ...row, appId: this.app.id };
       this.$refs.ModifyAppVersion.open();
     },
-    toArchived(row) {
+    async toSetMaster(row) {
+      const confirm = await this.$confirm(
+        `确定要设置版本号【${row.name}】为主干版本吗?`,
+        "提示",
+        {
+          type: "warning"
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      await appSetMasterVersion({
+        appId: this.app.id,
+        versionId: row.id
+      });
+      this.$message.success("操作成功!");
+      this.curMasterVersionId = row.id;
+      this.$emit("master-change");
+    },
+    async toArchived(row) {
       const action = row.archived ? "取消归档" : "归档";
-      this.$confirm(`确定要${action}版本号【${row.name}】吗?`, "提示", {
-        type: "warning"
-      })
-        .then(async () => {
-          const archived = !row.archived;
-          await appVersionInsertOrUpdate({
-            id: row.id,
-            archived
-          });
-          row.archived = archived;
-          this.$message.success("操作成功!");
-        })
-        .catch(() => {});
+      const confirm = await this.$confirm(
+        `确定要${action}版本号【${row.name}】吗?`,
+        "提示",
+        {
+          type: "warning"
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      const archived = !row.archived;
+      await appVersionInsertOrUpdate({
+        id: row.id,
+        archived
+      });
+      row.archived = archived;
+      this.$message.success("操作成功!");
     }
   }
 };

+ 2 - 17
src/modules/admin/views/AppManage.vue

@@ -27,20 +27,7 @@
         <el-table-column prop="id" label="ID" width="80"></el-table-column>
         <el-table-column prop="name" label="名称"> </el-table-column>
         <el-table-column prop="code" label="编码"> </el-table-column>
-        <el-table-column
-          prop="masterVersionName"
-          label="主干版本"
-          class-name="action-column"
-        >
-          <template slot-scope="scope">
-            <el-button
-              class="btn-primary"
-              type="text"
-              title="切换主干版本"
-              @click="toSwithMasterVersion(scope.row)"
-              >{{ scope.row.masterVersionName }}</el-button
-            >
-          </template>
+        <el-table-column prop="masterVersionName" label="主干版本">
         </el-table-column>
         <el-table-column prop="createTime" label="创建时间" width="170">
           <span slot-scope="scope">{{
@@ -127,6 +114,7 @@
     <app-version-manage
       ref="AppVersionManage"
       :app="curRow"
+      @master-change="getList"
     ></app-version-manage>
   </div>
 </template>
@@ -194,9 +182,6 @@ export default {
       this.curRow = row;
       this.$refs.ModifyApp.open();
     },
-    toSwithMasterVersion(row) {
-      console.log(row);
-    },
     toEditUser(row) {
       this.curRow = row;
       this.$refs.AppUserManage.open();