index.jsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import React, { Component } from "react";
  2. import Taro, { getCurrentInstance } from "@tarojs/taro";
  3. import { View, Text, Image, } from "@tarojs/components";
  4. import {
  5. AtButton,
  6. AtTextarea,
  7. } from "taro-ui";
  8. import Skeleton from "taro-skeleton";
  9. import {
  10. projectDetails,
  11. examineRecord,
  12. } from "../../utils/servers/servers";
  13. import { resourceAddress } from "../../utils/config";
  14. import dayjs from "dayjs";
  15. import './index.less'
  16. class ProjectDetail extends Component {
  17. $instance = getCurrentInstance();
  18. constructor(props) {
  19. super(props);
  20. this.state = {
  21. opinion: "",
  22. attachmentUrl: [],
  23. data: {},
  24. historicalIsOpened: false,
  25. }
  26. this.getProjectDetail = this.getProjectDetail.bind(this);
  27. }
  28. componentDidMount() {
  29. this.getProjectDetail();
  30. }
  31. componentDidShow() {
  32. this.getProjectDetail();
  33. }
  34. // 项目详情
  35. getProjectDetail() {
  36. projectDetails({
  37. id: this.$instance.router.params.id,
  38. }).then((v) => {
  39. if (v.code === 200) {
  40. if (v.data) {
  41. let list = [];
  42. for (let i of (v.data.annexUrl || '').split(',')) {
  43. if (i) {
  44. list.push({ 'url': resourceAddress + i })
  45. }
  46. }
  47. this.setState({
  48. data: v.data,
  49. attachmentUrl: list,
  50. })
  51. } else {
  52. setTimeout(() => {
  53. Taro.switchTab({
  54. url: "/pages/project/index",
  55. });
  56. }, 1800);
  57. Taro.showToast({
  58. title: "您没有权限查看此详情",
  59. icon: "none",
  60. duration: 1800,
  61. });
  62. }
  63. } else {
  64. Taro.showToast({ title: v.msg, icon: "none" });
  65. }
  66. })
  67. .catch((err) => {
  68. Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
  69. // console.log(err);
  70. });
  71. }
  72. // 同意/驳回
  73. agree(sta) {
  74. if (!this.state.opinion) {
  75. Taro.showToast({ title: "请填写审批意见", icon: "none" });
  76. return;
  77. }
  78. examineRecord({
  79. id: this.$instance.router.params.id,
  80. processStatus: sta,
  81. content: this.state.opinion,
  82. })
  83. .then((v) => {
  84. if (v.code === 200) {
  85. Taro.showToast({
  86. title: "操作成功",
  87. icon: "none",
  88. });
  89. this.getReleasetDails();
  90. } else {
  91. Taro.showToast({ title: v.msg, icon: "none" });
  92. }
  93. })
  94. .catch((err) => {
  95. Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
  96. // console.log(err);
  97. });
  98. }
  99. render() {
  100. const { data, attachmentUrl } = this.state
  101. return (
  102. <View className="indexPage">
  103. {Object.keys(data).length === 0 ?
  104. <Skeleton
  105. title
  106. row={3}
  107. animateName="elastic"
  108. avatarShape="square"
  109. loading
  110. /> :
  111. <View className="list">
  112. <View className="item">
  113. <View className="infor">
  114. <View className="title">
  115. <View className="aname">
  116. {data.name}
  117. </View>
  118. </View>
  119. <View className="userName">
  120. <View className="uNtext">
  121. 项目编号:{data.projectNumber}
  122. </View>
  123. </View>
  124. <View className="userName">
  125. <View className="uNtext">
  126. 项目名称:{data.name}
  127. </View>
  128. </View>
  129. <View className="userName">
  130. <View className="uNtext">
  131. 项目起止时间:{dayjs(data.startTime).format("YYYY-MM-DD") + " 至 " + dayjs(data.endTime).format("YYYY-MM-DD")}
  132. </View>
  133. </View>
  134. <View className="userName">
  135. <View className="uNtext">
  136. 是否跨年:{["否", "是"][data.crossYear]}
  137. </View>
  138. </View>
  139. <View className="userName">
  140. <View className="uNtext">
  141. 创建年份:{data.createYear}
  142. </View>
  143. </View>
  144. <View className="userName">
  145. <View className="uNtext">
  146. 项目年份:{data.projectYear}
  147. </View>
  148. </View>
  149. <View className="userName">
  150. <View className="uNtext">
  151. 项目负责人:{data.adminName}
  152. </View>
  153. </View>
  154. <View className="userName">
  155. <View className="uNtext">
  156. 研发人员:{data.staffName}
  157. </View>
  158. </View>
  159. <View className="userName" style={{ marginBottom: 20 }}>
  160. <View className="uNtext">
  161. 备注:{data.remark}
  162. </View>
  163. </View>
  164. <AtButton type='primary'>累计研发工时:{data.duration}</AtButton>
  165. </View>
  166. </View>
  167. </View>}
  168. </View>
  169. );
  170. }
  171. }
  172. export default ProjectDetail;