import React, { Component } from "react";
import {
AutoComplete,
Button,
DatePicker,
Input,
message,
Modal,
Select,
Spin,
Table,
Tabs,
Tag,
Tooltip,
} from "antd";
import { ShowModal, splitUrl, getClockState } from "@/tools";
import { clockState } from "@/dataDic";
import { ChooseList } from "../../order/orderNew/chooseList";
import $ from "jquery/src/ajax";
import "./index.less";
import moment from "moment";
import ImgList from "../../../common/imgList";
import Cascaders from "../../../common/cascaders";
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
class PublicSummary extends Component {
constructor(props) {
super(props);
this.state = {
pageNo: 1,
loading: false,
changeList: undefined,
annexUrlArr: [],
photoUrlArr: [],
imgListVisible: false,
logVisible: false,
columns: [
{
title: "编号",
dataIndex: "key",
key: "key",
width: 45,
fixed: "left",
},
{
title: "客户名称",
dataIndex: "userName",
key: "userName",
width: 150,
fixed: "left",
render: (text, record) => {
return (
{text}
{["未签单", "已签单"][record.signBills]}
{record.signBills == 1 && `(${record.signTime})`}
);
},
},
// {
// title: "公出地址",
// dataIndex: "addressName",
// key: "addressName",
// width: 130,
// render: (text) => {
// return (
// {text}
// );
// },
// },
{
title: "公出地点",
dataIndex: "districtName",
key: "districtName",
width: 120,
render: (text) => {
return (
{text}
);
},
},
{
title: "跟单人",
dataIndex: "sname",
key: "sname",
width: 90,
render: (text, record) => {
return (
{text}
);
},
},
{
title: "公出人员",
dataIndex: "aname",
key: "aname",
width: 190,
render: (text, record) => {
return (
[ 打卡人:{text} ]
{record.assist !== 0 &&
[ 协单人:{record.assistAidName}]
}
{!!record.assistantName &&
[ 协单助手:{record.assistantName}]
}
);
},
},
{
title: "申请时间",
dataIndex: "createTimes",
key: "createTimes",
width: 80,
},
{
title: "公出时间",
dataIndex: "releaseStarts",
key: "releaseStarts",
width: 130,
render: (text, record) => (
{text}
至
{record.releaseEnds}
),
},
{
title: "公出时长(时)",
dataIndex: "duration",
key: "duration",
width: 50,
},
{
title: "打卡时间",
dataIndex: "clockInTimes",
key: "clockInTimes",
width: 120,
render: (text, record) => (
{text.split("\n").map(it =>
{it}
)}
{record.alone == 2 && record.assist == 1
?
无需打卡
:
{["未打卡", "已打卡", "异常打卡"][record.clockIn]}}
)
},
{
title: "标签",
dataIndex: "status",
key: "status",
width: 200,
render: (text, record) => (
{
record.type === 0
? "业务公出" : record.type === 1
? "技术公出" : record.type === 2
? "行政公出" : record.type === 3
? "技术协单" : record.type === 4
? "协单助手" : ""
}
{getClockState(text).title}
{record.updateStatus == 1 && 改}
{record.type === 1 &&
{record.contractNo}
}
{record.type === 1 &&
{record.totalAmout + "(万元)"}
}
),
},
{
title: "公出目标",
dataIndex: "remarks",
key: "remarks",
width: 280,
render: (text) => {
return (
{text}
);
},
},
{
title: "公出计划",
dataIndex: "plan",
key: "plan",
width: 280,
render: (text) => {
return (
{text}
);
},
},
{
title: "预计效果",
dataIndex: "expectedEffect",
key: "expectedEffect",
width: 280,
render: (text) => {
return (
{text}
);
},
},
{
title: "本次公出目标总结",
dataIndex: "supplement",
key: "supplement",
width: 280,
render: (text) => {
return (
{text}
);
},
},
{
title: "下一次公出计划",
dataIndex: "nextPlan",
key: "nextPlan",
width: 280,
render: (text) => {
return (
{text}
);
},
},
{
title: "审核/指导",
dataIndex: "auditInfo",
key: "auditInfo",
width: 200,
render: (text, record) => {
return
{record.auditTimes && `审核时间:${record.auditTimes}`}
{text}
;
},
},
{
title: "操作",
dataIndex: "annexUrl",
key: "annexUrl",
render: (text, record) => (
),
},
],
logColumns: [
{
title: "状态",
dataIndex: "status",
key: "status",
render: (text) => (
{getClockState(text, true).title}
),
},
{
title: "操作人",
dataIndex: "aname",
key: "aname",
},
{
title: "操作时间",
dataIndex: "createTimes",
key: "createTimes",
},
{
title: "备注",
dataIndex: "remarks",
key: "remarks",
render: (text) => {
return (
{text}
);
},
}
],
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return "共" + total + "条数据";
},
},
dataSource: [],
logData: [],
releaseDate: [moment(Date.now() - 777600000).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD')],
status: undefined,
clockIn: undefined,
deps: undefined,
theTypes: undefined,
theTypes1: undefined,
theCustomerTypes: undefined,
contractNo: undefined,
};
this.loadData = this.loadData.bind(this);
this.resetAll = this.resetAll.bind(this);
this.changeList = this.changeList.bind(this);
this.selectSuperId = this.selectSuperId.bind(this);
this.supervisor = this.supervisor.bind(this);
this.httpChange = this.httpChange.bind(this);
this.blurChange = this.blurChange.bind(this);
this.selectAuto = this.selectAuto.bind(this);
this.httpChange1 = this.httpChange1.bind(this);
this.blurChange1 = this.blurChange1.bind(this);
this.selectAuto1 = this.selectAuto1.bind(this);
this.getCustomer = this.getCustomer.bind(this);
this.selectCustomerAuto = this.selectCustomerAuto.bind(this);
this.httpCustomerChange = this.httpCustomerChange.bind(this);
this.blurCustomerChange = this.blurCustomerChange.bind(this);
this.exportExec = this.exportExec.bind(this);
this.addRowColor = this.addRowColor.bind(this)
}
//获取上级组织
selectSuperId() {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/organization/selectSuperId",
data: {},
success: function (data) {
let theArr = [];
if (data.error && data.error.length === 0) {
for (let i = 0; i < data.data.length; i++) {
let theData = data.data[i];
theArr.push(
{theData.name}
);
}
this.setState({
contactsOption: theArr,
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
}
addRowColor(record) {
if (record.assist === 1 || record.assist === 2 || record.assist === 3) {
return 'light'
} else {
return 'dark'
}
}
changeList(arr) {
const newArr = [];
this.state.columns.forEach((item) => {
arr.forEach((val) => {
if (val === item.title) {
newArr.push(item);
}
});
});
this.setState({
changeList: newArr,
});
}
loadData(pageNo) {
this.setState({
loading: true,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/release/publicReleaseDtails",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
releaseStart: this.state.releaseDate[0] || undefined,
releaseEnd: this.state.releaseDate[1] || undefined,
aid: this.state.theTypes || undefined,
sid: this.state.theTypes1 || undefined,
uid: this.state.theCustomerTypes || undefined,
status: this.state.status,
clockIn: this.state.clockIn,
deps: this.state.deps || undefined,
publicType: this.state.type,
contractNo: this.state.contractNo || undefined,
},
success: function (data) {
ShowModal(this);
let theArr = [];
this.setState({
loading: false,
});
if (data.error && data.error.length === 0) {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
thisdata.key = (data.data.pageNo - 1) * data.data.pageSize + i + 1;
theArr.push(thisdata);
}
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
if (data.data && data.data.list && !data.data.list.length) {
this.state.pagination.current = 0;
this.state.pagination.total = 0;
}
this.setState({
dataSource: theArr,
pagination: this.state.pagination,
pageNo: data.data.pageNo,
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
}
resetAll() {
this.setState(
{
releaseDate: [moment(Date.now() - 777600000).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD')],
theCustomerTypes: undefined,
status: undefined,
clockIn: undefined,
deps: undefined,
auto: "",
auto1: "",
customer: "",
theTypes: undefined,
theTypes1: undefined,
type: undefined,
contractNo: undefined,
},
() => {
this.Cascaders.empty();
this.loadData();
}
);
}
supervisor(e) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/listAdminByName",
data: {
adminName: e,
status: "2",
},
success: function (data) {
if (data.error && data.error.length === 0) {
this.setState({
customerArr: data.data,
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(function () { }.bind(this));
}
supervisor1(e) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/listAdminByName",
data: {
adminName: e,
status: "2",
},
success: function (data) {
if (data.error && data.error.length === 0) {
this.setState({
customerArr1: data.data,
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(function () { }.bind(this));
}
httpChange(e) {
if (e.length >= 1) {
this.supervisor(e);
}
this.setState({
auto: e,
});
}
httpChange1(e) {
if (e.length >= 1) {
this.supervisor1(e);
}
this.setState({
auto1: e,
});
}
selectAuto(value, options) {
this.setState({
auto: value,
});
}
selectAuto1(value, options) {
this.setState({
auto1: value,
});
}
httpCustomerChange(e) {
if (e.length >= 1) {
this.getCustomer(e);
}
this.setState({
customer: e,
});
}
selectCustomerAuto(value, options) {
this.setState({
customer: value,
});
}
getCustomer(e) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/getUserByName",
data: {
name: e,
},
success: function (data) {
if (data.error && data.error.length === 0) {
this.setState({
customerList: data.data,
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(function () { }.bind(this));
}
blurCustomerChange(e) {
let theType = "";
let contactLists = this.state.customerList || [];
if (e) {
contactLists.map(function (item) {
if (item.name == e.toString()) {
theType = item.id;
}
});
}
this.setState({
theCustomerTypes: theType,
});
}
blurChange(e) {
let theType = "";
let contactLists = this.state.customerArr || [];
if (e) {
contactLists.map(function (item) {
if (item.name == e.toString()) {
theType = item.id;
}
});
}
this.setState({
theTypes: theType,
});
}
blurChange1(e) {
let theType = "";
let contactLists = this.state.customerArr1 || [];
if (e) {
contactLists.map(function (item) {
if (item.name == e.toString()) {
theType = item.id;
}
});
}
this.setState({
theTypes1: theType,
});
}
componentWillMount() {
this.loadData();
this.selectSuperId();
}
exportExec() {
this.setState({
exportPendingLoading: true,
});
message.config({
duration: 20,
});
let loading = message.loading("下载中...");
let data = {
releaseStart: this.state.releaseDate[0] || undefined,
releaseEnd: this.state.releaseDate[1] || undefined,
aid: this.state.theTypes || undefined,
sid: this.state.theTypes1 || undefined,
uid: this.state.theCustomerTypes || undefined,
status: this.state.status,
clockIn: this.state.clockIn,
// depId: this.state.depId,
deps: this.state.deps || undefined,
publicType: this.state.type,
contractNo: this.state.contractNo || 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];
}
}
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url:
globalConfig.context + "/api/admin/release/publicReleaseDtails/export",
data,
success: function (data) {
if (data.error.length === 0) {
this.download(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;
}
// 公出日志
getLog(e) {
this.setState({
loading: true,
logVisible: true
});
$.ajax({
method: "get",
dataType: "json",
url: globalConfig.context + "/api/admin/release/listPublicReleaseLog",
data: {
id: e,
},
success: function (data) {
if (data.error.length === 0) {
this.setState({
logData: data.data || [],
});
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
}
render() {
const dataSources = this.state.customerArr || [];
const dataSources1 = this.state.customerArr1 || [];
const options = dataSources.map((group) => (
{group.name}
));
const options1 = dataSources1.map((group) => (
{group.name}
));
const customerList = this.state.customerList || [];
const customerOptions = customerList.map((group) => (
{group.name}
));
return (
{this.state.imgListVisible ? (
{
this.setState({
imgListVisible: false,
});
}}
onCancel={() => {
this.setState({
imgListVisible: false,
});
}}
width="500px"
title="图片"
footer=""
>
申请附件
打卡照片
{
this.state.phoList.map(it =>
)
}
) : null}
{
this.state.logVisible &&
{
this.setState({
logVisible: false,
});
}}
>
}
);
}
}
export default PublicSummary;