|
@@ -1,5 +1,5 @@
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
-import { Plus, Search, X } from "lucide-react";
|
|
|
|
|
|
|
+import { Search, X } from "lucide-react";
|
|
|
import { customerGetList, rowsOf } from "../lib/api/bos";
|
|
import { customerGetList, rowsOf } from "../lib/api/bos";
|
|
|
import { useLoad } from "../lib/useLoad";
|
|
import { useLoad } from "../lib/useLoad";
|
|
|
import { SearchInput } from "./ui/search-input";
|
|
import { SearchInput } from "./ui/search-input";
|
|
@@ -50,20 +50,31 @@ export function PartnerCustomerPicker({ selectedIds, blockedIds, onChange, disab
|
|
|
<button className="org-inline-link" type="button" onClick={results.reload}>重试</button>
|
|
<button className="org-inline-link" type="button" onClick={results.reload}>重试</button>
|
|
|
</div>
|
|
</div>
|
|
|
) : matches.length ? (
|
|
) : matches.length ? (
|
|
|
- <ul className="partner-customer-list">
|
|
|
|
|
- {matches.map(({ id, name }) => {
|
|
|
|
|
- const selected = selectedIds.includes(id);
|
|
|
|
|
- const blocked = blockedIds.has(id);
|
|
|
|
|
- return (
|
|
|
|
|
- <li key={id}>
|
|
|
|
|
- <div className="partner-customer-label"><span title={name}>{name}</span>{name !== id && <small title={id}>{id}</small>}</div>
|
|
|
|
|
- {selected || blocked ? <span className="partner-customer-status">{selected ? "已选" : "其他合伙人已选"}</span> : (
|
|
|
|
|
- <button className="partner-customer-icon" aria-label={`添加 ${name}`} title="添加" disabled={disabled} onClick={() => onChange([...selectedIds, id])} type="button"><Plus size={16} /></button>
|
|
|
|
|
- )}
|
|
|
|
|
- </li>
|
|
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- </ul>
|
|
|
|
|
|
|
+ <fieldset className="partner-customer-options" disabled={disabled}>
|
|
|
|
|
+ <legend className="sr-only">可选客户</legend>
|
|
|
|
|
+ <ul className="partner-customer-list">
|
|
|
|
|
+ {matches.map(({ id, name }) => {
|
|
|
|
|
+ const selected = selectedIds.includes(id);
|
|
|
|
|
+ const blocked = blockedIds.has(id) && !selected;
|
|
|
|
|
+ return (
|
|
|
|
|
+ <li key={id}>
|
|
|
|
|
+ <label className="partner-customer-option">
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="checkbox"
|
|
|
|
|
+ checked={selected}
|
|
|
|
|
+ disabled={blocked}
|
|
|
|
|
+ onChange={(event) => onChange(event.target.checked
|
|
|
|
|
+ ? [...selectedIds, id]
|
|
|
|
|
+ : selectedIds.filter((customerId) => customerId !== id))}
|
|
|
|
|
+ />
|
|
|
|
|
+ <span className="partner-customer-label"><span title={name}>{name}</span>{name !== id && <small title={id}>{id}</small>}</span>
|
|
|
|
|
+ {blocked && <span className="partner-customer-status">其他合伙人已选</span>}
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ );
|
|
|
|
|
+ })}
|
|
|
|
|
+ </ul>
|
|
|
|
|
+ </fieldset>
|
|
|
) : <p className="partner-customer-feedback" role="status">{keyword ? "未找到匹配的客户。" : "暂无可选客户。"}</p>}
|
|
) : <p className="partner-customer-feedback" role="status">{keyword ? "未找到匹配的客户。" : "暂无可选客户。"}</p>}
|
|
|
</div>
|
|
</div>
|
|
|
<div className="partner-customer-pane">
|
|
<div className="partner-customer-pane">
|
|
@@ -75,7 +86,7 @@ export function PartnerCustomerPicker({ selectedIds, blockedIds, onChange, disab
|
|
|
return (
|
|
return (
|
|
|
<li key={id}>
|
|
<li key={id}>
|
|
|
<div className="partner-customer-label"><span title={name}>{name}</span>{name !== id && <small title={id}>{id}</small>}</div>
|
|
<div className="partner-customer-label"><span title={name}>{name}</span>{name !== id && <small title={id}>{id}</small>}</div>
|
|
|
- <button className="partner-customer-icon is-remove" aria-label={`移除 ${name}`} title="移除" disabled={disabled} onClick={() => onChange(selectedIds.filter((selected) => selected !== id))} type="button"><X size={15} /></button>
|
|
|
|
|
|
|
+ <button className="partner-customer-icon" aria-label={`移除 ${name}`} title="移除" disabled={disabled} onClick={() => onChange(selectedIds.filter((selected) => selected !== id))} type="button"><X size={15} /></button>
|
|
|
</li>
|
|
</li>
|
|
|
);
|
|
);
|
|
|
})}
|
|
})}
|