import React from "react";
import $ from "jquery/src/ajax";
import "react-quill/dist/quill.bubble.css";
import moment from "moment";
import {
Form,
Icon,
Button,
Input,
Table,
message,
Modal,
Select,
DatePicker,
Popconfirm,
} from "antd";
import SpinContainer from '../../SpinContainer';
const { Option } = Select;
const { TextArea } = Input;
const { RangePicker } = DatePicker;
//主体
const Customers = Form.create()(
React.createClass({
loadData(pageNo = 1) {
this.state.data = [];
this.setState({
loading: true,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url:
globalConfig.context +
"/api/admin/visitingCustomers/listVisitingCustomers",
data: {
pageNo: pageNo,
pageSize: this.state.pagination.pageSize,
name: this.state.name,
startTime: this.state.time[0],
endTime: this.state.time[1],
status:this.state.statusView
},
success: function(data) {
let theArr = [];
if (!data.data || !data.data.list) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
theArr.push({
key: i + 1,
id: thisdata.id,
name: thisdata.name,
mobile: thisdata.mobile,
status: thisdata.status,
remark: thisdata.remark,
createTimes: thisdata.createTimes,
});
}
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
}
this.setState({
dataSource: theArr,
pagination: this.state.pagination,
page: data.data.pageNo
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
getInitialState() {
return {
//数据类型
loading: false,
visible: false,
time: [],
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function(page) {
this.loadData(page);
this.setState({
selectedRowKeys: []
});
}.bind(this),
showTotal: function(total) {
return "共" + total + "条数据";
}
},
columns: [
{
title: "序号",
dataIndex: "id",
key: "id"
},
{
title: "姓名",
dataIndex: "name",
key: "name"
},
{
title: "联系方式",
dataIndex: "mobile",
key: "mobile"
},
{
title: "提交时间",
dataIndex: "createTimes",
key: "createTimes"
},
{
title: "是否查看",
dataIndex: "status",
key: "status",
render: text => {
if (text == 0) {
return "未读";
} else if (text == 1) {
return "已读";
}
}
},
{
title: "回复备注",
dataIndex: "remark",
key: "remark"
},
{
title: "操作",
dataIndex: "aab",
key: "aab",
render: (text, record) => {
return (
{
this.delete(record);
}}
okText="确认"
cancelText="取消"
>
);
}
}
],
//数据列表
dataSource: []
};
},
componentWillMount() {
this.loadData();
},
stopPropagation(e) {
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
},
addRemarks(record) {
let status = record.status + ""
this.setState({
visible: true,
id: record.id,
status,
remark: record.remark
})
},
cancel() {
this.setState({
visible: false,
remarks: undefined,
status: []
})
},
// 导出
exportExec() {
message.config({
duration: 20,
});
let loading = message.loading("下载中...");
this.setState({
exportPendingLoading: true,
});
let data = {
name: this.state.name || undefined,
startTime: this.state.time[0] || undefined,
endTime: this.state.time[1] || undefined,
status:this.state.statusView || undefined
};
for (let i of Object.keys(data)) {
if (i === "status" || i === "clockIn") {
if (isNaN(parseInt(data[i]))) {
delete data[i];
}
} else if (!data[i]) {
delete data[i];
}
}
// console.log(data);
// debugger
// let obj1 = JSON.parse(JSON.stringify(this.state.columns));
// console.log(obj1);
// data = Object.assign(data, obj1);
// if (this.props.exportExecProcessing) {
// data = this.props.exportExecProcessing(data);
// }
// console.log(data);
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context +'/api/admin/visitingCustomers/listVisitingCustomers/export',
data,
success: function (data) {
if (data.error.length === 0) {
this.download(data.data.data);
// console.log(data.data.data);
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
loading();
this.setState({
exportPendingLoading: false,
});
}.bind(this)
);
},
download(fileName) {
window.location.href =
globalConfig.context + "/open/download?fileName=" + fileName+"&delete=true";
},
delete(record) {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url:
globalConfig.context +
"/api/admin/visitingCustomers/updateVisitingCustomers",
data: {
id: record.id,
status: 2,
remark: record.remark
},
success: function(data) {
let theArr = [];
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
message.success("删除成功!");
this.loadData();
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
tijiao() {
this.setState({
loading: true
})
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url:
globalConfig.context +
"/api/admin/visitingCustomers/updateVisitingCustomers",
data: {
id: this.state.id,
status: this.state.status,
remark: this.state.remark
},
success: function(data) {
let theArr = [];
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}else {
this.loadData()
this.cancel()
message.success("提交成功!");
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
reset() {
this.state.time = []
this.state.name = undefined
this.state.statusView = undefined
this.loadData()
},
render() {
const FormItem = Form.Item;
return (
);
}
})
);
export default Form.create()(Customers);