提交 e1e0501b authored 作者: 王绍森's avatar 王绍森

删除操作修改

上级 01fba0fe
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
addOrEditTableItem, addOrEditTableItem,
deleteTableItem, deleteTableItem,
} from '@/webPublic/Services'; } from '@/webPublic/Services';
import { ModalConfirm } from '@/baseComponent/Modal';
const getValue = obj => const getValue = obj =>
Object.keys(obj) Object.keys(obj)
...@@ -111,14 +112,7 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -111,14 +112,7 @@ class ListWithAddEditTemplate extends React.Component {
<div> <div>
<a onClick={this.modify.bind(this, record)}>编辑</a> <a onClick={this.modify.bind(this, record)}>编辑</a>
<Divider type="vertical" /> <Divider type="vertical" />
<Popconfirm <a onClick={this.delete.bind(this, record)}>删除</a>
title="确定删除该数据?"
onConfirm={this.delete.bind(this, record)}
okText="确定"
cancelText="取消"
>
<a>删除</a>
</Popconfirm>
</div> </div>
</Fragment> </Fragment>
); );
...@@ -161,13 +155,18 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -161,13 +155,18 @@ class ListWithAddEditTemplate extends React.Component {
}; };
delete = record => { delete = record => {
const { objId } = this.props; ModalConfirm('确定删除?', {
// 找出主键 onOk: () => {
const { primaryKey } = this.state; const { objId } = this.props;
const Keys = {}; // 找出主键
Keys[primaryKey] = record[primaryKey]; const { primaryKey } = this.state;
deleteTableItem(objId, primaryKey, record[primaryKey]).then(res => { const Keys = {};
this.getPage();
Keys[primaryKey] = record[primaryKey];
deleteTableItem(objId, primaryKey, record[primaryKey]).then(res => {
this.getPage();
});
},
}); });
}; };
...@@ -253,15 +252,20 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -253,15 +252,20 @@ class ListWithAddEditTemplate extends React.Component {
}; };
batchDelete = e => { batchDelete = e => {
const { selectedRows, objId, primaryKey } = this.state; const { selectedRows, primaryKey } = this.state;
const { objId } = this.props;
if (!selectedRows) return; if (!selectedRows) return;
deleteTableItem(objId, primaryKey, selectedRows.map(row => row[primaryKey])).then(res => { ModalConfirm('确定删除?', {
this.setState({ onOk: () => {
selectedRows: [], deleteTableItem(objId, primaryKey, selectedRows.map(row => row[primaryKey])).then(res => {
}); this.setState({
this.getPage(); selectedRows: [],
});
this.getPage();
});
},
}); });
}; };
...@@ -328,7 +332,7 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -328,7 +332,7 @@ class ListWithAddEditTemplate extends React.Component {
config={{ condition: searchConfig, fromTab: true }} config={{ condition: searchConfig, fromTab: true }}
/> />
) : null} ) : null}
<Shell styleShell={{marginTop: searchConfig && searchConfig.length ? 16 : 0 }}> <Shell styleShell={{ marginTop: searchConfig && searchConfig.length ? 16 : 0 }}>
<div style={{ paddingLeft: '10px', marginTop: '20px' }}> <div style={{ paddingLeft: '10px', marginTop: '20px' }}>
<ButtonDiy icon="plus" className="primaryBlue" handleClick={this.add} name="新建" /> <ButtonDiy icon="plus" className="primaryBlue" handleClick={this.add} name="新建" />
{hasImport && <ImportUtil objId={objId} />} {hasImport && <ImportUtil objId={objId} />}
...@@ -342,7 +346,7 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -342,7 +346,7 @@ class ListWithAddEditTemplate extends React.Component {
selectedRows={selectedRows} selectedRows={selectedRows}
onSelectRow={this.handleSelectRows} onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange} onChange={this.handleStandardTableChange}
scroll={{x: 1200}} scroll={{ x: 1200 }}
/> />
</Shell> </Shell>
</Fragment> </Fragment>
......
...@@ -55,7 +55,7 @@ export const fetchTableHeader = objId => ...@@ -55,7 +55,7 @@ export const fetchTableHeader = objId =>
* @param {String} value 主键对应的值,删除多条数据时传数组 * @param {String} value 主键对应的值,删除多条数据时传数组
*/ */
export const deleteTableItem = (objId, primaryKey, value) => { export const deleteTableItem = (objId, primaryKey, value) => {
const copyValue = Array.isArray[value] ? value.join(',') : value; const copyValue = Array.isArray(value) ? value.join(',') : value;
return uaaRequest('/DataObjApi/deleteFormData', { return uaaRequest('/DataObjApi/deleteFormData', {
objId, objId,
keys: JSON.stringify({ [primaryKey]: copyValue }), keys: JSON.stringify({ [primaryKey]: copyValue }),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论