puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8" />
  <title>amis demo</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta
          name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1"
  />
  <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  <link rel="stylesheet" href="${ctxPath}/sdk/sdk.css" />
  <link rel="stylesheet" href="${ctxPath}/sdk/helper.css" />
  <link rel="stylesheet" href="${ctxPath}/sdk/iconfont.css" />
  <!-- 这是默认主题所需的,如果是其他主题则不需要 -->
  <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11,如果要支持 IE11 请引用这个 css,并把前面那个删了 -->
  <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
  <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果,所以可能有细节功能用不了,如果发现请报 issue -->
  <style>
    html,
    body,
    .app-wrapper {
      position: relative;
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }
  </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<script src="${ctxPath}/sdk/sdk.js"></script>
<script type="text/javascript">
  (function () {
    let amis = amisRequire('amis/embed');
    // 通过替换下面这个配置来生成不同页面
    let amisJSON = {
      "type": "form",
      "body": [
        {
          "type": "grid",
          "id": "u:747bced162da",
          "columns": [
          ]
        },
        {
          "type": "input-text",
          "id": "u:32cb99df3eb8",
          "label": "id",
          "name": "id",
          "size": "md",
          "mode": "horizontal",
          "hidden": true,
          "value":`${item.id!}`
        },
 
        {
          "type": "tpl",
          "id": "u:2dd6bf52bf62",
          "tpl": "学员信息",
          "inline": true,
          "wrapperComponent": "h2"
        },
        {
          "type": "input-text",
          "label": "所属用户",
          "id": "u:b60e636c6098",
          "name": "userName",
          "size": "md",
          "mode": "horizontal",
          "required": true,
          "disabled": true,
          "value":`${item.userName!}`
        },
        {
          "type": "input-text",
          "label": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp姓名",
          "id": "u:0b2463bbffe8",
          "name": "name",
          "size": "md",
          "mode": "horizontal",
          "required": true,
          "value":`${item.name!}`
        },
        {
          "type": "input-date",
          "label": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp生日",
          "name": "birthday",
          "id": "u:9fe564fc31fc",
          "size": "md",
          "mode": "horizontal",
          "embed": false,
          "format": "YYYY-MM-DD hh:mm:ss",
          "inputFormat": "YYYY-MM-DD",
          "required": true,
          "value":`${item.birthday!}`
        },
        {
          "type": "select",
          "label": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp性别",
          "name": "sex",
          "id": "u:196a32204b25",
          "size": "md",
          "mode": "horizontal",
          "options": [
            {
              "label": "男",
              "value": "1"
            },
            {
              "label": "女",
              "value": "2"
            }
          ],
          "multiple": false,
          "required": true,
          "value":`${item.sex!}`
        },
        {
          "type": "input-text",
          "label": "联系电话",
          "name": "phone",
          "id": "u:e7cf50e4f755",
          "size": "md",
          "mode": "horizontal",
          "required": true,
          "validationErrors": {
            "isPhoneNumber": "请输入正确的手机号"
          },
          "validateOnChange": true,
          "validations": {
            "isPhoneNumber": true
          },
          "value":`${item.phone!}`
        },
        {
          "type": "input-text",
          "label": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp身高",
          "name": "height",
          "id": "u:c69b5e6ae298",
          "size": "md",
          "mode": "horizontal",
          "required": true,
          "validationErrors": {
            "maximum": "请输入正确的身高",
            "isNumeric": "请输入数字"
          },
          "validateOnChange": true,
          "validations": {
            "maximum": 250,
            "isNumeric": true
          },
          "addOn": {
            "label": "cm",
            "type": "text"
          },
          "value":`${item.height!}`
        },
        {
          "type": "input-text",
          "label": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp体重",
          "name": "weight",
          "id": "u:e1e5d1a95e71",
          "size": "md",
          "mode": "horizontal",
          "required": true,
          "addOn": {
            "label": "kg",
            "type": "text"
          },
          "validationErrors": {
            "maximum": "请输入正确的身高",
            "isNumeric": "请输入数字"
          },
          "validateOnChange": true,
          "validations": {
            "maximum": 250,
            "isNumeric": true
          },
          "value":`${item.weight!}`
        },
        {
          "type": "input-text",
          "id": "u:75a1f3f0c491",
          "label": "身份证号",
          "name": "idCard",
          "size": "md",
          "mode": "horizontal",
          "required": false,
          "validateOnChange": true,
          "value":`${item.idCard!}`
        },
        {
          "type": "tpl",
          "tpl": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp体测表:请上传长图&nbsp&nbsp&nbsp&nbsp推荐像素:宽度780px",
          "inline": true,
          "wrapperComponent": "",
          "id": "u:8224ab367da8"
        },
        {
          "type": "input-image",
          "id": "u:53e0d6a37b69",
          "label": "",
          "name": "image1",
          "autoUpload": true,
          "proxy": true,
          "uploadType": "fileReceptor",
          "imageClassName": "r w-full",
          "receiver": {
            "url": "/mgr/uploadImgAmis",
            "method": "post"
          },
          "accept": ".jpeg, .jpg, .png, .gif",
          "multiple": false,
          "hideUploadButton": false,
          "fixedSize": false,
          "mode": "inline",
          "value":`${pic1!}`
        },
        {
          "type": "input-image",
          "id": "u:53e0d6a37b69",
          "label": "",
          "name": "image2",
          "autoUpload": true,
          "proxy": true,
          "uploadType": "fileReceptor",
          "imageClassName": "r w-full",
          "receiver": {
            "url": "/mgr/uploadImgAmis",
            "method": "post"
          },
          "accept": ".jpeg, .jpg, .png, .gif",
          "multiple": false,
          "hideUploadButton": false,
          "fixedSize": false,
          "mode": "inline",
          "value":`${pic2!}`
        },
        {
          "type": "input-image",
          "id": "u:53e0d6a37b69",
          "label": "",
          "name": "image3",
          "autoUpload": true,
          "proxy": true,
          "uploadType": "fileReceptor",
          "imageClassName": "r w-full",
          "receiver": {
            "url": "/mgr/uploadImgAmis",
            "method": "post"
          },
          "accept": ".jpeg, .jpg, .png, .gif",
          "multiple": false,
          "hideUploadButton": false,
          "fixedSize": false,
          "mode": "inline",
          "value":`${pic3!}`
        },
        {
          "type": "container",
          "body": [
            {
              "type": "tpl",
              "id": "u:8224ab367da8",
              "tpl": "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp",
              "inline": true,
              "wrapperComponent": ""
            },
            {
              "type": "button",
              "id": "u:783ce71739db",
              "label": "保存",
              "onEvent": {
                "click": {
                  "actions": [
                    {
                      "componentId": "u:7c5f75a3b7b5",
                      "args": {
                      },
                      "outputVar": "responseResult",
                      "actionType": "submit"
                    },
                    {
                      "args": {
                      },
                      "script": "parent.layer.close(window.parent.TStudent.layerIndex);\n\n                    window.parent.TStudent.table.refresh();",
                      "actionType": "custom"
                    }
                  ]
                }
              },
              "level": "info"
            },
            {
              "type": "tpl",
              "id": "u:8224ab367da8",
              "tpl": "&nbsp&nbsp&nbsp",
              "inline": true,
              "wrapperComponent": ""
            },
            {
              "type": "button",
              "id": "u:008bc32396cc",
              "label": "取消",
              "onEvent": {
                "click": {
                  "actions": [
                    {
                      "args": {
                      },
                      "script": "parent.layer.close(window.parent.TStudent.layerIndex);\nconsole.log(\"===关闭\")",
                      "actionType": "custom"
                    }
                  ]
                }
              },
              "block": false
            }
          ],
          "style": {
            "position": "static",
            "display": "block"
          },
          "id": "u:59d68a32f7fd"
        }
      ],
      "id": "u:7c5f75a3b7b5",
      "api": {
        "method": "post",
        "url": "/tStudent/update",
        "messages": {
        }
      },
      "actions": [
      ],
      "title": "编辑",
      "mode": "normal",
      "validateOnChange": true
    };
    let amisScoped = amis.embed('#root', amisJSON);
 
 
  })();
 
  function test(){
    console.log("测试成功")
  }
 
  var myButton = document.getElementById("ttt");
  myButton.addEventListener("click",test);
</script>
 
</body>
</html>