import React from 'react';
import { Link } from 'react-router-dom';
import { Button, Modal, Form, InputNumber, Row, Col } from 'antd';
import './index.less';
import Page from '@src/containers/Page';
import Block from '@src/components/Block';
import FilterLayout from '@src/layouts/FilterLayout';
import ActionLayout from '@src/layouts/ActionLayout';
import TableLayout from '@src/layouts/TableLayout';
import { formatDate, bindSearch } from '@src/services/Tools';
import { asyncSMessage } from '@src/services/AsyncTools';
import { ExperienceScore, ExperiencePercent } from '../../../../Constant';
import { System } from '../../../stores/system';
import { Course } from '../../../stores/course';
import { User } from '../../../stores/user';
export default class extends Page {
init() {
this.filterForm = [
{
key: 'keyword',
type: 'input',
allowClear: true,
name: '搜索',
placeholder: '标题或正文',
}, {
key: 'userId',
type: 'select',
name: '用户',
allowClear: true,
select: [],
number: true,
placeholder: '请输入',
},
];
this.actionList = [{
key: 'info',
name: '数据管理',
}, {
key: 'add',
type: 'primary',
name: '创建',
render: (item) => {
return ;
},
}];
this.columns = [{
title: '文章标题',
dataIndex: 'title',
}, {
title: '作者',
dataIndex: 'user',
render: (text) => {
return (text || {}).nickname;
},
}, {
title: '更新时间',
dataIndex: 'updateTime',
render: (text) => {
return formatDate(text);
},
}, {
title: '阅读数',
dataIndex: 'viewNumber',
}, {
title: '收藏数',
dataIndex: 'collectNumber',
}, {
title: '操作',
dataIndex: 'handler',
render: (text, record) => {
return
{编辑}
;
},
}];
System.getExperienceInfo().then(result => {
return this.refreshInfo(result);
}).then(() => {
this.initData();
});
bindSearch(this.filterForm, 'userId', this, (search) => {
return User.list(search);
}, (row) => {
return {
title: `${row.nickname}(${row.mobile})`,
value: row.id,
};
}, this.state.search.userId ? Number(this.state.search.userId) : [], null);
}
initData() {
Course.listExperience(this.state.search).then(result => {
this.setTableData(result.list, result.total);
});
}
refreshInfo(result) {
this.setState({ info: result });
}
infoAction() {
const { info = {} } = this.state;
this.open(info);
}
changeInfoList(field, index, value) {
const { detail } = this.state;
if (!detail[field]) detail[field] = [];
detail[field][index] = value;
this.setState({ detail });
}
changeInfo(field, value) {
const { detail } = this.state;
detail[field] = value;
this.setState({ detail });
}
submitInfo() {
const { detail } = this.state;
System.setExperienceInfo(detail).then(() => {
asyncSMessage('保存成功');
this.close(false, 'detail');
return this.refreshInfo(detail);
});
}
renderView() {
return
{
this.search(data);
}} />
this.onAction(key)}
/>
this.tableChange(pagination, filters, sorter)}
onSelect={(keys, rows) => this.tableSelect(keys, rows)}
selectedKeys={this.state.selectedKeys}
/>
{this.state.detail && {
this.close(false, 'detail');
}} onOk={() => {
this.submitInfo();
}}>
{ExperienceScore.map((row, index) => {
return
{
this.changeInfoList('score', index, value);
}} />
;
})}
{
this.changeInfo('period', value);
}} />
{ExperiencePercent.map((row, index) => {
return
{
this.changeInfoList('percent', index, value);
}} />
;
})}
}
;
}
}