accountlist.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import moment from "moment";
  4. import {
  5. Button,
  6. Form,
  7. Input,
  8. Spin,
  9. Table,
  10. Select,
  11. message,
  12. Tabs,
  13. AutoComplete,
  14. DatePicker,
  15. Modal,
  16. } from "antd";
  17. import { ChooseList } from "../../order/orderNew/chooseList";
  18. import { ShowModal, getVehicleName, getTypeName, commonAdd, dealBigMoney } from "../../../tools"
  19. import ShowModalDiv from "@/showModal.jsx";
  20. import AccountDetails from "./accountDetails";
  21. import { accountType, accountStatus } from "@/dataDic";
  22. const FormItem = Form.Item;
  23. const { RangePicker } = DatePicker;
  24. const { TabPane } = Tabs;
  25. const AccountList = React.createClass({
  26. getInitialState() {
  27. return {
  28. showDetails: false,
  29. data: {},
  30. logvisible: false,
  31. logdataSour: [],
  32. visible: "",
  33. reason: "",
  34. checkData: {},
  35. aname: "",
  36. searchValues: {}, // 列表筛选条件
  37. loading: false, //加载动画
  38. changeList: undefined, // 更改后的表格显示数据
  39. dataSource: [], // 列表数据
  40. departmentArr: [],
  41. pagination: {
  42. defaultCurrent: 1,
  43. defaultPageSize: 10,
  44. showQuickJumper: true,
  45. pageSize: 10,
  46. onChange: function (page) {
  47. this.loadData(page);
  48. }.bind(this),
  49. showTotal: function (total) {
  50. return "共" + total + "条数据";
  51. },
  52. },
  53. columns: [
  54. {
  55. title: "类型",
  56. dataIndex: "type",
  57. key: "type",
  58. render: (text, record) => {
  59. return (
  60. <span>
  61. {text == 0 ? record.typeOther : accountType.find(item => item.value === text).label}
  62. </span>
  63. );
  64. },
  65. },
  66. {
  67. title: "报销金额(元)",
  68. dataIndex: "totalAmount",
  69. key: "totalAmount",
  70. },
  71. {
  72. title: "实报金额(元)",
  73. dataIndex: "realAmount",
  74. key: "realAmount",
  75. },
  76. {
  77. title: "报销编号",
  78. dataIndex: "checkNo",
  79. key: "checkNo",
  80. },
  81. {
  82. title: "报销至订单",
  83. dataIndex: "buyerName",
  84. key: "buyerName",
  85. render: (text, record) => {
  86. return (
  87. record.targetType == 0
  88. ? <div>固定费用</div>
  89. : <div>
  90. <div>{text || ""}</div>
  91. <div>{record.contractNo || ""}</div>
  92. </div>
  93. );
  94. },
  95. },
  96. {
  97. title: "报销至部门",
  98. dataIndex: "applyDepName",
  99. key: "applyDepName",
  100. render: (text, record) => {
  101. return (
  102. <span>{record.targetType == 0 && text}</span>
  103. );
  104. },
  105. },
  106. {
  107. title: "报销人",
  108. dataIndex: "aname",
  109. key: "aname",
  110. },
  111. {
  112. title: "财务负责人",
  113. dataIndex: "financeName",
  114. key: "financeName",
  115. },
  116. {
  117. title: "状态",
  118. dataIndex: "status",
  119. key: "status",
  120. render: (text, record) => {
  121. return (
  122. <span style={{ color: accountStatus[text].color }}>
  123. {accountStatus[text].label}
  124. </span>
  125. );
  126. },
  127. },
  128. {
  129. title: "报销公司/支付公司",
  130. dataIndex: "payDepName",
  131. key: "payDepName",
  132. render: (text, record) => {
  133. return (
  134. <div>
  135. <div>{record.applyDepName || ""}</div>
  136. <div>{text || ""}</div>
  137. </div>
  138. );
  139. },
  140. },
  141. {
  142. title: "报销时间",
  143. dataIndex: "createTimeStr",
  144. key: "createTimeStr",
  145. },
  146. {
  147. title: "操作",
  148. dataIndex: "operate",
  149. key: "operate",
  150. render: (text, record) => {
  151. return (
  152. <div>
  153. <div>
  154. {this.props.isOperate &&
  155. <Button type="primary"
  156. style={{ margin: 4 }}
  157. onClick={() => { this.download(record.attachmentUrl) }}
  158. >下载</Button>}
  159. {this.props.isOperate && record.examine == 1 &&
  160. <Button type="primary"
  161. style={{ margin: 4 }}
  162. onClick={(e) => {
  163. e.stopPropagation();
  164. this.setState({
  165. visible: "adopt",
  166. checkData: record,
  167. })
  168. }}
  169. >同意</Button>}
  170. {this.props.isOperate && record.examine == 1 &&
  171. <Button type="danger"
  172. style={{ margin: 4 }}
  173. onClick={(e) => {
  174. e.stopPropagation();
  175. this.setState({
  176. visible: "reject",
  177. checkData: record,
  178. })
  179. }}
  180. >驳回</Button>}
  181. {record.status != 0 && <Button
  182. style={{ margin: 4 }}
  183. onClick={() => {
  184. this.setState({
  185. logvisible: true
  186. })
  187. this.getLogData(record.mainId)
  188. }}>日志</Button>}
  189. </div>
  190. </div>
  191. )
  192. }
  193. },
  194. ],
  195. logcolumns: [
  196. {
  197. title: "审核人",
  198. dataIndex: "auditorName",
  199. key: "auditorName"
  200. },
  201. {
  202. title: "操作",
  203. dataIndex: "status",
  204. key: "status",
  205. width: 120,
  206. render: (text, record) => {
  207. return (
  208. <span style={{ color: ["#1D4FEA", "#34DE38", "#108EE9", "red", "#1D4FEA"][text] }}>
  209. {["【发起】", "【通过】", "【完成】", "【驳回】", "【重新发起】"][text]}
  210. {this.state.processStatus == record.processStatus && !record.id &&
  211. <span style={{ color: "#FFA500" }}>&nbsp;审核中...</span>}
  212. </span>
  213. );
  214. },
  215. },
  216. {
  217. title: "操作时间",
  218. dataIndex: "createTimeStr",
  219. key: "createTimeStr",
  220. width: 88,
  221. },
  222. {
  223. title: "备注",
  224. dataIndex: "remarks",
  225. key: "remarks",
  226. render: (text, record) => {
  227. return (
  228. <div style={{ minWidth: 250 }}>{text}</div>
  229. )
  230. }
  231. }
  232. ],
  233. };
  234. },
  235. componentWillMount() {
  236. this.departmentList();
  237. this.loadData();
  238. },
  239. // 列表接口
  240. loadData(pageNo) {
  241. const { searchValues, pagination } = this.state;
  242. this.setState({
  243. loading: true,
  244. });
  245. let datas = Object.assign(searchValues, {
  246. pageNo: pageNo || 1,
  247. pageSize: pagination.pageSize,
  248. expenseMain: 0,
  249. processStatus: this.props.isOperate ? 1 : 2,
  250. });
  251. $.ajax({
  252. method: "get",
  253. dataType: "json",
  254. crossDomain: false,
  255. url: globalConfig.context + "/api/admin/expenseAccount/pageList",
  256. data: datas,
  257. success: function (data) {
  258. ShowModal(this);
  259. this.setState({
  260. loading: false,
  261. });
  262. if (data.error && data.error.length === 0) {
  263. if (data.data.list) {
  264. pagination.current = data.data.pageNo;
  265. pagination.total = data.data.totalCount;
  266. if (data.data && data.data.list && !data.data.list.length) {
  267. pagination.current = 0;
  268. pagination.total = 0;
  269. }
  270. this.setState({
  271. dataSource: data.data.list,
  272. pagination: this.state.pagination,
  273. pageNo: data.data.pageNo,
  274. totalAmount: data.data.totalAmount,
  275. });
  276. } else {
  277. this.setState({
  278. dataSource: data.data,
  279. pagination: false,
  280. });
  281. }
  282. } else {
  283. message.warning(data.error[0].message);
  284. }
  285. }.bind(this),
  286. }).always(
  287. function () {
  288. this.setState({
  289. loading: false,
  290. });
  291. }.bind(this)
  292. );
  293. },
  294. // 日志
  295. getLogData(eaid) {
  296. $.ajax({
  297. method: "get",
  298. dataType: "json",
  299. crossDomain: false,
  300. url: globalConfig.context + "/api/admin/expenseAccount/log/list",
  301. data: { eaid },
  302. success: function (data) {
  303. if (data.error.length === 0) {
  304. this.setState({
  305. logdataSour: data.data || []
  306. });
  307. this.isHere(data.data || [])
  308. } else {
  309. message.warning(data.error[0].message);
  310. }
  311. }.bind(this)
  312. }).always(
  313. function () {
  314. }.bind(this)
  315. );
  316. },
  317. //
  318. isHere(list = []) {
  319. for (var i = 0; i < list.length; i++) {
  320. if (!list[i].id) {
  321. this.setState({
  322. processStatus: list[i].processStatus
  323. })
  324. return
  325. }
  326. }
  327. },
  328. download(urls) {
  329. if (!urls) {
  330. message.error("暂无可下载的附件!");
  331. } else {
  332. let list = urls.split(',') || []
  333. list.forEach(e => {
  334. var aLink = document.createElement('a');
  335. aLink.download = e;
  336. aLink.href = globalConfig.context + `/open/download?fileName=${e}&delete=false`;
  337. document.body.appendChild(aLink);
  338. aLink.click();
  339. document.body.removeChild(aLink);
  340. });
  341. }
  342. },
  343. departmentList() {
  344. $.ajax({
  345. method: "get",
  346. dataType: "json",
  347. crossDomain: false,
  348. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  349. data: {},
  350. success: function (data) {
  351. let thedata = data.data;
  352. let theArr = [];
  353. if (!thedata) {
  354. if (data.error && data.error.length) {
  355. message.warning(data.error[0].message);
  356. }
  357. } else {
  358. thedata.map(function (item, index) {
  359. theArr.push({
  360. key: index,
  361. name: item.name,
  362. id: item.id
  363. });
  364. });
  365. }
  366. this.setState({
  367. departmentArr: theArr
  368. });
  369. }.bind(this)
  370. }).always(
  371. function () {
  372. }.bind(this)
  373. );
  374. },
  375. // 审核
  376. toExamine(num) {
  377. const { checkData, reason } = this.state
  378. if (!reason) {
  379. message.warning("请填写审核说明~");
  380. return;
  381. }
  382. this.setState({
  383. loading: true,
  384. });
  385. $.ajax({
  386. method: "POST",
  387. dataType: "json",
  388. crossDomain: false,
  389. url: globalConfig.context + "/api/admin/expenseAccount/examine",
  390. data: {
  391. id: checkData.id,
  392. reason,
  393. status: num,//1同意 3驳回
  394. },
  395. }).done(
  396. function (data) {
  397. if (!data.error.length) {
  398. message.success("审核成功!");
  399. this.setState({
  400. visible: "",
  401. reason: "",
  402. showDetails: false,
  403. checkData: {},
  404. });
  405. this.loadData()
  406. } else {
  407. message.warning(data.error[0].message);
  408. }
  409. }.bind(this)
  410. );
  411. },
  412. tableRowClick(e) {
  413. this.setState({
  414. showDetails: true,
  415. id: e.id,
  416. })
  417. // this.getDetails(e.id)
  418. },
  419. // 查询负责人
  420. followUp(e) {
  421. this.setState({
  422. aname: e
  423. });
  424. $.ajax({
  425. method: "get",
  426. dataType: "json",
  427. crossDomain: false,
  428. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  429. data: {
  430. adminName: e,
  431. },
  432. success: function (data) {
  433. let thedata = data.data || [];
  434. if (!thedata) {
  435. if (data.error && data.error.length) {
  436. message.warning(data.error[0].message);
  437. }
  438. thedata = {};
  439. }
  440. this.setState({
  441. fjlist: thedata,
  442. });
  443. }.bind(this),
  444. }).always(
  445. function () {
  446. this.setState({
  447. loading: false,
  448. });
  449. }.bind(this)
  450. );
  451. },
  452. // 选中负责人
  453. selectF(value) {
  454. const { searchValues, fjlist } = this.state;
  455. const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist;
  456. this.setState({
  457. searchValues: Object.assign(searchValues, {
  458. aid: newdataSources.find((item) => item.name == value).id,
  459. }),
  460. });
  461. },
  462. // 搜索
  463. search() {
  464. this.loadData();
  465. },
  466. // 重置
  467. reset() {
  468. this.setState({
  469. aname: "",
  470. searchValues: JSON.parse(JSON.stringify({})),
  471. }, () => {
  472. this.loadData();
  473. })
  474. },
  475. changeList(arr) {
  476. const newArr = [];
  477. this.state.columns.forEach((item) => {
  478. arr.forEach((val) => {
  479. if (val === item.title) {
  480. newArr.push(item);
  481. }
  482. });
  483. });
  484. this.setState({
  485. changeList: newArr,
  486. });
  487. },
  488. render() {
  489. const { TextArea } = Input
  490. const { searchValues, visible, } = this.state
  491. const formItemLayout = {
  492. labelCol: { span: 5 },
  493. wrapperCol: { span: 18 },
  494. };
  495. const dataSources = this.state.fjlist || [];
  496. const options = dataSources.map((group) => (
  497. <Select.Option key={group.id} value={group.name}>
  498. {group.name}
  499. </Select.Option>
  500. ));
  501. return (
  502. <div className="user-content">
  503. <ShowModalDiv ShowModal={this.state.showModal} />
  504. <div className="content-title" style={{ marginBottom: 10 }}>
  505. <span style={{ fontWeight: 900, fontSize: 16 }}>费用单列表</span>
  506. </div>
  507. <Tabs defaultActiveKey="2" className="test">
  508. <TabPane tab="搜索" key="2">
  509. <div className="user-search" style={{ marginLeft: 10 }}>
  510. <Input
  511. placeholder="合同编号"
  512. value={searchValues["contractNo"]
  513. ? searchValues["contractNo"]
  514. : ""}
  515. onChange={(e) => {
  516. searchValues["contractNo"] = e.target.value;
  517. this.setState({
  518. searchValues: searchValues,
  519. });
  520. }}
  521. />
  522. <Input
  523. placeholder="客户名称"
  524. value={searchValues["username"]
  525. ? searchValues["username"]
  526. : ""}
  527. onChange={(e) => {
  528. searchValues["username"] = e.target.value;
  529. this.setState({
  530. searchValues: searchValues,
  531. });
  532. }}
  533. />
  534. <Select
  535. style={{ width: 140 }}
  536. placeholder="报销类型"
  537. value={searchValues["type"]
  538. ? searchValues["type"]
  539. : undefined}
  540. onChange={(e) => {
  541. searchValues["type"] = e;
  542. this.setState({
  543. searchValues: searchValues,
  544. });
  545. }}
  546. >
  547. <Option value="1">差旅费</Option>
  548. <Option value="2">非业务报销</Option>
  549. <Option value="3">第三方付款</Option>
  550. <Option value="4">申请借支</Option>
  551. <Option value="5">申请抵扣</Option>
  552. <Option value="0">其他</Option>
  553. </Select>
  554. <AutoComplete
  555. className="certain-category-search"
  556. dropdownClassName="certain-category-search-dropdown"
  557. dropdownMatchSelectWidth={false}
  558. style={{ width: 140 }}
  559. dataSource={options}
  560. placeholder="报销人"
  561. value={this.state.aname}
  562. onChange={this.followUp.bind(this)}
  563. filterOption={true}
  564. onSelect={this.selectF.bind(this)}
  565. >
  566. <Input />
  567. </AutoComplete>
  568. <Select
  569. placeholder="所属部门"
  570. style={{ width: 200, marginRight: 10 }}
  571. value={searchValues["depId"]
  572. ? searchValues["depId"]
  573. : undefined}
  574. onChange={e => {
  575. searchValues["depId"] = e;
  576. this.setState({
  577. searchValues: searchValues,
  578. });
  579. }}
  580. >
  581. {this.state.departmentArr.map(function (item) {
  582. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  583. })}
  584. </Select>
  585. <Select
  586. placeholder="申请部门"
  587. style={{ width: 200, marginRight: 10 }}
  588. value={searchValues["applyDep"]
  589. ? searchValues["applyDep"]
  590. : undefined}
  591. onChange={e => {
  592. searchValues["applyDep"] = e;
  593. this.setState({
  594. searchValues: searchValues,
  595. });
  596. }}
  597. >
  598. {this.state.departmentArr.map(function (item) {
  599. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  600. })}
  601. </Select>
  602. <Select
  603. placeholder="支付部门"
  604. style={{ width: 200, marginRight: 10 }}
  605. value={searchValues["payDep"]
  606. ? searchValues["payDep"]
  607. : undefined}
  608. onChange={e => {
  609. searchValues["payDep"] = e;
  610. this.setState({
  611. searchValues: searchValues,
  612. });
  613. }}
  614. >
  615. {this.state.departmentArr.map(function (item) {
  616. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  617. })}
  618. </Select>
  619. <Select
  620. style={{ width: 140 }}
  621. placeholder="审核状态"
  622. value={searchValues["examineStatus"]
  623. ? searchValues["examineStatus"]
  624. : undefined}
  625. onChange={(e) => {
  626. searchValues["examineStatus"] = e;
  627. this.setState({
  628. searchValues: searchValues,
  629. });
  630. }}
  631. >
  632. <Option value="0">待审核</Option>
  633. <Option value="1">已审核</Option>
  634. </Select>
  635. <Input
  636. placeholder="报销编号"
  637. value={searchValues["checkNo"]
  638. ? searchValues["checkNo"]
  639. : ""}
  640. onChange={(e) => {
  641. searchValues["checkNo"] = e.target.value;
  642. this.setState({
  643. searchValues: searchValues,
  644. });
  645. }}
  646. />
  647. <div style={{ marginTop: 10 }}>
  648. <span>报销时间:</span>
  649. <RangePicker
  650. style={{ width: 300 }}
  651. value={[
  652. searchValues.startTime ? moment(searchValues.startTime) : null,
  653. searchValues.endTime ? moment(searchValues.endTime) : null,
  654. ]}
  655. onChange={(data, dataString) => {
  656. this.setState({
  657. searchValues: Object.assign(searchValues, {
  658. startTime: dataString[0],
  659. endTime: dataString[1],
  660. }),
  661. });
  662. }}
  663. />
  664. <Button
  665. type="primary"
  666. onClick={this.search}
  667. style={{ margin: "0 10px" }}
  668. >
  669. 搜索
  670. </Button>
  671. <Button onClick={this.reset}>重置</Button>
  672. </div>
  673. </div>
  674. </TabPane>
  675. <TabPane tab="更改表格显示数据" key="1">
  676. <div style={{ marginLeft: 10 }}>
  677. <ChooseList
  678. columns={this.state.columns}
  679. changeFn={this.changeList}
  680. changeList={this.state.changeList}
  681. top={55}
  682. margin={11}
  683. />
  684. </div>
  685. </TabPane>
  686. </Tabs>
  687. <div className="patent-table">
  688. <Spin spinning={this.state.loading}>
  689. <Table
  690. bordered
  691. columns={
  692. this.state.changeList == undefined
  693. ? this.state.columns
  694. : this.state.changeList
  695. }
  696. dataSource={this.state.dataSource}
  697. pagination={this.state.pagination}
  698. // onRowDoubleClick={this.tableRowClick.bind(this)}
  699. size="small"
  700. />
  701. </Spin>
  702. <p
  703. style={{ display: "inline-block", fontSize: "14px", color: "red" }}
  704. >
  705. {
  706. <span style={{ marginRight: 10 }}>
  707. {`金额总计(元):${this.state.totalAmount}`}
  708. </span>
  709. }
  710. </p>
  711. </div>
  712. {
  713. //审核弹窗
  714. this.state.visible != "" &&
  715. <Modal
  716. width="400px"
  717. maskClosable={false}
  718. title="审核"
  719. confirmLoading={this.state.loading}
  720. visible={this.state.visible != ""}
  721. onOk={() => { this.toExamine(visible == "adopt" ? 1 : visible == "reject" && 3) }}
  722. okText={this.state.visible == "adopt" ? "通过" : this.state.visible == "reject" && "驳回"}
  723. onCancel={() => {
  724. this.setState({
  725. visible: '',
  726. reason: "",
  727. checkData: {},
  728. })
  729. }}
  730. >
  731. <div style={{ width: "90%", margin: "0 auto" }}>
  732. <TextArea
  733. rows={4}
  734. value={this.state.reason}
  735. onChange={(e) => {
  736. this.setState({
  737. reason: e.target.value,
  738. })
  739. }}
  740. placeholder="请填写审核内容"
  741. />
  742. </div>
  743. </Modal>
  744. }
  745. {
  746. this.state.showDetails &&
  747. <AccountDetails
  748. showDetails={this.state.showDetails}
  749. id={this.state.id}
  750. isOperate={this.props.isOperate}
  751. onCancel={() => { this.setState({ showDetails: false }) }}
  752. />
  753. }
  754. {
  755. // 审核日志
  756. this.state.logvisible &&
  757. <Modal
  758. visible={this.state.logvisible}
  759. className="admin-desc-content"
  760. width="800px"
  761. maskClosable={false}
  762. title="审核日志"
  763. footer={null}
  764. onCancel={() => {
  765. this.setState({
  766. logvisible: false,
  767. })
  768. }}
  769. >
  770. <div className="patent-table">
  771. <Spin spinning={this.state.loading}>
  772. <Table
  773. columns={this.state.logcolumns}
  774. dataSource={this.state.logdataSour}
  775. pagination={false}
  776. bordered
  777. size="small"
  778. />
  779. </Spin>
  780. </div>
  781. </Modal>
  782. }
  783. </div>
  784. );
  785. },
  786. });
  787. export default AccountList;