From d2fd67a1bcec35db7870f55a83a25c043ae854f8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 06 九月 2023 15:58:16 +0800
Subject: [PATCH] 2023-09-06

---
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx |   56 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index 71db29c..4ce4d1b 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -4,6 +4,7 @@
 import { Table, Typography, Modal, Input, InputNumber, Button, notification, message, Select } from 'antd'
 import { EditOutlined, QuestionCircleOutlined } from '@ant-design/icons'
 import moment from 'moment'
+import md5 from 'md5'
 
 import Api from '@/api'
 import asyncComponent from '@/utils/asyncComponent'
@@ -947,6 +948,7 @@
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     columns: null,        // 鏄剧ず鍒�
     forms: [],
+    signForms: [],
     orderfields: {},      // 鎺掑簭id涓巉ield杞崲
     loading: false,
     pageOptions: [],
@@ -963,6 +965,7 @@
     let deForms = []
     let _forms = {}
     let hasBid = false
+    let signForms = []
 
     let getColumns = (cols) => {
       return cols.map(item => {
@@ -974,6 +977,8 @@
         } else {
           if (item.editable === 'true') {
             _forms[item.field] = item
+
+            signForms.push(item.field)
 
             if (item.ctrlField) {
               item.ctrlValue = item.ctrlValue.split(',')
@@ -1046,6 +1051,7 @@
 
     this.setState({
       forms,
+      signForms,
       pageSize: setting.pageSize || 10,
       pageOptions,
       columns: _columns,
@@ -1108,10 +1114,28 @@
   }
 
   transferData = (menuid, data, type) => {
-    const { MenuID } = this.props
-    const { edData } = this.state
+    const { MenuID, setting } = this.props
+    const { edData, signForms } = this.state
 
     if (menuid !== MenuID) return
+
+    if (setting.commit !== 'all' && setting.standard !== 'change') {
+      if (type !== 'line') {
+        data.forEach(item => {
+          let value = ''
+          signForms.forEach(field => {
+            value += item[field]
+          })
+          item.$sign = md5(value)
+        })
+      } else {
+        let value = ''
+        signForms.forEach(field => {
+          value += data[field]
+        })
+        data.$sign = md5(value)
+      }
+    }
 
     if (type !== 'line') {
       let index = edData.findIndex(item => !item.$origin && !item.$forbid)
@@ -1461,19 +1485,31 @@
 
   changeRecord = (id, record) => {
     const { setting } = this.props
-    const { tableId } = this.state
+    const { tableId, signForms } = this.state
 
     if (id !== tableId) return
 
-    let lock = record.$lock
+    if (!record.$sign) {
+      record.$origin = false
+      record.$lock = true
+      delete record.$forbid
+    } else {
+      let value = ''
+      signForms.forEach(field => {
+        value += record[field]
+      })
+
+      if (record.$sign !== md5(value)) {
+        record.$origin = false
+        record.$lock = true
+      } else {
+        record.$origin = true
+        record.$lock = false
+      }
+    }
 
     let _data = this.state.edData.map(item => {
       if (item.$$uuid === record.$$uuid) {
-        record.$origin = false
-        record.$lock = true
-
-        delete record.$forbid
-
         return record
       } else {
         return item
@@ -1481,7 +1517,7 @@
     })
 
     this.setState({edData: _data}, () => {
-      if (setting.tableType && setting.hasAction && !lock && this.state.selectedRowKeys.includes(record.$$uuid)) {
+      if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) {
         this.selectdata(this.state.selectedRowKeys)
       }
     })

--
Gitblit v1.8.0