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

删除操作修改

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