softwareConfigure.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. import React,{Component} from 'react';
  2. import {Button, Input, message, Select, Spin, Table, Tag, Popconfirm, Tabs} from "antd";
  3. import AddSoftWritingPrice from './addSoftWritingPrice'
  4. import $ from "jquery/src/ajax";
  5. import '../content.less';
  6. import {ChooseList} from "../../order/orderNew/chooseList";
  7. const TabPane = Tabs.TabPane;
  8. class SoftwareConfigure extends Component{
  9. constructor(props) {
  10. super(props);
  11. this.state={
  12. companyName:'', //公司名称
  13. urgent: undefined, //加急
  14. material: undefined, //材料
  15. pagination: {
  16. defaultCurrent: 1,
  17. defaultPageSize: 10,
  18. showQuickJumper: true,
  19. pageSize: 10,
  20. onChange: function (page) {
  21. this.loadData(page);
  22. }.bind(this),
  23. showTotal: function (total) {
  24. return '共' + total + '条数据';
  25. }
  26. },
  27. dataSource: [],
  28. columns: [
  29. {
  30. title: '供应商名称',
  31. dataIndex: 'companyName',
  32. key: 'companyName',
  33. },
  34. {
  35. title: '材料',
  36. dataIndex: 'material',
  37. key: 'material',
  38. render: (text) => {
  39. return text === 0 ? '无材料' : '有材料'
  40. }
  41. },
  42. {
  43. title: '加急天数',
  44. dataIndex: 'urgent',
  45. key: 'urgent',
  46. render: (text) => {
  47. switch (text) {
  48. case 0:
  49. return '无加急';
  50. case 1:
  51. return '加急3-5个工作日';
  52. case 2:
  53. return '加急6-10个工作日';
  54. case 3:
  55. return '加急11-15个工作日';
  56. case 4:
  57. return '加急16-20个工作日';
  58. case 5:
  59. return '加急21-25个工作日';
  60. case 6:
  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. pageNo: 1,
  111. }
  112. this.loadData = this.loadData.bind(this);
  113. this.tableRowClick = this.tableRowClick.bind(this);
  114. this.reset = this.reset.bind(this);
  115. this.changeList = this.changeList.bind(this);
  116. }
  117. componentDidMount() {
  118. this.loadData();
  119. }
  120. //搜索功能和初始列表加载
  121. loadData(pageNo) {
  122. this.setState({
  123. loading: true,
  124. });
  125. $.ajax({
  126. method: "get",
  127. dataType: "json",
  128. crossDomain: false,
  129. url: globalConfig.context + '/api/admin/company/listSoftWritingPrice',
  130. data: {
  131. pageNo: pageNo || 1,
  132. pageSize: this.state.pagination.pageSize,
  133. companyName:this.state.companyName || undefined, //公司名称
  134. urgent: this.state.urgent, //加急
  135. material: this.state.material, //材料
  136. },
  137. success: function (data) {
  138. if (!data.data || !data.data.list) {
  139. if (data.error && data.error.length) {
  140. message.warning(data.error[0].message);
  141. }
  142. } else {
  143. this.state.pagination.current = data.data.pageNo;
  144. this.state.pagination.total = data.data.totalCount;
  145. if (data.data && data.data.list && !data.data.list.length) {
  146. this.state.pagination.current = 0;
  147. this.state.pagination.total = 0;
  148. }
  149. data.data.list.map((v,i)=>{v.key = i})
  150. this.setState({
  151. dataSource: data.data.list,
  152. pagination: this.state.pagination,
  153. pageNo: data.data.pageNo
  154. });
  155. }
  156. }.bind(this),
  157. }).always(function () {
  158. this.setState({
  159. loading: false
  160. });
  161. }.bind(this));
  162. }
  163. tableRowClick(infor) {
  164. this.setState({
  165. addSoftVisible : true,
  166. infor: infor
  167. })
  168. }
  169. reset(){
  170. this.setState({
  171. companyName:'', //公司名称
  172. urgent: undefined, //加急
  173. material: undefined, //材料
  174. },()=>{
  175. this.loadData();
  176. })
  177. }
  178. //删除
  179. deleteSoftWritingPrice(id) {
  180. let _this = this;
  181. this.setState({
  182. loading: true
  183. });
  184. $.ajax({
  185. method: "post",
  186. dataType: "json",
  187. crossDomain: false,
  188. url:globalConfig.context + '/api/admin/company/deleteSoftWritingPrice',
  189. data:{
  190. id: id
  191. },
  192. }).done(function (data) {
  193. _this.setState({
  194. loading: false
  195. });
  196. if (!data.error.length) {
  197. message.success('删除成功!');
  198. _this.loadData();
  199. } else {
  200. message.warning(data.error[0].message);
  201. }
  202. }.bind(this));
  203. }
  204. changeList(arr) {
  205. const newArr = [];
  206. this.state.columns.forEach(item => {
  207. arr.forEach(val => {
  208. if (val === item.title) {
  209. newArr.push(item);
  210. }
  211. });
  212. });
  213. this.setState({
  214. changeList: newArr
  215. });
  216. }
  217. render() {
  218. return(
  219. <div className="user-content" >
  220. <div className="content-title">
  221. <Tabs defaultActiveKey="1" className="test">
  222. <TabPane tab="搜索" key="1">
  223. <div className="user-search" style={{display:'flex',flexFlow:'row'}}>
  224. <Input placeholder="公司名称" style={{width:'150px',marginRight:'10px',marginBottom:'10px',marginLeft:10}}
  225. value={this.state.companyName}
  226. onChange={(e) => { this.setState({ companyName: e.target.value }); }} />
  227. <div style={{display:'flex',flexFlow:'row nowrap'}}>
  228. <div style={{marginLeft:10,marginRight:10}}>材料:</div>
  229. <Select
  230. placeholder="材料"
  231. style={{ width:'200px',marginRight:'10px' }}
  232. value={this.state.material}
  233. onChange={(e) => {this.setState({ material: e }) }}>
  234. <Select.Option value={0}>无</Select.Option>
  235. <Select.Option value={1}>有</Select.Option>
  236. </Select>
  237. </div>
  238. <div style={{display:'flex',flexFlow:'row nowrap'}}>
  239. <div style={{marginLeft:10,marginRight:10}}>加急天数:</div>
  240. <Select placeholder="加急天数"
  241. style={{ width:'200px',marginRight:'10px' }}
  242. value={this.state.urgent}
  243. onChange={(e) => { this.setState({ urgent: e }) }}>
  244. <Select.Option value={0}>无加急</Select.Option>
  245. <Select.Option value={1}>加急3-5个工作日</Select.Option>
  246. <Select.Option value={2}>加急6-10个工作日</Select.Option>
  247. <Select.Option value={3}>加急11-15个工作日</Select.Option>
  248. <Select.Option value={4}>加急16-20个工作日</Select.Option>
  249. <Select.Option value={5}>加急21-25个工作日</Select.Option>
  250. <Select.Option value={6}>加急26-30个工作日</Select.Option>
  251. </Select>
  252. </div>
  253. <Button type="primary" onClick={()=>{
  254. this.loadData();
  255. }} style={{marginRight:'10px'}}>搜索</Button>
  256. <Button onClick={this.reset} style={{marginRight:'10px'}}>重置</Button>
  257. <span style={{marginLeft: 'auto'}}>
  258. <Button type="primary" size={'middle'} onClick={()=>{
  259. this.setState({
  260. addSoftVisible : true
  261. })
  262. }}>
  263. 增加
  264. </Button>
  265. </span>
  266. </div>
  267. </TabPane>
  268. <TabPane tab="更改表格显示数据" key="2">
  269. <div style={{ marginLeft: 10 }}>
  270. <ChooseList
  271. columns={this.state.columns}
  272. changeFn={this.changeList}
  273. changeList={this.state.changeList}
  274. top={55}
  275. margin={11}
  276. />
  277. </div>
  278. </TabPane>
  279. </Tabs>
  280. <div className="patent-table">
  281. <Spin spinning={this.state.loading}>
  282. <Table size="middle" columns={
  283. this.state.changeList
  284. ? this.state.changeList
  285. : this.state.columns
  286. }
  287. style={{
  288. cursor: 'pointer',
  289. }}
  290. dataSource={this.state.dataSource}
  291. pagination={this.state.pagination}
  292. onRowClick={this.tableRowClick}/>
  293. </Spin>
  294. </div>
  295. </div>
  296. {this.state.addSoftVisible ? <AddSoftWritingPrice
  297. infor={this.state.infor}
  298. visible={this.state.addSoftVisible}
  299. onCancel={()=>{
  300. this.setState({
  301. addSoftVisible : false,
  302. infor: {},
  303. })
  304. }}
  305. successFn={()=>{
  306. this.loadData(this.state.pageNo);
  307. this.setState({
  308. addSoftVisible : false,
  309. infor: {}
  310. })
  311. }}/> : <div/>}
  312. </div>
  313. )
  314. }
  315. }
  316. export default SoftwareConfigure