瀏覽代碼

平台配置

liu_lake 6 月之前
父節點
當前提交
b4de5948ee
共有 2 個文件被更改,包括 143 次插入14 次删除
  1. 10 3
      admin-ui/src/api/platform/index.ts
  2. 133 11
      admin-ui/src/views/platform/index.vue

+ 10 - 3
admin-ui/src/api/platform/index.ts

@@ -6,16 +6,23 @@ import { Result, deleteRequest, get, post, put } from "../base";
  * @returns .
  */
 export function queryPage<T>(query?: any): Promise<Result<T>> {
-  return get("/sys/pay/platform/setting/page",  query);
+  return get("/sys/pay/platform/setting/page", query);
+}
+/**
+ * 列表查询
+ * @param query .
+ * @returns .
+ */
+export function info<T>(): Promise<Result<T>> {
+  return get("/sys/pay/platform/setting/info", {});
 }
-
 /**
  * 列表查询
  * @param query .
  * @returns .
  */
 export function queryList<T>(query?: any): Promise<Result<T>> {
-  return get("/sys/pay/platform/setting/list",  query);
+  return get("/sys/pay/platform/setting/list", query);
 }
 
 /**

+ 133 - 11
admin-ui/src/views/platform/index.vue

@@ -1,19 +1,141 @@
 <script setup lang="ts">
-import { reactive } from "vue";
-import list from "./modules/list.vue";
+import {onMounted, reactive, ref} from "vue";
+import * as $api from "@/api/platform/index";
+import {message} from "@/utils/message";
+import type {FormInstance} from "element-plus";
+import {cloneDeep} from "@pureadmin/utils";
 
-defineOptions({
-  name: "platformManage"
-});
+defineOptions({name: "templateEdit"});
+const isDetail = ref(false);
+const formRef = ref<FormInstance>();
+// 初始化数据
+const initData = {
+  serviceId: undefined,
+  privateKey: undefined,
+  publicKey: undefined,
+  status: 1
+};
+
+// 表单校验规则
+const formRules = {
+  appId: [{required: true, message: "appId不能为空", trigger: "blur"}],
+  privateKey: [{required: true, message: "密钥不能为空", trigger: "blur"}],
+  publicKey: [{required: true, message: "公钥不能为空", trigger: "blur"}]
+};
+
+// 页面数据
 const pageData: any = reactive({
-  mode: "table"
+  dialogVisible: false,
+  title: "",
+  formLoading: false,
+  mode: "add",
+  isUpdate: false,
+  // 表单数据
+  formData: initData,
+  formRules: formRules
+});
+// 暴露给父级调用
+const emits = defineEmits(["ok", "close"]);
+
+const _save = () => {
+  pageData.formLoading = true;
+  const _data = cloneDeep(pageData.formData);
+  $api
+    .save(_data)
+    .then((res: any) => {
+      if (res.success) {
+        _confirm();
+      } else {
+        message(res.message, {type: "warning"});
+      }
+    })
+    .finally(() => {
+      pageData.formLoading = false;
+    });
+};
+const _update = () => {
+  pageData.formLoading = true;
+  const _data = cloneDeep(pageData.formData);
+  $api
+    .update(pageData.formData.id, _data)
+    .then((res: any) => {
+      if (res.success) {
+        _confirm();
+      } else {
+        message(res.message, {type: "warning"});
+      }
+    })
+    .finally(() => {
+      pageData.formLoading = false;
+    });
+};
+const _confirm = () => {
+  message("操作成功",{type:"success"});
+};
+
+// 确定并关闭弹窗
+const handleConfirm = () => {
+  formRef.value!.validate((isValid: boolean) => {
+    if (isValid) {
+      const {id} = pageData.formData;
+      if (id) {
+        _update();
+      } else {
+        _save();
+      }
+    } else {
+      message("表单校验失败", {type: "warning"});
+    }
+  });
+};
+onMounted(() => {
+  $api.info().then((res: any) => {
+    pageData.formData = res.result;
+    console.log(pageData.formData);
+  });
 });
 </script>
 
 <template>
-  <el-card :shadow="'never'">
-    <template #default>
-      <list :mode="pageData.mode" />
-    </template>
-  </el-card>
+  <el-form
+    ref="formRef"
+    :model="pageData.formData"
+    style="width: 50%; margin: 20px auto 0"
+    label-width="auto"
+    :rules="pageData.formRules"
+  >
+    <el-form-item label="appId" prop="appId">
+      <el-input
+        v-model="pageData.formData.appId"
+        clearable
+        placeholder="请输入appId"
+        size="small"
+        :readonly="isDetail"
+      />
+    </el-form-item>
+    <el-form-item label="密钥" prop="privateKey">
+      <el-input
+        v-model="pageData.formData.privateKey"
+        clearable
+        placeholder="请输入密钥"
+        size="small"
+        :readonly="isDetail"
+      />
+    </el-form-item>
+    <el-form-item label="公钥" prop="publicKey">
+      <el-input
+        v-model="pageData.formData.publicKey"
+        clearable
+        placeholder="请输入公钥"
+        size="small"
+        :readonly="isDetail"
+      />
+    </el-form-item>
+    <div>
+      <el-button v-if="!isDetail" type="primary" @click="handleConfirm"
+      >保存</el-button
+      >
+    </div>
+  </el-form>
+
 </template>