Commit 77dccf9e by haojie

1

parent ff417675
......@@ -9,9 +9,9 @@ import {getDirectionColor, getOpenText} from '@/js/utils/trade';
import {getLocalContractHelper, getUserName} from '@/js/utils/local';
import {open_loading} from '@/js/utils/tdesign';
import {ContractRevoke} from '@/js/utils/api/multipleUse';
import {show_message} from "@/js/utils/tdesign";
import CustomCheckBox from '@/js/components/CheckBox';
import {isShow} from '@/js/utils/dom';
import {getSelectedIds} from '@/js/service/TradeService';
// 当前委托
class CurrentConsignment extends Component<any, any> {
......@@ -201,14 +201,8 @@ class CurrentConsignment extends Component<any, any> {
} else {
// 获取选中的行--is_checked
const list = this.state.list;
const ids: any[] = [];
list.forEach((item: any) => {
if (item.is_checked) {
ids.push(item.id);
}
})
if (!ids.length) {
show_message('未选择行');
const ids = getSelectedIds(list);
if (!ids) {
return;
}
params = {
......
......@@ -12,6 +12,7 @@ import {show_message} from "@/js/utils/tdesign";
import CustomCheckBox from '@/js/components/CheckBox';
import {SpotCurrentEntrustment} from '@/js/utils/api/spot';
import {isShow} from '@/js/utils/dom';
import {getSelectedIds} from '@/js/service/TradeService';
// 当前委托
class CurrentConsignment extends Component<any, any> {
......@@ -201,14 +202,8 @@ class CurrentConsignment extends Component<any, any> {
} else {
// 获取选中的行--is_checked
const list = this.state.list;
const ids: any[] = [];
list.forEach((item: any) => {
if (item.is_checked) {
ids.push(item.id);
}
})
if (!ids.length) {
show_message('未选择行');
const ids = getSelectedIds(list);
if (!ids) {
return;
}
params = {
......
......@@ -30,7 +30,6 @@ export default function (props) {
inputChange(value);
}}
onClear={() => {
console.log('onClear');
}}
/>
);
......
import {show_message} from "../utils/tdesign";
/**
* 撤销(返回选中项的id列表)
*/
export const getSelectedIds = (list: any[], condition: any = {status: 'NEW'}, key: string = 'is_checked') => {
const ids: any[] = [];
for (let i = 0; i < list.length; i++) {
const item = list[i];
if (item[key]) {
// 循环条件列表
const keys = Object.keys(condition);
for (let j = 0; j < keys.length; j++) {
const conditionKey = keys[j];
if (item[conditionKey]) {
// 存在这个字段,值是否相等
if (item[conditionKey] !== condition[conditionKey]) {
show_message('所选撤销行不满足条件', 'error');
return;
} else {
// 等于
ids.push(item.id);
}
}
}
}
}
if (!ids.length) {
show_message('未选择行');
return;
}
return ids;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment