businessCategory.jsx 20 KB

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