index.jsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import React, { Component } from "react";
  2. import Taro, { getCurrentInstance } from "@tarojs/taro";
  3. import { View, Image, Button } from "@tarojs/components";
  4. import {
  5. AtButton,
  6. AtCalendar,
  7. AtIcon,
  8. AtTextarea,
  9. AtModal,
  10. AtModalContent,
  11. AtModalAction,
  12. } from "taro-ui";
  13. import Skeleton from "taro-skeleton";
  14. import {
  15. recordDetails,
  16. examineRecord,
  17. } from "../../utils/servers/servers";
  18. import InquiryModal from "../../components/common/inquiryModal";
  19. import "../mybusiness/index";
  20. class Detail extends Component {
  21. $instance = getCurrentInstance();
  22. constructor(props) {
  23. super(props);
  24. this.state = {
  25. opinion: "",
  26. data: {},
  27. }
  28. this.getReleasetDails = this.getReleasetDails.bind(this);
  29. }
  30. componentDidMount() {
  31. this.getReleasetDails();
  32. }
  33. // 项目详情
  34. getReleasetDails() {
  35. recordDetails({
  36. id: this.$instance.router.params.id,
  37. }).then((v) => {
  38. if (v.data.code === 200) {
  39. if (v.data.data) {
  40. this.setState({
  41. data: v.data.data
  42. })
  43. } else {
  44. setTimeout(() => {
  45. Taro.switchTab({
  46. url: "/pages/mybusiness/index",
  47. });
  48. }, 1800);
  49. Taro.showToast({
  50. title: "您没有权限查看此公出详情",
  51. icon: "none",
  52. duration: 1800,
  53. });
  54. }
  55. } else {
  56. Taro.showToast({ title: v.data.msg, icon: "none" });
  57. }
  58. })
  59. .catch((err) => {
  60. Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
  61. // console.log(err);
  62. });
  63. }
  64. // 同意/驳回
  65. agree(sta) {
  66. if (!this.state.opinion) {
  67. Taro.showToast({ title: "请填写审批意见", icon: "none" });
  68. return;
  69. }
  70. examineRecord({
  71. id: this.$instance.router.params.id,
  72. processStatus: sta,
  73. content: this.state.opinion,
  74. })
  75. .then((v) => {
  76. if (v.data.code === 200) {
  77. Taro.showToast({
  78. title: "操作成功",
  79. icon: "none",
  80. });
  81. this.getReleasetDails();
  82. } else {
  83. Taro.showToast({ title: v.data.msg, icon: "none" });
  84. }
  85. })
  86. .catch((err) => {
  87. Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
  88. // console.log(err);
  89. });
  90. }
  91. render() {
  92. const { data } = this.state
  93. return (
  94. <View className="indexPage">
  95. {Object.keys(data).length === 0 ?
  96. <Skeleton
  97. title
  98. row={3}
  99. animateName="elastic"
  100. avatarShape="square"
  101. loading
  102. /> :
  103. <View className="list">
  104. <View
  105. className="item"
  106. >
  107. <View className="infor">
  108. <View className="title">
  109. <View className="aname">
  110. {data.projectName}
  111. </View>
  112. </View>
  113. <View className="userName">
  114. <View className="uNtext">
  115. 负责人:{data.adminName}
  116. </View>
  117. </View>
  118. <View className="userName">
  119. <View className="uNtext">
  120. 研发人员:{data.name}
  121. </View>
  122. </View>
  123. <View className="userName">
  124. <View className="uNtext">
  125. 累积工时:{data.duration}
  126. </View>
  127. </View>
  128. {data.processStatus == 1 && <View style={{ marginTop: "30px" }}>
  129. <AtTextarea
  130. value={this.state.opinion}
  131. onChange={(value) => {
  132. this.setState({
  133. opinion: value,
  134. });
  135. }}
  136. maxLength={50}
  137. placeholder="请填写审批意见"
  138. />
  139. <View className="operation">
  140. <AtButton
  141. type="secondary"
  142. circle
  143. loading={this.state.loading}
  144. onClick={() => {
  145. this.setState({
  146. isInquiryOpened: true,
  147. inquiryTitle: "提醒",
  148. inquiryContent: "您确定要驳回此申请吗?",
  149. inquiryFn: () => {
  150. this.agree(3);
  151. },
  152. });
  153. }}
  154. >
  155. 驳回
  156. </AtButton>
  157. <AtButton
  158. type="primary"
  159. loading={this.state.loading}
  160. circle
  161. onClick={() => {
  162. if (this.state.loading) {
  163. return;
  164. }
  165. this.setState({
  166. isInquiryOpened: true,
  167. inquiryTitle: "提醒",
  168. inquiryContent: "您确定要同意此申请吗?",
  169. inquiryFn: () => {
  170. this.agree(2);
  171. },
  172. });
  173. }}
  174. >
  175. 同意
  176. </AtButton>
  177. </View>
  178. </View>}
  179. </View>
  180. </View>
  181. </View>}
  182. <InquiryModal
  183. isOpened={this.state.isInquiryOpened}
  184. title={this.state.inquiryTitle}
  185. content={this.state.inquiryContent}
  186. onClose={() => {
  187. this.setState({
  188. isInquiryOpened: false,
  189. inquiryTitle: "",
  190. inquiryContent: "",
  191. isNo: true,
  192. });
  193. }}
  194. onDetermine={() => {
  195. this.state.inquiryFn();
  196. this.setState({
  197. isInquiryOpened: false,
  198. inquiryTitle: "",
  199. inquiryContent: "",
  200. isNo: true,
  201. inquiryFn: () => { },
  202. });
  203. }}
  204. />
  205. </View>
  206. );
  207. }
  208. }
  209. export default Detail;