baozhangchao před 3 roky
rodič
revize
301d662596

+ 3
- 3
src/components/XForm/ImageUpload.jsx Zobrazit soubor

@@ -1,8 +1,8 @@
1 1
 import React from 'react';
2 2
 import { Upload, Icon, message } from 'antd';
3 3
 import './style.less';
4
-import { uploaderProps } from '../../utils/upload';
5
-
4
+import { uploaderProps } from '@/utils/upload';
5
+import { getImgURL } from '@/utils/image';
6 6
 
7 7
 
8 8
 class ImageUpload extends React.Component {
@@ -65,7 +65,7 @@ class ImageUpload extends React.Component {
65 65
         onSuccess={this.handleUploadSucess}
66 66
       >
67 67
         {(this.state.imageUrl || value) ? (
68
-          <img src={this.state.imageUrl || value} alt="avatar" style={{ width: "100%" }} />
68
+          <img src={getImgURL(this.state.imageUrl) || getImgURL(value)} alt="avatar" style={{ width: "100%" }} />
69 69
         ) : (
70 70
             uploadButton
71 71
           )}

+ 192
- 244
src/pages/course/Edit/index.jsx Zobrazit soubor

@@ -1,259 +1,207 @@
1
-import React, { useState, useEffect } from 'react';
2
-import { UploadOutlined } from '@ant-design/icons';
3
-import { Input, Card, message, Radio, Select,Upload, Button } from 'antd';
4
-import { FormattedMessage } from 'umi-plugin-react/locale';
5
-import BuildSelect from '@/components/SelectButton/BuildSelectCourse'
6
-import router from 'umi/router';
7
-import { FieldTypes, createForm } from '@/components/XForm';
8
-import Wangedit from '@/components/Wangedit/Wangedit'
9
-// import channels from './channelList.less';
10
-// import Tagss from '../components/Tagss.jsx';
11
-import apis from '@/services/apis';
12
-import request from '@/utils/request'
13
-import BuildingSelection from '../components/BuildingSelection'
14
-import { render } from 'react-dom';
1
+import React, { useEffect, useState, useCallback } from 'react';
2
+import { Button, Form, Select, Input, InputNumber, Radio, message, Card } from 'antd';
15 3
 import ImageUpload from '@/components/XForm/ImageUpload';
16
-//下拉
17
-function handleChange(value) {
18
-  console.log(`selected ${value}`);
19
-}
20
-const { TextArea } = Input;
21
-const { Option } = Select;
22
-let consultantChecked = false;
23
-
24
-const setExtraData = (data) => {
25
-  consultantChecked = data.isConsultant
26
-}
27
-
28
-const handleFormValueChange = (props, changedValues, allValues) => {
29
-    setExtraData(allValues)
30
-}
31
-
32
-const XForm = createForm({ onValuesChange: handleFormValueChange })
33
-
34
-/**
35
- *
36
- *
37
- * @param {*} props
38
- * @returns
39
- */
40
-const StaffEdit = (props) => {
41
-  const roleId = props.location.query.roleId
42
-  const [userData, setUserData] = useState({})
43
-  const [tagData, setTagData] = useState([])
44
-  const [roleData, setRoleData] = useState([])
45
-  const [buildData, setBuildData] = useState([])
46
-  const [visible, setVisible] = useState(false)
47
-  //图文单选详情Radio
48
-  const [newsDetailType, setNewsOenType] = useState(1);
49
-
50
-  //视频组件
4
+import FileUpload from '@/components/XForm/FileUpload';
5
+import Wangedit from '@/components/Wangedit/Wangedit';
6
+import router from 'umi/router';
7
+import { fetch, apis } from '@/utils/request';
8
+
9
+const FormItem = Form.Item;
10
+const Option = Select.Option;
11
+const getCurriculumData = fetch(apis.course.searchCourse);
12
+const saveCurriculumData = fetch(apis.course.addCourse);
13
+const updateCurriculumData = fetch(apis.course.alterCourse);
14
+const goBack = () => router.goBack(-1);
15
+
16
+const CurriculumForm = React.forwardRef((props, ref) => {
17
+  const [loading, setLoading] = useState(false);//防止多次点击 定义loadind
18
+  const [formData, setFormData] = useState();//提交表单的数据
19
+  const [contentType, setContentType] = useState(1);//单选。初始默认显示1 富文本框。点击视频, 渲染2
20
+  const { form, history } = props;
21
+  const { getFieldDecorator, setFieldsValue, validateFields } = form;
22
+  const { curriculumId } = history.location.query || {}
51 23
   
52
-  const getVideo = {
53
-    action: '//jsonplaceholder.typicode.com/posts/',
54
-    listType: 'picture',
55
-    previewFile(file) {
56
-      console.log('Your upload file:', file);
57
-      // Your process logic. Here we just mock to the same file
58
-      return fetch('https://next.json-generator.com/api/json/get/4ytyBoLK8', {
59
-        method: 'POST',
60
-        body: file,
61
-      })
62
-        .then(res => res.json())
63
-        .then(({ thumbnail }) => thumbnail);
64
-    },
65
-  };
24
+  const formItemLayout = {
25
+    //布局
26
+    labelCol: { span: 6 },
27
+    wrapperCol: { span: 14 },
66 28
 
67
-  const getTagList = () => {
68
-    request({ ...apis.staff.taTags, params: { pageNum: 1, pageSize: 999 } }).then((data) => {
69
-      setTagData(data.records)
70
-    })
71
-  }
72
-
73
-  const getRoleList = () => {
74
-    request({ ...apis.role.getRoleList, params: { pageNum: 1, pageSize: 999 } }).then((data) => {
75
-      console.log(data)
76
-      setRoleData(data.records)
77
-    })
78
-  }
29
+  };
79 30
 
80
-  //获取项目列表
81
-  const getBuildList = e => {
82
-    request({ ...apis.building.buildingSelect, params: { pageNum: 1, pageSize: 999 } }).then(data => {
83
-        setBuildData(data)
84
-    })
31
+  const handleSubmit = (e) => {
32
+    e.preventDefault();
33
+    validateFields((err, values) => {
34
+      if (err) {
35
+        return;
36
+        //字符验证未填写---返回
37
+      }
38
+
39
+      setLoading(true);//loading开始
40
+
41
+      if (curriculumId) {
42
+        //如果有这个id拿。没有就,拿返回的curriculumId
43
+        updateCurriculumData({
44
+          data: {
45
+            ...values,
46
+            curriculumId
47
+          },
48
+          urlData: { id: curriculumId }
49
+        }).then(() => {
50
+          setLoading(false);
51
+          message.success('数据更新成功');
52
+          goBack()
53
+        }).catch((err) => {
54
+          setLoading(false);//loading消失
55
+          message.error(err.message || err);
56
+        })
57
+      } else {
58
+        saveCurriculumData({ data: values }).then(() => {
59
+          setLoading(false);
60
+          message.success('数据保存成功');
61
+          goBack()
62
+        }).catch((err) => {
63
+          setLoading(false);//loading消失
64
+          message.error(err.message || err);
65
+        })
66
+      }
67
+    });
85 68
   }
86 69
 
87
-  // 查询列表
88
-  const getUserData = (roleId) => {
89
-    request({ ...apis.staff.getTaUser, urlData: { id: roleId } }).then((data) => {
90
-      consultantChecked = data.isConsultant
91
-      setUserData(data)
92
-      setNewsOenType(Number(data.newsDetailType))
70
+  const getCourseData = useCallback(({ curriculumId }) => {//函数结果存 初始化运行一次,等待调用。
71
+    getCurriculumData({urlData: { id: curriculumId }}).then((res) => {
72
+      setFormData(res)
93 73
     })
94
-  }
95
-
96
-  if(userData.buildingIds && buildData.length > 0 && !consultantChecked){
97
-      const newBuildings = userData.buildingIds.filter(x => buildData.filter(it => it.buildingId === x)[0])
98
-      userData.buildingIds = newBuildings
99
-  }
100
-
101
-  if(userData.roleIds && roleData.length > 0){
102
-    const newRoleIds = userData.roleIds.filter(x => roleData.filter(it => it.roleId === x)[0])
103
-      userData.roleIds = newRoleIds
104
-  }
105
-
106
-  useEffect(() => {
107
-    getTagList();
108
-    getRoleList();
109
-    getBuildList();
110
-    if (roleId) {
111
-      getUserData(roleId);
112
-    }
113 74
   }, [])
114 75
 
115
-  // const tagsChange = (value) => {
116
-  //   console.log(`selected ${value}`);
117
-  // }
118
-
119
-  const handleSubmit = val => {
120
-    if (roleId) {
121
-      request({ ...apis.course.alterCourse, urlData: { id: roleId }, data: val, }).then((data) => {
122
-        console.log(data, "tauser")
123
-        message.info("保存成功")
124
-        router.go(-1)
125
-      }).catch(error => {
126
-        // message.info(error.message)
127
-      })
128
-    } else {
129
-      request({ ...apis.course.addCourse, data: val, }).then((data) => {
130
-        console.log(data, "tauser")
131
-        message.info("保存成功")
132
-        router.go(-1)
133
-      }).catch(error => {
134
-        // message.info(error.message)
135
-      })
76
+  useEffect(() => {
77
+    if (curriculumId) {
78
+      getCourseData({curriculumId})//第一次渲染前//获取id
136 79
     }
137
-  }
138
-
139
-
140
-  //视频--------------------
141
- 
80
+  }, [curriculumId])//第二次id一样不执行
142 81
 
143
-
144
-
145
-
146
-  const photoBeforeUpload = (file) => {
147
-    // const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
148
-    // if (!isJpgOrPng) {
149
-    //   message.error('请上传 JPG/PNG 格式的图片!');
150
-    // }
151
-    console.log(file.size, file.size / 1024)
152
-    const isLt100k = (file.size / 1024) < 100;
153
-    if (!isLt100k) {
154
-      message.error('请上传小于100k的图片!');
82
+  useEffect(() => {
83
+    if (formData) {//1.form表单数据{2} 执行。无变更不执行
84
+      setFieldsValue(formData)
155 85
     }
156
-    return isLt100k;
157
-  }
158
-  const handleChange = (value) => {
159
-    console.log(`selected ${value}`);
160
-  }
161
-
162
-  const fields = [
163
-    {
164
-      label: '参与对象',
165
-      name: 'roleId',
166
-      render:<Select  initialValue={'0'} style={{ width: 200 }}>
167
-        <Option value='0'>置业顾问</Option>
168
-        <Option value='1'>经纪人</Option>
169
-        <Option value='2'>置业顾问&amp;经纪人</Option>
170
-      </Select> ,
171
-      rules: [
172
-        { required: true, message: '请输入参与对象' },
173
-      ],
174
-    },
175
-    {
176
-      label: '主图',
177
-      name: 'curriculumImg',
178
-      type: FieldTypes.ImageUploader,
179
-      extra: '建议尺寸:750px*600px,比例5:4,格式:jpg,用于:列表和详情',
180
-      value: userData.curriculumImg,
181
-      // render:<ImageUpload/>,
182
-      // beforeUpload: (e) => photoBeforeUpload(e),
183
-      rules: [
184
-        { required: true, message: '主图' },
185
-      ]
186
-    },
187
-
188
-    {
189
-      label: '课程标题',
190
-      name: 'content',
191
-      render: <Input style={{width:'550px'}} ></Input>,
192
-      value: userData.usernew,
193
-    
194
-      // className={channels.inpuitTxt}
195
-      rules: [
196
-        { required: true, message: '请输入课程标题' },
197
-      ]
198
-    },
199
-    {
200
-      label: '简介',
201
-      name: 'remark',
202
-      render: <TextArea  style={{width:'550px'}}  rows='5' ></TextArea>,
203
-      value: userData.description,
204
-      rules: [
205
-        { required: true, message: '请输入简介' },
206
-      ]
86
+  }, [formData])//2.有变更跟的话
207 87
   
208
-      // className={channels.inpuitTxt}
209
-    },
210
-    {
211
-      label:'详情',
212
-      name:'newsOen',
213
-      render:(
214
-        <Radio.Group 
215
-        onChange={e=>{
216
-          setNewsOenType(e.target.value)
217
-        }} >
218
-          <Radio value='1'>图文</Radio>,
219
-          <Radio value='0'>视频</Radio>,
220
-        </Radio.Group>
221
-      ),
222
-      value:userData,
223
-      rules: [{ required: true, message: '请选择详情类型' }],
224 88
 
225
-    },
226
-    {
227
-      label: '详情内容',
228
-      name: 'newsDetail',
229
-      render: <Wangedit />,
230
-      hidden: newsDetailType == 0,
231
-      value: userData.newsDetail,
232
-      rules: [{ required: true, message: '请输入详情内容' }],
233
-    },
234
-    {
235
-      label:'视频详情',
236
-      name:'newVideo',
237
-      hidden: newsDetailType == 1,
238
-      value:userData.newVideo,
239
-      render: <Upload {...getVideo} maxCount='1' accept='.avi,.mp4,.wmv,.flv'>
240
-      <Button ><UploadOutlined />上传视频</Button>
241
-    </Upload>,
242
-      extra: '仅支AVI、MP4、WMV、FIV格式视频',
243
-    rules:[{required:true,message:'请上传视频详情'}]
244
-    },
245
-    {
246
-      label: '权重',
247
-      name: 'weight',
248
-      type: FieldTypes.Number,
249
-      render: <Input type="number" style={{ width: 150}} />,
250
-      value: '1',
251
-      help: '数字越大越靠前',
252
-    },
253
-  ]
89
+  return (
90
+  <Card>
91
+    <Form {...formItemLayout} onSubmit={handleSubmit}>
92
+      {/* 布局提交表单 */}
93
+      <FormItem label="参与对象">
94
+        {
95
+          getFieldDecorator('roleId', {
96
+            rules: [
97
+              { required: true, message: '请选择参与对象' }
98
+            ]
99
+          })(
100
+            <Select style={{width:'500px'}}>
101
+              <Option value="1">经纪人</Option>
102
+              <Option value="2">职业顾问</Option>
103
+              <Option value="0">职业顾问&amp;经纪人</Option>
104
+            </Select>
105
+          )
106
+        }
107
+      </FormItem>
108
+      <FormItem label="主图" help="建议尺寸:750px*600px,比例5:4,格式:jpg,用于:列表和详情">
109
+        {
110
+          getFieldDecorator('curriculumImg', {
111
+            rules: [
112
+              { required: true, message: '请上传主图' }
113
+            ]
114
+          })(
115
+            <ImageUpload  />
116
+          )
117
+        }
118
+      </FormItem>
119
+      <FormItem label="课程标题">
120
+        {
121
+          getFieldDecorator('name', {
122
+            rules: [
123
+              { required: true, message: '请输入课程标题' }
124
+            ]
125
+          })(
126
+            <Input style={{width:'500px'}} />
127
+          )
128
+        }
129
+      </FormItem>
130
+      <FormItem label="简介">
131
+        {
132
+          getFieldDecorator('remark', {
133
+            rules: [
134
+              { required: true, message: '请填写简介' }
135
+            ]
136
+          })(
137
+            <Input.TextArea  rows='5'  style={{width:'500px'}}/>
138
+          )
139
+        }
140
+      </FormItem>
141
+
142
+      <FormItem label="详情">
143
+        {
144
+          getFieldDecorator('type', {
145
+            rules: [
146
+              { required: true, message: '请选择详情类型' }
147
+            ]
148
+          })(
149
+              <Radio.Group value={contentType} onChange={e=> setContentType(e.target.value)} style={{width:'500px'}} defaultValue={1}>
150
+                <Radio value={1}>图文</Radio>
151
+                <Radio value={2}>视频</Radio>
152
+              </Radio.Group>
153
+          )
154
+        }
155
+      </FormItem>
156
+{/*       
157
+      <FormItem label="详情">
158
+        {
159
+        getFieldDecorator('type'),{
160
+          rules:[
161
+            {required:true,message:'请选择详情类型'}
162
+          ]
163
+
164
+        },
165
+        <Radio.Group value={contentType} onChange={e => setContentType(e.target.value)}>
166
+        <Radio value={1} type='0'>图文</Radio>
167
+        <Radio value={2}type='1'>视频</Radio>
168
+      </Radio.Group>
169
+        }
170
+
171
+      </FormItem> */}
172
+
173
+      <FormItem label="详情内容">
174
+        {
175
+          getFieldDecorator('content', {
176
+            rules: [
177
+              { required: true, message: '请输入详情内容' }
178
+            ]
179
+          })(
180
+            contentType == 1 ? <Wangedit style={{width:'500px'}}  /> : <FileUpload />
181
+          )
182
+        }
183
+      </FormItem>
184
+      <FormItem label="权重" >
185
+        {
186
+          getFieldDecorator('weight', {
187
+            rules: [{ required: true, message: '请设置权重' }]})(
188
+            <InputNumber min='0'   />
189
+          )
190
+        }
191
+      </FormItem>
192
+
193
+      <FormItem wrapperCol={{ span: 12, offset: 6 }}>
194
+        <Button loading={loading} type="primary" htmlType="submit">
195
+          保存
196
+        </Button>
197
+        <Button style={{marginLeft: '2em'}} onClick={goBack}>
198
+          取消
199
+        </Button>
200
+      </FormItem>
201
+    </Form>
202
+    </Card>
203
+  
204
+  )
205
+})
254 206
 
255
-  return <Card>
256
-            <XForm onChange={console.log} onSubmit={handleSubmit} fields={fields.filter(Boolean)} onCancel={() => router.go(-1)}></XForm>
257
-        </Card>
258
-}
259
-export default StaffEdit
207
+export default Form.create({})(CurriculumForm);

+ 62
- 92
src/pages/course/list/index.jsx Zobrazit soubor

@@ -1,5 +1,5 @@
1 1
 import React, { useMemo, useRef, useCallback, useState } from 'react';
2
-import { Button, Avatar,Radio ,Modal, message } from 'antd';
2
+import { Button, Avatar, Radio, Modal, message } from 'antd';
3 3
 import moment from 'moment';
4 4
 import apis from '@/services/apis';
5 5
 import request from '@/utils/request';
@@ -9,95 +9,65 @@ import BuildingSelect from '@/components/SelectButton/BuildSelect';
9 9
 import OperButton from '@/components/OperButton';
10 10
 import withActions from '@/components/ActionList';
11 11
 import { router } from 'umi';
12
+import { getImgURL } from '@/utils/image';
13
+import Navigate from '@/components/Navigate';
12 14
 
13 15
 
14 16
 export default props => {
15 17
   const ref = useRef();
16
-  const [visible, setVisible] = useState(false);
17
-  const [data, setData] = useState(false);
18 18
   const toEdit = useCallback(row => {
19 19
     //跳转到编辑页面
20 20
     router.push({
21 21
       pathname: '/course/Edit',
22 22
       query: {
23
-        userId: row?.userId || undefined,
23
+        curriculumId: row?.curriculumId || undefined,
24 24
       },
25 25
     });
26 26
   }, []);
27 27
 
28 28
 
29
-  const confirm = data => () => {
30
-    // console.log(data, "11111")
31
-    if (data.status === 1) {
32
-      if (data.isConsultant) {
33
-        request({
34
-          // ...apis.staff.check,
35
-          ...apis.course.alterCourse,
36
-          
37
-          params: {
38
-            content: data.content,
39
-            // roleId: data.consultantPersonId,
40
-            roleId: data.roleId,
41
-            createdBy: data.createdBy,
42
-          },
43
-        }).then(res => {
44
-          if (res.length > 0) {
45
-          } else {
46
-            const titleMessahe = data.isConsultant
47
-              ? '确认取消发布此课程吗?'
48
-              : '确认发布此课程吗?';
49
-            Modal.confirm({
50
-              title: titleMessahe,
51
-              okText: '确认',
52
-              cancelText: '取消',
53
-              onOk() {
54
-                // ...apis.staff.change,
55
-                request({ ...apis.course.alterCourse, urlData: { id: data.userId, type: 'off' } }).then(
56
-                  res => {
57
-                    message.info('操作成功');
58
-                    ref.current.reload();
59
-                  },
60
-                );
61
-              },
62
-            });
63
-          }
64
-        });
65
-      } else {
66
-        const titleMessahe = data.isConsultant
67
-          ? '确认发布此课程吗?'
68
-          : '确认取消发布此课程吗?';
69
-        Modal.confirm({
70
-          title: titleMessahe,
71
-          okText: '确认',
72
-          cancelText: '取消',
73
-          onOk() {
74
-            request({ ...apis.course.alterCourse, urlData: { id: data.userId, type: 'off' } }).then(
75
-              res => {
29
+  const confirm = data => {
30
+      // {...data,isPublish}
31
+        if (data.isPublish === 1) {
32
+          const titleCourse = data.isPublish
33
+            ? '确认取消发布此课程吗?' : '确认发布此课程吗?'
34
+          Modal.confirm({
35
+            title: titleCourse,
36
+            okText: '确认',
37
+            cancelText: '取消',
38
+            onOk() {
39
+              request({ ...apis.course.alterCourse, urlData: { id: data.curriculumId }, data: { ...data, isPublish: 0 } }).then(res => {
76 40
                 message.info('操作成功');
77
-                ref.current.reload();
78
-              },
79
-            );
80
-          },
81
-        });
82
-      }
83
-    } else {
84
-      Modal.confirm({
85
-        title: '确认发布此课程吗?',
86
-        okText: '确认',
87
-        cancelText: '取消',
88
-        onOk() {
89
-          request({ ...apis.course.alterCourse, urlData: { id: data.userId, type: 'on' } }).then(res => {
90
-            message.info('操作成功');
91
-            ref.current.reload();
41
+                ref.current.reload();//
42
+              });
43
+            },
92 44
           });
93
-        },
94
-      });
95
-    }
96
-  };
45
+        } else {
46
+          const titleCourse = data.isPublish
47
+            ? '确认取消发布此课程吗?' : '确认发布此课程吗?'
48
+          Modal.confirm({
49
+            title: titleCourse,
50
+            okText: '确认',
51
+            cancelText: '取消',
52
+            onOk() {
53
+              request({ ...apis.course.alterCourse, urlData: { id: data.curriculumId }, data: { ...data, isPublish: 1 } }).then(res => {
54
+                message.info('操作成功');
55
+                ref.current.reload();//
56
+              });
57
+            },
58
+          });
59
+        }
60
+  }
97 61
 
62
+  
63
+  
64
+  
65
+  
66
+  
67
+  
98 68
   const searchFields = [
99 69
     {
100
-      name: 'content',
70
+      name: 'name',
101 71
       label: '课程标题',
102 72
       placeholder: '请输入课程标题',
103 73
     },
@@ -107,26 +77,30 @@ export default props => {
107 77
       placeholder: '请选阅读对象',
108 78
       type: 'select',
109 79
       options: [
110
-        { label: '全部', value: '' },
111
-        { label: '置业顾问', value: '0' },
112 80
         { label: '经纪人', value: '1' },
81
+        { label: '置业顾问', value: '2' },
82
+        { label: '置业顾问&经纪人', value: '0' },
83
+
84
+
113 85
       ],
114 86
     },
115 87
   ];
116 88
   const tableColumns = [
117 89
     {
118 90
       title: '课程标题',
119
-      dataIndex: 'content',
120
-      key: 'content',
91
+      dataIndex: 'name',
92
+      key: 'name',
121 93
       align: 'center',
94
+      render: (text, record) => <Navigate to={`/${record.curriculumUrl}`}>{text}</Navigate>
122 95
     },
123 96
     {
124
-      title:'课程主图',
125
-      dataIndex:'curriculumImg',
126
-      key:'curriculumImg',
127
-      align:'center',
128
-      render: (_,record) => <img src={record.curriculumImg} style={{ width: '165px', height: '104px' }} />,
129
-      // render:(record)=>(<img src={require(record)}/>)
97
+      title: '课程主图',
98
+      dataIndex: 'curriculumImg',
99
+      key: 'curriculumImg',
100
+      align: 'center',
101
+      render: (_, record) => <img src={getImgURL(record.curriculumImg)} style={{ width: '165px', height: '104px' }} />,
102
+      // render:(_,record)=>(record.curriculumImg)==''?<img src={require(record)}/>:<img src={getImgURL(record.curriculumImg)} style={{ width: '165px', height: '104px' }} />
103
+
130 104
     },
131 105
     {
132 106
       title: '阅读人数',
@@ -139,9 +113,9 @@ export default props => {
139 113
       dataIndex: 'roleId',
140 114
       key: 'roleId',
141 115
       align: 'center',
142
-      render: text  => (text === '0' ? '置业顾问' :text === '1' ? '经纪人':'置业顾问&经纪人'),
116
+      render: text => (text === '2' ? '置业顾问' : text === '1' ? '经纪人' : '置业顾问&经纪人'),
143 117
     },
144
-    
118
+
145 119
     {
146 120
       //权重---
147 121
       title: '权重',
@@ -152,18 +126,16 @@ export default props => {
152 126
     },
153 127
     {
154 128
       title: '操作',
129
+      dataIndex: 'isPublish',
155 130
       key: 'isPublish',
156 131
       //isPublish
157 132
       align: 'center',
158 133
       render: withActions(
159 134
         (_, row) => [
160
-          <AuthButton name="admin.building.public" noRight={null}>
161
-            <OperButton onClick={confirm(row)}> {row.status === 1 ? '取消发布' : '发布'}</OperButton>
162
-          </AuthButton>,
135
+            <OperButton onClick={()=>confirm(row)}> {row.isPublish === 0 ? '发布' : '取消发布'}</OperButton>,
163 136
           <AuthButton name="admin.building.delete" noRight={null}>
164
-               <OperButton onClick>添加标签</OperButton>
165
-               <OperButton onClick={()=>toEdit(row)}>{row.status ===1? '编辑':''}</OperButton>
166
-               {/* <OperButton onClick={()=>toEdit(row)} >编辑</OperButton> */}
137
+            <OperButton>添加标签</OperButton>
138
+            <OperButton onClick={() => toEdit(row)}>{row.isPublish === 1 ? '编辑' : ''}</OperButton>
167 139
           </AuthButton>,
168 140
         ],
169 141
         { noMargin: true },
@@ -184,9 +156,7 @@ export default props => {
184 156
     <>
185 157
       <QueryTable
186 158
         ref={ref}
187
-        rowKey="curriculumId"
188
-        // api={apis.staff.taUser}
189
-        
159
+        rowKey='curriculumId'
190 160
         api={apis.course.Tablecourse}
191 161
         columns={tableColumns}
192 162
         searchFields={searchFields}

+ 4
- 2
src/pages/staff/Organization/index.jsx Zobrazit soubor

@@ -1,5 +1,5 @@
1 1
 import React, { Component } from 'react';
2
-import { Tree } from 'antd';
2
+import { Card, Tree } from 'antd';
3 3
 const { DirectoryTree } = Tree;
4 4
 
5 5
 // function Organization(props) {
@@ -134,7 +134,9 @@ class Treetest extends Component {
134 134
     render() {
135 135
         return (
136 136
           <div>
137
-            <DirectoryTree  treeData={treeData} />
137
+            <Card style={{width:'60%'}}>
138
+              <DirectoryTree  treeData={treeData} />
139
+            </Card>
138 140
           </div>
139 141
         )
140 142
     }

+ 12
- 3
src/services/apis.js Zobrazit soubor

@@ -730,19 +730,22 @@ export default {
730 730
       action: 'admin.taCustomImg.id.get',
731 731
     },
732 732
   },
733
-  //Course+
733
+  //Course课程+
734 734
   course:{
735
+    //查询
735 736
   Tablecourse:{
736 737
     method:'GET',
737 738
     url:`${prefix}/curriculum`,
738 739
     action: 'admin.curriculum.get',
739 740
   },
741
+  //根据ID查询
740 742
     searchCourse:{
741 743
       method:'GET',
742 744
       url:`${prefix}/curriculum/:id`,
743 745
       // action:'admin.curriculum.id.get'
744
-      action: 'admin.taCustomImg.id.get',
746
+      action: 'admin.curriculum.id.get',
745 747
     },
748
+    //新增
746 749
     addCourse:{
747 750
       method:'POST',
748 751
       // POST /api/admin/curriculum
@@ -754,7 +757,13 @@ export default {
754 757
       method:'PUT',
755 758
       url:`${prefix}/curriculum/:id`,
756 759
       action:'admin.curriculum.id.put'
757
-    }
760
+    },
761
+    //deleteCourse
762
+    deleteCourse: {
763
+      url: `${prefix}/curriculum/:id`,
764
+      method: 'DELETE',
765
+      action: 'admin.curriculum.id.delete',
766
+    },
758 767
   },
759 768
   system: {
760 769
     taPolicy: {

+ 7
- 0
src/utils/image.js Zobrazit soubor

@@ -0,0 +1,7 @@
1
+
2
+export function getImgURL(img) {
3
+    if (!img) return undefined;
4
+
5
+    const isProd = process.env.NODE_ENV === 'production'
6
+    return isProd ? img : `http://81.69.196.8:8567${img}`;
7
+}