index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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, Form,Spin,InputNumber, Table,Select, Switch, message, DatePicker,Upload,Modal} from 'antd';
  7. import {getNewOrderType,beforeUploadFile} from '@/tools';
  8. import {newOrderType} from '@/dataDic';
  9. import { exportExcel } from 'xlsx-oc';
  10. const FormItem = Form.Item;
  11. const Order = React.createClass({
  12. departmentList() {
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  21. data: {},
  22. success: function(data) {
  23. let thedata = data.data;
  24. let theArr=[];
  25. if(!thedata) {
  26. if(data.error && data.error.length) {
  27. message.warning(data.error[0].message);
  28. };
  29. }else{
  30. thedata.map(function(item,index){
  31. theArr.push({
  32. key:index,
  33. name:item.name,
  34. id:item.id,
  35. })
  36. })
  37. }
  38. this.setState({
  39. departmentArr:theArr,
  40. })
  41. }.bind(this),
  42. }).always(function() {
  43. this.setState({
  44. loading: false
  45. });
  46. }.bind(this));
  47. },
  48. loadData(pageNo) {
  49. this.state.data = [];
  50. this.setState({
  51. page:pageNo,
  52. loading: true
  53. });
  54. let orderN = Number(this.state.orderType);
  55. let time = new Date(),
  56. year = time.getFullYear(),
  57. month = time.getMonth()+1,
  58. mon1 = this.state.releaseDate.length?this.state.releaseDate[0].replace(/-/g,''):'',
  59. mon2 = this.state.releaseDate.length?this.state.releaseDate[1].replace(/-/g,''):'';
  60. $.ajax({
  61. method: "get",
  62. dataType: "json",
  63. crossDomain: false,
  64. url: globalConfig.context + "/api/admin/bonus/orderReportList",
  65. data: {
  66. pageNo: pageNo || 1,
  67. pageSize:this.state.pagination.pageSize,
  68. saleName: this.state.signName,//客户名称
  69. departmentId:this.state.departmenttList,
  70. type:orderN>=0?orderN+1:'',
  71. month: mon1||Number(year+''+(month<10?('0'+month):month)),
  72. month1: mon2||Number((month+1>12?year+1:year)+''+(month+1>12?'01':(month+1)<10?'0'+(month+1):(month+1))),
  73. },
  74. success: function (data) {
  75. let theArr = [];
  76. if (!data.data || !data.data.list) {
  77. if (data.error && data.error.length) {
  78. message.warning(data.error[0].message);
  79. };
  80. } else {
  81. for (let i = 0; i < data.data.list.length; i++) {
  82. let thisdata = data.data.list[i];
  83. theArr.push({
  84. key: i+1,
  85. id:thisdata.id,
  86. mid:thisdata.mid,
  87. deptName:thisdata.deptName,
  88. type:thisdata.type,
  89. saleName:thisdata.saleName,
  90. proofCount:thisdata.proofCount,
  91. amount:thisdata.amount
  92. });
  93. };
  94. }
  95. this.state.pagination.current = data.data.pageNo;
  96. this.state.pagination.total = data.data.totalCount;
  97. if(data.data&&data.data.list&&!data.data.list.length){
  98. this.state.pagination.current=0
  99. this.state.pagination.total=0
  100. }
  101. this.setState({
  102. dataSource: theArr,
  103. pagination: this.state.pagination
  104. });
  105. }.bind(this),
  106. }).always(function () {
  107. this.setState({
  108. loading: false
  109. });
  110. }.bind(this));
  111. },
  112. getInitialState() {
  113. return {
  114. searchMore: true,
  115. releaseDate: [],
  116. RowData:{},
  117. selectedRowKeys: [],
  118. selectedRows: [],
  119. proofData:{},
  120. loading: false,
  121. pagination: {
  122. defaultCurrent: 1,
  123. defaultPageSize: 10,
  124. showQuickJumper: true,
  125. pageSize: 10,
  126. onChange: function (page) {
  127. this.loadData(page);
  128. }.bind(this),
  129. showTotal: function (total) {
  130. return '共' + total + '条数据';
  131. }
  132. },
  133. columns: [
  134. {
  135. title: '序号',
  136. dataIndex: 'id',
  137. key: 'id',
  138. },
  139. {
  140. title: '订单部门',
  141. dataIndex: 'deptName',
  142. key: 'deptName',
  143. },
  144. {
  145. title: '订单类型',
  146. dataIndex: 'type',
  147. key: 'type',
  148. render:text=>{
  149. return getNewOrderType(text)
  150. },
  151. },
  152. {
  153. title: '签单人员',
  154. dataIndex: 'saleName',
  155. key: 'saleName',
  156. },
  157. {
  158. title: '签单数量',
  159. dataIndex: 'proofCount',
  160. key: 'proofCount',
  161. },
  162. {
  163. title: '累计签单金额(万)',
  164. dataIndex: 'amount',
  165. key: 'amount',
  166. },
  167. {
  168. title:'修改单量',
  169. dataIndex:'dl',
  170. key:'d1',
  171. render:(text,recard)=>{
  172. return <Button onClick={(e)=>{e.stopPropagation();this.modify(recard)}}>修改单量</Button>
  173. }
  174. }
  175. ],
  176. dataSource: [],
  177. searchTime: [,]
  178. }
  179. },
  180. //修改单量
  181. modify(recard){
  182. this.setState({
  183. boHuiVisible:true,
  184. recard,
  185. result:recard.proofCount,
  186. amount:recard.amount
  187. })
  188. },
  189. bohuiOk(){
  190. this.setState({
  191. boHuiVisible:false
  192. })
  193. this.loadData(this.state.page);
  194. },
  195. boHuiCancel(){
  196. this.setState({
  197. boHuiVisible:false
  198. })
  199. },
  200. boHuiSubmit(e){
  201. e.preventDefault();
  202. var resType = typeof this.state.result;
  203. if(resType != 'number'){
  204. message.warning('请填写校对信息');
  205. return false;
  206. };
  207. var amountType = typeof this.state.amount;
  208. if(amountType != 'number'){
  209. message.warning('请填写金额');
  210. return false;
  211. };
  212. this.setState({
  213. loading:true
  214. });
  215. const recard = this.state.recard;
  216. var api = '/api/admin/bonus/updateProof';
  217. $.ajax({
  218. method: "POST",
  219. dataType: "json",
  220. crossDomain: false,
  221. url: globalConfig.context + api,
  222. data: {
  223. id:recard.mid,
  224. amount:this.state.amount,
  225. proofCount:this.state.result
  226. }
  227. }).done(function (data) {
  228. if (!data.error.length) {
  229. message.success('修改单量成功');
  230. this.bohuiOk();
  231. } else {
  232. message.warning(data.error[0].message);
  233. };
  234. this.setState({
  235. loading: false
  236. });
  237. }.bind(this));
  238. },
  239. componentWillMount() {
  240. this.loadData();
  241. this.departmentList();
  242. },
  243. search() {
  244. this.loadData();
  245. },
  246. reset() {
  247. this.state.signName='';
  248. this.state.releaseDate = [];
  249. this.state.departmenttList=undefined;
  250. this.state.orderType=undefined;
  251. this.loadData();
  252. },
  253. searchSwitch() {
  254. this.setState({
  255. searchMore: !this.state.searchMore
  256. });
  257. },
  258. loadExcel(){
  259. window.location.href=globalConfig.context+"/api/admin/bonus/downOrderModelExcel";
  260. },
  261. //导出exec
  262. exec(){
  263. let orderN = Number(this.state.orderType);
  264. let time = new Date(),
  265. year = time.getFullYear(),
  266. month = time.getMonth()+1,
  267. mon1 = this.state.releaseDate.length?this.state.releaseDate[0].replace(/-/g,''):'',
  268. mon2 = this.state.releaseDate.length?this.state.releaseDate[1].replace(/-/g,''):'';
  269. let data = {
  270. departmentId:this.state.departmentId,
  271. saleName: this.state.signName,
  272. type:orderN>=0?orderN+1:'',
  273. month: mon1||Number((year+''+month)),
  274. month1: mon2||Number((month+1>12?year+1:year)+''+(month+1>12?'01':month+1)),
  275. }
  276. window.location.href=(globalConfig.context+'/api/admin/bonus/exportOrderData?'+$.param(data));
  277. },
  278. render() {
  279. const { RangePicker } = DatePicker;
  280. let departmentArr = this.state.departmentArr || [];
  281. const recard = this.state.recard || {};
  282. return ( <div className="user-content">
  283. <div className="content-title">
  284. <span>订单统计报表</span>
  285. </div>
  286. <div className="user-search">
  287. <Select placeholder="部门机构"
  288. style={{ width: 150 ,marginRight:10}}
  289. value={this.state.departmenttList}
  290. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  291. {
  292. departmentArr.map(function (item) {
  293. return <Select.Option key={item.id} >{item.name}</Select.Option>
  294. })
  295. }
  296. </Select>
  297. <Input placeholder="签单人员"
  298. value={this.state.signName}
  299. onChange={(e) => { this.setState({ signName: e.target.value }); }} />
  300. <Select placeholder="订单类型"
  301. style={{ width: 150 ,marginRight:10}}
  302. value={this.state.orderType}
  303. onChange={(e) => { this.setState({ orderType: e }) }}>
  304. {
  305. newOrderType.map(function (item) {
  306. return <Select.Option key={item.value} >{item.key}</Select.Option>
  307. })
  308. }
  309. </Select>
  310. <span>起止时间 :</span>
  311. <RangePicker
  312. format="YYYY-MM"
  313. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  314. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  315. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  316. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  317. <Button onClick={this.reset}>重置</Button>
  318. <div style={{float:'right'}}>
  319. {/*<Button type="primary" onClick={this.loadExcel} style={{margin:'0 10px'}}>下载导入模板</Button>
  320. <Upload
  321. action={globalConfig.context + "/api/admin/bonus/uploadOrderExcel"}
  322. data={{ 'sign': '' }}
  323. beforeUpload={beforeUploadFile}
  324. showUploadList={false}
  325. onChange={(info) => {
  326. if (info.file.status !== 'uploading') {
  327. }
  328. if (info.file.status === 'done') {
  329. if (!info.file.response.error.length) {
  330. message.success(`${info.file.name} 文件上传成功!`);
  331. this.loadData();
  332. } else {
  333. message.warning(info.file.response.error[0].message);
  334. return;
  335. };
  336. } else if (info.file.status === 'error') {
  337. message.error(`${info.file.name} 文件上传失败。`);
  338. };
  339. }} >
  340. <Button>导入年度销售数据</Button>
  341. </Upload>*/}
  342. <Button type="primary" onClick={this.exec} style={{margin:'0 10px'}}>导出到excel</Button>
  343. </div>
  344. </div>
  345. <div className="patent-table clearfix" id="table">
  346. <Spin spinning={this.state.loading}>
  347. <Table columns={this.state.columns}
  348. dataSource={this.state.dataSource}
  349. pagination={this.state.pagination}
  350. bordered
  351. size="small"
  352. />
  353. </Spin>
  354. </div>
  355. <Modal maskClosable={false} visible={this.state.boHuiVisible}
  356. width="400px"
  357. title='修改单量'
  358. footer=''
  359. onOk={this.boHuiOk}
  360. onCancel={this.boHuiCancel}
  361. >
  362. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  363. <Spin spinning={this.state.loading}>
  364. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label={<span><strong style={{color:'#f00'}}>*</strong>单量校对结果</span>}>
  365. <InputNumber min={0} max={1} placeholder="输入单量"
  366. value={this.state.result}
  367. onChange={(e)=>{this.setState({result:e})}}
  368. />
  369. </FormItem>
  370. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label={<span><strong style={{color:'#f00'}}>*</strong>金额</span>}>
  371. <InputNumber min={0} max={9999} placeholder="金额"
  372. value={this.state.amount}
  373. onChange={(e)=>{this.setState({amount:e})}}
  374. />
  375. <span> 万元</span>
  376. </FormItem>
  377. <FormItem wrapperCol={{ span: 12, offset:8 }}>
  378. <Button type="primary" htmlType="submit" style={{marginRight:20}}>修改</Button>
  379. <Button type="default" onClick={()=>{this.boHuiCancel()}}>取消</Button>
  380. </FormItem>
  381. </Spin>
  382. </Form>
  383. </Modal>
  384. </div> )
  385. }
  386. })
  387. export default Order;