index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <div>
  3. <van-nav-bar title="查看日报" left-text="返回" @click-left="back" fixed left-arrow />
  4. <div class="login_form">
  5. <van-sticky :offset-top="46">
  6. <van-field readonly clickable name="datetimePicker" :value="nowTime" label="时间选择" placeholder="点击选择时间"
  7. @click="showPicker = true" />
  8. </van-sticky>
  9. <van-popup v-model="showPicker" position="bottom">
  10. <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate"
  11. @confirm="changeTime" @cancel="showPicker = false" />
  12. </van-popup>
  13. <van-skeleton :v-if="report.length != 0" v-for="(item, index) in report" title avatar :row="3" :loading="false"
  14. :key="index">
  15. <van-panel class="one_report" :title="item.name" :status="statusTxt[item.state]">
  16. <template #header>
  17. <div class="van-cell van-panel__header">
  18. <div class="van-cell__title">
  19. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  20. :openid='item.name'></ww-open-data></span>
  21. <span v-else>{{ item.name }}</span>
  22. </div>
  23. <div class="van-cell__value van-panel__header-value">
  24. <span>{{ statusTxt[item.state] }}</span>
  25. </div>
  26. </div>
  27. </template>
  28. <div class="form_text">
  29. <span style="margin-right:20px;margin-left:5px;font-size:14px;">
  30. 总填报:
  31. <span>{{ parseFloat(item.reportTime).toFixed(1) }}h</span>
  32. </span>
  33. </div>
  34. <div v-for="(item1, index1) in item.data" class="one_report_data" :key="index1">
  35. <div class="project_title" style="font-weight:bold;">项目:{{ item1.project }} <span
  36. :style="'color:' + statusColor[item1.state]">[
  37. <span v-if="item1.state == 0">
  38. <span v-if="item1.isDeptAudit == 0">
  39. <span v-if="item1.projectAuditState == 0">
  40. 待项目审核人<span v-if="item1.projectAuditorName != null">(
  41. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  42. :openid='item1.projectAuditorName'></ww-open-data></span>
  43. <span v-else>{{ item1.projectAuditorName }}</span>
  44. )</span>审核
  45. </span>
  46. <span style="color:#32CD32;" v-else-if="item1.projectAuditState == 1">
  47. 项目审核人<span v-if="item1.projectAuditorName != null">(
  48. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  49. :openid='item1.projectAuditorName'></ww-open-data></span>
  50. <span v-else>{{ item1.projectAuditorName }}</span>
  51. )</span>审核通过
  52. </span>
  53. </span>
  54. <span v-else-if="item1.isDeptAudit == 1">
  55. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='departmentName'
  56. :openid='item1.auditDeptName'></ww-open-data></span>
  57. <span v-else>{{ item1.auditDeptName }}</span>
  58. 审核
  59. </span>
  60. </span>
  61. <span v-else>
  62. {{ statusTxt[item1.state] }}
  63. </span>
  64. <!-- {{statusTxt[item1.state]}} -->
  65. ] </span></div>
  66. <div style="color:red;" v-if="item1.state == 2 && item1.rejectReason != null">原因:{{
  67. item1.rejectReason }}
  68. </div>
  69. <div class="project_title" v-if="item1.subProjectName != null && user.companyId != yuzhongCompId">子项目:{{ item1.subProjectName }}</div>
  70. <div class="project_title" v-if="user.companyId == yuzhongCompId" >角色:{{item1.extraField1?roleList.find(r=>r.value==item1.extraField1).label:''}}</div>
  71. <div class="project_title" v-if="user.company.packageProject == 1 && item1.groupName != null">
  72. 任务分组:{{ item1.groupName }}</div>
  73. <div class="project_title" v-if="user.companyId == yuzhongCompId" >工作职责:{{item1.extraField2?item1.extraField2Name:''}}</div>
  74. <div class="project_title" v-if="user.companyId == yuzhongCompId" >工作内容:{{item1.extraField3?item1.extraField3Name:''}}</div>
  75. <div class="project_title" v-if="user.company.packageProject == 1 && item1.stage != '-'">
  76. 投入阶段:{{ item1.stage }}</div>
  77. <!--自定义维度 -->
  78. <div class="project_title" v-if="user.timeType.customDegreeActive == 1">
  79. {{ user.timeType.customDegreeName }}:{{ item1.degreeName }}</div>
  80. <div class="project_title" v-if="user.timeType.customDataActive == 1">
  81. {{ user.timeType.customDataName }}:{{ item1.customData }}</div>
  82. <div class="project_title" v-if="user.timeType.customTextActive == 1">
  83. {{ user.timeType.customTextName }}:{{ item1.customText }}</div>
  84. <div class="project_title" v-if="user.company.packageEngineering == 1">
  85. 专业进度:
  86. <span style="margin-right:10px;" v-for="progressItem in item1.professionProgress"
  87. :key="progressItem.id">{{ progressItem.professionName }}({{ progressItem.progress }}%)
  88. </span>
  89. </div>
  90. <div class="project_title" v-if="item1.taskId">任务:{{ item1.taskName }}</div>
  91. <!--根据类型选择使用的模板 -->
  92. <div v-if="item1.multiWorktime == 0">
  93. <div class="project_time">时长:
  94. <span v-if="item1.reportTimeType == 0" style="margin-right:10px;">{{
  95. fullDayTxt[item1.timeType] }}</span>
  96. <span v-if="item1.reportTimeType == 2" style="margin-right:10px;">{{ item1.startTime + '-' +
  97. item1.endTime }}</span>{{ item1.time.toFixed(1) }}h
  98. <div class="button" v-if="item1.isOvertime == 1">加班<span v-if="item1.overtimeHours">{{
  99. item1.overtimeHours.toFixed(1) }}h</span></div>
  100. </div>
  101. <div class="project_content">事项:<span v-html="item1.content"></span></div>
  102. </div>
  103. <div v-if="item1.multiWorktime == 1">
  104. <div>项目时长:<span style="margin-right:10px;">{{ item1.time.toFixed(1) }}h</span>
  105. <div class="button" v-if="item1.isOvertime == 1">加班<span v-if="item1.overtimeHours">{{
  106. item1.overtimeHours.toFixed(1) }}h</span></div>
  107. </div>
  108. <div style="position:relative;border:#ccc 0.5px solid;padding:3px;margin:5px 0px;"
  109. v-for="(timeItem, index) in item1.worktimeList" :key="index">
  110. <div class="project_time">时长:
  111. <!-- <span v-if="timeItem.reportTimeType == 0" style="margin-right:10px;">{{fullDayTxt[item1.timeType]}}</span> -->
  112. <span style="margin-right:10px;">{{ timeItem.startTime + '-' + timeItem.endTime
  113. }}</span>{{ timeItem.time.toFixed(1) }}h
  114. </div>
  115. <div class="project_content">事项:<span v-html="timeItem.content"></span></div>
  116. </div>
  117. </div>
  118. <div style="padding:5px;text-align:center;" v-if="item1.pics != null && item1.pics.length > 0">
  119. <span v-for="(p, index) in item1.pics" :key="p" style="margin-right:10px;">
  120. <img :src="p" style="width:80px; height:80px;" @click="showLargeImg(item1.pics, index)" />
  121. </span>
  122. </div>
  123. <van-divider />
  124. </div>
  125. <van-popup v-model="imgShow" position="bottom" closeable>
  126. <van-swipe class="my-swipe" indicator-color="white">
  127. <van-swipe-item v-for="(picItem, index) in tmpPics" :key="index">
  128. <img :src="picItem" style="width:100%;" />
  129. </van-swipe-item>
  130. </van-swipe>
  131. </van-popup>
  132. <!-- 编辑 -->
  133. <div slot="footer" class="foot">
  134. <van-button size="small" type="primary" @click="editor(item)"
  135. v-if="item.id == user.id && (item.state == 2 || item.state == 3)">编辑日报</van-button>
  136. </div>
  137. </van-panel>
  138. </van-skeleton>
  139. <van-empty v-if="report.length == 0" description="暂无日报">
  140. <van-button round type="primary" class="bottom-button" @click="toWriteReport()">去填写</van-button>
  141. </van-empty>
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. export default {
  147. data() {
  148. return {
  149. yuzhongCompId: 3385,
  150. roleList:[{value: 1,label: 'CRC&LM'},{value: 2,label: 'PM'}],
  151. tmpPics: [],
  152. imgShow: false,
  153. hasWaiting: false,
  154. state: 0,
  155. statusColor: ['orange', 'green', 'red'],
  156. user: JSON.parse(localStorage.userInfo),
  157. minDate: new Date(2010, 0, 1),
  158. maxDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),
  159. currentDate: new Date(),
  160. nowTime: this.format(new Date(new Date()), "yyyy-MM-dd"),
  161. showPicker: false,
  162. report: [],
  163. fullDayTxt: ['全天', '上午', '下午'],
  164. statusTxt: ["待审核", "已通过", "已驳回", "待提交"],
  165. };
  166. },
  167. created() {
  168. },
  169. methods: {
  170. showLargeImg(item, index) {
  171. this.imgShow = true;
  172. this.tmpPics = item;
  173. },
  174. // 返回
  175. back() {
  176. history.back();
  177. },
  178. // 时间转换
  179. format(date, pattern) {
  180. pattern = pattern || "yyyy-MM-dd";
  181. var _this = this;
  182. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  183. switch ($0.charAt(0)) {
  184. case 'y': return _this.padding(date.getFullYear(), $0.length);
  185. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  186. case 'd': return _this.padding(date.getDate(), $0.length);
  187. case 'w': return date.getDay() + 1;
  188. case 'h': return _this.padding(date.getHours(), $0.length);
  189. case 'm': return _this.padding(date.getMinutes(), $0.length);
  190. case 's': return _this.padding(date.getSeconds(), $0.length);
  191. }
  192. });
  193. },
  194. padding(s, len) {
  195. var len = len - (s + '').length;
  196. for (var i = 0; i < len; i++) { s = '0' + s; }
  197. return s;
  198. },
  199. // 改变时间
  200. changeTime(time) {
  201. this.nowTime = this.format(new Date(time), "yyyy-MM-dd");
  202. this.currentDate = time;
  203. this.showPicker = false;
  204. this.getReport();
  205. },
  206. // 获取日报
  207. getReport() {
  208. this.hasWaiting = false;
  209. const toast = this.$toast.loading({
  210. forbidClick: true,
  211. duration: 0
  212. });
  213. this.$axios.post("/report/getReportList", { date: this.nowTime })
  214. .then(res => {
  215. if (res.code == "ok") {
  216. this.$toast.clear();
  217. this.report = res.data;
  218. //计算状态
  219. for (var i = 0; i < this.report.length; i++) {
  220. var item = this.report[i];
  221. if (item.state == 0) {
  222. this.hasWaiting = true;
  223. }
  224. }
  225. } else {
  226. this.$toast.clear();
  227. this.$toast.fail('获取失败:' + res.msg);
  228. }
  229. }).catch(err => { this.$toast.clear(); });
  230. },
  231. // 点击编辑
  232. editor(item) {
  233. console.log(item, '编辑')
  234. this.$router.push({
  235. path: '/edit',
  236. query: {
  237. date: this.nowTime
  238. }
  239. });
  240. },
  241. // 去填写日报
  242. toWriteReport() {
  243. if(this.user.companyId == '1071') {
  244. //物奇要填到按周填报
  245. this.$router.push({
  246. path: '/weekEdit',
  247. query: {
  248. date: this.nowTime
  249. }
  250. });
  251. } else {
  252. this.$router.push({
  253. path: '/edit',
  254. query: {
  255. date: this.nowTime
  256. }
  257. });
  258. }
  259. }
  260. },
  261. mounted() {
  262. if (sessionStorage.targetDate != null) {
  263. this.nowTime = sessionStorage.targetDate;
  264. sessionStorage.removeItem('targetDate');
  265. }
  266. this.getReport();
  267. }
  268. };
  269. </script>
  270. <style lang="less" scoped>
  271. .login_form {
  272. margin-top: 46px;
  273. }
  274. .one_report {
  275. margin-bottom: 15px;
  276. font-size: 14px;
  277. }
  278. .form_text {
  279. margin: 15px 0 15px;
  280. padding: 0 12px;
  281. }
  282. .form_btn {
  283. text-align: right;
  284. }
  285. .form_btn button {
  286. margin-left: 10px;
  287. }
  288. .one_report_data {
  289. margin-bottom: 10px;
  290. padding: 0 22px;
  291. div {
  292. line-height: 30px;
  293. }
  294. }
  295. </style>
  296. <style lang="less">
  297. .van-nav-bar .van-icon,
  298. .van-nav-bar__text {
  299. color: #20a0ff;
  300. }
  301. .button {
  302. float: right;
  303. width: 80px;
  304. height: 25px;
  305. line-height: 25px;
  306. text-align: center;
  307. border: 1px solid red;
  308. color: red;
  309. box-sizing: border-box;
  310. border-radius: 10px;
  311. font-size: 14px;
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. }
  316. .foot {
  317. width: 100%;
  318. display: flex;
  319. justify-content: end;
  320. }
  321. .bottom-button {
  322. width: 160px;
  323. height: 40px;
  324. background-color: rgb(53, 130, 245);
  325. border-color: rgb(53, 130, 245);
  326. }
  327. </style>