当前位置: 首页 > news >正文

2025.3.27-2025.3.30

 1.useTable

复盘一下最近让同事帮忙解决的问题:

1.soybean的框架 useTable 的 动态添加吗,某列:


 

watch(
  () => invoiceType,
  (val: any) => {
    if (val.value === 0) {
      columnChecks.value[11].checked = false;
    }
    if (val.value !== 0) {
      columnChecks.value[11].checked = true;
    }
  },
  { deep: true, immediate: true }
);

// 表格
const {
  columns,
  columnChecks,
  data
  // getData,
  // getDataByPage,
  // loading,
  // mobilePagination
  // searchParams,
  // resetSearchParams
}: any = useTable({
  apiFn: () => {
    return new Promise(resolve => {
      resolve({
        data: {
          records: [
            {
              key: 1, // 确保数据包含 key
              index: 1,
              phone: '13800138000',
              name: '张三',
              orderId: 1001,
              orderTime: new Date(),
              departure: '北京',
              destination: '上海',
              goodName: '电子产品',
              car: '京A12345',
              pay: '¥5000'
            },
            {
              key: 2, // 确保数据包含 key
              index: 1,
              phone: '13800138000',
              name: '李四',
              orderId: 1001,
              orderTime: new Date(),
              departure: '北京',
              destination: '上海',
              goodName: '电子产品',
              car: '京A12345',
              pay: '¥5000'
            }
          ],
          current: 1,
          size: 10,
          total: 200
        }
      } as any);
    });
  },
  showTotal: true,
  apiParams: {
    current: 1,
    size: 10
  } as any,
  columns: () => [
    {
      type: 'selection'
      // key: 'selection'
    },
    {
      key: 'index',
      title: '序号',
      align: 'center',
      width: 64
    },
    {
      key: 'phone',
      title: '发单人电话',
      align: 'center',
      width: 120
    },
    {
      key: 'name',
      title: '发单人姓名',
      align: 'center',
      width: 100
    },
    {
      key: 'orderId',
      title: '运单编号',
      align: 'center',
      width: 100
    },
    {
      key: 'orderTime',
      title: '发单时间',
      align: 'center',
      width: 120
    },
    {
      key: 'departure',
      title: '装货地址',
      align: 'center',
      width: 100
    },
    {
      key: 'destination',
      title: '卸货地址',
      align: 'center',
      width: 120
    },
    {
      key: 'goodName',
      title: '货物名称',
      align: 'center',
      width: 100
    },
    {
      key: 'car',
      title: '承运车',
      align: 'center',
      width: 120
    },
    {
      key: 'pay',
      title: '运单实付',
      align: 'center',
      width: 120
    },
    {
      key: 'operate',
      title: '操作',
      align: 'center',
      width: 120,
      render: () => (
        <div>
          <a href="#" onClick={() => (showCheckInfo.value = true)}>
            查看
          </a>
        </div>
      )
    }
  ]
});

2.分页器

题外话:推荐阅读文档:useTableHook 函数 | SoybeanAdmin
(这里也学会了该如何阅读文档哈~)

再说一句题外话:

export function getDispatchBlackList(data: baseParams) { // 注意此处的类型哈
  return request({
    url: '/rescue/Driver/getDispatchBlackList',
    method: 'post',
    data
  });
}

 gobal.d.ts

  export interface baseParams {
    [key: string]: any;
  }

useTable

const {
  columns,
  // columnChecks,
  data,
  // getData,
  // getDataByPage,
  loading,
  pagination,
  updatePagination
  // mobilePagination
  // searchParams,
  // resetSearchParams
}: any = useTable({
  apiFn: getDispatchBlackList, // 这里只需直接添加访问接口的方法即可
  showTotal: true,
  apiParams: {
    pageNum: 1,
    pageSize: 20
  } as any,
  columns: () =>
    [
      {
        title: '司机头像',
        key: 'pic',
        align: 'center'
      },
      {
        title: '司机姓名',
        key: 'driverName',
        align: 'center'
      },
      {
        title: '手机尾号',
        key: 'phone',
        align: 'center'
      },
      {
        title: '拉黑时间',
        key: 'blackTime',
        align: 'center'
      },
      {
        title: '操作',
        key: 'operate',
        align: 'center',
        render: () => <NButton type="info">移除</NButton>
      }
    ] as any
});

完成这个诉求的根本文档重点是在步骤三和步骤四:

步骤三表明了:后端接口的返回值必须要符合相应的结构,否则就要使用transformer函数来进行修改结构了!

步骤四:

提一句,步骤五我怎么看着有点多余,但是一般情况下是不会画蛇添足的。我肯定有什么东西尚未参透! 

3.腾讯地图(尚未被我攻略!)

4.强推待看文档一篇

https://juejin.cn/post/7156482845614030862

5.uni小程序(路由攻略一篇

vite-plugin-uni-pages | Uni Helper

相关文章:

  • C语言基础—构造类型
  • ubuntu 安装 g++
  • QT6使用Mysql全流程
  • StarRocks 证书SRCA和SRCP
  • 内容中台的数字化管理价值是什么?
  • UniApp开发多端应用——流式语音交互场景优化
  • uvm configuration
  • 线程同步——条件变量
  • supabase新增用户的完整流程和注册
  • Pycharm(七):几个简单案例
  • 从排泄危机到数字免疫:解码餐饮业“全息食安大脑“的进化逻辑
  • SQL 链接服务器的查询提示“不允许使用远程表值函数调用”(NOLOCK)
  • 【Deepseek】Deepseek学习
  • vscode连接服务器失败问题解决
  • JavaScript中闭包的使用
  • 【vLLM 学习】快速入门
  • React19源码系列之Hooks(useRef)
  • SQL中累计求和与滑动求和函数sum() over()的用法
  • WebRTC简介及应用
  • 惠购供应链 SAAS 系统正式上线,构建数字商业生态版图
  • 香港建设 天津 招聘信息网站/seochan是什么意思
  • 自己做的网站怎么被百度收录/产品如何做市场推广
  • 高校里做网站的工作/长沙推广引流
  • app资源网站开发/seopeix
  • 塑料机械怎么做网站/指数搜索
  • 网站类型/今日舆情热点