Commit 3e32beaa authored by 皮倩雯's avatar 皮倩雯

替换新拖拽组件

parent adcfb38f
Pipeline #39390 skipped with stages
/* eslint-disable array-callback-return */
/* eslint-disable no-plusplus */ /* eslint-disable no-plusplus */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Modal } from 'antd'; import { Modal } from 'antd';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import styles from './incident.less'; import styles from './incident.less';
import DragTable from '@/components/DragTable/DragTable';
const SortModal = props => { const SortModal = props => {
const { const {
callBackSubmit = () => {}, callBackSubmit = () => {},
...@@ -12,36 +14,46 @@ const SortModal = props => { ...@@ -12,36 +14,46 @@ const SortModal = props => {
onCancel, onCancel,
sortData1, sortData1,
} = props; } = props;
const [drag, setDrag] = useState([]); const [orderTable, setOrderTable] = useState([]);
const [flowIDs, setFlowIDs] = useState([]);
useEffect(() => {
draftSort();
}, [visible]);
const onSumbit = () => { const onSumbit = () => {
callBackSubmit({ str: drag }); console.log(flowIDs);
callBackSubmit({ str: flowIDs });
}; };
// 拖拽初始化及逻辑 // 根据orderTable值改变flowIDs
const draftSort = () => { useEffect(() => {
let el = document.getElementById('doctor-drag-items'); let ids = [];
if (el) { orderTable.map(item => {
let sortable = Sortable.create(el, { ids.push(item.ID);
animation: 100, // 动画参数 });
onEnd(evt) { console.log(ids);
// 拖拽完毕之后发生,只需关注该事件 setFlowIDs(ids);
let arr = []; }, [orderTable]);
let len = evt.from.children.length;
for (let i = 0; i < len; i++) { useEffect(() => {
console.log(i); console.log(sortData1);
arr.push(evt.from.children[i].getAttribute('drag-id')); if (visible) {
} setOrderTable(sortData1);
console.log(arr); }
setDrag(arr); }, [visible]);
},
}); // 拖拽回调函数
const dragCallBack = data => {
console.log(data);
if (data) {
setOrderTable(data);
} }
}; };
const columns = [
{
title: '字段名',
dataIndex: 'name',
width: 150,
key: 'name',
},
];
return ( return (
<Modal <Modal
title={title} title={title}
...@@ -56,7 +68,7 @@ const SortModal = props => { ...@@ -56,7 +68,7 @@ const SortModal = props => {
style={{ width: '26rem', marginLeft: '24px' }} style={{ width: '26rem', marginLeft: '24px' }}
> >
<div className={styles.doctorTable}> <div className={styles.doctorTable}>
<table style={{ width: '104%', marginLeft: '-5px' }}> {/* <table style={{ width: '104%', marginLeft: '-5px' }}>
<thead> <thead>
<tr> <tr>
<td>事件名称</td> <td>事件名称</td>
...@@ -71,7 +83,19 @@ const SortModal = props => { ...@@ -71,7 +83,19 @@ const SortModal = props => {
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table> */}
<DragTable
bordered
style={{ marginBottom: '10px' }}
rowKey={record => record.extendID}
columns={columns}
dataSource={orderTable}
showHeader={false}
pagination={false}
size="small"
dragCallBack={dragCallBack}
ItemTypes="flowOrder"
/>
</div> </div>
</div> </div>
</Modal> </Modal>
......
...@@ -40,7 +40,7 @@ const AddModal = props => { ...@@ -40,7 +40,7 @@ const AddModal = props => {
const [arrValue, setArrValue] = useState([]); const [arrValue, setArrValue] = useState([]);
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [flagg, setFlagg] = useState(0); const [flagg, setFlagg] = useState(0);
const [type, setType] = useState(); const [type, setType] = useState(); // 是否全选
let objArr = []; let objArr = [];
const onChangeList = (list, index, title) => { const onChangeList = (list, index, title) => {
...@@ -181,57 +181,6 @@ const AddModal = props => { ...@@ -181,57 +181,6 @@ const AddModal = props => {
? (checkedListArr[e.target.index] = e.target.checkvalue) ? (checkedListArr[e.target.index] = e.target.checkvalue)
: (checkedListArr[e.target.index] = []); : (checkedListArr[e.target.index] = []);
setType(e.target.checked); setType(e.target.checked);
// console.log(checkedListArr);
// console.log(arrValue);
// let objArr = [];
// checkedListArr.map((item, index) => {
// objArr = objArr.concat(item);
// });
// console.log(objArr);
// let newArr = [];
// let lastArr = [];
// arrValue.map(item => {
// if (item.name == undefined) {
// newArr = arrValue;
// } else {
// newArr = arrValue.map(item => item.name);
// }
// });
// console.log(newArr);
// if (e.target.checked == false) {
// newArr.map(item => {
// if (objArr.indexOf(item) != -1) {
// lastArr.push(item);
// }
// });
// let newArr1 = lastArr.map(item => ({ name: item }));
// if (newArr1.length === 1 && newArr1[0].name === '') {
// newArr1 = [];
// }
// console.log(newArr1);
// setSelectData(newArr1);
// setArrValue(lastArr);
// } else {
// let addArr = [];
// objArr.map(item => {
// if (newArr.indexOf(item) == -1) {
// addArr.push(item);
// }
// });
// console.log(addArr);
// addArr.map(item => {
// newArr.push(item);
// });
// console.log(newArr);
// let newArr1 = newArr.map(item => ({ name: item }));
// if (newArr1.length === 1 && newArr1[0].name === '') {
// newArr1 = [];
// }
// console.log(newArr1);
// setSelectData(newArr1);
// setArrValue(newArr);
// }
setCheckedList(checkedListArr); setCheckedList(checkedListArr);
setIndeterminate(indeterminateArr); setIndeterminate(indeterminateArr);
setCheckAll(checkAllArr); setCheckAll(checkAllArr);
...@@ -377,12 +326,7 @@ const AddModal = props => { ...@@ -377,12 +326,7 @@ const AddModal = props => {
let indeterminateArr = []; let indeterminateArr = [];
let checkAllArr = []; let checkAllArr = [];
console.log(newCheckedList); console.log(newCheckedList);
// let b = []
// let a = []
arr.map((item, index) => { arr.map((item, index) => {
// filed1[item].map((i, j) => {
// b.push(i)
// })
checkArr[index] = []; checkArr[index] = [];
newCheckedList.map(checkItem => { newCheckedList.map(checkItem => {
if (filed1[item].includes(checkItem)) { if (filed1[item].includes(checkItem)) {
...@@ -402,7 +346,6 @@ const AddModal = props => { ...@@ -402,7 +346,6 @@ const AddModal = props => {
let newArr = characterValue.length ? characterValue.split(',') : []; let newArr = characterValue.length ? characterValue.split(',') : [];
console.log(newArr); console.log(newArr);
setSelectData(newArr); setSelectData(newArr);
// draftSort();
} }
} else { } else {
setSelectData([]); setSelectData([]);
......
/* eslint-disable camelcase */
/* /*
* @Description: * @Description:
* @Author: leizhe * @Author: leizhe
* @Date: 2021-07-23 10:42:58 * @Date: 2021-07-23 10:42:58
* @LastEditTime: 2021-09-16 16:57:48 * @LastEditTime: 2021-12-03 11:26:01
* @LastEditors: leizhe * @LastEditors: leizhe
*/ */
import { CITY_SERVICE, get, PUBLISH_SERVICE, post, postForm } from '../index'; import { CITY_SERVICE, get, PUBLISH_SERVICE, post, postForm } from '../index';
......
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