Przeglądaj źródła

检验改为索引判断

luolei 4 lat temu
rodzic
commit
a7a2f9f65d

+ 14 - 14
src/components/AddInspect/SlidePic/index.jsx

@@ -82,13 +82,13 @@ class SlideSelect extends Component {
       show:!tmpShow
     })
   }
-  handleDel(time){
+  handleDel(part,idx){
     const {handleDelClick,item} = this.props;
     this.setState({
       activeInd:true,
       activeName:item.uniqueName,
     })
-    handleDelClick&&handleDelClick(1,time);
+    handleDelClick&&handleDelClick(1,part,idx);
   }
   handleCancel(){
     this.setState({
@@ -96,9 +96,9 @@ class SlideSelect extends Component {
       activeName:''
     })
   }
-  delConfirm(item){
+  delConfirm(item,idx){
     const {handleDelConfirm,handlePush} = this.props;
-    handleDelConfirm&&handleDelConfirm(item);
+    handleDelConfirm&&handleDelConfirm(item,idx);
     Notify.success("删除成功");
     handlePush && handlePush({mode:8});       //右侧推送
     this.setState({
@@ -149,9 +149,9 @@ class SlideSelect extends Component {
     $('.canEdit').attr('disabled','disabled')
     handlePush && handlePush({mode:8});       //右侧推送
   }
-  checkOnOff(item){
+  checkOnOff(item,idx){
     const {checkOnOff,handlePush} = this.props
-    checkOnOff(item)
+    checkOnOff(item,idx)
     handlePush && handlePush({mode:8});       //右侧推送
   }
   setEdit(e){
@@ -163,13 +163,13 @@ class SlideSelect extends Component {
     $(e.target).removeAttr('disabled').focus()
   }
   render() {
-    const {item,idx,time} = this.props;
+    const {item,idx,activeIdx,activeSign} = this.props;
     const {canEdit,activeInd,activeName,value,style} = this.state;
     return (
       item.flg == 1?<li key={item.uniqueName+idx} className={`${styles.slideLi} clearfix`}> 
           <table>
             <tr>
-              <img className={styles.imgCheck} src={item.check?checkOn:checkOff} onClick={()=>this.checkOnOff(item)} alt=""/>
+              <img className={styles.imgCheck} src={item.check?checkOn:checkOff} onClick={()=>this.checkOnOff(item,idx)} alt=""/>
               <span className={styles.bigname}>{item.uniqueName}</span>
               <span className={styles.smallname}></span>
               <span className={styles.edit}></span>
@@ -186,15 +186,15 @@ class SlideSelect extends Component {
                     onBlur={()=>{this.handleBlur()}}
                     />
               </span>
-              <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item.time)}}></span>
+              <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>
             </tr>
           </table>
-          <DelToast show={time==item.time&&activeInd?true:false}
+          <DelToast show={activeSign==item.flg&&activeIdx==idx&&activeInd?true:false}
                     name={activeName} 
                     right={'-34px'}
                     top={'30px'}
                     cancel={this.handleCancel}
-                    confirm={()=>{this.delConfirm(item)}}/>
+                    confirm={()=>{this.delConfirm(item,idx)}}/>
       </li>:<li key={item.uniqueName+idx} className={`${styles.slideLi} clearfix`}> 
           <span style={{width:'22px'}}></span>
           <span className={styles.bigname}>{item.name}</span>
@@ -224,13 +224,13 @@ class SlideSelect extends Component {
                 onBlur={()=>{this.handleBlur()}}
                 />
           </span>
-          <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item.time)}}></span>
-          <DelToast show={time==item.time&&activeInd?true:false}
+          <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>
+          <DelToast show={activeSign==item.flg&&activeIdx==idx&&activeInd?true:false}
                     name={activeName}
                     right={'-34px'}
                     top={'30px'}
                     cancel={this.handleCancel}
-                    confirm={()=>{this.delConfirm(item)}}/>
+                    confirm={()=>{this.delConfirm(item,idx)}}/>
       </li>
     );
   }

+ 11 - 6
src/components/AddInspect/index.jsx

@@ -23,7 +23,9 @@ class Inspect extends React.Component {
       time: null,
       pageTop: '',
       // tmpIds: [],      //内层外层
-      impId: null
+      impId: null,
+      activeIdx: '',
+      activeSign:'',
     }
     this.$ul = React.createRef();
     this.handleChangeDate = this.handleChangeDate.bind(this)
@@ -51,7 +53,7 @@ class Inspect extends React.Component {
     Notify.success("删除成功");
     handlePush && handlePush({mode:8});       //右侧推送
   }
-  handleDelClick(type, time) {
+  handleDelClick(type, part,idx) {
     if (type == 2) {
       this.setState({
         impId: idx,
@@ -61,7 +63,8 @@ class Inspect extends React.Component {
     } else {
       this.setState({
         type: type,
-        time: time,
+        activeIdx: idx,
+        activeSign:part.flg,
         impId: null
       })
     }
@@ -323,7 +326,7 @@ class Inspect extends React.Component {
   }
   render() {
     const {setHighter,refreshScroller,checkOnOff, getInfomation,setTipValue, handleChangeValue,labelListSmall,inspectList, inspectVal, list, labelListBig, windowHeight, windowWidth,detailClick, handleLabelSub, handleClear, handleConfirm, fillActive, getExcelDataList, handleCloseExcel, handlePush,handleDelConfirm } = this.props;
-    const { tmpId, tmpIdx, time, pageTop, impId } = this.state;
+    const { tmpId, tmpIdx, time, pageTop, impId,activeIdx,activeSign } = this.state;
     const contStyle={
       opacity:'0.4',
       right:'0',
@@ -343,7 +346,8 @@ class Inspect extends React.Component {
                   item={item}
                   checkOnOff={checkOnOff}
                   idx={idx}
-                  time={time}
+                  activeIdx={activeIdx}
+                  activeSign={activeSign}
                   handlePush={handlePush}
                   handleDelClick={this.handleDelClick}
                   setTipValue={setTipValue}
@@ -357,7 +361,8 @@ class Inspect extends React.Component {
                   item={item}
                   checkOnOff={checkOnOff}
                   idx={idx}
-                  time={time}
+                  activeIdx={activeIdx}
+                  activeSign={activeSign}
                   handlePush={handlePush}
                   handleDelClick={this.handleDelClick}
                   setTipValue={setTipValue}

+ 2 - 2
src/containers/Inspect.js

@@ -61,8 +61,8 @@ function mapDispatchToProps(dispatch) {
     setContext(obj){
       dispatch(setContext(obj))
     },
-    handleDelConfirm(obj){
-      dispatch(delOnePic(obj))
+    handleDelConfirm(obj,idx){
+      dispatch(delOnePic(obj,idx))
     },
     handleChangeValue(val) {
       dispatch(getSearchList(val))

+ 4 - 4
src/store/actions/inspect.js

@@ -74,13 +74,13 @@ export const searchType = (value) => ({
     value
 })
 
-export const delOnePic = (item) => ({
+export const delOnePic = (item,tip) => ({
     type:DEL_ONE_PIC,
-    item
+    item,tip
 })
-export const checkOffOn = (item) => ({
+export const checkOffOn = (item,tip) => ({
     type:CHECK_ON_OFF,
-    item
+    item,tip
 })
 
 

+ 12 - 4
src/store/reducers/inspect.js

@@ -49,7 +49,7 @@ export default (state = initSearchList, action) => {
         let tmpLis = action.item,tempBigOrder=[],tempSmallOrder=[],tempTotalOrder=[];
         if(tmpLis&&tmpLis.flg == 1){
             for(let i = 0;i < tempArr.length;i++){
-                if(tempArr[i].time == tmpLis.time){
+                if(action.tip == i){
                     let flg = tempArr[i].check;
                     tempArr[i].check = !flg
                 }
@@ -57,7 +57,7 @@ export default (state = initSearchList, action) => {
             newState.labelListBig = [...tempArr]
         }else{
             for(let i = 0;i < tempArrs.length;i++){
-                if(tempArrs[i].time == tmpLis.time){
+                if(action.tip==i){
                     let flg = tempArrs[i].check;
                     tempArrs[i].check = !flg
                 }
@@ -76,10 +76,18 @@ export default (state = initSearchList, action) => {
         let tempArrs = newState.labelListSmall;
         let tmpLis = action.item,tempBigOrder=[],tempSmallOrder=[],tempTotalOrder=[];
         if(tmpLis&&tmpLis.flg == 1){//大项
-            tempArr = tempArr.filter((item)=>item.time != tmpLis.time)
+            tempArr = tempArr.filter((item,idx)=>{
+                if(action.tip == idx){
+                    return item
+                }
+            })
             newState.labelListBig = [...tempArr]
         }else{//小项
-            tempArrs = tempArrs.filter((item)=> item.time != tmpLis.time )
+            tempArrs = tempArrs.filter((item,idx)=> {
+                if(action.tip == idx){
+                    return item
+                }
+            } )
             newState.labelListSmall = [...tempArrs]
         }
         tempBigOrder = tempArr.filter((item)=>item.check)