回答

收藏

检索和表单同时使用的下拉数据封装

ddAdmin ddAdmin 1753 人阅读 | 0 人回复 | 2025-03-10

1、全部采用异步请求的方式处理,在init的文件中,需要注意enumList方法的请求接口地址不能使用path变量,直接使用真实接口
  1. import {
  2.   enumList
  3. } from './api'

  4. const getEnumList = async(type) => {
  5.   const arr = []
  6.   const response = await enumList({
  7.     type: type
  8.   })

  9.   const list = response.data.list
  10.   for (const key in list) {
  11.     arr.push({
  12.       text: list[key],
  13.       value: key
  14.     })
  15.   }
  16.   return arr
  17. }
复制代码
2、在表单中调用方法获取options

  1.   source: {
  2.     type: 'select',
  3.     label: '商机来源',
  4.     options: () => {
  5.       return getEnumList('businessSource')
  6.     }
  7.   },
复制代码



3、在检索中配置list值

  1. export const filterInfo = {
  2.   fieldList: [{
  3.     label: '关键字',
  4.     type: 'input',
  5.     placeholder: '请输入关键字',
  6.     value: 'DiandiBusinessOpportunityList[keywords]'
  7.   }, {
  8.     label: '客户名称',
  9.     type: 'input',
  10.     value: 'DiandiBusinessOpportunityList[name]'
  11.   }, {
  12.     label: '状态',
  13.     type: 'select',
  14.     value: 'DiandiBusinessOpportunityList[status]',
  15.     list: 'statusList'
  16.   }, {
  17.     label: '商机来源',
  18.     type: 'select',
  19.     value: 'DiandiBusinessOpportunityList[source]',
  20.     list: 'stjList'
  21.   }, {
  22.     label: '跟进人',
  23.     type: 'select',
  24.     value: 'DiandiBusinessOpportunityList[follower]'
  25.   }],
  26.   listTypeInfo: {
  27.     stjList: () => {
  28.       return getEnumList('businessSource')
  29.     },
  30.     statusList: () => {
  31.       return getEnumList('businessStatus')
  32.     }
  33.   }
  34. }
复制代码


分享到:
您需要登录后才可以回帖 登录 | 立即注册 |

本版积分规则

200 积分
12 主题