softwareConfigure.js 10 KB

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