Forráskód Böngészése

feat: 订阅相关

段立波 4 éve
szülő
commit
5c6f4f3cb4

+ 1 - 1
src/pages/openplatform/components/FontManage/index.js

@@ -79,7 +79,7 @@ class FontManage extends Component {
 
     return (
       <>
-        <Button type="primary" type="link" onClick={this.showModal}>
+        <Button type="primary" type="link" onClick={this.showModal} style={{ padding: '0' }}>
           字段管理
         </Button>
         <Modal

+ 20 - 16
src/pages/openplatform/datacore/sublist/structure.js

@@ -16,34 +16,37 @@ export default {
     bordered: true,
     columnConfig: [
       {
-        title: 'ID',
-        dataIndex: 'id'
-      },
-      {
+        align: 'center',
         title: '订阅ID',
         dataIndex: 'subId'
       },
       {
+        align: 'center',
+        title: '分类名称',
+        dataIndex: 'groupName'
+      },
+      {
+        align: 'center',
+        title: '订阅名称',
+        dataIndex: 'name'
+      },
+      {
+        align: 'center',
         title: '回调参数',
-        dataIndex: 'callbackParams'
+        dataIndex: 'callbackParams',
+        textLength: 20
       },
       {
+        align: 'center',
         title: '回调地址',
         dataIndex: 'callbackUrl',
         textLength: 20
       },
       {
+        align: 'center',
         title: '事件类型',
         dataIndex: 'eventType'
       },
-      {
-        title: 'group',
-        dataIndex: 'groupName'
-      },
-      {
-        title: '订阅名称',
-        dataIndex: 'name'
-      },
       // {
       //   title: '创建者',
       //   dataIndex: 'creator'
@@ -54,11 +57,13 @@ export default {
       //   dataIndex: 'naupdaterme'
       // },
       {
+        align: 'center',
         title: '订阅描述',
         dataIndex: 'remark',
         textLength: 20
       },
       {
+        align: 'center',
         title: '创建时间',
         dataIndex: 'createdAt'
       }
@@ -72,13 +77,12 @@ export default {
       //   ]
       // }
     ],
-    operateBar: [
-    ]
+    operateBar: []
   },
   filterSetting: {
     formFields: [
       {
-        label: 'ID:',
+        label: '订阅ID:',
         type: 'input',
         key: 'id',
         placeholder: '请输入ID',

+ 92 - 0
src/pages/openplatform/datacore/subscribeList/components/editModel/index.js

@@ -0,0 +1,92 @@
+import React, { useState } from 'react'
+import { message, Modal } from 'antd'
+import { FormItem } from 'wptpc-design'
+
+import { editParams, addParams } from '../../services'
+
+let getCheck = null
+
+function Edit (props) {
+  const { setVisible, params, identify, refreshPage } = props
+  const [childParams, setChildParams] = useState(params)
+  const formSetting = [
+    {
+      label: '订阅名称',
+      isRequired: true,
+      type: 'input',
+      key: 'name',
+      value: childParams.name
+    },
+    {
+      label: '订阅场景',
+      isRequired: true,
+      type: 'input',
+      key: 'scene',
+      value: childParams.scene
+    },
+    {
+      label: '描述',
+      isRequired: true,
+      type: 'textarea',
+      key: 'description',
+      maxLength: 2000,
+      value: childParams.description
+    }
+  ]
+
+  const onParamsChange = (key, value) => {
+    setChildParams({
+      ...childParams,
+      [key]: value
+    })
+  }
+
+  const handleOk = () => {
+    if (identify) {
+      addParams({ ...childParams })
+        .then(res => {
+          if (res && res.code === 0) {
+            message.success('添加订阅成功')
+            setVisible(false)
+            refreshPage()
+          }
+        })
+        .catch(err => {
+          message.error(err)
+          setVisible(false)
+        })
+    } else {
+      if (!getCheck()) return false
+      editParams({ ...childParams })
+        .then(res => {
+          if (res && res.code === 0) {
+            message.success('编辑成功')
+            setVisible(false)
+            refreshPage()
+          }
+        })
+        .catch(err => {
+          message.error(err)
+          setVisible(false)
+        })
+    }
+  }
+  const handleCancel = () => {
+    setVisible(false)
+  }
+
+  return (
+    <Modal title={identify ? '添加订阅' : '编辑'} visible onOk={handleOk} onCancel={handleCancel}>
+      <FormItem
+        getCheck={cb => {
+          getCheck = cb
+        }}
+        formSetting={formSetting}
+        onChange={onParamsChange}
+        params={childParams}
+      />
+    </Modal>
+  )
+}
+
+export default Edit

+ 263 - 0
src/pages/openplatform/datacore/subscribeList/index.js

@@ -0,0 +1,263 @@
+import React, { useState } from 'react'
+import { FilterTable } from 'wptpc-design'
+import { Tag, Popconfirm, message, Divider } from 'antd'
+
+import Edit from './components/editModel'
+import { wop } from '@/conf/config.js'
+import { forbiddenParams, showParams, deleteParams } from './services'
+
+const apiUrl = `${wop}/v1/admin/sub/item/get-sub-item-list`
+
+let refreshPage
+
+const Index = props => {
+  const [visible, setVisible] = useState(false)
+  const [params, setParams] = useState({})
+  // 区别编辑,添加  编辑false 添加true
+  const [identify, setIdentify] = useState(false)
+
+  // 启用 禁用
+  const startSwitch = (id) => {
+    forbiddenParams({ id }).then(res => {
+      if (res && res.code === 0) {
+        message.success('操作成功')
+        refreshPage()
+      }
+    }).catch(err => {
+      message.error(err)
+    })
+  }
+  // 显示 隐藏
+  const showSwitch = (id) => {
+    showParams({ id }).then(res => {
+      if (res && res.code === 0) {
+        message.success('操作成功')
+        refreshPage()
+      }
+    }).catch(err => {
+      message.error(err)
+    })
+  }
+  // 删除
+  const remove = (id) => {
+    deleteParams({ id })
+      .then(res => {
+        if (res && res.code === 0) {
+          message.success('操作成功')
+          refreshPage()
+        }
+      })
+      .catch(err => {
+        message.error(err)
+      })
+  }
+
+  const renderOption = record => {
+    const id = record.id
+    const btns = []
+    btns.push(
+      <span>
+        <a
+          onClick={() => {
+            setVisible(true)
+            setIdentify(false)
+            setParams(record)
+          }}
+        >
+          编辑
+        </a>
+        <Divider type="vertical" />
+      </span>
+    )
+    record.state
+      ? btns.push(
+        <Popconfirm title="确定禁用" onConfirm={() => startSwitch(id)}>
+          <a>禁用</a>
+          <Divider type="vertical" />
+        </Popconfirm>
+      )
+      : btns.push(
+        <Popconfirm title="确定启用" onConfirm={() => startSwitch(id)}>
+          <a>启用</a>
+          <Divider type="vertical" />
+        </Popconfirm>
+      )
+    record.is_show
+      ? btns.push(
+        <Popconfirm title="确定隐藏" onConfirm={() => showSwitch(id)}>
+          <a>隐藏</a>
+          <Divider type="vertical" />
+        </Popconfirm>
+      )
+      : btns.push(
+        <Popconfirm title="确定显示" onConfirm={() => showSwitch(id)}>
+          <a>显示</a>
+          <Divider type="vertical" />
+        </Popconfirm>
+      )
+    btns.push(
+      <Popconfirm title="确定删除" onConfirm={() => remove(id)}>
+        <a>删除</a>
+      </Popconfirm>
+    )
+    return btns
+  }
+
+  // 添加订阅
+  const add = () => {
+    setVisible(true)
+    setParams({})
+    setIdentify(true)
+  }
+
+  const filterSetting = {
+    hasSearchBtn: true, // 是否有搜索按钮
+    hasClearBtn: true, // 是否有重置按钮
+    beforeSearchFunc: params => {
+      // 搜索前数据处理
+    },
+    changeApiData: ({ data: { list = [], total } }) => {
+      return {
+        code: 0,
+        data: {
+          list,
+          total
+        }
+      }
+    },
+    formFields: [
+      {
+        label: '订阅名称:',
+        type: 'input',
+        key: 'name',
+        placeholder: '请输入订阅名称',
+        allowEnterSearch: true
+      },
+      {
+        label: '状态:',
+        type: 'select',
+        option: [
+          {
+            value: '',
+            label: '全部'
+          },
+          {
+            value: '1',
+            label: '启用'
+          },
+          {
+            value: '0',
+            label: '禁用'
+          }
+        ],
+        styles: {
+          width: 120
+        },
+        key: 'state',
+        defaultValue: ''
+      },
+      {
+        label: '显示:',
+        type: 'select',
+        option: [
+          {
+            value: '',
+            label: '全部'
+          },
+          {
+            value: '1',
+            label: '显示'
+          },
+          {
+            value: '0',
+            label: '隐藏'
+          }
+        ],
+        styles: {
+          width: 120
+        },
+        key: 'is_show',
+        defaultValue: ''
+      }
+    ]
+  }
+
+  const tableSetting = {
+    getRefresh: refresh => {
+      refreshPage = refresh;
+    },
+    rowKey: 'id',
+    defaultExpandAllRows: true,
+    bordered: true,
+    batchBtns: [{ label: '添加订阅', enabled: true, type: 'primary', onClick: add }],
+    columnConfig: [
+      {
+        align: 'center',
+        title: 'ID',
+        dataIndex: 'id',
+      },
+      {
+        align: 'center',
+        title: '名称',
+        dataIndex: 'name',
+      },
+      {
+        align: 'center',
+        title: '描述',
+        dataIndex: 'description',
+      },
+      {
+        align: 'center',
+        title: '场景',
+        dataIndex: 'scene',
+        textLength: 20,
+      },
+      {
+        align: 'center',
+        title: '状态',
+        dataIndex: 'state',
+        render: text => {
+          if (text === 1) {
+            return <Tag color="green">启用</Tag>;
+          } else {
+            return <Tag color="red">禁用</Tag>;
+          }
+        },
+      },
+      {
+        align: 'center',
+        title: '是否显示',
+        dataIndex: 'is_show',
+        render: text => {
+          if (text === 1) {
+            return <Tag color="green">显示</Tag>;
+          } else {
+            return <Tag color="red">隐藏</Tag>;
+          }
+        },
+      },
+      {
+        align: 'center',
+        title: '创建时间',
+        dataIndex: 'created_at',
+      },
+      {
+        align: 'center',
+        title: '操作',
+        dataIndex: 'actions',
+        render: (text, record) => renderOption(record),
+      },
+    ],
+  };
+  return (
+    <>
+      {visible && <Edit setVisible={setVisible} params={params} identify={identify} refreshPage={refreshPage}/> }
+      <FilterTable
+        filterSetting={filterSetting}
+        tableSetting={tableSetting}
+        apiUrl={apiUrl}
+      />
+    </>
+  )
+}
+export default Index

+ 32 - 0
src/pages/openplatform/datacore/subscribeList/services.js

@@ -0,0 +1,32 @@
+import { fetchApi } from '@/apis/'
+import { wop } from '@/conf/config'
+
+// 编辑
+export async function editParams(body) {
+  const url = `${wop}/v1/admin/sub/item/update-sub-item`
+  return fetchApi(url, { method: 'POST', ...body })
+}
+
+// 添加
+export async function addParams(body) {
+  const url = `${wop}/v1/admin/sub/item/create-sub-item`
+  return fetchApi(url, { method: 'POST', ...body })
+}
+
+// 禁用
+export async function forbiddenParams(body) {
+  const url = `${wop}/v1/admin/sub/item/enable-disable-self-state`
+  return fetchApi(url, { method: 'POST', ...body })
+}
+
+// 显示
+export async function showParams(body) {
+  const url = `${wop}/v1/admin/sub/item/enable-disable-show`
+  return fetchApi(url, { method: 'POST', ...body })
+}
+
+// 删除
+export async function deleteParams(body) {
+  const url = `${wop}/v1/admin/sub/item/delete-sub-item`
+  return fetchApi(url, { method: 'POST', ...body })
+}

+ 23 - 14
src/pages/openplatform/devcore/aplist/structure.js

@@ -17,53 +17,65 @@ export default {
     bordered: true,
     columnConfig: [
       {
+        align: 'center',
         title: 'ID',
         dataIndex: 'id'
       },
       {
+        align: 'center',
         title: '用户标识',
         dataIndex: 'userInfoId'
       },
       {
+        align: 'center',
         title: 'AppKey',
         dataIndex: 'appKey'
       },
       {
-        title: 'appSecret',
+        align: 'center',
+        title: 'AppSecret',
         dataIndex: 'appSecret',
         textLength: 20
-
       },
       {
+        align: 'center',
         title: '回调地址',
-        dataIndex: 'callback'
+        dataIndex: 'callback',
+        textLength: 20
       },
       {
+        align: 'center',
         title: '应用名称',
         dataIndex: 'name'
       },
       {
+        align: 'center',
         title: '应用描述',
         dataIndex: 'description',
         textLength: 20
       },
       {
+        align: 'center',
         title: '状态',
         dataIndex: 'stateDesc',
         render: (t, record) => {
           if (record.state === 1) {
-            return <Tag color='green'>{t}</Tag>
+            return <Tag color="green">{t}</Tag>
           } else {
-            return <Tag color='red' >{t}</Tag>
+            return <Tag color="red">{t}</Tag>
           }
         }
       },
       {
+        align: 'center',
         title: '创建时间',
         dataIndex: 'createdAt'
       },
       {
+        align: 'center',
         title: '操作',
+        width: 200,
+        fixed: 'right',
         dataIndex: 'state',
         coloumnRender: [
           {
@@ -72,7 +84,7 @@ export default {
               {
                 key: 'state',
                 relationship: '=',
-                value: 2
+                value: 0
               }
             ],
             props: {
@@ -168,9 +180,7 @@ export default {
                 }
               ],
               params: {
-                cloumnParams: [
-                  'id'
-                ],
+                cloumnParams: ['id'],
                 formParams: []
               }
             }
@@ -191,8 +201,7 @@ export default {
         ]
       }
     ],
-    operateBar: [
-    ]
+    operateBar: []
   },
   filterSetting: {
     formFields: [
@@ -222,7 +231,7 @@ export default {
         type: 'select',
         option: [
           {
-            value: '0',
+            value: '',
             label: '全部'
           },
           {
@@ -230,7 +239,7 @@ export default {
             label: '通过'
           },
           {
-            value: '2',
+            value: '0',
             label: '未通过'
           }
         ],
@@ -238,7 +247,7 @@ export default {
           width: 120
         },
         key: 'state',
-        defaultValue: '0'
+        defaultValue: ''
       }
     ],
     hasClearBtn: false

+ 110 - 72
src/pages/openplatform/devcore/appsublist/structure.js

@@ -6,14 +6,13 @@ export default {
   requestFormat: data => {
     // data.startTime = moment.unix(data.startTime)
     // data.endTime = moment.unix(data.endTime)
-    return data
+    return data;
   },
   dataFormat: data => {
     data.data.list.forEach(item => {
-      item.eventType = item.eventType?.split(',')
-    })
-    console.log(data.data.list, 111)
-    return data
+      item.eventType = item.eventType?.split(',');
+    });
+    return data;
   },
   constParam: {},
   fetctWhenMount: true,
@@ -23,57 +22,96 @@ export default {
     bordered: true,
     columnConfig: [
       {
+        align: 'center',
         title: 'ID',
-        dataIndex: 'id'
+        dataIndex: 'id',
       },
       {
+        align: 'center',
         title: '用户标识',
-        dataIndex: 'userInfoId'
+        dataIndex: 'userInfoId',
       },
       {
+        align: 'center',
         title: 'AppKey',
-        dataIndex: 'appKey'
+        dataIndex: 'appKey',
       },
       {
-        title: 'appSecret',
-        dataIndex: 'appSecret',
-        textLength: 20
-
+        align: 'center',
+        title: '过滤规则',
+        dataIndex: 'rule',
+        textLength: 20,
       },
       {
+        align: 'center',
         title: '订阅类目',
-        dataIndex: 'name'
+        dataIndex: 'name',
       },
       {
+        align: 'center',
         title: '回调地址',
         dataIndex: 'callback',
-        textLength: 20
+        textLength: 20,
       },
       {
+        align: 'center',
         title: '事件类型',
-        dataIndex: 'eventTypeName'
+        dataIndex: 'eventTypeName',
       },
       {
+        align: 'center',
         title: '状态',
         dataIndex: 'stateDesc',
         render: (t, record) => {
           if (record.state === 1) {
-            return <Tag color='green'>{t}</Tag>
+            return <Tag color="green">{t}</Tag>;
           } else {
-            return <Tag color='red' >{t}</Tag>
+            return <Tag color="red">{t}</Tag>;
           }
-        }
+        },
       },
       {
+        align: 'center',
         title: '创建时间',
-        dataIndex: 'createdAt'
+        dataIndex: 'createdAt',
       },
       {
+        align: 'center',
         title: '操作',
+        width: 300,
+        fixed: 'right',
         dataIndex: 'nickname',
         coloumnRender: [
           {
-            type: 'FontManage'
+            type: 'FontManage',
+          },
+          {
+            type: 'modalFormButton',
+            props: {
+              buttonType: 'link',
+              buttonText: '过滤规则',
+              modalTitle: '过滤规则',
+              modalWidth: 600,
+              apiUrl: `${wop}/v1/admin/developer/subscribe/update-rule`,
+              formFields: [
+                {
+                  type: 'TextArea',
+                  label: '过滤规则',
+                  key: 'rule',
+                  isRequired: true,
+                  componentProps: {
+                    placeholder: '请输入',
+                    rows: 10,
+                  },
+                  extra:
+                    '示例: id>0 and isAuction=true and saving > 12.2 and (secCategory=3001 or secCategory=3002) and type != 0 and profileJson exist "name" and profileJson noexist "age" and profileJson.status = "normal"',
+                },
+              ],
+              params: {
+                cloumnParams: ['id'],
+                formParams: [],
+              },
+            },
           },
           {
             type: 'operatButton',
@@ -81,8 +119,8 @@ export default {
               {
                 key: 'state',
                 relationship: '=',
-                value: 2
-              }
+                value: 0,
+              },
             ],
             props: {
               buttonType: 'link',
@@ -91,18 +129,19 @@ export default {
               confirmText: '确认改变状态吗?',
               apiUrl: `${wop}/v1/admin/developer/subscribe/check`,
               params: {
-                cloumnParams: ['id']
-              }
-            }
+                cloumnParams: ['id'],
+              },
+            },
           },
+
           {
             type: 'operatButton',
             showControl: [
               {
                 key: 'state',
                 relationship: '=',
-                value: 1
-              }
+                value: 1,
+              },
             ],
             props: {
               buttonType: 'link',
@@ -111,9 +150,9 @@ export default {
               confirmText: '确认改变状态吗?',
               apiUrl: `${wop}/v1/admin/developer/subscribe/check`,
               params: {
-                cloumnParams: ['id']
-              }
-            }
+                cloumnParams: ['id'],
+              },
+            },
           },
           {
             type: 'modalFormButton',
@@ -124,9 +163,9 @@ export default {
               modalWidth: 600,
               apiUrl: `${wop}/v1/admin/developer/subscribe/update`,
               requestFormat: data => {
-                data.eventType = data.eventType.length ? data.eventType.toLocaleString() : ''
-                console.log(data, 1)
-                return data
+                data.eventType = data.eventType.length ? data.eventType.toLocaleString() : '';
+                console.log(data, 1);
+                return data;
               },
               formFields: [
                 {
@@ -135,8 +174,8 @@ export default {
                   key: 'id',
                   isRequired: false,
                   componentProps: {
-                    disabled: true
-                  }
+                    disabled: true,
+                  },
                 },
                 {
                   type: 'CheckBox',
@@ -148,18 +187,18 @@ export default {
                     options: [
                       {
                         value: '1',
-                        label: 'insert'
+                        label: 'insert',
                       },
                       {
                         value: '2',
-                        label: 'update'
+                        label: 'update',
                       },
                       {
                         value: '3',
-                        label: 'delete'
-                      }
-                    ]
-                  }
+                        label: 'delete',
+                      },
+                    ],
+                  },
                 },
                 {
                   type: 'TextArea',
@@ -167,18 +206,18 @@ export default {
                   key: 'callback',
                   isRequired: true,
                   componentProps: {
+                    rows: 8,
                     placeholder: '请输入',
                     maxLength: 200,
-                    minLength: 2
-                  }
-                }
+                    minLength: 2,
+                  },
+                },
               ],
               params: {
-                cloumnParams: [
-                ],
-                formParams: []
-              }
-            }
+                cloumnParams: [],
+                formParams: [],
+              },
+            },
           },
           {
             type: 'operatButton',
@@ -189,15 +228,14 @@ export default {
               confirmText: '确认删除吗?',
               apiUrl: `${wop}/v1/admin/developer/subscribe/delete`,
               params: {
-                cloumnParams: ['id']
-              }
-            }
-          }
-        ]
-      }
+                cloumnParams: ['id'],
+              },
+            },
+          },
+        ],
+      },
     ],
-    operateBar: [
-    ]
+    operateBar: [],
   },
   filterSetting: {
     formFields: [
@@ -206,46 +244,46 @@ export default {
         type: 'input',
         key: 'userInfoId',
         placeholder: '请输入用户标识',
-        allowEnterSearch: true
+        allowEnterSearch: true,
       },
       {
         label: 'AppKey:',
         type: 'input',
         key: 'appKey',
         placeholder: '请输入AppKey',
-        allowEnterSearch: true
+        allowEnterSearch: true,
       },
       {
         label: '订阅类目:',
         type: 'input',
         key: 'name',
         placeholder: '请输入订阅类目',
-        allowEnterSearch: true
+        allowEnterSearch: true,
       },
       {
         label: '状态:',
         type: 'select',
         option: [
           {
-            value: '0',
-            label: '全部'
+            value: '',
+            label: '全部',
           },
           {
             value: '1',
-            label: '启用'
+            label: '启用',
           },
           {
-            value: '2',
-            label: '未启用'
-          }
+            value: '0',
+            label: '未启用',
+          },
         ],
         styles: {
-          width: 120
+          width: 120,
         },
         key: 'state',
-        defaultValue: '0'
-      }
+        defaultValue: '',
+      },
     ],
-    hasClearBtn: false
-  }
-}
+    hasClearBtn: false,
+  },
+};

+ 18 - 15
src/pages/openplatform/devcore/numlist/structure.js

@@ -17,45 +17,51 @@ export default {
     bordered: true,
     columnConfig: [
       {
+        align: 'center',
         title: 'ID',
         dataIndex: 'id'
       },
       {
+        align: 'center',
         title: '用户标识',
         dataIndex: 'userInfoId'
       },
       {
+        align: 'center',
         title: '手机号',
         dataIndex: 'phone'
       },
       {
+        align: 'center',
         title: '邮箱',
         dataIndex: 'email'
         // textLength: 40
       },
       {
+        align: 'center',
         title: '类型',
         dataIndex: 'type',
-        render: (t) =>
-          (Number(t) === 1 ? '个人' : '商家')
-
+        render: t => (Number(t) === 1 ? '个人' : '商家')
       },
       {
+        align: 'center',
         title: '状态',
         dataIndex: 'stateDesc',
         render: (t, record) => {
           if (record.state === 1) {
-            return <Tag color='green'>{t}</Tag>
+            return <Tag color="green">{t}</Tag>
           } else {
-            return <Tag color='red' >{t}</Tag>
+            return <Tag color="red">{t}</Tag>
           }
         }
       },
       {
+        align: 'center',
         title: '创建时间',
         dataIndex: 'createdAt'
       },
       {
+        align: 'center',
         title: '操作',
         dataIndex: 'nickname',
         coloumnRender: [
@@ -78,7 +84,7 @@ export default {
               {
                 key: 'state',
                 relationship: '=',
-                value: 2
+                value: 0
               }
             ],
             props: {
@@ -124,7 +130,7 @@ export default {
                 {
                   type: 'Input',
                   label: '用户标识',
-                  key: 'name',
+                  key: 'userInfoId',
                   isRequired: true,
                   componentProps: {
                     disabled: true,
@@ -164,9 +170,7 @@ export default {
                 }
               ],
               params: {
-                cloumnParams: [
-                  'id'
-                ],
+                cloumnParams: ['id'],
                 formParams: []
               }
             }
@@ -174,8 +178,7 @@ export default {
         ]
       }
     ],
-    operateBar: [
-    ]
+    operateBar: []
   },
   filterSetting: {
     formFields: [
@@ -198,7 +201,7 @@ export default {
         type: 'select',
         option: [
           {
-            value: '0',
+            value: '',
             label: '全部'
           },
           {
@@ -206,7 +209,7 @@ export default {
             label: '启用'
           },
           {
-            value: '2',
+            value: '0',
             label: '禁用'
           }
         ],
@@ -214,7 +217,7 @@ export default {
           width: 120
         },
         key: 'state',
-        defaultValue: '0'
+        defaultValue: ''
       }
     ],
     hasClearBtn: false

+ 105 - 67
src/pages/poster/list/index.js

@@ -1,7 +1,7 @@
 /* eslint-disable no-return-assign */
 /* eslint-disable camelcase */
 import React, { Component, Fragment } from 'react'
-import { Divider, Modal, message,Button,Tag } from 'antd'
+import { Divider, Modal, message, Button, Tag } from 'antd'
 import { FilterTable, ImagePreview } from 'wptpc-design'
 import { connect } from 'dva'
 import { routerRedux } from 'dva/router'
@@ -10,9 +10,9 @@ import ConfigModal from './components/ConfigModal'
 import CopyTemplateModal from './components/CopyTemplateModal'
 import { dc } from '@/conf/config'
 import { fetchApi_get } from '@/apis/'
-import ExportPower from './components/JsonExport';
-import ImportPower from './components/JsonImport';
-import { delTemplateAction,changePosterState } from './services'
+import ExportPower from './components/JsonExport'
+import ImportPower from './components/JsonImport'
+import { delTemplateAction, changePosterState } from './services'
 
 // less
 import styles from './index.less'
@@ -75,6 +75,7 @@ class Poster extends Component {
       }
     })
   }
+
   changeState = (status, id) => {
     Modal.confirm({
       title: status === 0 ? '确定要禁用该海报模板吗' : '确定要启用该海报模板吗',
@@ -87,12 +88,13 @@ class Poster extends Component {
             } else if (status === 0) {
               message.success('已启用')
             }
-            this.refresh();
+            this.refresh()
           }
         })
       }
     })
   }
+
   render () {
     // 搜索框配置
     const filterSettingConfig = {
@@ -121,9 +123,9 @@ class Poster extends Component {
         option: [
           { label: '全部', value: '' },
           { label: '启用', value: 1 },
-          { label: '禁用', value: 0 },
+          { label: '禁用', value: 0 }
         ],
-        defaultValue: '',
+        defaultValue: ''
       }]
       // 查询前触发的函数,进行参数整合
       // beforeSearchFunc: (data) => {
@@ -140,73 +142,109 @@ class Poster extends Component {
       //   pageSize: 10,
       // },
       // 每一列配置
-      columnConfig: [{
-        title: '序号',
-        dataIndex: 'id'
-      }, {
-        title: '海报缩略图',
+      columnConfig: [
+        {
+          align: 'center',
+          title: '序号',
+          dataIndex: 'id',
+        },
+        {
+          align: 'center',
+          title: '海报缩略图',
           dataIndex: 'preview',
-        width:100,
-        render: (_, record) => <img src={_} className={styles.previewImg} onClick={this.previewImg.bind(this, record)} />
-      }, {
-        title: '海报标识',
-        dataIndex: 'name'
-      }, {
-        title: '海报描述',
-        dataIndex: 'description'
-      },{
-        title: '状态',
-        dataIndex: 'stateName',
-        render: (t, record) => {
-          if (record.state === 1) {
-            return <Tag color='green'>{t}</Tag>
-          } else {
-            return <Tag color='red' >{t}</Tag>
-          }
-        }
-      },{
-        title: '创建人',
-        dataIndex: 'creator'
-      },{
-        title: '最后修改人',
-        dataIndex: 'updater'
-      },{
-        title: '操作',
-        dataIndex: 'actions',
-        render: (_, record) => {
-          const { id } = record
-          return (
-            <Fragment>
-              <a href={`/poster/edit/${record.id}`}>编辑</a>
-              {record.state === 0 && <>
+          width: 100,
+          render: (_, record) => (
+            <img
+              src={_}
+              className={styles.previewImg}
+              onClick={this.previewImg.bind(this, record)}
+            />
+          ),
+        },
+        {
+          align: 'center',
+          title: '海报标识',
+          dataIndex: 'name',
+        },
+        {
+          align: 'center',
+          title: '海报描述',
+          dataIndex: 'description',
+        },
+        {
+          align: 'center',
+          title: '状态',
+          dataIndex: 'stateName',
+          render: (t, record) => {
+            if (record.state === 1) {
+              return <Tag color="green">{t}</Tag>;
+            } else {
+              return <Tag color="red">{t}</Tag>;
+            }
+          },
+        },
+        {
+          align: 'center',
+          title: '创建人',
+          dataIndex: 'creator',
+          width: 150
+        },
+        {
+          align: 'center',
+          title: '最后修改人',
+          dataIndex: 'updater',
+          width: 150
+        },
+        {
+          align: 'center',
+          title: '操作',
+          dataIndex: 'actions',
+          render: (_, record) => {
+            const { id } = record;
+            return (
+              <Fragment>
+                <a href={`/poster/edit/${record.id}`}>编辑</a>
+                {record.state === 0 && (
+                  <>
+                    <Divider type="vertical" />
+                    <a onClick={this.changeState.bind(this, 1, id)}>启用</a>
+                  </>
+                )}
+                {record.state === 1 && (
+                  <>
+                    <Divider type="vertical" />
+                    <a onClick={this.changeState.bind(this, 0, id)}>禁用</a>
+                  </>
+                )}
+                <Divider type="vertical" />
+                <a onClick={this.delImg.bind(this, record)}>删除</a>
                 <Divider type="vertical" />
-                <a onClick={this.changeState.bind(this,1,id)}>启用</a>
-              </>}
-              {record.state === 1 && <>
+                <ExportPower record={record} />
                 <Divider type="vertical" />
-                <a onClick={this.changeState.bind(this,0,id)}>禁用</a>
-              </>}
-              <Divider type="vertical" />
-              <a onClick={this.delImg.bind(this, record)}>删除</a>
-              <Divider type="vertical" />
-              <ExportPower record={ record}/>
-              <Divider type="vertical" />
-              <a onClick={this.handleConfig.bind(this, record)}>查看配置</a>
-              <Divider type="vertical" />
-              <a onClick={this.handleCopyTemplate.bind(this, record)}>复制模版</a>
-            </Fragment>
-          )
-        }
-      }],
+                <a onClick={this.handleConfig.bind(this, record)}>查看配置</a>
+                <Divider type="vertical" />
+                <a onClick={this.handleCopyTemplate.bind(this, record)}>复制模版</a>
+              </Fragment>
+            );
+          },
+        },
+      ],
       batchBtnsJxs: [
-        <Button type='primary'  onClick={(e) => { this.props.dispatch(routerRedux.push({ pathname: '/poster/edit' })) }}>创建</Button>,
-        <ImportPower refresh={ this.refresh}/>
+        <Button
+          type="primary"
+          onClick={e => {
+            this.props.dispatch(routerRedux.push({ pathname: '/poster/edit' }));
+          }}
+        >
+          创建
+        </Button>,
+        <ImportPower refresh={this.refresh} />,
       ],
       // 刷新页面
       getRefresh: refresh => {
-        this.refresh = refresh
-      }
-    }
+        this.refresh = refresh;
+      },
+    };
 
     const { imgs, visible } = this.state
     return (