weiximei 5 years ago
parent
commit
367c214bac
1 changed files with 20 additions and 7 deletions
  1. 20
    7
      src/pages/UserManage/Editor/Miniapp.jsx

+ 20
- 7
src/pages/UserManage/Editor/Miniapp.jsx View File

14
     setVal(props.value)
14
     setVal(props.value)
15
   }, [props.value])
15
   }, [props.value])
16
 
16
 
17
+  console.log('props.value:', props)
18
+
17
   const handleChange = field => e => {
19
   const handleChange = field => e => {
18
-    const newVal = { ...val, [`${field}`]: (e.target ? e.target.value : e) }
20
+    // console.log(field, e)
21
+    let inputVal = null
22
+    if (field === 'tplId') {
23
+      inputVal = (e.target ? e.target.value : e)
24
+    }
25
+    if (field === 'fieldNum') {
26
+      inputVal = e
27
+    }
28
+    const newVal = { ...val, [`${field}`]: inputVal }
19
     setVal(newVal)
29
     setVal(newVal)
20
-
21
     if (typeof props.onChange === 'function') {
30
     if (typeof props.onChange === 'function') {
22
       console.log('--change--->', newVal)
31
       console.log('--change--->', newVal)
23
       props.onChange(newVal)
32
       props.onChange(newVal)
26
 
35
 
27
   return (
36
   return (
28
     <Input.Group compact ref={ref}>
37
     <Input.Group compact ref={ref}>
29
-      <Input style={{ width: '70%' }} value={val.tplId} placeholder="消息模板ID" onChange={handleChange('tplId')}></Input>
30
-      <InputNumber style={{ width: '30%' }} value={val.fieldNum} placeholder="字段数" onChange={handleChange('fieldNum')}></InputNumber>
38
+      <Input style={{ width: '70%' }} value={val.tplId} placeholder="消息模板ID" onChange={e => handleChange('tplId')(e)}></Input>
39
+      <InputNumber style={{ width: '30%' }} value={val.fieldNum} placeholder="字段数" onChange={e => handleChange('fieldNum')(e)}></InputNumber>
31
     </Input.Group>
40
     </Input.Group>
32
   );
41
   );
33
 })
42
 })
162
   ]
171
   ]
163
 
172
 
164
   const checkTPLData = (submitData) => {
173
   const checkTPLData = (submitData) => {
165
-    let tplData = [...tpls]
174
+    // let tplData = [...tpls]
175
+    let tplData = []
166
     let errors = []
176
     let errors = []
167
 
177
 
168
     Object.keys(submitData).forEach((key) => {
178
     Object.keys(submitData).forEach((key) => {
169
       if (key.indexOf('tpl-') === 0) {
179
       if (key.indexOf('tpl-') === 0) {
170
-        const [, code] = key.split('-')
180
+        // const [, code] = key.split('-')
181
+        const code = key.substring(key.indexOf('-') + 1, key.length)
182
+        console.log('code:', code)
171
         const { tplId, fieldNum } = submitData[key].result || submitData[key]
183
         const { tplId, fieldNum } = submitData[key].result || submitData[key]
172
         const tplType = (props.tplTyps || []).filter(x => x.code === code)[0] || {}
184
         const tplType = (props.tplTyps || []).filter(x => x.code === code)[0] || {}
173
-
185
+    
174
         if (tplId && !fieldNum) {
186
         if (tplId && !fieldNum) {
175
           errors.push(`请填写${tplType.name}模板字段数`)
187
           errors.push(`请填写${tplType.name}模板字段数`)
176
           return
188
           return
201
     console.log('-----val--->', val)
213
     console.log('-----val--->', val)
202
 
214
 
203
     const [tplData, errors] = checkTPLData(otherData)
215
     const [tplData, errors] = checkTPLData(otherData)
216
+    console.log('-----tplData--->', tplData)
204
 
217
 
205
     if (errors.length > 0) {
218
     if (errors.length > 0) {
206
       notification.error({ message: errors[0] })
219
       notification.error({ message: errors[0] })