Bladeren bron

应用部署自定义参数设置

zhangjie 1 jaar geleden
bovenliggende
commit
f1494a9123

+ 7 - 0
src/assets/styles/home.scss

@@ -688,3 +688,10 @@
     }
   }
 }
+
+// modify-app-deploy
+.modify-app-deploy {
+  .el-input-number .el-input__inner {
+    text-align: left;
+  }
+}

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

@@ -219,6 +219,9 @@ export const appDeployList = (datas) => {
 export const appDeploySecret = (deviceId) => {
   return $postParam("/api/admin/deploy/secret", { id: deviceId });
 };
+export const appDeployCustomParams = (appId) => {
+  return $postParam("/api/admin/deploy/control/params", { appId });
+};
 export const appDeployModes = () => {
   return $post("/api/admin/deploy/modes", {});
 };

+ 21 - 3
src/modules/admin/app-deploy/AppDeployControlKey.vue

@@ -1,13 +1,30 @@
 <template>
   <div class="app-deploy-control-key">
+    <el-input
+      v-if="keyType === 'string'"
+      v-model.trim="data"
+      style="width: 100%"
+      placeholder="请输入内容"
+      clearable
+      @change="dataChange"
+    ></el-input>
     <el-input-number
       v-if="keyType === 'number'"
       v-model="data"
-      style="width: 100%"
+      style="width: 120px"
       :controls="false"
       placeholder="请输入数字"
       @change="dataChange"
     ></el-input-number>
+    <el-radio-group
+      v-if="keyType === 'boolean'"
+      v-model="data"
+      @change="dataChange"
+    >
+      <el-radio :label="null">无</el-radio>
+      <el-radio :label="true">是</el-radio>
+      <el-radio :label="false">否</el-radio>
+    </el-radio-group>
     <el-date-picker
       v-if="keyType === 'time'"
       v-model="data"
@@ -15,6 +32,7 @@
       style="width: 100%"
       value-format="timestamp"
       placeholder="选择日期时间"
+      clearable
       @change="dataChange"
     >
     </el-date-picker>
@@ -25,11 +43,11 @@
 export default {
   name: "app-deploy-control-key",
   props: {
-    value: { type: [Number, String] },
+    value: { type: [Number, String, Boolean] },
     keyType: {
       type: String,
       default: "number",
-      validator: (val) => ["number", "time"].includes(val),
+      validator: (val) => ["number", "time", "string", "boolean"].includes(val),
     },
   },
   watch: {

+ 36 - 4
src/modules/admin/app-deploy/ModifyAppDeploy.vue

@@ -51,6 +51,15 @@
           ></app-deploy-control-key>
         </el-form-item>
       </template>
+      <!-- custom param -->
+      <template v-for="cont in customOptions">
+        <el-form-item :key="cont.key" :label="`${cont.name}:`">
+          <app-deploy-control-key
+            v-model="modalForm.control.custom[cont.key]"
+            :key-type="cont.type"
+          ></app-deploy-control-key>
+        </el-form-item>
+      </template>
     </el-form>
     <div slot="footer">
       <el-button type="danger" @click="cancel" plain>取消</el-button>
@@ -64,7 +73,7 @@
 <script>
 import { DEPLOY_CONTROL_KEYS } from "@/constants/enumerate";
 import { clearData } from "@/plugins/utils";
-import { appDeployInsertOrUpdate } from "../api";
+import { appDeployInsertOrUpdate, appDeployCustomParams } from "../api";
 import AppDeployControlKey from "./AppDeployControlKey.vue";
 
 const initModalForm = {
@@ -73,11 +82,13 @@ const initModalForm = {
   name: "",
   mode: "",
   ipAllow: "",
-  control: {},
+  control: {
+    custom: {},
+  },
 };
 
 export default {
-  name: "modify-app",
+  name: "modify-app-deploy",
   components: { AppDeployControlKey },
   props: {
     instance: {
@@ -123,9 +134,18 @@ export default {
           },
         ],
       },
+      customOptions: [],
     };
   },
   methods: {
+    async getCustomParams() {
+      if (this.customOptions.length) return;
+      const res = await appDeployCustomParams(this.instance.appId);
+      this.customOptions = res || [];
+      this.customOptions.forEach((item) => {
+        item.type = item.type.toLowerCase();
+      });
+    },
     initData(val) {
       this.modalForm = this.$objAssign(initModalForm, val);
 
@@ -140,9 +160,21 @@ export default {
       });
       this.modalForm.control = control;
 
+      const customVals = val.control?.custom || {};
+      let custom = {};
+      this.customOptions.forEach((cont) => {
+        const defaultVal = cont.type === "number" ? undefined : null;
+        custom[cont.key] =
+          customVals[cont.key] || customVals[cont.key] === 0
+            ? customVals[cont.key]
+            : defaultVal;
+      });
+      this.modalForm.control.custom = custom;
+
       this.$refs.modalFormComp.clearValidate();
     },
-    visibleChange() {
+    async visibleChange() {
+      await this.getCustomParams();
       this.initData(this.instance);
     },
     cancel() {