From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/templates/zshare/modalform/datatable/index.jsx |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/src/templates/zshare/modalform/datatable/index.jsx b/src/templates/zshare/modalform/datatable/index.jsx
index 2a361f8..ec8b5a1 100644
--- a/src/templates/zshare/modalform/datatable/index.jsx
+++ b/src/templates/zshare/modalform/datatable/index.jsx
@@ -2,8 +2,8 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { DndProvider, DragSource, DropTarget } from 'react-dnd'
-import { Table, Input, Popconfirm, Form, notification } from 'antd'
-import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons'
+import { Table, Input, Popconfirm, Form, notification, message } from 'antd'
+import { PlusOutlined, EditOutlined, DeleteOutlined, SwapOutlined } from '@ant-design/icons'
 
 import Utils from '@/utils/utils.js'
 import FileUpload from '@/tabviews/zshare/fileupload'
@@ -118,14 +118,14 @@
     return (
       <td {...restProps}>
         {editing ? (
-          <Form.Item style={{ margin: 0 }}>
+          <Form.Item style={{ margin: '0 -5px 0 -5px' }}>
             {getFieldDecorator(dataIndex, {
-              rules: [
-                {
-                  required: dataIndex === '$value',
-                  message: `Please Input ${title}!`,
-                },
-              ],
+              // rules: [
+              //   {
+              //     required: dataIndex === '$value',
+              //     message: `Please Input ${title}!`,
+              //   },
+              // ],
               initialValue: _val,
             })(this.getInput(form))}
           </Form.Item>
@@ -258,6 +258,7 @@
         ) : (
           <div className={'operation-btn' + (editingKey !== '' ? ' disabled' : '')}>
             <span className="primary" onClick={() => {editingKey === '' && this.edit(record.key)}}><EditOutlined /></span>
+            <span className="hide-control" title="鏄剧ず/闅愯棌" onClick={() => {editingKey === '' && this.handleHide(record.key)}}><SwapOutlined /></span>
             {editingKey === '' ? <Popconfirm
               overlayClassName="popover-confirm"
               title={this.props.dict['model.query.delete']}
@@ -281,8 +282,20 @@
   }
 
   onSave = (record) => {
+    const { type } = this.props
     const newData = [...this.state.data]
     const index = newData.findIndex(item => record.key === item.key)
+
+    if (type === 'link') {
+      if (newData.filter(m => record.key !== m.key && record.$value === m.$value && record.ParentID === m.ParentID).length > 0) {
+        message.warning('鐩稿悓ParentID涓嬶紝姝alue鍊煎凡瀛樺湪锛�')
+      }
+    } else {
+      if (newData.filter(m => record.key !== m.key && record.$value === m.$value).length > 0) {
+        message.warning('姝alue鍊煎凡瀛樺湪锛�')
+      }
+    }
+
     if (index > -1) {
       newData.splice(index, 1, record)
       this.setState({ data: newData, editingKey: '' }, () => {
@@ -303,6 +316,8 @@
   }
 
   save(form, key) {
+    const { type } = this.props
+
     form.validateFields((error, row) => {
       if (error) {
         return;
@@ -310,6 +325,17 @@
 
       const newData = [...this.state.data]
       const index = newData.findIndex(item => key === item.key)
+
+      if (type === 'link') {
+        if (newData.filter(m => key !== m.key && row.$value === m.$value && row.ParentID === m.ParentID).length > 0) {
+          message.warning('鐩稿悓ParentID涓嬶紝姝alue鍊煎凡瀛樺湪锛�')
+        }
+      } else {
+        if (newData.filter(m => key !== m.key && row.$value === m.$value).length > 0) {
+          message.warning('姝alue鍊煎凡瀛樺湪锛�')
+        }
+      }
+
       if (index > -1) {
         const item = newData[index]
         newData.splice(index, 1, {
@@ -358,6 +384,20 @@
 
   edit(key) {
     this.setState({ editingKey: key })
+  }
+
+  handleHide = (key) => {
+    let _data = this.state.data.map(item => {
+      if (item.key === key) {
+        item.Hide = !item.Hide
+      }
+      return item
+    })
+    this.setState({
+      data: _data
+    }, () => {
+      this.props.onChange(_data)
+    })
   }
 
   moveRow = (dragIndex, hoverIndex) => {
@@ -418,7 +458,7 @@
               rowKey="key"
               dataSource={this.state.data}
               columns={columns}
-              rowClassName="editable-row"
+              rowClassName={(record) => record.Hide ? 'editable-row hide' : 'editable-row'}
               onRow={(record, index) => ({
                 index,
                 moveAble: !this.state.editingKey,

--
Gitblit v1.8.0