lanjianrong 4 years ago
parent
commit
d80fcae90c
1 changed files with 40 additions and 14 deletions
  1. 40 14
      src/pages/Business/Contact/index.tsx

+ 40 - 14
src/pages/Business/Contact/index.tsx

@@ -26,26 +26,30 @@ interface StageSettingsType {
   id: React.Key
   id: React.Key
   name?: string
   name?: string
   stage?: string
   stage?: string
+  isDefault?: boolean
   percentage?: number
   percentage?: number
 }
 }
 
 
 const defaultData = [
 const defaultData = [
   {
   {
-    id: 1,
+    id: 624748504,
     stage: '结束',
     stage: '结束',
     name: '赢单',
     name: '赢单',
+    isDefault: true,
     percentage: '100'
     percentage: '100'
   },
   },
   {
   {
-    id: 2,
+    id: 624691229,
     stage: '结束',
     stage: '结束',
-    name: '赢单',
+    name: '输单',
+    isDefault: true,
     percentage: '0'
     percentage: '0'
   },
   },
   {
   {
-    id: 3,
+    id: 624691258,
     stage: '结束',
     stage: '结束',
     name: '无效',
     name: '无效',
+    isDefault: true,
     percentage: '0'
     percentage: '0'
   }
   }
 ]
 ]
@@ -67,17 +71,19 @@ const Contact: React.FC = () => {
     {
     {
       title: '阶段',
       title: '阶段',
       dataIndex: 'stage',
       dataIndex: 'stage',
-      width: '15%'
+      width: '15%',
+      // 第二行不允许编辑
+      editable: false
     },
     },
     {
     {
       title: '阶段名称',
       title: '阶段名称',
       dataIndex: 'name',
       dataIndex: 'name',
-      width: '45%'
+      width: '28%'
     },
     },
     {
     {
       title: '赢单率',
       title: '赢单率',
       dataIndex: 'percentage',
       dataIndex: 'percentage',
-      width: '30%',
+      width: '27%',
       valueType: 'text',
       valueType: 'text',
       fieldProps: {
       fieldProps: {
         addonAfter: '%'
         addonAfter: '%'
@@ -86,7 +92,28 @@ const Contact: React.FC = () => {
     {
     {
       title: '操作',
       title: '操作',
       valueType: 'option',
       valueType: 'option',
-      width: '10%'
+      width: '20%',
+      render: (text, record, index, action) => {
+        if (record.isDefault) {
+          return null
+        }
+        return [
+          <a
+            key="editable"
+            onClick={() => {
+              action?.startEditable?.(record.id)
+            }}>
+            编辑
+          </a>,
+          <a
+            key="delete"
+            onClick={() => {
+              setDataSource(dataSource.filter(item => item.id !== record.id))
+            }}>
+            删除
+          </a>
+        ]
+      }
     }
     }
   ]
   ]
   const { run: tryGetList } = useRequest(getBusinessgroupList, {
   const { run: tryGetList } = useRequest(getBusinessgroupList, {
@@ -224,12 +251,12 @@ const Contact: React.FC = () => {
             if (state.type === modalType.CREATE) {
             if (state.type === modalType.CREATE) {
               await tryAddBusinessgroup({
               await tryAddBusinessgroup({
                 ...value,
                 ...value,
-                stageSettings: JSON.stringify(value.stageSettings)
+                stageSettings: JSON.stringify(value.stageSettings.filter(item => !item.isDefault))
               })
               })
             } else {
             } else {
               await tryUpdateBusinessGroup({
               await tryUpdateBusinessGroup({
                 ...value,
                 ...value,
-                stageSettings: JSON.stringify(value.stageSettings)
+                stageSettings: JSON.stringify(value.stageSettings.filter(item => !item.isDefault))
               })
               })
             }
             }
             return true
             return true
@@ -254,10 +281,9 @@ const Contact: React.FC = () => {
             columns={columns}
             columns={columns}
             recordCreatorProps={{
             recordCreatorProps={{
               newRecordType: 'dataSource',
               newRecordType: 'dataSource',
-              position: 'top',
-              record: index => ({
-                id: Date.now(),
-                stage: `阶段${index - 2}`
+              position: 'bottom',
+              record: () => ({
+                id: Date.now()
               })
               })
             }}
             }}
             editable={{
             editable={{