zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
 * @Author: lixiong
 * @Date: 2019-08-21 14:35:07
 * @Last Modified by: zheng
 * @Last Modified time: 2021-06-09 09:52:31
 */
 
/**
 * 贷款申请查询
 */
 
import ApiModel from '@dreamSend/serve/core/ApiModel'
import * as dayjs from 'dayjs'
 
// 表单信息
const formList = [
  {
    type: 'input',
    label: '模板编号',
    value: '',
    name: 'tempNo'
  },
  {
    type: 'select',
    label: '渠道名称',
    value: '',
    options: [],
    name: 'channelId',
    attrs: ['collapse-tags', 'filterable', 'clearable']
  },
  {
    type: 'select',
    label: '主体名称',
    value: '',
    options: [],
    name: 'accountId',
    attrs: ['collapse-tags', 'filterable', 'clearable']
  },
  {
    type: 'select',
    label: '状态',
    value: '',
    options: [],
    name: 'status',
    attrs: ['collapse-tags', 'filterable', 'clearable']
  },
  {
    type: 'select',
    label: '模板类型',
    value: '',
    options: [],
    name: 'tempType',
    attrs: ['collapse-tags', 'filterable', 'clearable']
  },
]
 
// 表格信息
const tableList = [
  {
    prop: "tempNo",
    label: "模板编号",
    width: "200px",
    // fixed: true,
    // type: "link" // link, button, buttons
  },
  {
    prop: 'tempName',
    label: '模板名称',
    width: '200px',
    showTooltip: true
  },
  {
    prop: 'channelName',
    label: '渠道',
    width: '120px'
  },
  {
    prop: 'accountName',
    label: '主体名称',
    width: '120px'
  },
  {
    prop: 'tempContent',
    label: '模板内容',
    width: '300px',
    showTooltip: true
  },
  {
    prop: 'createdBy',
    label: '创建人',
    width: '90px'
  },
  {
    prop: 'createdAt',
    label: '创建时间',
    width: '150px'
  },
  {
    prop: 'updatedBy',
    label: '更新人',
    width: '90px'
  },
  {
    prop: 'updatedAt',
    label: '更新时间',
    width: '150px'
  },
  {
    prop: "lastAction",
    label: "操作管理",
    width: "170px",
    type: "buttons",
    fixed: "right"
  }
]
 
export default options => {
  // 接口地址,required
  const api = 'admin/sms/temp'
 
  return new ApiModel({
    api,
    formList,
    tableList,
    request(params) {
      return this.get(params)
    },
    computedItem(item) {
      // 表格部分字段特殊处理
      let {
        termUnit,
        businessTermMonth,
        businessTermDay,
        amountloan,
        businessSum,
        updatedAt,
        createdAt
      } = item
      let businessTerm = ''
      if (termUnit === 'M' && businessTermMonth) {
        businessTerm = `${businessTermMonth}月`
      }
      if (termUnit === 'D' && businessTermDay) {
        businessTerm = `${businessTermDay}天`
      }
      amountloan =
        amountloan === '' || amountloan === '0' ? businessSum : amountloan
      item.updatedAt = updatedAt ? dayjs(updatedAt).format('YYYY-MM-DD HH:mm:ss') : ''
      item.createdAt = createdAt ? dayjs(createdAt).format('YYYY-MM-DD HH:mm:ss') : ''
      
      return { ...item, businessTerm, amountloan }
    },
    computedValue(val, name, list) {
      // 表单部分字段特殊处理(这里为:多选项按接口要求转换为拼接字符串)
      const { formList } = this
      if (typeof list === 'undefined') {
        list = [...formList]
      }
      if (
        formList.some(
          ({ attrs = [], name: findName }) =>
            attrs.includes('multiple') && findName === name
        )
      ) {
        return Array.isArray(val) ? val.join(',') : val
      }
 
      return val
    }
    // computedValues(values = {}) {
    //   const { formList } = this
    //   return Object.keys(values).reduce((pre, curr) => {
    //     // let { name, value } = curr
    //     let value = values[curr]
    //     const findItem = formList.find(
    //       item =>
    //         item.name === curr &&
    //         (Array.isArray(item.attrs) && item.attrs.includes('multiple'))
    //     )
    //     if (findItem && Array.isArray(value)) {
    //       value = value.join(',')
    //     }
    //     pre[curr] = value
    //     return pre
    //   }, {})
    // }
  })
}