index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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-cell title="时间选择" clickable :value="nowTime" @click="showPicker = true" />
  7. </van-sticky>
  8. <div v-if="user.manageDeptId != 0 || reportsCompany || reportsDept">
  9. <van-sticky :offset-top="90">
  10. <van-cell title="选择部门" clickable :value="departmentText" @click="selectDepartmentShow = true">
  11. <template #extra>
  12. <van-icon v-if="departmentText" name="close" class="clearSeach"
  13. @click.stop="selectUserClear('dept')" />
  14. </template>
  15. <template #default>
  16. <span v-if="user.userNameNeedTranslate == '1'">
  17. <span v-if="departmentText">
  18. <ww-open-data type='departmentName' :openid='departmentText'></ww-open-data>
  19. </span>
  20. </span>
  21. <span v-else>{{ departmentText }}</span>
  22. </template>
  23. </van-cell>
  24. </van-sticky>
  25. <van-sticky :offset-top="134" class="one_report_select">
  26. <van-cell title="选择人员" clickable :value="userNameValue" @click="selectUserShow = true"
  27. value-class="userNameValue">
  28. <template #extra>
  29. <van-icon v-if="selectPeopleVal.name" name="close" class="clearSeach"
  30. @click.stop="selectUserClear('user')" />
  31. </template>
  32. <template #default>
  33. <span v-if="user.userNameNeedTranslate == '1'">
  34. <span v-if="selectPeopleVal.name">
  35. <ww-open-data type='userName' :openid='selectPeopleVal.name'></ww-open-data>
  36. </span>
  37. </span>
  38. <span v-else>{{ userNameValue }}</span>
  39. </template>
  40. </van-cell>
  41. </van-sticky>
  42. </div>
  43. <van-popup v-model="showPicker" position="bottom">
  44. <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate"
  45. @confirm="changeTime" @cancel="showPicker = false" />
  46. </van-popup>
  47. <van-skeleton :v-if="report.length != 0" v-for="(item, index) in report" title avatar :row="3" :loading="false"
  48. :key="index">
  49. <van-panel class="one_report" :title="item.name" :status="statusTxt[item.state]">
  50. <template #header>
  51. <div class="van-cell van-panel__header">
  52. <div class="van-cell__title">
  53. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  54. :openid='item.name'></ww-open-data></span>
  55. <span v-else>{{ item.name }}</span>
  56. </div>
  57. <div class="van-cell__value van-panel__header-value">
  58. <span>{{ statusTxt[item.state] }}</span>
  59. </div>
  60. </div>
  61. </template>
  62. <div class="form_text">
  63. <span style="margin-right:20px;margin-left:5px;font-size:14px;">
  64. 总填报:
  65. <span>{{ parseFloat(item.reportTime).toFixed(1) }}h</span>
  66. </span>
  67. </div>
  68. <div v-if="user.timeType.enableNewWeeklyfill == 1 && item.summary != null" style="margin-left:20px;"
  69. v-html="'<b>' + item.summaryTitle + '</b><br>' + item.summary.replace(/\r\n/g, '<br>')">
  70. </div>
  71. <div v-for="(item1, index1) in item.data" class="one_report_data" :key="index1">
  72. <div class="project_title" style="font-weight:bold;">项目:{{ item1.project }} <span
  73. :style="'color:' + statusColor[item1.state]">[
  74. <span v-if="item1.state == 0">
  75. <span v-if="item1.isDeptAudit == 0">
  76. <span v-if="item1.projectAuditState == 0">
  77. 待项目审核人<span v-if="item1.projectAuditorName != null">(
  78. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  79. :openid='item1.projectAuditorName'></ww-open-data></span>
  80. <span v-else>{{ item1.projectAuditorName }}</span>
  81. )</span>审核
  82. </span>
  83. <span style="color:#32CD32;" v-else-if="item1.projectAuditState == 1">
  84. 项目审核人<span v-if="item1.projectAuditorName != null">(
  85. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  86. :openid='item1.projectAuditorName'></ww-open-data></span>
  87. <span v-else>{{ item1.projectAuditorName }}</span>
  88. )</span>审核通过
  89. </span>
  90. </span>
  91. <span v-else-if="item1.isDeptAudit == 1">
  92. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='departmentName'
  93. :openid='item1.auditDeptName'></ww-open-data></span>
  94. <span v-else>{{ item1.auditDeptName }}</span>
  95. 审核
  96. </span>
  97. </span>
  98. <span v-else>
  99. {{ statusTxt[item1.state] }}
  100. </span>
  101. <!-- {{statusTxt[item1.state]}} -->
  102. ] </span></div>
  103. <div style="color:red;" v-if="item1.state == 2 && item1.rejectReason != null">原因:{{
  104. item1.rejectReason }}
  105. </div>
  106. <div class="project_title" v-if="item1.subProjectName != null && user.companyId != yuzhongCompId">
  107. 子项目:{{ item1.subProjectName }}</div>
  108. <div class="project_title" v-if="user.companyId == yuzhongCompId">
  109. 角色:{{ item1.extraField1 ? roleList.find(r => r.value == item1.extraField1).label : '' }}</div>
  110. <div class="project_title" v-if="user.company.packageProject == 1 && item1.groupName != null">
  111. 任务分组:{{ item1.groupName }}</div>
  112. <div class="project_title" v-if="user.companyId == yuzhongCompId">
  113. 工作职责:{{ item1.extraField2 ? item1.extraField2Name : '' }}</div>
  114. <div class="project_title" v-if="user.companyId == yuzhongCompId">
  115. 工作内容:{{ item1.extraField3 ? item1.extraField3Name : '' }}</div>
  116. <div class="project_title" v-if="user.company.packageProject == 1 && item1.stage != '-'">
  117. 投入阶段:{{ item1.stage }}</div>
  118. <!--自定义维度 -->
  119. <div class="project_title" v-if="user.timeType.customDegreeActive == 1">
  120. {{ user.timeType.customDegreeName }}:{{ item1.degreeName }}</div>
  121. <div class="project_title" v-if="user.timeType.customDataActive == 1">
  122. {{ user.timeType.customDataName }}:{{ item1.customData }}</div>
  123. <div class="project_title" v-if="user.timeType.customTextActive == 1">
  124. {{ user.timeType.customTextName }}:{{ item1.customText }}</div>
  125. <div class="project_title" v-if="user.company.packageEngineering == 1">
  126. 专业进度:
  127. <span style="margin-right:10px;" v-for="progressItem in item1.professionProgress"
  128. :key="progressItem.id">{{ progressItem.professionName }}({{ progressItem.progress }}%)
  129. </span>
  130. </div>
  131. <div class="project_title" v-if="item1.taskId">任务:{{ item1.taskName }}</div>
  132. <!--根据类型选择使用的模板 -->
  133. <div v-if="item1.multiWorktime == 0">
  134. <div class="project_time">时长:
  135. <span v-if="item1.reportTimeType == 0" style="margin-right:10px;">{{
  136. fullDayTxt[item1.timeType] }}</span>
  137. <span v-if="item1.reportTimeType == 2" style="margin-right:10px;">{{ item1.startTime + '-' +
  138. item1.endTime }}</span>{{ item1.time.toFixed(1) }}h
  139. <div class="button" v-if="item1.isOvertime == 1">加班<span v-if="item1.overtimeHours">{{
  140. item1.overtimeHours.toFixed(1) }}h</span></div>
  141. </div>
  142. <div class="project_content">事项:<span v-html="item1.content"></span></div>
  143. </div>
  144. <div v-if="item1.multiWorktime == 1">
  145. <div>项目时长:<span style="margin-right:10px;">{{ item1.time.toFixed(1) }}h</span>
  146. <div class="button" v-if="item1.isOvertime == 1">加班<span v-if="item1.overtimeHours">{{
  147. item1.overtimeHours.toFixed(1) }}h</span></div>
  148. </div>
  149. <div style="position:relative;border:#ccc 0.5px solid;padding:3px;margin:5px 0px;"
  150. v-for="(timeItem, index) in item1.worktimeList" :key="index">
  151. <div class="project_time">时长:
  152. <!-- <span v-if="timeItem.reportTimeType == 0" style="margin-right:10px;">{{fullDayTxt[item1.timeType]}}</span> -->
  153. <span style="margin-right:10px;">{{ timeItem.startTime + '-' + timeItem.endTime
  154. }}</span>{{ timeItem.time.toFixed(1) }}h
  155. </div>
  156. <div class="project_content">事项:<span v-html="timeItem.content"></span></div>
  157. </div>
  158. </div>
  159. <div style="padding:5px;text-align:center;" v-if="item1.pics != null && item1.pics.length > 0">
  160. <span v-for="(p, index) in item1.pics" :key="p" style="margin-right:10px;">
  161. <img :src="p" style="width:80px; height:80px;" @click="showLargeImg(item1.pics, index)" />
  162. </span>
  163. </div>
  164. <van-divider />
  165. </div>
  166. <van-popup v-model="imgShow" position="bottom" closeable>
  167. <van-swipe class="my-swipe" indicator-color="white">
  168. <van-swipe-item v-for="(picItem, index) in tmpPics" :key="index">
  169. <img :src="picItem" style="width:100%;" />
  170. </van-swipe-item>
  171. </van-swipe>
  172. </van-popup>
  173. <!-- 编辑 -->
  174. <div slot="footer" class="foot">
  175. <van-button size="small" type="primary" @click="editor(item)"
  176. v-if="item.id == user.id && (item.state == 2 || item.state == 3)">编辑日报</van-button>
  177. </div>
  178. </van-panel>
  179. </van-skeleton>
  180. <van-empty v-if="report.length == 0" description="暂无日报">
  181. <van-button round type="primary" class="bottom-button" @click="toWriteReport()">去填写</van-button>
  182. </van-empty>
  183. <!-- 人员选择 -->
  184. <van-popup v-model="selectUserShow" position="bottom" style="height: 90%">
  185. <div class="popupDiv">
  186. <div class="popupSearch">
  187. <van-search v-model.trim="searchInputValue" placeholder="输入员工姓名搜索" @clear="userListSearch" @search="userListSearch"
  188. shape="round" background="#F4F4F4"></van-search>
  189. </div>
  190. <div class="popupCon conBorder" style="flex: 1;background-color: #fff;">
  191. <div class="popupConBox">
  192. <van-radio-group v-model="selectPeopleVal">
  193. <van-radio v-for="uitem in showUserList" :key="uitem.id" :name="uitem" style="padding:10px"
  194. class="popupItem marginNone borderNone">
  195. <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
  196. :openid='uitem.name'></ww-open-data></span>
  197. <span v-else>{{ uitem.name ? uitem.name : '' }}</span>
  198. </van-radio>
  199. </van-radio-group>
  200. </div>
  201. </div>
  202. <div class="popupBtn">
  203. <van-button style="width:100%;background: #1989fa;color: #ffffff;" round
  204. @click="selectUserConfirm()">确定</van-button>
  205. </div>
  206. </div>
  207. </van-popup>
  208. <!-- 部门选择 -->
  209. <van-popup v-model="selectDepartmentShow" position="bottom" style="height: 90%">
  210. <div class="popupDiv">
  211. <div class="comPaceholder">
  212. 已选择部门:
  213. <span v-if="user.userNameNeedTranslate != '1'">
  214. {{ selectDepartmentText.length > 0 ? selectDepartmentText[0].label : '请选择部门' }}
  215. </span>
  216. <span v-else>
  217. <span v-if="selectDepartmentText.length > 0">
  218. <ww-open-data type='departmentName' :openid='selectDepartmentText[0].label'></ww-open-data>
  219. </span>
  220. <span v-else>请选择部门</span>
  221. </span>
  222. </div>
  223. <div class="popupCon conBorder comTree" style="flex: 1;">
  224. <el-tree :data="departmentList" :props="defaultProps" @node-click="treeNodeClick">
  225. <span class="custom-tree-node" slot-scope="{ node }">
  226. <span v-if="user.userNameNeedTranslate == '1'">
  227. <span>
  228. <ww-open-data type='departmentName' :openid='node.label'></ww-open-data>
  229. </span>
  230. </span>
  231. <span v-if="user.userNameNeedTranslate != '1'">
  232. {{ node.label }}
  233. </span>
  234. </span>
  235. </el-tree>
  236. </div>
  237. <div class="popupBtn">
  238. <van-button style="width:100%;background: #1989fa;color: #ffffff;" round
  239. @click="treeBtn">确定</van-button>
  240. </div>
  241. </div>
  242. </van-popup>
  243. </div>
  244. </div>
  245. </template>
  246. <script>
  247. export default {
  248. components: {},
  249. data() {
  250. return {
  251. yuzhongCompId: 3385,
  252. roleList: [{ value: 1, label: 'CRC&LM' }, { value: 2, label: 'PM' }],
  253. tmpPics: [],
  254. imgShow: false,
  255. hasWaiting: false,
  256. state: 0,
  257. statusColor: ['orange', 'green', 'red'],
  258. user: JSON.parse(localStorage.userInfo),
  259. minDate: new Date(2010, 0, 1),
  260. maxDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),
  261. currentDate: new Date(),
  262. nowTime: this.format(new Date(new Date()), "yyyy-MM-dd"),
  263. showPicker: false,
  264. report: [],
  265. fullDayTxt: ['全天', '上午', '下午'],
  266. statusTxt: ["待审核", "已通过", "已驳回", "待提交"],
  267. selectUserShow: false,
  268. searchInputValue: '',
  269. userList: '',
  270. showUserList: '',
  271. userIdList: '',
  272. userNameValue: '',
  273. selectPeopleVal: {},
  274. selectDepartmentShow: false,
  275. selectDepartmentText: [],
  276. departmentText: '',
  277. departmentList: [],
  278. defaultProps: {
  279. children: 'children',
  280. label: 'label'
  281. },
  282. reportsCompany: false,
  283. reportsDept: false
  284. };
  285. },
  286. created() {
  287. },
  288. methods: {
  289. showLargeImg(item, index) {
  290. this.imgShow = true;
  291. this.tmpPics = item;
  292. },
  293. // 返回
  294. back() {
  295. history.back();
  296. },
  297. getUsers() {
  298. this.$axios.post("/user/getEmployeeList", {
  299. departmentId: -1,
  300. pageIndex: 1,
  301. pageSize: -1
  302. })
  303. .then(res => {
  304. if (res.code == "ok") {
  305. this.userList = res.data.records;
  306. this.showUserList = res.data.records
  307. } else {
  308. this.$toast.fail('获取失败');
  309. }
  310. }).catch(err => { this.$toast.clear(); });
  311. },
  312. getDepartmentList() {
  313. this.$axios.post("/department/list", {})
  314. .then(res => {
  315. if (res.code == "ok") {
  316. this.departmentList = res.data;
  317. } else {
  318. this.$toast.fail('获取失败');
  319. }
  320. }).catch(err => { this.$toast.clear(); });
  321. },
  322. userListSearch(val) {
  323. const { userNameNeedTranslate } = this.user
  324. if(!this.searchInputValue) {
  325. this.showUserList = JSON.parse(JSON.stringify(this.userList))
  326. return
  327. }
  328. if (userNameNeedTranslate != 1) {
  329. const newUserList = JSON.parse(JSON.stringify(this.userList))
  330. this.showUserList = newUserList.filter(item => item.name.indexOf(this.searchInputValue) != -1)
  331. }
  332. if (userNameNeedTranslate == 1) {
  333. this.$axios.post("/user/getEmployeeList", {
  334. departmentId: -1, pageIndex: 1, pageSize: 200,
  335. keyword: this.searchInputValue, status: '',
  336. roleId: '', cursor: '', onlyDirect: 0, matchingType: 0
  337. })
  338. .then(res => {
  339. if (res.code == "ok") {
  340. const dataList = res.data.records
  341. const userNameList = dataList.map(item => item.name)
  342. const newUserList = JSON.parse(JSON.stringify(this.userList))
  343. this.showUserList = newUserList.filter(item => userNameList.some(uItem => uItem.includes(item.name)))
  344. console.log(userNameList)
  345. } else {
  346. this.$toast.fail('搜索失败');
  347. }
  348. }).catch(err => { this.$toast.clear(); });
  349. }
  350. },
  351. selectUserConfirm() {
  352. console.log(this.selectPeopleVal)
  353. this.selectUserShow = false
  354. this.getReport()
  355. },
  356. selectUserClear(str) {
  357. if (str == 'user') {
  358. this.selectPeopleVal = {}
  359. }
  360. if (str == 'dept') {
  361. this.departmentText = '',
  362. this.selectDepartmentText = []
  363. }
  364. this.getReport()
  365. },
  366. treeNodeClick(item) {
  367. this.selectDepartmentText = [item]
  368. },
  369. treeBtn() {
  370. if (this.selectDepartmentText.length <= 0) {
  371. this.$toast('请选择部门');
  372. return
  373. }
  374. this.departmentText = this.selectDepartmentText[0].label
  375. this.selectDepartmentShow = false
  376. this.getReport()
  377. },
  378. // 时间转换
  379. format(date, pattern) {
  380. pattern = pattern || "yyyy-MM-dd";
  381. var _this = this;
  382. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  383. switch ($0.charAt(0)) {
  384. case 'y': return _this.padding(date.getFullYear(), $0.length);
  385. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  386. case 'd': return _this.padding(date.getDate(), $0.length);
  387. case 'w': return date.getDay() + 1;
  388. case 'h': return _this.padding(date.getHours(), $0.length);
  389. case 'm': return _this.padding(date.getMinutes(), $0.length);
  390. case 's': return _this.padding(date.getSeconds(), $0.length);
  391. }
  392. });
  393. },
  394. padding(s, len) {
  395. var len = len - (s + '').length;
  396. for (var i = 0; i < len; i++) { s = '0' + s; }
  397. return s;
  398. },
  399. // 改变时间
  400. changeTime(time) {
  401. this.nowTime = this.format(new Date(time), "yyyy-MM-dd");
  402. this.currentDate = time;
  403. this.showPicker = false;
  404. this.getReport();
  405. },
  406. // 获取日报
  407. getReport() {
  408. this.hasWaiting = false;
  409. const toast = this.$toast.loading({
  410. forbidClick: true,
  411. duration: 0
  412. });
  413. let pames = {
  414. date: this.nowTime,
  415. }
  416. if (this.selectPeopleVal.id) {
  417. pames.userId = this.selectPeopleVal.id
  418. }
  419. if (this.departmentText && this.selectDepartmentText.length > 0) {
  420. pames.deptId = this.selectDepartmentText[0].id
  421. }
  422. this.$axios.post("/report/getReportList", pames)
  423. .then(res => {
  424. if (res.code == "ok") {
  425. this.$toast.clear();
  426. this.report = res.data;
  427. //计算状态
  428. for (var i = 0; i < this.report.length; i++) {
  429. var item = this.report[i];
  430. if (item.state == 0) {
  431. this.hasWaiting = true;
  432. }
  433. }
  434. } else {
  435. this.$toast.clear();
  436. this.$toast.fail('获取失败:' + res.msg);
  437. }
  438. }).catch(err => { this.$toast.clear(); });
  439. },
  440. // 点击编辑
  441. editor(item) {
  442. var path = '/edit';
  443. if (this.user.timeType.enableNewWeeklyfill == 1) {
  444. //物奇要填到按周填报
  445. path = '/weekEdit';
  446. }
  447. this.$router.push({
  448. path: path,
  449. query: {
  450. date: this.nowTime
  451. }
  452. });
  453. },
  454. // 去填写日报
  455. toWriteReport() {
  456. var path = '/edit';
  457. if (this.user.timeType.enableNewWeeklyfill == 1) {
  458. //物奇要填到按周填报
  459. path = '/weekEdit';
  460. }
  461. this.$router.push({
  462. path: path,
  463. query: {
  464. date: this.nowTime
  465. }
  466. });
  467. }
  468. },
  469. mounted() {
  470. if (sessionStorage.targetDate != null) {
  471. this.nowTime = sessionStorage.targetDate;
  472. sessionStorage.removeItem('targetDate');
  473. }
  474. const { functionList } = this.user
  475. for (var i in functionList) {
  476. if (functionList[i].name == '查看全公司工时') {
  477. this.reportsCompany = true
  478. }
  479. if (functionList[i].name == '查看本部门工时') {
  480. this.查看本部门工时 = true
  481. }
  482. }
  483. this.getReport();
  484. this.getUsers()
  485. this.getDepartmentList()
  486. }
  487. };
  488. </script>
  489. <style lang="less" scoped>
  490. .login_form {
  491. margin-top: 46px;
  492. }
  493. .one_report {
  494. margin-bottom: 15px;
  495. font-size: 14px;
  496. }
  497. .one_report_select {
  498. margin-bottom: 15px;
  499. }
  500. .form_text {
  501. margin: 15px 0 15px;
  502. padding: 0 12px;
  503. }
  504. .form_btn {
  505. text-align: right;
  506. }
  507. .form_btn button {
  508. margin-left: 10px;
  509. }
  510. .one_report_data {
  511. margin-bottom: 10px;
  512. padding: 0 22px;
  513. div {
  514. line-height: 30px;
  515. }
  516. }
  517. .comPaceholder {
  518. margin: 10px 15px;
  519. background: #fff;
  520. padding: 10px 10px;
  521. border-radius: 6px;
  522. font-size: 14px;
  523. color: #606266;
  524. }
  525. .comTree {
  526. background: #ffffff;
  527. }
  528. </style>
  529. <style lang="less">
  530. .van-nav-bar .van-icon,
  531. .van-nav-bar__text {
  532. color: #20a0ff;
  533. }
  534. .button {
  535. float: right;
  536. width: 80px;
  537. height: 25px;
  538. line-height: 25px;
  539. text-align: center;
  540. border: 1px solid red;
  541. color: red;
  542. box-sizing: border-box;
  543. border-radius: 10px;
  544. font-size: 14px;
  545. display: flex;
  546. justify-content: center;
  547. align-items: center;
  548. }
  549. .foot {
  550. width: 100%;
  551. display: flex;
  552. justify-content: end;
  553. }
  554. .bottom-button {
  555. width: 160px;
  556. height: 40px;
  557. background-color: rgb(53, 130, 245);
  558. border-color: rgb(53, 130, 245);
  559. }
  560. .clearSeach {
  561. line-height: 0.64rem;
  562. position: relative;
  563. left: 5px;
  564. }
  565. .userNameValue {
  566. white-space: nowrap;
  567. text-overflow: ellipsis;
  568. }
  569. </style>