softwareConfigure.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. import React,{Component} from 'react';
  2. import {Button, Input, message, Select, Spin, Table, Tag, Popconfirm} from "antd";
  3. import AddSoftWritingPrice from './addSoftWritingPrice'
  4. import $ from "jquery/src/ajax";
  5. import '../content.less';
  6. class SoftwareConfigure extends Component{
  7. constructor(props) {
  8. super(props);
  9. this.state={
  10. companyName:'', //公司名称
  11. urgent: '', //加急
  12. material: '', //材料
  13. pagination: {
  14. defaultCurrent: 1,
  15. defaultPageSize: 10,
  16. showQuickJumper: true,
  17. pageSize: 10,
  18. onChange: function (page) {
  19. this.loadData(page);
  20. }.bind(this),
  21. showTotal: function (total) {
  22. return '共' + total + '条数据';
  23. }
  24. },
  25. dataSource: [],
  26. columns: [
  27. {
  28. title: '供应商名称',
  29. dataIndex: 'companyName',
  30. key: 'companyName',
  31. },
  32. {
  33. title: '材料',
  34. dataIndex: 'material',
  35. key: 'material',
  36. render: (text) => {
  37. return text === 0 ? '无材料' : '有材料'
  38. }
  39. },
  40. {
  41. title: '加急天数',
  42. dataIndex: 'urgent',
  43. key: 'urgent',
  44. render: (text) => {
  45. switch (text) {
  46. case 0:
  47. return '无加急';
  48. case 1:
  49. return '加急3天';
  50. case 2:
  51. return '加急4天';
  52. case 3:
  53. return '加急5-10天';
  54. case 4:
  55. return '加急11-15天';
  56. case 5:
  57. return '加急16-20天';
  58. case 6:
  59. return '加急21-25天';
  60. case 7:
  61. return '加急26-30天';
  62. }
  63. }
  64. },
  65. {
  66. title: '价格万元/个',
  67. dataIndex: 'unitPrice',
  68. key: 'unitPrice',
  69. },
  70. {
  71. title: '备注',
  72. dataIndex: 'remarks',
  73. key: 'remarks',
  74. },
  75. {
  76. title: '状态',
  77. dataIndex: 'status',
  78. key: 'status',
  79. render: (text) => {
  80. return text === 0 ? <Tag color="#87d068">正常</Tag> :
  81. text === 1 ? <Tag>停用</Tag> : <Tag color="#f50">删除</Tag>
  82. }
  83. },
  84. {
  85. title: '操作',
  86. dataIndex: 'id',
  87. key: 'id',
  88. render: (text) => {
  89. return <div>
  90. <Popconfirm
  91. title="是否删除?"
  92. onConfirm={() => {
  93. this.deleteSoftWritingPrice(text);
  94. }}
  95. okText="删除"
  96. cancelText="不删除"
  97. >
  98. <Button type="danger" onClick={(e) => {
  99. e.stopPropagation()
  100. }}>
  101. 删除
  102. </Button>
  103. </Popconfirm>
  104. </div>
  105. }
  106. },
  107. ],
  108. addSoftVisible: false,
  109. infor: {},
  110. }
  111. this.loadData = this.loadData.bind(this);
  112. this.tableRowClick = this.tableRowClick.bind(this);
  113. this.reset = this.reset.bind(this);
  114. }
  115. componentDidMount() {
  116. this.loadData();
  117. }
  118. //搜索功能和初始列表加载
  119. loadData() {
  120. this.setState({
  121. loading: true,
  122. });
  123. $.ajax({
  124. method: "get",
  125. dataType: "json",
  126. crossDomain: false,
  127. url: globalConfig.context + '/api/admin/company/listSoftWritingPrice',
  128. data: {
  129. companyName:this.state.companyName, //公司名称
  130. urgent: this.state.urgent, //加急
  131. material: this.state.material, //材料
  132. },
  133. success: function (data) {
  134. let theArr = [];
  135. if (!data.data || !data.data.list) {
  136. if (data.error && data.error.length) {
  137. message.warning(data.error[0].message);
  138. };
  139. } else {
  140. this.state.pagination.current = data.data.pageNo;
  141. this.state.pagination.total = data.data.totalCount;
  142. data.data.list.map((v,i)=>{v.key = i})
  143. this.setState({
  144. dataSource: data.data.list,
  145. pagination: this.state.pagination
  146. });
  147. };
  148. }.bind(this),
  149. }).always(function () {
  150. this.setState({
  151. loading: false
  152. });
  153. }.bind(this));
  154. }
  155. tableRowClick(infor) {
  156. this.setState({
  157. addSoftVisible : true,
  158. infor: infor
  159. })
  160. }
  161. reset(){
  162. this.setState({
  163. companyName:'', //公司名称
  164. urgent: '', //加急
  165. material: '', //材料
  166. },()=>{
  167. this.loadData();
  168. })
  169. }
  170. //删除
  171. deleteSoftWritingPrice(id) {
  172. this.setState({
  173. loading: true
  174. });
  175. $.ajax({
  176. method: "post",
  177. dataType: "json",
  178. crossDomain: false,
  179. url:globalConfig.context + '/api/admin/company/deleteSoftWritingPrice',
  180. data:{
  181. id: id
  182. },
  183. }).done(function (data) {
  184. this.setState({
  185. loading: false
  186. });
  187. if (!data.error.length) {
  188. message.success('删除成功!');
  189. this.loadData();
  190. } else {
  191. message.warning(data.error[0].message);
  192. }
  193. }.bind(this));
  194. }
  195. render() {
  196. return(
  197. <div className="user-content" >
  198. <div className="content-title">
  199. <div className="user-search" style={{display:'flex',flexFlow:'row'}}>
  200. <Input placeholder="公司名称" style={{width:'150px',marginRight:'10px',marginBottom:'10px',marginLeft:10}}
  201. value={this.state.companyName}
  202. onChange={(e) => { this.setState({ companyName: e.target.value }); }} />
  203. <div style={{display:'flex',flexFlow:'row nowrap'}}>
  204. <div style={{marginLeft:10,marginRight:10}}>材料:</div>
  205. <Select style={{ width:'200px',marginRight:'10px' }}
  206. value={this.state.material}
  207. onChange={(e) => {this.setState({ material: e }) }}>
  208. <Select.Option value={0}>无</Select.Option>
  209. <Select.Option value={1}>有</Select.Option>
  210. </Select>
  211. </div>
  212. <div style={{display:'flex',flexFlow:'row nowrap'}}>
  213. <div style={{marginLeft:10,marginRight:10}}>加急天数:</div>
  214. <Select placeholder="加急天数"
  215. style={{ width:'200px',marginRight:'10px' }}
  216. value={this.state.urgent}
  217. onChange={(e) => { this.setState({ urgent: e }) }}>
  218. <Select.Option value={0}>无加急</Select.Option>
  219. <Select.Option value={1}>加急3天</Select.Option>
  220. <Select.Option value={2}>加急4天</Select.Option>
  221. <Select.Option value={3}>加急5-10天</Select.Option>
  222. <Select.Option value={4}>加急11-15天</Select.Option>
  223. <Select.Option value={5}>加急16-20天</Select.Option>
  224. <Select.Option value={6}>加急21-25天</Select.Option>
  225. <Select.Option value={7}>加急26-30天</Select.Option>
  226. </Select>
  227. </div>
  228. <Button type="primary" onClick={this.loadData} style={{marginRight:'10px'}}>搜索</Button>
  229. <Button onClick={this.reset} style={{marginRight:'10px'}}>重置</Button>
  230. <span style={{marginLeft: 'auto'}}>
  231. <Button type="primary" size={'middle'} onClick={()=>{
  232. this.setState({
  233. addSoftVisible : true
  234. })
  235. }}>
  236. 增加
  237. </Button>
  238. </span>
  239. </div>
  240. <div className="patent-table">
  241. <Spin spinning={this.state.loading}>
  242. <Table columns={this.state.columns}
  243. dataSource={this.state.dataSource}
  244. pagination={this.state.pagination}
  245. onRowClick={this.tableRowClick}/>
  246. </Spin>
  247. </div>
  248. </div>
  249. {this.state.addSoftVisible ? <AddSoftWritingPrice
  250. infor={this.state.infor}
  251. visible={this.state.addSoftVisible}
  252. onCancel={()=>{
  253. this.setState({
  254. addSoftVisible : false,
  255. infor: {},
  256. })
  257. }}
  258. successFn={()=>{
  259. this.loadData();
  260. this.setState({
  261. addSoftVisible : false,
  262. infor: {}
  263. })
  264. }}/> : <div/>}
  265. </div>
  266. )
  267. }
  268. }
  269. export default SoftwareConfigure