softwareConfigure.js 11 KB

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