index.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import '@/manageCenter/financialManage/distribute/public.less';
  6. import { Button, Input, Spin, Table,Select, Switch, message, DatePicker,Upload} from 'antd';
  7. import {getNewOrderType,beforeUploadFile} from '@/tools';
  8. import {newOrderType} from '@/dataDic';
  9. import { exportExcel } from 'xlsx-oc';
  10. const Order = React.createClass({
  11. departmentList() {
  12. this.setState({
  13. loading: true
  14. });
  15. $.ajax({
  16. method: "get",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  20. data: {},
  21. success: function(data) {
  22. let thedata = data.data;
  23. let theArr=[];
  24. if(!thedata) {
  25. if(data.error && data.error.length) {
  26. message.warning(data.error[0].message);
  27. };
  28. }else{
  29. thedata.map(function(item,index){
  30. theArr.push({
  31. key:index,
  32. name:item.name,
  33. id:item.id,
  34. })
  35. })
  36. }
  37. this.setState({
  38. departmentArr:theArr,
  39. })
  40. }.bind(this),
  41. }).always(function() {
  42. this.setState({
  43. loading: false
  44. });
  45. }.bind(this));
  46. },
  47. loadData(pageNo) {
  48. this.state.data = [];
  49. this.setState({
  50. page:pageNo,
  51. loading: true
  52. });
  53. let time = new Date(),
  54. year = time.getFullYear(),
  55. month = time.getMonth()+1,
  56. mon1 = this.state.releaseDate.length?this.state.releaseDate[0].replace(/-/g,''):'',
  57. mon2 = this.state.releaseDate.length?this.state.releaseDate[1].replace(/-/g,''):'';
  58. $.ajax({
  59. method: "get",
  60. dataType: "json",
  61. crossDomain: false,
  62. url: globalConfig.context + "/api/admin/bonus/orderReportList",
  63. data: {
  64. pageNo: pageNo || 1,
  65. pageSize:this.state.pagination.pageSize,
  66. saleName: this.state.signName,//客户名称
  67. departmentId:this.state.departmenttList,
  68. type:this.state.orderType>='0'?Number(this.state.orderType)+1:'',
  69. month: mon1||Number((year+''+month)),
  70. month1: mon2||Number((month+1>12?year+1:year)+''+(month+1>12?'01':month+1)),
  71. },
  72. success: function (data) {
  73. let theArr = [];
  74. if (!data.data || !data.data.list) {
  75. if (data.error && data.error.length) {
  76. message.warning(data.error[0].message);
  77. };
  78. } else {
  79. for (let i = 0; i < data.data.list.length; i++) {
  80. let thisdata = data.data.list[i];
  81. theArr.push({
  82. key: i+1,
  83. id:thisdata.id,
  84. deptName:thisdata.deptName,
  85. type:thisdata.type,
  86. saleName:thisdata.saleName,
  87. proofCount:thisdata.proofCount,
  88. amount:thisdata.amount
  89. });
  90. };
  91. }
  92. this.state.pagination.current = data.data.pageNo;
  93. this.state.pagination.total = data.data.totalCount;
  94. if(data.data&&data.data.list&&!data.data.list.length){
  95. this.state.pagination.current=0
  96. this.state.pagination.total=0
  97. }
  98. this.setState({
  99. dataSource: theArr,
  100. pagination: this.state.pagination
  101. });
  102. }.bind(this),
  103. }).always(function () {
  104. this.setState({
  105. loading: false
  106. });
  107. }.bind(this));
  108. },
  109. getInitialState() {
  110. return {
  111. searchMore: true,
  112. releaseDate: [],
  113. RowData:{},
  114. selectedRowKeys: [],
  115. selectedRows: [],
  116. proofData:{},
  117. loading: false,
  118. pagination: {
  119. defaultCurrent: 1,
  120. defaultPageSize: 10,
  121. showQuickJumper: true,
  122. pageSize: 10,
  123. onChange: function (page) {
  124. this.loadData(page);
  125. }.bind(this),
  126. showTotal: function (total) {
  127. return '共' + total + '条数据';
  128. }
  129. },
  130. columns: [
  131. {
  132. title: '序号',
  133. dataIndex: 'id',
  134. key: 'id',
  135. },
  136. {
  137. title: '订单部门',
  138. dataIndex: 'deptName',
  139. key: 'deptName',
  140. },
  141. {
  142. title: '订单类型',
  143. dataIndex: 'type',
  144. key: 'type',
  145. render:text=>{
  146. return getNewOrderType(text)
  147. },
  148. },
  149. {
  150. title: '签单人员',
  151. dataIndex: 'saleName',
  152. key: 'saleName',
  153. },
  154. {
  155. title: '签单数量',
  156. dataIndex: 'proofCount',
  157. key: 'proofCount',
  158. },
  159. {
  160. title: '累计签单金额(万)',
  161. dataIndex: 'amount',
  162. key: 'amount',
  163. },
  164. ],
  165. dataSource: [],
  166. searchTime: [,]
  167. }
  168. },
  169. componentWillMount() {
  170. this.loadData();
  171. this.departmentList();
  172. },
  173. search() {
  174. this.loadData();
  175. },
  176. reset() {
  177. this.state.signName='';
  178. this.state.releaseDate = [];
  179. this.state.departmenttList=undefined;
  180. this.state.orderType=undefined;
  181. this.loadData();
  182. },
  183. searchSwitch() {
  184. this.setState({
  185. searchMore: !this.state.searchMore
  186. });
  187. },
  188. loadExcel(){
  189. window.location.href=globalConfig.context+"/api/admin/bonus/downOrderModelExcel";
  190. },
  191. //导出exec
  192. exec(){
  193. let time = new Date(),
  194. year = time.getFullYear(),
  195. month = time.getMonth()+1,
  196. mon1 = this.state.releaseDate.length?this.state.releaseDate[0].replace(/-/g,''):'',
  197. mon2 = this.state.releaseDate.length?this.state.releaseDate[1].replace(/-/g,''):'';
  198. let data = {
  199. departmentId:this.state.departmentId,
  200. saleName: this.state.signName,
  201. type:this.state.orderType>='0'?Number(this.state.orderType)+1:'',
  202. month: mon1||Number((year+''+month)),
  203. month1: mon2||Number((month+1>12?year+1:year)+''+(month+1>12?'01':month+1)),
  204. }
  205. window.location.href=(globalConfig.context+'/api/admin/bonus/exportOrderData?'+$.param(data));
  206. },
  207. render() {
  208. const { RangePicker } = DatePicker;
  209. let departmentArr = this.state.departmentArr || [];
  210. return ( <div className="user-content">
  211. <div className="content-title">
  212. <span>订单统计报表</span>
  213. </div>
  214. <div className="user-search">
  215. <Select placeholder="部门机构"
  216. style={{ width: 150 ,marginRight:10}}
  217. value={this.state.departmenttList}
  218. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  219. {
  220. departmentArr.map(function (item) {
  221. return <Select.Option key={item.id} >{item.name}</Select.Option>
  222. })
  223. }
  224. </Select>
  225. <Input placeholder="签单人员"
  226. value={this.state.signName}
  227. onChange={(e) => { this.setState({ signName: e.target.value }); }} />
  228. <Select placeholder="订单类型"
  229. style={{ width: 150 ,marginRight:10}}
  230. value={this.state.orderType}
  231. onChange={(e) => { this.setState({ orderType: e }) }}>
  232. {
  233. newOrderType.map(function (item) {
  234. return <Select.Option key={item.value} >{item.key}</Select.Option>
  235. })
  236. }
  237. </Select>
  238. <Button type="primary" onClick={this.search}>搜索</Button>
  239. <Button onClick={this.reset}>重置</Button>
  240. <div style={{float:'right'}}>
  241. <Button type="primary" onClick={this.loadExcel} style={{margin:'0 10px'}}>下载导入模板</Button>
  242. <Upload
  243. action={globalConfig.context + "/api/admin/bonus/uploadOrderExcel"}
  244. data={{ 'sign': '' }}
  245. beforeUpload={beforeUploadFile}
  246. showUploadList={false}
  247. onChange={(info) => {
  248. if (info.file.status !== 'uploading') {
  249. }
  250. if (info.file.status === 'done') {
  251. if (!info.file.response.error.length) {
  252. message.success(`${info.file.name} 文件上传成功!`);
  253. this.loadData();
  254. } else {
  255. message.warning(info.file.response.error[0].message);
  256. return;
  257. };
  258. } else if (info.file.status === 'error') {
  259. message.error(`${info.file.name} 文件上传失败。`);
  260. };
  261. }} >
  262. <Button>导入年度销售数据</Button>
  263. </Upload>
  264. <Button type="primary" onClick={this.exec} style={{margin:'0 10px'}}>导出到excel</Button>
  265. </div>
  266. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch.bind(this)} /></span>
  267. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  268. <span>起止时间 :</span>
  269. <RangePicker
  270. format="YYYY-MM"
  271. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  272. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  273. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  274. </div>
  275. </div>
  276. <div className="patent-table clearfix" id="table">
  277. <Spin spinning={this.state.loading}>
  278. <Table columns={this.state.columns}
  279. dataSource={this.state.dataSource}
  280. pagination={this.state.pagination}
  281. />
  282. </Spin>
  283. </div>
  284. </div> )
  285. }
  286. })
  287. export default Order;