softwareConfigure.js 10 KB

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