import React, { useState, useEffect } from 'react';
import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, notification, Modal } from 'antd';
import moment from 'moment';
import request from '../../../utils/request';
import apis from '../../../services/apis';
import Styles from './style.less';
import { router } from 'umi';
import AuthButton from '@/components/AuthButton';
const { Option } = Select;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { Meta } = Card;
const tempDate = [{ code: 's101' }]
function openNotificationWithIcon(type, message) {
notification[type]({
message,
description:
'',
});
}
/**
*卡片
*
* @returns
*/
function CartBody(props) {
const { data } = props
function toEdi(record) {
router.push({
pathname: '/building/list/add',
query: {
id: record.buildingId,
},
})
}
/**
*发布 取消 发布
*
* @param {*} record
*/
function pulicAndUnPulic(record) {
const modal = Modal.confirm();
const buidingStatus = record.status === 1 ? 2 : 1
const title = record.status === 1 ? '确认取消发布此数据?' : '确认发布此数据?'
modal.update({
content: title,
okText: '确认',
cancelText: '关闭',
onOk: () => {
request({ ...apis.building.updateStatus, data: { id: record.buildingId, status: buidingStatus } }).then(() => {
openNotificationWithIcon('success', '操作成功')
props.onSuccess()
}).catch(err => {
openNotificationWithIcon('error', err.message)
})
modal.destroy();
},
onCancel: () => {
modal.destroy();
},
});
}
/**
*删除楼盘
*
* @param {*} record
*/
function deleteBuilding(record) {
const { url, method } = apis.building.deleteBuilding
const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(record.buildingId)
const modal = Modal.confirm();
modal.update({
content: '确定删除此楼盘?',
okText: '确认',
cancelText: '关闭',
onOk: () => {
request({ url: tempUrl, method }).then(() => {
openNotificationWithIcon('success', '操作成功')
props.onSuccess()
}).catch(err => {
openNotificationWithIcon('error', err.message)
})
modal.destroy();
},
onCancel: () => {
modal.destroy();
},
});
}
return (
楼盘编号
:{data.code}
toEdi(data)}>
编辑
楼盘名称
:{data.name}
均价
:约 {data.price} 元/m
项目地址
:{data.address}
发布状态
:{data.status === 1 ? '已发布' : '未发布'}
录入时间
:{data.createDate}
pulicAndUnPulic(data)}>
{/* 已发布的时候,需要显示取消发布的字样 */}
{data.status === 1 ? '取消发布' : '发布'}