memberPowerList.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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,Checkbox,Row,InputNumber,Radio,Col,Tabs} from 'antd';
  6. import {areaSelect, getProvince} from '@/NewDicProvinceList';//省市区
  7. import { getGameState, splitUrl, getprovince, getStatuslist, getLvl,beforeUploadFile} from '@/tools.js';
  8. //主体
  9. const MemberPowerList = Form.create()(
  10. React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true,
  15. page: pageNo
  16. });
  17. $.ajax({
  18. method: 'get',
  19. dataType: 'json',
  20. crossDomain: false,
  21. url: globalConfig.context + '/api/admin/listLvltype',
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: this.state.pagination.pageSize,
  25. },
  26. success: function(data) {
  27. let theArr = [];
  28. if (!data.data || !data.data) {
  29. if (data.error && data.error.length) {
  30. message.warning(data.error[0].message);
  31. }
  32. } else {
  33. for (let i = 0; i < data.data.length; i++) {
  34. let thisdata = data.data[i];
  35. theArr.push({
  36. key: i,
  37. id: thisdata.id,
  38. typeName: thisdata.typeName,
  39. lvlNumber: thisdata.lvlNumber,
  40. viewCg: thisdata.viewCg,
  41. viewQy: thisdata.viewQy,
  42. viewJmc: thisdata.viewJmc,
  43. viewMjc: thisdata.viewMjc,
  44. viewCyc: thisdata.viewCyc,
  45. viewDyc:thisdata.viewDyc,
  46. viewQyc:thisdata.viewQyc,
  47. });
  48. }
  49. this.state.pagination.current = data.data.pageNo;
  50. this.state.pagination.total = data.data.totalCount;
  51. }
  52. this.setState({
  53. dataSource: theArr,
  54. pagination: this.state.pagination
  55. });
  56. }.bind(this)
  57. }).always(
  58. function() {
  59. this.setState({
  60. loading: false
  61. });
  62. }.bind(this)
  63. );
  64. },
  65. getInitialState() {
  66. return {
  67. loading: false,
  68. flag: true,
  69. totalData:{
  70. mark: false,
  71. },
  72. pagination: {
  73. defaultCurrent: 1,
  74. defaultPageSize: 10,
  75. showQuickJumper: true,
  76. pageSize: 10,
  77. onChange: function(page) {
  78. this.loadData(page);
  79. this.setState({
  80. selectedRowKeys: []
  81. });
  82. }.bind(this),
  83. showTotal: function(total) {
  84. return '共' + total + '条数据';
  85. }
  86. },
  87. columns: [
  88. {
  89. title: '序号',
  90. dataIndex: 'lvlNumber',
  91. key: 'lvlNumber'
  92. },
  93. {
  94. title: '名称',
  95. dataIndex: 'typeName',
  96. key: 'typeName'
  97. },
  98. {
  99. title: '操作',
  100. dataIndex: 'a',
  101. key: 'a',
  102. render:(text,record,index)=>{
  103. return <Button type="primary" onClick={()=>{
  104. this.tableRowClick(record)
  105. }}>修改</Button>
  106. }
  107. },
  108. ],
  109. dataSource: []
  110. };
  111. },
  112. componentWillMount() {
  113. this.loadData()
  114. },
  115. detailes(record) {
  116. this.setState({
  117. loading:true
  118. });
  119. $.ajax({
  120. method: 'get',
  121. dataType: 'json',
  122. crossDomain: false,
  123. url: globalConfig.context + '/api/admin/detailsLvltype',
  124. data: {
  125. id: record.id,
  126. },
  127. success: function(data) {
  128. let theArr = [];
  129. let thisdata = data.data;
  130. if (!data.data || !data.data.list) {
  131. if (data.error && data.error.length) {
  132. message.warning(data.error[0].message);
  133. }
  134. }
  135. Object.assign(this.state.totalData,{},this.state.RowData)
  136. console.log(this.state.totalData)
  137. }.bind(this)
  138. }).always(
  139. function() {
  140. this.setState({
  141. loading: false
  142. });
  143. }.bind(this)
  144. );
  145. },
  146. stopPropagation(e){
  147. e.stopPropagation();
  148. e.nativeEvent.stopImmediatePropagation();
  149. },
  150. //项目列表整行点击
  151. tableRowClick(record, index) {
  152. this.state.RowData = record;
  153. this.setState({
  154. editvisible: true,
  155. });
  156. this.detailes(record);
  157. },
  158. edithandleCancel(e) {
  159. this.setState({
  160. editvisible: false
  161. },()=>{
  162. this.addReset()
  163. });
  164. this.loadData()
  165. },
  166. search() {
  167. this.loadData();
  168. },
  169. add(){
  170. this.setState({
  171. editvisible: true,
  172. flag: false,
  173. });
  174. },
  175. addNew(){
  176. this.setState({
  177. loading:true
  178. });
  179. $.ajax({
  180. method: 'post',
  181. dataType: 'json',
  182. crossDomain: false,
  183. url: globalConfig.context + (this.state.flag?'/api/admin/updateLvltype':'/api/admin/addLvltype'),
  184. data: this.state.totalData,
  185. }).done(function(data) {
  186. this.setState({
  187. loading: false
  188. });
  189. if(!data.error.length) {
  190. message.success('保存成功!');
  191. this.cancelAdd()
  192. } else {
  193. message.warning(data.error[0].message);
  194. }
  195. }.bind(this));
  196. },
  197. saveNew(){
  198. this.addNew()
  199. },
  200. issueNew(){
  201. this.addNew()
  202. },
  203. delete(id){
  204. this.setState({
  205. loading:true
  206. });
  207. $.ajax({
  208. method: 'post',
  209. dataType: 'json',
  210. crossDomain: false,
  211. url: "api/admin/deleteLvltype",
  212. data: {
  213. id: id,
  214. },
  215. }).done(function(data) {
  216. this.setState({
  217. loading: false
  218. });
  219. if(!data.error.length) {
  220. message.success('删除成功!');
  221. this.loadData()
  222. } else {
  223. message.warning(data.error[0].message);
  224. }
  225. }.bind(this));
  226. },
  227. cancelAdd(){
  228. this.setState({
  229. editvisible: false,
  230. },()=>{
  231. this.setState({
  232. flag:true
  233. })
  234. this.addReset()
  235. });
  236. this.loadData()
  237. },
  238. //新增框的清零
  239. addReset(){
  240. this.setState({
  241. totalData:{
  242. mark:false,
  243. },
  244. },()=>{
  245. console.log(this.state.totalData)
  246. })
  247. },
  248. //搜索部分的清零
  249. reset() {
  250. this.loadData();
  251. },
  252. change(key, e, f){
  253. if(f === undefined ){
  254. this.state.totalData[key] = e
  255. this.setState({
  256. totalData:this.state.totalData
  257. })
  258. }else if(typeof(f) === "function"){
  259. this.state.totalData[key] = e
  260. this.setState({
  261. totalData:this.state.totalData
  262. },f)
  263. }
  264. },
  265. render() {
  266. const FormItem = Form.Item;
  267. const rowSelection = {
  268. selectedRowKeys: this.state.selectedRowKeys,
  269. onChange: (selectedRowKeys, selectedRows) => {
  270. this.setState({
  271. selectedRows: selectedRows.slice(-1),
  272. selectedRowKeys: selectedRowKeys.slice(-1)
  273. });
  274. }
  275. };
  276. let data = this.state.totalData;
  277. const { TextArea } = Input;//文本域
  278. const { TabPane } = Tabs;//标签页
  279. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;//日期输入框
  280. return (
  281. <div className="user-content">
  282. <div className="content-title">
  283. <span>会员权限列表</span>
  284. <div className="user-search">
  285. {/*<Input
  286. placeholder="企业名称"
  287. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  288. value={this.state.nameSearch}
  289. onChange={(e) => {
  290. this.setState({ nameSearch: e.target.value });
  291. }}
  292. />
  293. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  294. 搜索
  295. </Button>
  296. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  297. 重置
  298. </Button>*/}
  299. <Button type="primary" onClick={this.add}>
  300. 新增会员权限
  301. </Button>
  302. </div>
  303. <div className="patent-table">
  304. <Spin spinning={this.state.loading}>
  305. <Table
  306. columns={this.state.columns}
  307. dataSource={this.state.dataSource}
  308. pagination={this.state.pagination}
  309. onRowClick={this.tableRowClick}
  310. />
  311. </Spin>
  312. </div>
  313. </div>
  314. <div className="patent-desc">
  315. <Modal
  316. className="customeDetails"
  317. title={this.state.flag?'会员权限详情':'新增会员权限'}
  318. width="1000px"
  319. visible={this.state.editvisible}
  320. onOk={this.edithandleCancel}
  321. onCancel={this.state.flag?this.edithandleCancel:this.cancelAdd}
  322. footer=""
  323. >
  324. <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
  325. <Spin spinning={this.state.loading}>
  326. <div className="clearfix">
  327. <Row style={{marginTop:"20px"}}>
  328. <Col span={8}>
  329. <Checkbox checked={data.viewCg} onChange={(e)=>{
  330. if (e.target.checked) {
  331. this.change("viewCg",1)
  332. }else{
  333. this.change("viewCg",0)
  334. }
  335. }}>查看采购联系人</Checkbox>
  336. </Col>
  337. <Col span={8}>
  338. <Checkbox checked={data.viewQy} onChange={(e)=>{
  339. if (e.target.checked) {
  340. this.change("viewQy",1)
  341. }else{
  342. this.change("viewQy",0)
  343. }
  344. }}>查看军工企业信息</Checkbox>
  345. </Col>
  346. <Col span={8}>
  347. <Checkbox checked={data.viewQyc} onChange={(e)=>{
  348. if (e.target.checked) {
  349. this.change("viewQyc",1)
  350. }else{
  351. this.change("viewQyc",0)
  352. }
  353. }}>查看军工企业联系信息</Checkbox>
  354. </Col>
  355. </Row>
  356. <Row style={{marginTop:"20px"}}>
  357. <Col span={8}>
  358. <Checkbox checked={data.viewJmc} onChange={(e)=>{
  359. if (e.target.checked) {
  360. this.change("viewJmc",1)
  361. }else{
  362. this.change("viewJmc",0)
  363. }
  364. }}>军转民联系信息</Checkbox>
  365. </Col>
  366. <Col span={8}>
  367. <Checkbox checked={data.viewMjc} onChange={(e)=>{
  368. if (e.target.checked) {
  369. this.change("viewMjc",1)
  370. }else{
  371. this.change("viewMjc",0)
  372. }
  373. }}>民参军联系信息</Checkbox>
  374. </Col>
  375. <Col span={8}>
  376. <Checkbox checked={data.viewCyc} onChange={(e)=>{
  377. if (e.target.checked) {
  378. this.change("viewCyc",1)
  379. }else{
  380. this.change("viewCyc",0)
  381. }
  382. }}>创业军人联系信息</Checkbox>
  383. </Col>
  384. </Row>
  385. <Row style={{marginTop:"20px"}}>
  386. <Col span={8}>
  387. <Checkbox checked={data.viewDyc} onChange={(e)=>{
  388. if (e.target.checked) {
  389. this.change("viewDyc",1)
  390. }else{
  391. this.change("viewDyc",0)
  392. }
  393. }}>待就业军人联系信息</Checkbox>
  394. </Col>
  395. </Row>
  396. </div>
  397. <div className="clearfix" style={{marginTop:'40px'}}>
  398. <FormItem
  399. className="half-item"
  400. labelCol={{ span: 2 }}
  401. wrapperCol={{ span: 12 }}
  402. label="名称"
  403. >
  404. <Input placeholder="请输入名称" value={data.typeName}
  405. onChange={(e)=>{
  406. this.change('typeName',e.target.value)
  407. }} style={{width:'240px'}} />
  408. </FormItem>
  409. <FormItem
  410. className="half-item"
  411. labelCol={{ span: 2 }}
  412. wrapperCol={{ span: 12 }}
  413. label="序号"
  414. >
  415. <Input placeholder="请输入序号" value={data.lvlNumber}
  416. onChange={(e)=>{
  417. this.change('lvlNumber',e.target.value)
  418. }} style={{width:'240px'}} />
  419. </FormItem>
  420. </div>
  421. <div className="clearfix">
  422. <Button type="primary" size="large" onClick={this.saveNew} style={{float:'right',marginRight:'80px',marginTop:'20px'}}>保存</Button>
  423. {/*<Button type="primary" size="large" onClick={this.issueNew} style={{float:'right',marginRight:'20px',marginTop:'20px'}}>保存并发布</Button>*/}
  424. </div>
  425. </Spin>
  426. </Form>
  427. </Modal>
  428. </div>
  429. </div>
  430. );
  431. }
  432. })
  433. );
  434. export default MemberPowerList;