Skip to content

Commit

Permalink
Rename record_id to id
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed May 12, 2020
1 parent 43ddba1 commit 87a3482
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 82 deletions.
6 changes: 3 additions & 3 deletions src/layouts/AdminLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class AdminLayout extends React.PureComponent {
let isParent = false;
for (let i = 0; i < openKeys.length - 1; i += 1) {
const item = menuMap[openKeys[i]] || {};
let path = item.record_id;
let path = item.id;
if (item.parent_path !== '') {
path = `${item.parent_path}/${path}`;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class AdminLayout extends React.PureComponent {
item.name
)
}
key={item.record_id}
key={item.id}
>
{this.renderNavMenuItems(item.children)}
</SubMenu>
Expand All @@ -199,7 +199,7 @@ class AdminLayout extends React.PureComponent {
} = this.props;

return (
<Menu.Item key={item.record_id}>
<Menu.Item key={item.id}>
{router.startsWith('http') ? (
<a href={router} target="_blank" rel="noopener noreferrer">
{icon}
Expand Down
14 changes: 7 additions & 7 deletions src/models/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export default {
}),
put({
type: 'fetchForm',
payload: { record_id: payload.id },
payload: { id: payload.id },
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
const response = yield call(demoService.get, payload.record_id);
const response = yield call(demoService.get, payload.id);
yield [
put({
type: 'saveFormData',
Expand All @@ -120,7 +120,7 @@ export default {
}
} else {
const response = yield call(demoService.create, params);
if (response.record_id && response.record_id !== '') {
if (response.id && response.id !== '') {
success = true;
}
}
Expand All @@ -142,7 +142,7 @@ export default {
}
},
*del({ payload }, { call, put }) {
const response = yield call(demoService.del, payload.record_id);
const response = yield call(demoService.del, payload.id);
if (response.status === 'OK') {
message.success('删除成功');
yield put({ type: 'fetch' });
Expand All @@ -151,9 +151,9 @@ export default {
*changeStatus({ payload }, { call, put, select }) {
let response;
if (payload.status === 1) {
response = yield call(demoService.enable, payload.record_id);
response = yield call(demoService.enable, payload.id);
} else {
response = yield call(demoService.disable, payload.record_id);
response = yield call(demoService.disable, payload.id);
}

if (response.status === 'OK') {
Expand All @@ -167,7 +167,7 @@ export default {

for (let i = 0; i < data.list.length; i += 1) {
const item = data.list[i];
if (item.record_id === payload.record_id) {
if (item.id === payload.id) {
item.status = payload.status;
}
newData.list.push(item);
Expand Down
4 changes: 2 additions & 2 deletions src/models/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {

yield put({
type: 'changeSelectedKeys',
payload: [item.record_id],
payload: [item.id],
});
},
*fetchUser(_, { call, put }) {
Expand All @@ -65,7 +65,7 @@ export default {
const menuMap = {};
function fillData(data) {
for (let i = 0; i < data.length; i += 1) {
menuMap[data[i].record_id] = data[i];
menuMap[data[i].id] = data[i];
if (data[i].router !== '') {
menuPaths[data[i].router] = data[i];
}
Expand Down
14 changes: 7 additions & 7 deletions src/models/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
}),
put({
type: 'fetchForm',
payload: { record_id: payload.id },
payload: { id: payload.id },
}),
];
} else {
Expand All @@ -105,7 +105,7 @@ export default {
}
},
*fetchForm({ payload }, { call, put }) {
const response = yield call(menuService.get, payload.record_id);
const response = yield call(menuService.get, payload.id);
yield put({
type: 'saveFormData',
payload: response,
Expand All @@ -128,7 +128,7 @@ export default {
}
} else {
const response = yield call(menuService.create, params);
if (response.record_id && response.record_id !== '') {
if (response.id && response.id !== '') {
success = true;
}
}
Expand All @@ -150,7 +150,7 @@ export default {
}
},
*del({ payload }, { call, put }) {
const response = yield call(menuService.del, payload.record_id);
const response = yield call(menuService.del, payload.id);
if (response.status === 'OK') {
message.success('删除成功');
yield put({ type: 'fetchTree' });
Expand All @@ -171,9 +171,9 @@ export default {
*changeStatus({ payload }, { call, put, select }) {
let response;
if (payload.status === 1) {
response = yield call(menuService.enable, payload.record_id);
response = yield call(menuService.enable, payload.id);
} else {
response = yield call(menuService.disable, payload.record_id);
response = yield call(menuService.disable, payload.id);
}

if (response.status === 'OK') {
Expand All @@ -187,7 +187,7 @@ export default {

for (let i = 0; i < data.list.length; i += 1) {
const item = data.list[i];
if (item.record_id === payload.record_id) {
if (item.id === payload.id) {
item.status = payload.status;
}
newData.list.push(item);
Expand Down
14 changes: 7 additions & 7 deletions src/models/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ export default {
}),
put({
type: 'fetchForm',
payload: { record_id: payload.id },
payload: { id: payload.id },
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
const response = yield call(roleService.get, payload.record_id);
const response = yield call(roleService.get, payload.id);

const { role_menus: roleMenus } = response;
if (roleMenus) {
Expand Down Expand Up @@ -140,7 +140,7 @@ export default {
}
} else {
const response = yield call(roleService.create, params);
if (response.record_id && response.record_id !== '') {
if (response.id && response.id !== '') {
success = true;
}
}
Expand All @@ -162,7 +162,7 @@ export default {
}
},
*del({ payload }, { call, put }) {
const response = yield call(roleService.del, payload.record_id);
const response = yield call(roleService.del, payload.id);
if (response.status === 'OK') {
message.success('删除成功');
yield put({ type: 'fetch' });
Expand All @@ -178,9 +178,9 @@ export default {
*changeStatus({ payload }, { call, put, select }) {
let response;
if (payload.status === 1) {
response = yield call(roleService.enable, payload.record_id);
response = yield call(roleService.enable, payload.id);
} else {
response = yield call(roleService.disable, payload.record_id);
response = yield call(roleService.disable, payload.id);
}

if (response.status === 'OK') {
Expand All @@ -194,7 +194,7 @@ export default {

for (let i = 0; i < data.list.length; i += 1) {
const item = data.list[i];
if (item.record_id === payload.record_id) {
if (item.id === payload.id) {
item.status = payload.status;
}
newData.list.push(item);
Expand Down
14 changes: 7 additions & 7 deletions src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export default {
}),
put({
type: 'fetchForm',
payload: { record_id: payload.id },
payload: { id: payload.id },
}),
];
}
},
*fetchForm({ payload }, { call, put }) {
const response = yield call(userService.get, payload.record_id);
const response = yield call(userService.get, payload.id);
yield put({
type: 'saveFormData',
payload: response,
Expand All @@ -117,7 +117,7 @@ export default {
}
} else {
const response = yield call(userService.create, params);
if (response.record_id && response.record_id !== '') {
if (response.id && response.id !== '') {
success = true;
}
}
Expand All @@ -139,7 +139,7 @@ export default {
}
},
*del({ payload }, { call, put }) {
const response = yield call(userService.del, payload.record_id);
const response = yield call(userService.del, payload.id);
if (response.status === 'OK') {
message.success('删除成功');
yield put({ type: 'fetch' });
Expand All @@ -148,9 +148,9 @@ export default {
*changeStatus({ payload }, { call, put, select }) {
let response;
if (payload.status === 1) {
response = yield call(userService.enable, payload.record_id);
response = yield call(userService.enable, payload.id);
} else {
response = yield call(userService.disable, payload.record_id);
response = yield call(userService.disable, payload.id);
}

if (response.status === 'OK') {
Expand All @@ -164,7 +164,7 @@ export default {

for (let i = 0; i < data.list.length; i += 1) {
const item = data.list[i];
if (item.record_id === payload.record_id) {
if (item.id === payload.id) {
item.status = payload.status;
}
newData.list.push(item);
Expand Down
14 changes: 7 additions & 7 deletions src/pages/Demo/DemoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class DemoList extends PureComponent {
onItemDisableClick = item => {
this.dispatch({
type: 'demo/changeStatus',
payload: { record_id: item.record_id, status: 2 },
payload: { id: item.id, status: 2 },
});
};

onItemEnableClick = item => {
this.dispatch({
type: 'demo/changeStatus',
payload: { record_id: item.record_id, status: 1 },
payload: { id: item.id, status: 1 },
});
};

Expand All @@ -48,7 +48,7 @@ class DemoList extends PureComponent {
type: 'demo/loadForm',
payload: {
type: 'E',
id: item.record_id,
id: item.id,
},
});
};
Expand All @@ -65,7 +65,7 @@ class DemoList extends PureComponent {
onDelOKClick(id) {
this.dispatch({
type: 'demo/del',
payload: { record_id: id },
payload: { id },
});
this.clearSelectRows();
}
Expand All @@ -84,15 +84,15 @@ class DemoList extends PureComponent {
okText: '确认',
okType: 'danger',
cancelText: '取消',
onOk: this.onDelOKClick.bind(this, item.record_id),
onOk: this.onDelOKClick.bind(this, item.id),
});
};

handleTableSelectRow = (record, selected) => {
const keys = [];
const rows = [];
if (selected) {
keys.push(record.record_id);
keys.push(record.id);
rows.push(record);
}
this.setState({
Expand Down Expand Up @@ -293,7 +293,7 @@ class DemoList extends PureComponent {
onSelect: this.handleTableSelectRow,
}}
loading={loading}
rowKey={record => record.record_id}
rowKey={record => record.id}
dataSource={list}
columns={columns}
pagination={paginationProps}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Menu/MenuCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MenuCard extends PureComponent {
}
const newData = [];
for (let i = 0; i < data.length; i += 1) {
const item = { ...data[i], title: data[i].name, value: data[i].record_id };
const item = { ...data[i], title: data[i].name, value: data[i].id };
if (item.children && item.children.length > 0) {
item.children = this.toTreeSelect(item.children);
}
Expand Down
Loading

0 comments on commit 87a3482

Please sign in to comment.