Commit ca331f73 authored by Sixiang_Zzb's avatar Sixiang_Zzb

服务范围bug处理

parent 94fd5d44
......@@ -57,9 +57,6 @@ class TagSelect extends React.Component {
handleInputConfirm = () => {
const { inputValue } = this.state;
let { value } = this.state;
console.log(value);
console.log(inputValue);
if (!inputValue.trim()) {
message.error('Not Null!!!');
return;
......@@ -78,6 +75,7 @@ class TagSelect extends React.Component {
};
handleEditInputChange = (e) => {
console.log(e.target.value);
this.setState({ editInputValue: e.target.value });
};
......@@ -85,6 +83,7 @@ class TagSelect extends React.Component {
this.setState(({ value, editInputIndex, editInputValue }) => {
const newTags = [...value];
newTags[editInputIndex] = editInputValue;
this.props.onAdd(editInputValue, editInputIndex);
this.props.onChange(newTags);
return {
value: newTags,
......@@ -104,19 +103,14 @@ class TagSelect extends React.Component {
render() {
const { value, inputVisible, inputValue, editInputIndex, editInputValue, visible } = this.state;
return (
<>
<Tag className="editTag" key="Accountant">
Accountant
</Tag>
{value.map((tag, index) => {
if (editInputIndex === index) {
return (
<Input
ref={this.saveEditInputRef}
key={tag.serviceName}
key={tag}
size="small"
className={styles.tagInput}
value={editInputValue}
......@@ -132,25 +126,27 @@ class TagSelect extends React.Component {
const tagElem = (
<Tag
className="editTag"
key={tag.serviceName}
closable={index !== -1}
key={tag}
closable={index !== 0 && index !== 1}
onClose={(e) => this.handleClose(tag, e)}
visible={true}
>
{/* <span
<span
onDoubleClick={(e) => {
this.setState({ editInputIndex: index, editInputValue: tag.serviceName }, () => {
this.editInput.focus();
});
e.preventDefault();
if (index !== 0 && index !== 1) {
this.setState({ editInputIndex: index, editInputValue: tag }, () => {
this.editInput.focus();
});
e.preventDefault();
}
}}
> */}
{isLongTag ? `${value.slice(0, 20)}...` : tag.serviceName}
{/* </span> */}
>
{isLongTag ? `${value.slice(0, 20)}...` : tag}
</span>
</Tag>
);
return isLongTag ? (
<Tooltip title={tag.serviceName} key={tag.serviceName}>
<Tooltip title={tag} key={tag}>
{tagElem}
</Tooltip>
) : (
......
......@@ -9,10 +9,14 @@ import { RA, ClearResult } from '@/utils/method';
import TitleBack from '@/components/TitleBack/TitleBack';
const module = 'User';
interface DataType {
serviceName: string;
id: string;
}
const Services = (props: any) => {
const { dispatch, DataServices, Result } = props;
const formRef = useRef(null as any);
const [DataList, setDataList] = useState(Object);
useEffect(() => {
RA(43, {}, module, dispatch);
......@@ -21,17 +25,10 @@ const Services = (props: any) => {
useEffect(() => {
if (DataServices != null) {
console.log(DataServices);
// let tmp = DataServices.data.rows.map((v: object, i: number) => {
// return v['serviceName'];
// });
// console.log(tmp);
// tmp = tmp.filter((v: string) => {
// return v !== 'Accountant';
// });
let tmp = DataServices.data.rows.filter(
setDataList(DataServices.data.rows);
let tmp = DataServices.data.rows.map(
(v: { serviceName: string; deleted: number }, i: number) => {
return v.serviceName !== 'Accountant' && v.deleted !== 1 && v;
return v.deleted !== 1 && v.serviceName;
},
);
console.log(tmp);
......@@ -40,12 +37,12 @@ const Services = (props: any) => {
}, [DataServices]);
// 添加服务范围
const Add = (values: string) => {
console.log(values);
const Add = (values: string, index?: number) => {
RA(
44,
{
serviceName: values,
id: index ? DataList[index].id : null,
},
module,
dispatch,
......@@ -53,16 +50,19 @@ const Services = (props: any) => {
};
// 删除服务范围
const Remove = (values: { id: string }) => {
console.log(values);
RA(
53,
{
id: values.id,
},
module,
dispatch,
);
const Remove = (values: string) => {
DataList.forEach((obj: DataType) => {
if (obj.serviceName === values) {
RA(
53,
{
id: obj.id,
},
module,
dispatch,
);
}
});
};
useEffect(() => {
......@@ -71,7 +71,7 @@ const Services = (props: any) => {
if (Result.error_code !== '0000') {
message.error('Failed: binding service provider!!!');
} else {
message.success(Result.error_msg);
message.success('Operate Success!!!');
}
ClearResult('User', dispatch);
RA(43, {}, module, dispatch);
......
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