liu_lake il y a 5 mois
Parent
commit
92495fe69f

+ 40 - 0
agent-ui/src/api/auth/routes.ts

@@ -4,6 +4,46 @@ import { get, Result } from "../base";
  * 当前用户的路由信息
  * @returns .
  */
+export function menuList(): Promise<any> {
+  return  [
+    {
+      component: "order/index",
+      meta: {
+        icon: "fa-solid:th-list",
+        keepAlive: false,
+        showLink: true,
+        showParent: false,
+        title: "订单管理"
+      },
+      name: "order",
+      path: "/order"
+    },
+    {
+      component: "channel/index",
+      meta: {
+        icon: "fa-solid:align-justify",
+        keepAlive: false,
+        showLink: true,
+        showParent: false,
+        title: "通道管理"
+      },
+      name: "channel",
+      path: "/channel"
+    },
+    {
+      component: "merchant/index",
+      meta: {
+        icon: "ep:avatar",
+        keepAlive: false,
+        showLink: true,
+        showParent: true,
+        title: "商户管理"
+      },
+      name: "merchant",
+      path: "/merchant"
+    }
+  ]
+}
 export function getRoutes(): Promise<Result<any>> {
   return get<any, Result<any>>("/sys/permission/routes", {});
 }

+ 7 - 7
agent-ui/src/api/order/index.ts

@@ -6,7 +6,7 @@ import { Result, deleteRequest, get, post, put } from "../base";
  * @returns .
  */
 export function queryPage<T>(query?: any): Promise<Result<T>> {
-  return get("/merchant/pay/order/page", query);
+  return get("/agent/pay/order/page", query);
 }
 
 /**
@@ -15,7 +15,7 @@ export function queryPage<T>(query?: any): Promise<Result<T>> {
  * @returns .
  */
 export function queryList<T>(query?: any): Promise<Result<T>> {
-  return get("/merchant/pay/order/list", query);
+  return get("/agent/pay/order/list", query);
 }
 
 /**
@@ -24,7 +24,7 @@ export function queryList<T>(query?: any): Promise<Result<T>> {
  * @returns .
  */
 export function save<T>(data: any): Promise<Result<T>> {
-  return post("/merchant/pay/order/save", data);
+  return post("/agent/pay/order/save", data);
 }
 
 /**
@@ -34,7 +34,7 @@ export function save<T>(data: any): Promise<Result<T>> {
  * @returns  .
  */
 export function update<T>(id: string, data: any): Promise<Result<T>> {
-  return put(`/merchant/pay/order/update/${id}`, {}, data);
+  return put(`/agent/pay/order/update/${id}`, {}, data);
 }
 
 /**
@@ -43,7 +43,7 @@ export function update<T>(id: string, data: any): Promise<Result<T>> {
  * @returns  .
  */
 export function del<T>(userIds: string[]): Promise<Result<T>> {
-  return deleteRequest(`/merchant/pay/order/remove`, {}, userIds);
+  return deleteRequest(`/agent/pay/order/remove`, {}, userIds);
 }
 
 
@@ -53,7 +53,7 @@ export function del<T>(userIds: string[]): Promise<Result<T>> {
  * @returns  .
  */
 export function queryPayStatus<T>(id: string): Promise<Result<T>> {
-  return get(`/merchant/pay/order/status/${id}`,{});
+  return get(`/agent/pay/order/status/${id}`,{});
 }
 
 
@@ -65,5 +65,5 @@ export function queryPayStatus<T>(id: string): Promise<Result<T>> {
  * @returns  .
  */
 export function orderCallback<T>(id: string): Promise<Result<T>> {
-  return get(`/merchant/pay/order/callback/${id}`,{});
+  return get(`/agent/pay/order/callback/${id}`,{});
 }

+ 2 - 1
agent-ui/src/router/utils.ts

@@ -24,7 +24,7 @@ import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
 import { usePermissionStoreHook } from "@/store/modules/permission";
 // 动态路由
 // import { getAsyncRoutes } from "@/api/routes";
-import { getRoutes } from "@/api/auth/routes";
+import {getRoutes, menuList} from "@/api/auth/routes";
 import { useAuthStoreHook } from "@/store/modules/auth";
 
 const IFrame = () => import("@/layout/frameView.vue");
@@ -149,6 +149,7 @@ function addPathMatch() {
 
 /** 处理动态路由(后端返回的路由) */
 function handleAsyncRoutes(routeList) {
+  routeList = menuList();
   if (routeList.length === 0) {
     usePermissionStoreHook().handleWholeMenus(routeList);
   } else {

+ 30 - 0
merchant-ui/src/api/auth/routes.ts

@@ -4,6 +4,36 @@ import { get, Result } from "../base";
  * 当前用户的路由信息
  * @returns .
  */
+export function menuList(): Promise<any> {
+  return  [
+      {
+        component: "order/index",
+        meta: {
+          icon: "fa-solid:th-list",
+          keepAlive: false,
+          showLink: true,
+          showParent: false,
+          title: "订单管理"
+        },
+        name: "order",
+        path: "/order"
+      },
+      {
+        component: "paytest/index",
+        meta: {
+          icon: "ep:share",
+          keepAlive: false,
+          showLink: true,
+          showParent: true,
+          title: "支付测试"
+        },
+        name: "paytest",
+        path: "/paytest/index"
+      }
+    ]
+}
 export function getRoutes(): Promise<Result<any>> {
   return get<any, Result<any>>("/sys/permission/routes", {});
 }
+
+

+ 10 - 8
merchant-ui/src/api/order/index.ts

@@ -6,7 +6,7 @@ import { Result, deleteRequest, get, post, put } from "../base";
  * @returns .
  */
 export function queryPage<T>(query?: any): Promise<Result<T>> {
-  return get("/agent/pay/order/page", query);
+  return get("/merchant/pay/order/page", query);
 }
 
 /**
@@ -15,7 +15,7 @@ export function queryPage<T>(query?: any): Promise<Result<T>> {
  * @returns .
  */
 export function queryList<T>(query?: any): Promise<Result<T>> {
-  return get("/agent/pay/order/list", query);
+  return get("/merchant/pay/order/list", query);
 }
 
 /**
@@ -24,7 +24,7 @@ export function queryList<T>(query?: any): Promise<Result<T>> {
  * @returns .
  */
 export function save<T>(data: any): Promise<Result<T>> {
-  return post("/agent/pay/order/save", data);
+  return post("/merchant/pay/order/save", data);
 }
 
 /**
@@ -34,7 +34,7 @@ export function save<T>(data: any): Promise<Result<T>> {
  * @returns  .
  */
 export function update<T>(id: string, data: any): Promise<Result<T>> {
-  return put(`/agent/pay/order/update/${id}`, {}, data);
+  return put(`/merchant/pay/order/update/${id}`, {}, data);
 }
 
 /**
@@ -43,7 +43,7 @@ export function update<T>(id: string, data: any): Promise<Result<T>> {
  * @returns  .
  */
 export function del<T>(userIds: string[]): Promise<Result<T>> {
-  return deleteRequest(`/agent/pay/order/remove`, {}, userIds);
+  return deleteRequest(`/merchant/pay/order/remove`, {}, userIds);
 }
 
 
@@ -53,10 +53,12 @@ export function del<T>(userIds: string[]): Promise<Result<T>> {
  * @returns  .
  */
 export function queryPayStatus<T>(id: string): Promise<Result<T>> {
-  return get(`/agent/pay/order/status/${id}`,{});
+  return get(`/merchant/pay/order/status/${id}`,{});
 }
 
-
+export function test<T>(): Promise<Result<T>> {
+  return get(`/merchant/pay/order/test`, {});
+}
 
 
 /**
@@ -65,5 +67,5 @@ export function queryPayStatus<T>(id: string): Promise<Result<T>> {
  * @returns  .
  */
 export function orderCallback<T>(id: string): Promise<Result<T>> {
-  return get(`/agent/pay/order/callback/${id}`,{});
+  return get(`/merchant/pay/order/callback/${id}`,{});
 }

+ 2 - 1
merchant-ui/src/router/utils.ts

@@ -24,7 +24,7 @@ import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
 import { usePermissionStoreHook } from "@/store/modules/permission";
 // 动态路由
 // import { getAsyncRoutes } from "@/api/routes";
-import { getRoutes } from "@/api/auth/routes";
+import {getRoutes, menuList} from "@/api/auth/routes";
 import { useAuthStoreHook } from "@/store/modules/auth";
 
 const IFrame = () => import("@/layout/frameView.vue");
@@ -149,6 +149,7 @@ function addPathMatch() {
 
 /** 处理动态路由(后端返回的路由) */
 function handleAsyncRoutes(routeList) {
+  routeList = menuList();
   if (routeList.length === 0) {
     usePermissionStoreHook().handleWholeMenus(routeList);
   } else {

+ 19 - 0
merchant-ui/src/views/paytest/index.vue

@@ -0,0 +1,19 @@
+
+<script setup lang="ts">
+import * as $merchantApi from "@/api/merchant";
+import Edit from "@/views/paytest/modules/edit.vue";
+import {ref} from "vue";
+
+const editRef = ref();
+const payTest = () => {
+  editRef.value!.open();
+};
+</script>
+<template>
+  <div>
+  <el-card style="width: 480px; border-radius: 8px" shadow="hover" @click="payTest">
+      支付测试
+  </el-card>
+    <edit ref="editRef" />
+  </div>
+</template>

+ 51 - 0
merchant-ui/src/views/paytest/modules/edit.vue

@@ -0,0 +1,51 @@
+<script setup lang="ts">
+import { reactive, ref } from "vue";
+import { message } from "@/utils/message";
+import * as $api from "@/api/order/index";
+import type { FormInstance } from "element-plus";
+import { cloneDeep } from "@pureadmin/utils";
+
+const title = "";
+defineOptions({ name: "templateEdit1" });
+const isDetail = ref(false);
+const formRef = ref<FormInstance>();
+// 初始化数据
+const initData = {
+  userName: undefined,
+  password: undefined,
+  status: 1
+};
+
+// 表单校验规则
+const formRules = {};
+
+// 页面数据
+const pageData: any = reactive({
+  dialogVisible: false,
+  title: "",
+  formLoading: false,
+  mode: "add",
+  isUpdate: false,
+  // 表单数据
+  formData: initData,
+  formRules: formRules
+});
+// 暴露给父级调用
+const emits = defineEmits(["ok", "close"]);
+const src = ref();
+// 打开弹窗
+const open = (data: any, dataSource: any, mode: string) => {
+  $api.test().then((res: any) => {
+    src.value = "data:image/png;base64," + res.result.result.imageBase64;
+  })
+  pageData.dialogVisible = true;
+};
+defineExpose({ open });
+</script>
+
+<template>
+  <el-dialog v-model="pageData.dialogVisible" destroy-on-close :width="500">
+
+    <img :src="src" />
+  </el-dialog>
+</template>

+ 371 - 0
merchant-ui/src/views/paytest/modules/list.vue

@@ -0,0 +1,371 @@
+<script setup lang="ts">
+import FormSearch, { type FormField } from "@/components/opts/form-search.vue";
+import TableButtons from "@/components/opts/btns2.vue";
+import Edit from "./edit.vue";
+import { PureTable } from "@pureadmin/table";
+import { computed, onBeforeMount, onMounted, reactive, ref, watch } from "vue";
+import * as $api from "@/api/agent/index";
+import { hasAuth } from "@/router/utils";
+import message from "@/utils/message";
+import { enableOptions } from "@/constants/constants";
+import { cloneDeep } from "@pureadmin/utils";
+
+const editRef = ref();
+
+defineOptions({
+  name: "merchantList"
+});
+
+const props: any = defineProps({
+  mode: {
+    required: false,
+    type: String,
+    default: "table"
+  }
+});
+
+const searchFormFields = computed((): FormField[] => {
+  const fields: FormField[] = [
+    {
+      type: "input",
+      label: "代理商名称",
+      prop: "agentname",
+      placeholder: "请输入代理商名模糊查询"
+    },
+    {
+      type: "select",
+      label: "状态",
+      prop: "status",
+      placeholder: "请选择",
+      dataSourceKey: "enableOptions",
+      options: {
+        keys: {
+          label: "label",
+          value: "value",
+          prop: "value"
+        },
+        filterable: true
+      }
+    }
+  ];
+  if (props.mode === "table") {
+    return fields;
+  } else {
+    return fields;
+  }
+});
+
+const pageData: any = reactive({
+  mode: "table",
+  permission: {
+    query: ["user:query"],
+    save: ["user:save"],
+    update: ["user:update"],
+    del: ["user:del"]
+  },
+  searchParam: {
+    searchState: true,
+    searchForm: {}
+  },
+  dataSource: {
+    enableOptions: enableOptions
+  },
+  /*按钮 */
+  btnOpts: {
+    size: "small",
+    leftBtns: [
+      {
+        key: "add",
+        label: "新增",
+        type: "primary",
+        icon: "ep:plus",
+        state: true,
+        permission: ["user:save"]
+      }
+    ],
+    rightBtns: [
+      {
+        key: "search",
+        label: "查询",
+        icon: "ep:search",
+        state: true,
+        options: {
+          circle: true
+        }
+      },
+      {
+        key: "refresh",
+        label: "刷新",
+        icon: "ep:refresh",
+        state: true,
+        options: {
+          circle: true
+        }
+      }
+    ]
+  },
+  tableParam: {
+    list: [],
+    columns: [
+      {
+        label: "ID",
+        prop: "id",
+        slot: "id",
+        width: 220
+      },
+      {
+        label: "代理商名称",
+        prop: "userName",
+        slot: "userName"
+      },
+      {
+        label: "余额",
+        prop: "amount",
+        slot: "amount"
+      },
+      {
+        label: "谷歌校验器",
+        prop: "hasTpop",
+        slot: "hasTpop"
+      },
+      {
+        label: "状态",
+        prop: "status",
+        slot: "status"
+      },
+      {
+        label: "更新时间",
+        prop: "updateTime",
+        slot: "updateTime"
+      },
+      {
+        label: "操作",
+        fixed: "right",
+        slot: "operation"
+      }
+    ],
+    loading: false,
+    pagination: {
+      small: true,
+      pageSize: 10,
+      defaultPageSize: 10,
+      currentPage: 1,
+      background: true,
+      total: 0
+    }
+  }
+});
+
+const btnClickHandle = (val: string) => {
+  switch (val) {
+    case "add":
+      editRef.value!.open({ enable: 1 }, pageData.dataSource, "add");
+      break;
+    case "update":
+      break;
+    case "search":
+      _updateSearchState();
+      break;
+    case "refresh":
+      _loadData();
+      break;
+    case "switch":
+      break;
+    default:
+      break;
+  }
+};
+
+/**
+ *  更新搜索表单
+ * @param data .
+ */
+const _updateSearchFormData = (data: any) => {
+  pageData.searchParam.searchForm = data;
+};
+/**
+ * 点击搜索按钮
+ */
+const _searchForm = (data: any) => {
+  pageData.searchParam.searchForm = data;
+  _loadData();
+};
+/**
+ * 重置
+ */
+const _resetSearchForm = (data?: any) => {
+  pageData.searchParam.searchForm = data;
+};
+/**
+ * 更新搜索表达的状态
+ */
+const _updateSearchState = () => {
+  pageData.searchParam.searchState = !pageData.searchParam.searchState;
+};
+/**
+ * 分页 - 改变每页条数
+ * @param val .
+ */
+const handleChangePageSize = (val: any) => {
+  pageData.tableParam.pagination.pageSize = val;
+  _loadData();
+};
+/**
+ * 分页 - 改变页码
+ * @param val .
+ */
+const handleChangeCurrentPage = (val: any) => {
+  pageData.tableParam.pagination.currentPage = val;
+  _loadData();
+};
+/**
+ * 获取查询参数
+ */
+const getQueryParams = () => {
+  const sqp = {};
+  const param = Object.assign(sqp, pageData.searchParam.searchForm);
+  param.current = pageData.tableParam.pagination.currentPage;
+  param.size = pageData.tableParam.pagination.pageSize;
+  return param;
+};
+/**
+ * 获取列表数据
+ * @param page .
+ */
+const _loadData = (page?: number) => {
+  const query = getQueryParams();
+  if (page) {
+    query.current = page;
+  }
+  pageData.tableParam.loading = true;
+  $api
+    .queryPage(query)
+    .then((res: any) => {
+      if (res.success) {
+        pageData.tableParam.list = res.result.records;
+        pageData.tableParam.pagination.total = Number(res.result.total);
+      }
+    })
+    .finally(() => {
+      pageData.tableParam.loading = false;
+    });
+};
+/**
+ * 查看详情
+ * @param row .
+ */
+const handleDetail = (row: any) => {
+  editRef.value!.open(cloneDeep(row), pageData.dataSource, "detail");
+};
+/**
+ * 编辑
+ * @param row .
+ */
+const handleEdit = (row: any) => {
+  editRef.value!.open(cloneDeep(row), pageData.dataSource, "edit");
+};
+/**
+ * 删除
+ * @param row .
+ */
+const handleDel = (row: any) => {
+  message.confirm(`确认删除 id 为 (${row.id}) 的数据?`).then(() => {
+    batchDel([row.id]);
+  });
+};
+/**
+ * 批量删除
+ * @param ids .
+ */
+const batchDel = (ids: string[]) => {
+  if (ids && ids.length > 0) {
+    $api.del(ids).then((res: any) => {
+      if (res.success) {
+        message.success("删除成功");
+        _loadData();
+      } else {
+        message.warning(res.message);
+      }
+    });
+  }
+};
+watch(
+  () => props.orgInfo,
+  val => {
+    if (val) {
+      _loadData();
+    }
+  }
+);
+onBeforeMount(() => {});
+onMounted(() => {
+  _loadData(1);
+});
+</script>
+
+<template>
+  <div>
+    <form-search
+      size="small"
+      :show="pageData.searchParam.searchState"
+      :form-field="searchFormFields"
+      :data-source="pageData.dataSource"
+      :query-permission="pageData.permission.query"
+      @search-form="_updateSearchFormData"
+      @search="_searchForm"
+      @reset="_resetSearchForm"
+    />
+    <!--operate-->
+    <table-buttons
+      :size="pageData.btnOpts.size"
+      :left-btns="pageData.btnOpts.leftBtns"
+      :right-btns="pageData.btnOpts.rightBtns"
+      @click="btnClickHandle"
+    />
+    <!--table-->
+    <pure-table
+      :data="pageData.tableParam.list"
+      :columns="pageData.tableParam.columns"
+      row-key="id"
+      size="small"
+      border
+      stripe
+      :header-row-class-name="'table-header'"
+      :loading="pageData.tableParam.loading"
+      :pagination="pageData.tableParam.pagination"
+      @page-current-change="handleChangeCurrentPage"
+      @page-size-change="handleChangePageSize"
+    >
+      <template #ellipsis="{ row, column }">
+        <el-tooltip placement="top-start" :content="row[column.property]"
+          >{{ row[column.property] }}
+        </el-tooltip>
+      </template>
+      <template #enableScope="scope">
+        <el-tag v-if="scope.row.enable">启用</el-tag>
+        <el-tag v-else type="info">禁用</el-tag>
+      </template>
+      <template #operation="{ row }">
+        <div class="flex justify-center items-center">
+          <el-link
+            v-show="hasAuth(pageData.permission.update)"
+            type="primary"
+            @click="handleEdit(row)"
+            >编辑
+          </el-link>
+          <el-divider
+            v-show="hasAuth(pageData.permission.del)"
+            direction="vertical"
+          />
+          <el-link
+            v-show="hasAuth(pageData.permission.del)"
+            type="primary"
+            @click="handleDel(row)"
+            >删除
+          </el-link>
+        </div>
+      </template>
+    </pure-table>
+    <edit ref="editRef" @ok="_loadData" />
+  </div>
+</template>