Commit 5bded2e7 authored by LeeJiancong's avatar LeeJiancong

'1'

parent 089186ea
This diff is collapsed.
/*
* @Date: 2020-07-13 15:01:40
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-18 15:12:44
* @LastEditTime: 2020-07-20 17:19:01
*/
import React, { ReactNode, useRef } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card } from 'antd'
import { Button, Popconfirm, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
......@@ -17,6 +17,7 @@ import {
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController'
import { getCompanyList, delCompany,updateCompanyStatus } from '@/services/logistics/index'
const data = [
{
......@@ -38,16 +39,12 @@ const data = [
]
// 模拟请求
const fetchData = (params: any) => {
const fetchData = (params?: any) => {
console.log(params)//可以直接打印参数
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.key === params.keywords)
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data
})
}, 1000)
getCompanyList({ current: params.page, pageSize: params.rows }).then(res => {
resolve(res.data)
})
})
}
......@@ -57,21 +54,24 @@ const Company: React.FC<{}> = () => {
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'key',
dataIndex: 'id',
align: 'center',
key: 'key',
key: 'id',
},
{
title: '物流公司编码/平台会员ID',
align: 'center',
dataIndex: 'required',
key: 'required',
dataIndex: 'memberId',
key: "memberId",
render: (value: any, recond: any) =>
<>{recond.memberId ? recond.memberId : recond.code}</>
},
{
title: '属性名称',
dataIndex: 'attrName',
dataIndex: 'name',
align: 'center',
key: 'attrName',
key: 'name',
render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
},
{
......@@ -113,13 +113,28 @@ const Company: React.FC<{}> = () => {
dataIndex: 'option',
align: 'center',
render: (text: any, record: any) => {
const status = record.status === 0?'启用':'停用'
const title = `确定要${status}吗?`
return (
<>
<Button type='link'>启用</Button>
{
record.status === 0 ? <><Button type='link'>编辑</Button><Button type='link'>删除</Button></> : ''
}
<Button type='link'>查看</Button>
<Popconfirm title={title} okText="是" cancelText="否" onConfirm={() => handleChangeStatus(record.id,record.status)}>
<Button type='link'>
{ record.status === 0?'启用':'停用'}
</Button>
</Popconfirm>
{ record.status === 0 ?
<>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/list/addCompany?id=${record.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => handleDelete(record.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
:''}
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/list/addCompany?id=${record.id}&isSee=true`)}>查看</Button>
</>
)
}
......@@ -135,6 +150,7 @@ const Company: React.FC<{}> = () => {
}
]
const searchBarActions: IButtonFilter[] = [
{
type: 'primary',
......@@ -145,6 +161,24 @@ const Company: React.FC<{}> = () => {
}
}
]
const handleDelete = (id: any) => {
delCompany({ id: id }).then(res => {
if (res.code === 1000) {
message.success(res.message)
ref.current.reload()
}
})
}
const handleChangeStatus = (id:any,status:any) => {
let _status = status == 0 ? 1: 0
updateCompanyStatus({id:id,status:_status}).then(res => {
if(res.code === 1000){
message.success(res.message)
console.log(ref)
ref.current.reload()
}
})
}
const handleSee = (record: any) => {
console.log('see')
......
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-14 15:07:34
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-18 17:48:11
* @LastEditTime: 2020-07-20 16:08:09
*/
import React, { Component, ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
......
declare namespace LogisticsApi {
interface RegisterTypeDTO{
/*
* @Author: LeeJiancong
* @Date: 2020-07-13 16:33:05
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-20 17:02:09
*/
declare namespace LogisticsAPI {
/**
* @description: 只有基础参数
* @param {type} current ;pageSize
* @return:
*/
export interface justBaseParams{
current: number,
pageSize: number
}
//删除id
export interface delID{
id: number| string
}
//查询id
export interface detailID{
id: number
}
//添加 || 编辑
export interface CompanyItem{
id?: number,
memberId ?: number,
name: string,
code?:string | number,
cooperateType: number,
remark: string
}
export interface CompanyStatus{
id: number,
status: number | string
}
}
\ No newline at end of file
/*
* @Author: LeeJiancong
* @Date: 2020-07-13 16:33:16
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-20 17:14:20
*/
import request from '@/utils/request';
const prefix = ''
/**
* @description 物流公司
* @description 物流公司列表
* @param
*/
export async function getCompanyList(params: LogisticsApi.RegisterTypeDTO) {
return request('', {
export async function getCompanyList(params: LogisticsAPI.justBaseParams) {
return request('/logistics/company/page', {
method: 'get',
prefix,
params//get请求 不用写 data: params这样形式
})
}
/**
* @description: 新增公司
* @param {type}
* @return:
*/
export async function addCompany(params: LogisticsAPI.CompanyItem){
return request('/logistics/company/add',{
method: 'post',
prefix,
data: params
})
}
/**
* @description: 编辑公司
* @param {type}
* @return:
*/
export async function updateCompany(params: LogisticsAPI.CompanyItem){
return request('/logistics/company/update',{
method: 'post',
prefix,
data: params
})
}
/**
* @description: 删除公司
* @param {type}
* @return:
*/
export async function delCompany(params: LogisticsAPI.delID){
return request('/logistics/company/delete',{
method: 'post',
prefix,
data: params
})
}
export async function getCompanyDetail(params: LogisticsAPI.delID){
return request('/logistics/company/get',{
method: 'get',
prefix,
params
})
}
/**
* @description: 公司状态
* @param {type}
* @return:
*/
export async function updateCompanyStatus(params: LogisticsAPI.CompanyStatus){
return request('/logistics/company/enable',{
method: 'post',
prefix,
data: params
})
}
/**
* @description: 物流模板列表
* @param {type}
* @return:
*/
export async function freightTemplateList(params: LogisticsAPI.justBaseParams){
return request('/logistics/freightTemplate/page',{
method: 'post',
prefix,
data: params
})
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment