businessCategory.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. import React from 'react';
  2. import ReactDom from 'react-dom';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload,Popconfirm,TimePicker } from 'antd';
  7. import {categoryState} from '../../../dataDic.js';
  8. const BusinessCategory=Form.create()(React.createClass({
  9. loadData(pageNo, apiUrl) {
  10. this.state.data = [];
  11. this.setState({
  12. loading: true
  13. });
  14. $.ajax({
  15. method: "get",
  16. dataType: "json",
  17. crossDomain: false,
  18. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  19. data: {
  20. pageNo: pageNo || 1,
  21. pageSize: this.state.pagination.pageSize,
  22. },
  23. success: function (data) {
  24. let theArr = [];
  25. if (!data.data || !data.data.list) {
  26. if (data.error && data.error.length) {
  27. message.warning(data.error[0].message);
  28. };
  29. } else {
  30. for (let i = 0; i < data.data.list.length; i++) {
  31. let thisdata = data.data.list[i];
  32. theArr.push({
  33. key: i,
  34. id: thisdata.id,
  35. serialNumber: thisdata.serialNumber,
  36. });
  37. };
  38. this.state.pagination.current = data.data.pageNo;
  39. this.state.pagination.total = data.data.totalCount;
  40. };
  41. this.setState({
  42. dataSource: theArr,
  43. pagination: this.state.pagination
  44. });
  45. }.bind(this),
  46. }).always(function () {
  47. this.setState({
  48. loading: false
  49. });
  50. }.bind(this));
  51. },
  52. getInitialState() {
  53. return {
  54. searchMore: true,
  55. selectedRowKeys: [],
  56. selectedRows: [],
  57. loading: false,
  58. pagination: {
  59. defaultCurrent: 1,
  60. defaultPageSize: 10,
  61. showQuickJumper: true,
  62. pageSize: 10,
  63. onChange: function (page) {
  64. this.loadData(page);
  65. }.bind(this),
  66. showTotal: function (total) {
  67. return '共' + total + '条数据';
  68. }
  69. },
  70. columns: [
  71. {
  72. title: '品类编号',
  73. dataIndex: 'serialNumber',
  74. key: 'serialNumber',
  75. }, {
  76. title: '品类名称',
  77. dataIndex: 'name',
  78. key: 'name',
  79. }, {
  80. title: '品类层级',
  81. dataIndex: 'category',
  82. key: 'category',
  83. render: text => { return getAchievementCategory(text); }
  84. }, {
  85. title: '上级品类',
  86. dataIndex: 'keyword',
  87. key: 'keyword',
  88. },{
  89. title: '品类状态',
  90. dataIndex: 'auditStatus',
  91. key: 'auditStatus',
  92. render: text => { return getTechAuditStatus(text) }
  93. }
  94. ],
  95. dataSource: [],
  96. };
  97. },
  98. componentWillMount() {
  99. this.loadData();
  100. },
  101. tableRowClick(record, index) {
  102. this.state.RowData = record;
  103. this.setState({
  104. showDesc: true
  105. });
  106. },
  107. delectRow() {
  108. let deletedIds = [];
  109. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  110. let rowItem = this.state.selectedRows[idx];
  111. if (rowItem.id) {
  112. deletedIds.push(rowItem.id)
  113. };
  114. };
  115. this.setState({
  116. selectedRowKeys: [],
  117. loading: deletedIds.length > 0
  118. });
  119. $.ajax({
  120. method: "POST",
  121. dataType: "json",
  122. crossDomain: false,
  123. url: globalConfig.context + "/api/admin/achievement/delete",
  124. data: {
  125. ids: deletedIds
  126. }
  127. }).done(function (data) {
  128. if (!data.error.length) {
  129. message.success('删除成功!');
  130. this.setState({
  131. loading: false,
  132. });
  133. } else {
  134. message.warning(data.error[0].message);
  135. };
  136. this.loadData();
  137. }.bind(this));
  138. },
  139. addClick() {
  140. this.state.RowData = {};
  141. this.setState({
  142. visible: true
  143. });
  144. },
  145. editClick() {
  146. this.state.RowData = {};
  147. this.setState({
  148. editvisible: true
  149. });
  150. },
  151. handleCancel() {
  152. this.setState({ visible: false })
  153. },
  154. edithandleCancel() {
  155. this.setState({ editvisible: false })
  156. },
  157. search() {
  158. this.loadData();
  159. },
  160. reset() {
  161. this.state.serialNumber = undefined;
  162. this.state.name = undefined;
  163. this.state.keyword = undefined;
  164. this.state.category = undefined;
  165. this.state.ownerType = undefined;
  166. this.state.releaseStatus = undefined;
  167. this.state.auditStatus = undefined;
  168. this.state.searchName = undefined;
  169. this.state.releaseDate = [];
  170. this.state.boutique = '';
  171. this.state.hot='' ;
  172. this.loadData();
  173. },
  174. searchSwitch() {
  175. this.setState({
  176. searchMore: !this.state.searchMore
  177. });
  178. },
  179. render() {
  180. const FormItem = Form.Item
  181. const rowSelection = {
  182. selectedRowKeys: this.state.selectedRowKeys,
  183. onChange: (selectedRowKeys, selectedRows) => {
  184. this.setState({
  185. selectedRows: selectedRows.slice(-1),
  186. selectedRowKeys: selectedRowKeys.slice(-1)
  187. });
  188. }
  189. };
  190. const formItemLayout = {
  191. labelCol: { span: 8 },
  192. wrapperCol: { span: 14 },
  193. };
  194. const { getFieldDecorator } = this.props.form;
  195. const hasSelected = this.state.selectedRowKeys.length > 0;
  196. const { RangePicker } = DatePicker;
  197. return (
  198. <div className="user-content" >
  199. <div className="content-title">
  200. <div className="user-search">
  201. <Input placeholder="业务品类名称" style={{width:'150px',marginRight:'10px',marginBottom:'10px'}}
  202. value={this.state.serialNumber}
  203. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  204. <Input placeholder="上级业务品类" style={{width:'150px',marginRight:'10px',marginBottom:'10px'}}
  205. value={this.state.serialNumber}
  206. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  207. <Button type="primary" onClick={this.search} style={{marginRight:'10px'}}>搜索</Button>
  208. <Button onClick={this.reset} style={{marginRight:'10px'}}>重置</Button>
  209. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  210. disabled={!hasSelected}
  211. onClick={this.delectRow}>删除<Icon type="minus" />
  212. </Button>
  213. <Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  214. <Button style={{ background: "#ea0862", border: "none", color: "#fff",marginRight:'10px' ,marginLeft:'10px'}}
  215. disabled={!hasSelected}
  216. >删除<Icon type="minus" />
  217. </Button>
  218. </Popconfirm>
  219. <Popconfirm title="是否停用?" onConfirm={this.delectRow} okText="是" cancelText="否">
  220. <Button style={{ background: "#ea0862", border: "none", color: "#fff",marginRight:'10px' ,marginLeft:'10px'}}
  221. disabled={!hasSelected}
  222. >停用<Icon type="minus" />
  223. </Button>
  224. </Popconfirm>
  225. <span style={{marginRight:'20px'}}>更多搜索 <Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  226. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {display: 'inline-block'}}>
  227. <Select placeholder="品类层级"
  228. style={{ width:'150px',marginRight:'10px' }}
  229. value={this.state.shareTypeSearch}
  230. onChange={(e) => { this.setState({ shareTypeSearch: e }) }}>
  231. <Select.Option value="0" >一级</Select.Option>
  232. <Select.Option value="1" >二级</Select.Option>
  233. <Select.Option value="2" >三级</Select.Option>
  234. <Select.Option value="3" >四级</Select.Option>
  235. <Select.Option value="4" >五级</Select.Option>
  236. <Select.Option value="5" >六级</Select.Option>
  237. </Select>
  238. <Select placeholder="品类状态"
  239. style={{width:'150px',marginRight:'50px'}}
  240. value={this.state.shareTypeSearch}
  241. onChange={(e) => { this.setState({ shareTypeSearch: e }) }}>
  242. <Select.Option value="0" >正常</Select.Option>
  243. <Select.Option value="1" >停用</Select.Option>
  244. </Select>
  245. </div>
  246. <Button type="primary" className="addButton" onClick={this.addClick} style={{float:'right',marginRight:'200px'}}>新增客户<Icon type="plus" /></Button>
  247. <Button type="primary" className="addButton" onClick={this.editClick}>编辑客户<Icon type="plus" /></Button>
  248. </div>
  249. <div className="patent-table">
  250. <Spin spinning={this.state.loading}>
  251. <Table columns={this.state.columns}
  252. dataSource={this.state.dataSource}
  253. rowSelection={rowSelection}
  254. pagination={this.state.pagination}
  255. onRowClick={this.tableRowClick} />
  256. </Spin>
  257. </div>
  258. <div className="patent-desc">
  259. <Modal maskClosable={false} visible={this.state.visible}
  260. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  261. width='400px'
  262. title='新增品类'
  263. footer=''
  264. className="admin-desc-content">
  265. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  266. <Spin spinning={this.state.loading}>
  267. <div className="clearfix">
  268. <FormItem className="half-item"
  269. labelCol={{ span: 7 }}
  270. wrapperCol={{ span: 12 }}
  271. label="品类名称" >
  272. {getFieldDecorator('name', {
  273. rules: [{ required: true, message: '此项为必填项!' }],
  274. initialValue: this.state.name
  275. })(
  276. <Input placeholder="品类名称" />
  277. )}
  278. </FormItem>
  279. </div>
  280. <div className="clearfix">
  281. <FormItem className="half-item"
  282. labelCol={{ span: 7 }}
  283. wrapperCol={{ span: 12}}
  284. label="上级品类" >
  285. {getFieldDecorator('content', {
  286. // rules: [{ required: true, message: '此项为必填项!' }],
  287. initialValue: this.state.content
  288. })(
  289. <Input placeholder="上级品类" />
  290. )}
  291. </FormItem>
  292. </div>
  293. <div className="clearfix">
  294. <FormItem
  295. labelCol={{ span: 7 }}
  296. wrapperCol={{ span: 12 }}
  297. label="上级品类"
  298. >
  299. {getFieldDecorator('societyTagt', {
  300. rules: [{ required: true, message: '此项为必填项!' }],
  301. initialValue: this.state.societyTagt
  302. })(
  303. <Select placeholder="上级品类"
  304. value={this.state.lastName}
  305. onChange={this.hundleName}>
  306. {this.state.orderStatusOption}
  307. </Select>
  308. )}
  309. </FormItem>
  310. </div>
  311. <FormItem wrapperCol={{ span: 12, offset: 7 }}>
  312. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  313. <Button className="set-submit" type="ghost" onClick={this.handleCancel} style={{marginLeft:'50px'}}>取消</Button>
  314. </FormItem>
  315. </Spin>
  316. </Form >
  317. </Modal>
  318. </div>
  319. <div className="patent-desc">
  320. <Modal maskClosable={false} visible={this.state.editvisible}
  321. onOk={this.checkPatentProcess} onCancel={this.edithandleCancel}
  322. width='600px'
  323. title='编辑品类'
  324. footer=''
  325. className="admin-desc-content">
  326. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  327. <Spin spinning={this.state.loading}>
  328. <div className="clearfix">
  329. <FormItem className="half-item"
  330. labelCol={{ span: 7 }}
  331. wrapperCol={{ span: 12 }}
  332. label="品类名称" >
  333. {getFieldDecorator('name', {
  334. rules: [{ required: true, message: '此项为必填项!' }],
  335. initialValue: this.state.name
  336. })(
  337. <Input placeholder="品类名称" />
  338. )}
  339. </FormItem>
  340. </div>
  341. <div className="clearfix">
  342. <FormItem className="half-item"
  343. labelCol={{ span: 7 }}
  344. wrapperCol={{ span: 12 }}
  345. label="品类状态"
  346. >
  347. {getFieldDecorator('societyTagt', {
  348. rules: [{ required: true, message: '此项为必填项!' }],
  349. initialValue: this.state.societyTagt
  350. })(
  351. <Select placeholder="品类状态">
  352. {
  353. categoryState.map(function (item) {
  354. return <Select.Option key={item.value} >{item.key}</Select.Option>
  355. })
  356. }
  357. </Select>
  358. )}
  359. </FormItem>
  360. </div>
  361. <div className="clearfix">
  362. <FormItem
  363. labelCol={{ span: 7 }}
  364. wrapperCol={{ span: 12 }}
  365. label="上级品类"
  366. >
  367. {getFieldDecorator('societyTagt', {
  368. rules: [{ required: true, message: '此项为必填项!' }],
  369. initialValue: this.state.societyTagt
  370. })(
  371. <Select placeholder="上级品类"
  372. value={this.state.lastName}
  373. onChange={this.hundleName}>
  374. {this.state.orderStatusOption}
  375. </Select>
  376. )}
  377. </FormItem>
  378. </div>
  379. <div className="clearfix">
  380. <FormItem className="half-item"
  381. labelCol={{ span: 7 }}
  382. wrapperCol={{ span: 12 }}
  383. label="品类层级"
  384. >
  385. <span>{}</span>
  386. </FormItem>
  387. </div>
  388. <div className="clearfix">
  389. <FormItem className="half-item"
  390. labelCol={{ span: 7 }}
  391. wrapperCol={{ span: 12 }}
  392. label="品类编号"
  393. >
  394. <span>{}</span>
  395. </FormItem>
  396. </div>
  397. <div className="clearfix" >
  398. <FormItem className="half-item"
  399. labelCol={{ span: 7 }}
  400. wrapperCol={{ span: 12 }}
  401. label="创建人"
  402. >
  403. <span>{}</span>
  404. </FormItem>
  405. </div>
  406. <div className="clearfix">
  407. <FormItem className="half-item"
  408. labelCol={{ span: 7 }}
  409. wrapperCol={{ span: 12 }}
  410. label="创建时间"
  411. >
  412. <span>{}</span>
  413. </FormItem>
  414. </div>
  415. <div className="clearfix">
  416. <FormItem className="half-item"
  417. labelCol={{ span: 7 }}
  418. wrapperCol={{ span: 12 }}
  419. label="更新时间" >
  420. <DatePicker placeholder="更新日期" value={moment(this.state.createYear,'YYYY-MM-DD')} onChange={(time) => {this.setState({createYear: time});}}/>
  421. <TimePicker placeholder="更新时间" value={moment(this.state.creatMent, 'HH:mm:ss')} onChange={(time) => { this.setState({creatMent: time}); }}/>
  422. </FormItem>
  423. </div>
  424. <FormItem wrapperCol={{ span: 12, offset: 7 }}>
  425. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  426. <Button className="set-submit" type="ghost" onClick={this.edithandleCancel} style={{marginLeft:'100px'}}>取消</Button>
  427. </FormItem>
  428. </Spin>
  429. </Form >
  430. </Modal>
  431. </div>
  432. </div>
  433. </div>
  434. );
  435. }
  436. }));
  437. export default BusinessCategory;