checkBuy.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import 'react-quill/dist/quill.bubble.css';
  4. import moment from 'moment';
  5. import {Form,Icon,Button,Input,Select,Spin,Table,message,DatePicker,Modal,Upload,Popconfirm,Cascader,InputNumber,Radio,TimePicker,Tabs} from 'antd';
  6. import {areaSelect, getProvince} from '@/NewDicProvinceList';//省市区
  7. import { getGameState, splitUrl, getprovince, getStatuslist, getLvl,beforeUploadFile,getSecretType,getBuyAuditType} from '@/tools.js';
  8. const PicturesWall = React.createClass({
  9. getInitialState() {
  10. return {
  11. previewVisible: false,
  12. previewImage: '',
  13. fileList: this.props.pictureUrl,
  14. }
  15. },
  16. getDefaultProps(){
  17. return{
  18. changeClick:this.modifyChange
  19. }
  20. },
  21. handleCancel() {
  22. this.setState({ previewVisible: false })
  23. },
  24. handlePreview(file) {
  25. this.setState({
  26. previewImage: file.url || file.thumbUrl,
  27. previewVisible: true,
  28. });
  29. },
  30. handleChange(info) {
  31. let fileList = info.fileList;
  32. this.setState({ fileList });
  33. this.props.fileList(fileList);
  34. },
  35. componentWillReceiveProps(nextProps) {
  36. this.state.fileList = nextProps.pictureUrl;
  37. },
  38. render() {
  39. const { previewVisible, previewImage, fileList } = this.state;
  40. const uploadButton = (
  41. <div>
  42. <Icon type="plus" />
  43. <div className="ant-upload-text">点击上传</div>
  44. </div>
  45. );
  46. return (
  47. <div style={{display:"inline-block"}}>
  48. <Upload
  49. beforeUpload={beforeUploadFile}
  50. action={globalConfig.context + "/api/admin/purchase/uploadPicture"}
  51. data={{ 'sign': 'purchase_picture' }}
  52. listType="picture-card"
  53. fileList={fileList}
  54. onPreview={this.handlePreview}
  55. onChange={this.handleChange} >
  56. {fileList.length >= 18 ? null : uploadButton}
  57. </Upload>
  58. <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
  59. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  60. </Modal>
  61. </div>
  62. );
  63. }
  64. });
  65. //主体
  66. const CheckBuy = Form.create()(
  67. React.createClass({
  68. loadData(pageNo) {
  69. this.state.data = [];
  70. this.setState({
  71. loading: true,
  72. page: pageNo
  73. });
  74. $.ajax({
  75. method: 'get',
  76. dataType: 'json',
  77. crossDomain: false,
  78. url: globalConfig.context + '/api/admin/purchase/listPurchase',
  79. data: {
  80. pageNo: pageNo || 1,
  81. pageSize: this.state.pagination.pageSize,
  82. auditStatus: 1,
  83. },
  84. success: function(data) {
  85. let theArr = [];
  86. if (!data.data || !data.data.list) {
  87. if (data.error && data.error.length) {
  88. message.warning(data.error[0].message);
  89. }
  90. } else {
  91. for (let i = 0; i < data.data.list.length; i++) {
  92. let thisdata = data.data.list[i];
  93. theArr.push({
  94. key: i,
  95. id: thisdata.id,
  96. title: thisdata.title,
  97. type: thisdata.type,
  98. secretType: thisdata.secretType,
  99. auditStatus: thisdata.auditStatus,
  100. topNumber: thisdata.topNumber,
  101. sortNumber: thisdata.sortNumber,
  102. home: thisdata.home,
  103. contacts: thisdata.contacts,
  104. contactsMobile:thisdata.contactsMobile,
  105. orgName:thisdata.orgName,
  106. endTimes:thisdata.endTimes,
  107. releaseDates:thisdata.releaseDates,
  108. userName:thisdata.userName,
  109. releaseStatus:thisdata.releaseStatus,
  110. });
  111. }
  112. this.state.pagination.current = data.data.pageNo;
  113. this.state.pagination.total = data.data.totalCount;
  114. }
  115. this.setState({
  116. dataSource: theArr,
  117. pagination: this.state.pagination
  118. });
  119. }.bind(this)
  120. }).always(
  121. function() {
  122. this.setState({
  123. loading: false
  124. });
  125. }.bind(this)
  126. );
  127. },
  128. getInitialState() {
  129. return {
  130. loading: false,
  131. flag: true,
  132. timesArr:[],
  133. totalData:{
  134. mark: false,
  135. },
  136. purchaseImg: [],
  137. pagination: {
  138. defaultCurrent: 1,
  139. defaultPageSize: 10,
  140. showQuickJumper: true,
  141. pageSize: 10,
  142. onChange: function(page) {
  143. this.loadData(page);
  144. this.setState({
  145. selectedRowKeys: []
  146. });
  147. }.bind(this),
  148. showTotal: function(total) {
  149. return '共' + total + '条数据';
  150. }
  151. },
  152. columns: [
  153. {
  154. title: '序号',
  155. dataIndex: 'key',
  156. key: 'key'
  157. },
  158. {
  159. title: '标题',
  160. dataIndex: 'title',
  161. key: 'title'
  162. },
  163. {
  164. title: '信息栏目',
  165. dataIndex: 'type',
  166. key: 'type',
  167. render:text=>{
  168. return text === 0?'中标公司':'投标公司'
  169. }
  170. },
  171. {
  172. title: '密级',
  173. dataIndex: 'secretType',
  174. key: 'secretType',
  175. render:(text)=>{
  176. return getSecretType(text);
  177. }
  178. },
  179. {
  180. title: '有限时限',
  181. dataIndex: 'endTimes',
  182. key: 'endTimes',
  183. width: 200,
  184. },
  185. {
  186. title: '发布时间',
  187. dataIndex: 'releaseDates',
  188. key: 'releaseDates',
  189. width: 200,
  190. },
  191. {
  192. title: '发布人',
  193. dataIndex: 'userName',
  194. key: 'userName',
  195. },
  196. {
  197. title: '排序',
  198. dataIndex: 'sortNumber',
  199. key: 'sortNumber'
  200. },
  201. {
  202. title: '发布状态',
  203. dataIndex: 'releaseStatus',
  204. key: 'releaseStatus',
  205. render:text=>{
  206. return text?'已发布':'未发布';
  207. }
  208. },
  209. {
  210. title: '审核状态',
  211. dataIndex: 'auditStatus',
  212. key: 'auditStatus',
  213. render:text=>{
  214. return getBuyAuditType(text);
  215. }
  216. },
  217. {
  218. title: '置顶',
  219. dataIndex: 'topNumber',
  220. key: 'topNumber',
  221. render:(text)=>{
  222. return text?'否':'是';
  223. }
  224. },
  225. {
  226. title: '操作',
  227. dataIndex: 'ads',
  228. key: 'ads',
  229. render:(text,record,index)=>{
  230. return <div>
  231. {<Button type="primary" onClick={(event)=>{
  232. this.stopPropagation(event)
  233. this.tableRowClick(record)
  234. }}>修改</Button>}
  235. {<Popconfirm okText="确定" cancelText="取消" title="是否确认删除?" onConfirm={()=>{
  236. this.delete(record.id)
  237. }}>
  238. <Button type="primary" style={{marginLeft:"10px"}} onClick={(event)=>{
  239. this.stopPropagation(event)
  240. }}>删除</Button>
  241. </Popconfirm>}
  242. </div>
  243. }
  244. },
  245. ],
  246. dataSource: []
  247. };
  248. },
  249. componentWillMount() {
  250. this.loadData()
  251. },
  252. detailes(record) {
  253. this.setState({
  254. loading:true
  255. });
  256. $.ajax({
  257. method: 'get',
  258. dataType: 'json',
  259. crossDomain: false,
  260. url: globalConfig.context + '/api/admin/purchase/details',
  261. data: {
  262. id: record.id,
  263. },
  264. success: function(data) {
  265. let theArr = [];
  266. let thisdata = data.data;
  267. if (!data.data || !data.data.list) {
  268. if (data.error && data.error.length) {
  269. message.warning(data.error[0].message);
  270. }
  271. }
  272. this.setState({
  273. purchaseImg: thisdata.purchaseImg ? splitUrl(thisdata.purchaseImg, ',', globalConfig.avatarHost + '/upload') : [],
  274. })
  275. Object.assign(this.state.totalData,{
  276. content: thisdata.content,
  277. },this.state.RowData)
  278. }.bind(this)
  279. }).always(
  280. function() {
  281. this.setState({
  282. loading: false
  283. });
  284. }.bind(this)
  285. );
  286. },
  287. stopPropagation(e){
  288. e.stopPropagation();
  289. e.nativeEvent.stopImmediatePropagation();
  290. },
  291. //项目列表整行点击
  292. tableRowClick(record, index) {
  293. this.state.RowData = record;
  294. this.setState({
  295. editvisible: true,
  296. });
  297. this.detailes(record);
  298. },
  299. edithandleCancel(e) {
  300. this.setState({
  301. editvisible: false
  302. },()=>{
  303. this.addReset()
  304. });
  305. this.loadData()
  306. },
  307. search() {
  308. this.loadData();
  309. },
  310. add(){
  311. this.setState({
  312. editvisible: true,
  313. flag: false,
  314. });
  315. },
  316. addNew(){
  317. let theorgCodeUrl = [];
  318. if (this.state.purchaseImg.length) {
  319. let picArr = [];
  320. this.state.purchaseImg.map(function (item) {
  321. if ( item.response && item.response.data && item.response.data.length ){
  322. picArr.push(item.response.data);
  323. }
  324. });
  325. theorgCodeUrl = picArr.join(",");
  326. };
  327. this.setState({
  328. loading:true
  329. });
  330. if(theorgCodeUrl.length){
  331. this.change("purchaseImg",theorgCodeUrl)
  332. }else{
  333. this.change("purchaseImg",[])
  334. }
  335. $.ajax({
  336. method: 'post',
  337. dataType: 'json',
  338. crossDomain: false,
  339. url: (this.state.flag?'/api/admin/purchase/updateAudit':'/api/admin/purchase/apply'),
  340. data: this.state.totalData,
  341. }).done(function(data) {
  342. this.setState({
  343. loading: false
  344. });
  345. if(!data.error.length) {
  346. message.success('保存成功!');
  347. this.setState({
  348. editvisible:false,
  349. flag:true
  350. })
  351. this.addReset()
  352. this.loadData()
  353. } else {
  354. message.warning(data.error[0].message);
  355. }
  356. }.bind(this));
  357. },
  358. saveNew(){
  359. this.change("auditStatus",2,()=>{
  360. this.addNew()
  361. })
  362. },
  363. issueNew(){
  364. this.change("auditStatus",2)
  365. this.change("releaseStatus",1,()=>{
  366. this.addNew()
  367. })
  368. },
  369. reject(){
  370. this.change("home",undefined)
  371. this.change("auditStatus",3,()=>{
  372. this.addNew()
  373. })
  374. },
  375. delete(id){
  376. this.setState({
  377. loading:true
  378. });
  379. $.ajax({
  380. method: 'post',
  381. dataType: 'json',
  382. crossDomain: false,
  383. url: "/api/admin/purchase/delete",
  384. data: {
  385. id: id,
  386. },
  387. }).done(function(data) {
  388. this.setState({
  389. loading: false
  390. });
  391. if(!data.error.length) {
  392. message.success('删除成功!');
  393. this.loadData()
  394. } else {
  395. message.warning(data.error[0].message);
  396. }
  397. }.bind(this));
  398. },
  399. cancelAdd(){
  400. this.setState({
  401. editvisible: false,
  402. },()=>{
  403. this.setState({
  404. flag:true
  405. })
  406. this.addReset()
  407. });
  408. this.loadData()
  409. },
  410. //新增框的清零
  411. addReset(){
  412. this.setState({
  413. totalData:{},
  414. purchaseImg:[],
  415. })
  416. },
  417. //搜索部分的清零
  418. reset() {
  419. this.setState({
  420. auditStatusSearch: undefined,
  421. typeSearch: undefined,
  422. secretTypeSearch: undefined,
  423. titleSearch: undefined,
  424. })
  425. this.loadData();
  426. },
  427. getOrgCodeUrl(e) {
  428. this.setState({ purchaseImg: e });
  429. },
  430. change(key, e, f){
  431. if(f === undefined ){
  432. this.state.totalData[key] = e
  433. this.setState({
  434. totalData:this.state.totalData
  435. })
  436. }else if(typeof(f) === "function"){
  437. this.state.totalData[key] = e
  438. this.setState({
  439. totalData:this.state.totalData
  440. },f)
  441. }
  442. },
  443. render() {
  444. const FormItem = Form.Item;
  445. const rowSelection = {
  446. selectedRowKeys: this.state.selectedRowKeys,
  447. onChange: (selectedRowKeys, selectedRows) => {
  448. this.setState({
  449. selectedRows: selectedRows.slice(-1),
  450. selectedRowKeys: selectedRowKeys.slice(-1)
  451. });
  452. }
  453. };
  454. let data = this.state.totalData;
  455. const { TextArea } = Input;//文本域
  456. const { TabPane } = Tabs;//标签页
  457. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;//日期输入框
  458. return (
  459. <div className="user-content">
  460. <div className="content-title">
  461. <span>采购审核列表</span>
  462. <div className="user-search">
  463. <Input
  464. placeholder="企业名称"
  465. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  466. value={this.state.nameSearch}
  467. onChange={(e) => {
  468. this.setState({ nameSearch: e.target.value });
  469. }}
  470. />
  471. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  472. 搜索
  473. </Button>
  474. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  475. 重置
  476. </Button>
  477. {/*<Button type="primary" onClick={this.add} style={{ marginLeft: '100px'}}>
  478. 新增采购审核
  479. </Button>*/}
  480. </div>
  481. <div className="patent-table">
  482. <Spin spinning={this.state.loading}>
  483. <Table
  484. columns={this.state.columns}
  485. dataSource={this.state.dataSource}
  486. pagination={this.state.pagination}
  487. onRowClick={this.tableRowClick}
  488. />
  489. </Spin>
  490. </div>
  491. </div>
  492. <div className="patent-desc">
  493. <Modal
  494. className="customeDetails"
  495. title={this.state.flag?'采购审核详情':'新增采购审核'}
  496. width="500px"
  497. visible={this.state.editvisible}
  498. onOk={this.edithandleCancel}
  499. onCancel={this.state.flag?this.edithandleCancel:this.cancelAdd}
  500. footer=""
  501. >
  502. <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
  503. <Spin spinning={this.state.loading}>
  504. <div className="clearfix">
  505. <FormItem
  506. className="half-item"
  507. labelCol={{ span: 8 }}
  508. wrapperCol={{ span: 12 }}
  509. label="是否首页"
  510. >
  511. <Radio.Group onChange={(e)=>{
  512. this.change('home',e.target.value)
  513. }} value={data.home}>
  514. <Radio value={0}>是</Radio>
  515. <Radio value={1}>否</Radio>
  516. </Radio.Group>
  517. </FormItem>
  518. </div>
  519. <div className="clearfix" style={{marginTop:'40px'}}>
  520. {/*<Button type="primary" size="large" onClick={this.addNew} style={{float:'right',marginRight:'80px',marginTop:'20px'}}>保存</Button>
  521. <Button type="primary" size="large" onClick={this.issueNew} style={{float:'right',marginRight:'20px',marginTop:'20px'}}>保存并发布</Button>*/}
  522. <Button type="primary" size="large" style={{float:"left",marginRight:'40px',marginTop:'20px'}} onClick={this.saveNew}>审核通过</Button>
  523. <Button type="primary" size="large" style={{float:"left",marginRight:'40px',marginTop:'20px'}} onClick={this.issueNew}>审核通过并发布</Button>
  524. <Button type="danger" size="large" style={{float:"left",marginRight:'40px',marginTop:'20px'}} onClick={this.reject}>驳回</Button>
  525. </div>
  526. </Spin>
  527. </Form>
  528. </Modal>
  529. </div>
  530. </div>
  531. );
  532. }
  533. })
  534. );
  535. export default CheckBuy;