amis icon indicating copy to clipboard operation
amis copied to clipboard

quickSaveItemApi配置了不生效了 beta1.0.15-beta.9

Open ClarenceStar opened this issue 6 years ago • 16 comments

我的配置schema是这样的 之前的版本应该是好的 是因为更新的缘故吗 quickSaveItemApi: { url: '/api/system/opsApiAlias', data: { requestUrl: '$requestUrl', apiAlias: '$apiAlias', }, } 需要更新的字段是这样配置的 { name: 'apiAlias', label: '操作', type: 'text', quickEditOn: 'logType==1', remark: '应用日志可编辑 设置备注', quickEdit: { type: 'text', required: true, saveImmediately: true, }, }

ClarenceStar avatar Jul 21 '20 08:07 ClarenceStar

不生效具体是哪块问题

RickCole21 avatar Jul 21 '20 09:07 RickCole21

不生效具体是哪块问题

就是我配了api 快捷保存也配置了 但是却没有触发接口调用

ClarenceStar avatar Jul 22 '20 03:07 ClarenceStar

貌似没复现,console里有啥报错么

RickCole21 avatar Jul 22 '20 03:07 RickCole21

image networks是空的 但是我明明配置了api

ClarenceStar avatar Jul 22 '20 03:07 ClarenceStar

试试补上 method 配置

2betop avatar Jul 22 '20 03:07 2betop

试试补上 method 配置

image 刚刚试了下 好像没用耶 都没有走api

ClarenceStar avatar Jul 22 '20 04:07 ClarenceStar

是不是你外部 fetcher 没有实现?

2betop avatar Jul 22 '20 06:07 2betop

是不是你外部 fetcher 没有实现?

实现了呢 就是这个接口没有触发 其他的api都是正常调用的 就是quickEdit这里没有生效 关键是上个月的版本还是好好的 更新了包就突然不行了

ClarenceStar avatar Jul 22 '20 07:07 ClarenceStar

完整配置贴一下

RickCole21 avatar Jul 22 '20 07:07 RickCole21

完整配置贴一下

{
  type: 'page',
  title: '操作记录',
  subTitle: '用户在本平台的操作记录:操作人 操作Api等',
  body: {
    type: 'crud',
    name: 'opsListCrud',
    api: {
      url:
        '/api/system/opsList?groupKey=$groupKey&currentPage=$currentPage&pageSize=$pageSize',
      method: 'get',
      data: {
        logType: '$logType',
      },
      requestAdaptor: (req: any) => {
        let decodeApi = decodeURIComponent(req.url)
        let argArray: Array<any> = decodeApi.match(/[^&=?]+=[^&]*/g) || []
        let valueList: Array<any> = []
        argArray.forEach((item: any) => {
          valueList.push(item.split('=')[1])
        })
        let logTypeList = valueList[3].split(',')
        if (logTypeList.length > 1) {
          req.url = `/api/system/opsList?groupKey=${valueList[0]}&currentPage=${valueList[1]}&pageSize=${valueList[2]}`
        } else {
          req.url = `/api/system/opsList?groupKey=${valueList[0]}&currentPage=${valueList[1]}&pageSize=${valueList[2]}&logType=${logTypeList[0]}`
        }
        return req
      },
      adaptor: (data: any) => {
        data.data?.opsList?.forEach((item: any) => {
          item.requestTime = formatTime(item.requestTime)
          item.apiAlias = item.apiAlias ? item.apiAlias : item.requestUrl
        })
        data.data.options = [
          {
            label: '系统日志',
            value: 0,
          },
          {
            label: '应用日志',
            value: 1,
          },
        ]
        return data
      },
    },
    source: '$opsList',
    // primaryField: 'id',
    pageField: 'currentPage',
    perPageField: 'pageSize',
    defaultParams: {
      pageSize: 20,
    },
    quickSaveItemApi: {
      url: '/api/system/opsApiAlias',
      requestAdaptor: (req: any) => {
        console.log(req)
        return req
      },
      method:'post',
      data: {
        requestUrl: '$requestUrl',
        apiAlias: '$apiAlias',
      },
    },
    // quickSaveApi: {
    //   url: '/api/system/opsApiAlias',
    //   data: {
    //     requestUrl:`${'$rows'}.0.requestUrl`,
    //     apiAlias:`${'$rows'}.0.apiAlias`,
    //   }
    // },
    hideQuickSaveBtn: true,
    filter: {
      title: '选择日志类型',
      controls: [
        {
          type: 'checkboxes',
          name: 'logType',
          source: '$options',
          inline: true,
          required: true,
          checkAll: true,
          defaultCheckAll: true,
        },
        {
          type: 'submit',
          level: 'primary',
          label: '确定',
        },
      ],
    },
    headerToolbar: [
      'filter-toggler',
      {
        type: 'tpl',
        tpl: '当前有 $count 条数据。',
      },
      'bulkActions',
      'pagination',
    ],
    footerToolbar: ['statistics', 'switch-per-page', 'pagination'],
    placeholder: '暂无数据',
    footable: true,
    filterTogglable: true,
    columns: [
      {
        name: 'userAccount',
        label: '操作人',
        type: 'text',
      },
      {
        name: 'pageName',
        label: '页面key',
        type: 'text',
      },
      {
        name: 'requestUrl',
        label: '操作API',
        type: 'text',
        breakpoint: '*',
      },
      {
        name: 'requestParameter',
        label: '请求参数',
        type: 'text',
        breakpoint: '*',
      },
      {
        name: 'responseStatusCode',
        label: '请求返回值',
        type: 'text',
        breakpoint: '*',
      },
      {
        name: 'apiAlias',
        label: '操作',
        type: 'text',
        quickEditOn: 'logType==1',
        remark: '应用日志可编辑 设置备注',
        quickEdit: {
          type: 'text',
          required: true,
          saveImmediately: true,
        },
      },
      {
        name: 'requestTime',
        label: '操作时间',
        type: 'text',
      },
    ],
  },
}

这是我的schema 用js写的

ClarenceStar avatar Jul 22 '20 07:07 ClarenceStar

不行,复现不了,你提交修改数据后,console面板里有啥报错没

image

RickCole21 avatar Jul 22 '20 07:07 RickCole21

或者你升级最新版本试试1.0.15-beta.11

RickCole21 avatar Jul 22 '20 07:07 RickCole21

image 就是看不到错误

不行,复现不了,你提交修改数据后,console面板里有啥报错没

image

ClarenceStar avatar Jul 22 '20 07:07 ClarenceStar

好的 我再试下升个版本吧

ClarenceStar avatar Jul 22 '20 07:07 ClarenceStar

或者你升级最新版本试试1.0.15-beta.11

我升到最新的beta版本 quickEdit的接口还是没有触发 我的schema配置看了下是没问题的

ClarenceStar avatar Jul 23 '20 07:07 ClarenceStar

quickEditOn 阻塞了接口 换成 quickEditEnabledOn属性即可 感谢amis团队答疑解惑

ClarenceStar avatar Oct 27 '20 11:10 ClarenceStar