Browse Source

编辑应用部署弹框:增加包含values属性的string类型控件

刘洋 10 months ago
parent
commit
88664c3096

+ 22 - 8
src/modules/admin/app-deploy/AppDeployControlKey.vue

@@ -1,13 +1,21 @@
 <template>
   <div class="app-deploy-control-key">
-    <el-input
-      v-if="keyType === 'string'"
-      v-model.trim="data"
-      style="width: 100%"
-      placeholder="请输入内容"
-      clearable
-      @input="dataChange"
-    ></el-input>
+    <template v-if="keyType === 'string'">
+      <el-input
+        v-if="!values"
+        v-model.trim="data"
+        style="width: 100%"
+        placeholder="请输入内容"
+        clearable
+        @input="dataChange"
+      ></el-input>
+      <el-radio-group v-else v-model="data" @change="dataChange">
+        <el-radio v-for="v in radioOptions" :label="v.value" :key="v.value">{{
+          v.name
+        }}</el-radio>
+      </el-radio-group>
+    </template>
+
     <el-input
       v-if="keyType === 'number'"
       v-model.number="data"
@@ -48,6 +56,12 @@ export default {
       default: "number",
       validator: (val) => ["number", "time", "string", "boolean"].includes(val),
     },
+    values: { type: Array },
+  },
+  computed: {
+    radioOptions() {
+      return this.values || [];
+    },
   },
   watch: {
     value: {

+ 9 - 0
src/modules/admin/app-deploy/ModifyAppDeploy.vue

@@ -65,6 +65,7 @@
           <app-deploy-control-key
             v-model="modalForm.control.custom[cont.key]"
             :key-type="cont.type"
+            :values="cont.values"
           ></app-deploy-control-key>
         </el-form-item>
       </template>
@@ -196,6 +197,14 @@ export default {
           customVals[cont.key] === false
             ? customVals[cont.key]
             : defaultVal;
+        if (
+          cont.type === "string" &&
+          Array.isArray(cont.values) &&
+          cont.values?.length &&
+          !custom[cont.key]
+        ) {
+          custom[cont.key] = cont.values[0].value;
+        }
         if (cont.type === "number") {
           this.rules[`control.custom.${cont.key}`] = [
             { ...this.numberValidator },