daily.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-date-picker v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" @change="changeMonthOut" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
  8. </el-form-item>
  9. </el-form>
  10. </el-col> -->
  11. <!--列表-->
  12. <div>
  13. <el-card class="box-card daily" shadow="never" >
  14. <div slot="header" class="clearfix">
  15. <el-date-picker size="small" v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" @change="changeMonthOut" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
  16. <span >
  17. <span>日期:</span>
  18. <span v-for="(item,index) in allDate" :id="'day'+index" :class="index==choseDay?'chooseDate date_item':'date_item'"
  19. @click="choseDate(index)" :key="index">{{item}}</span>
  20. </span>
  21. </div>
  22. <div>
  23. <div style="float:left;width:200px;" v-if="user.role == 1">
  24. <div>
  25. <el-select v-model="selectState" size="small" @change="stateChange">
  26. <el-option value="-1" label="全部状态" >全部状态</el-option>
  27. <el-option value="-2" label="未填报">未填报</el-option>
  28. <el-option value="1" label="已通过">已通过</el-option>
  29. <el-option value="0" label="待审核">待审核</el-option>
  30. <el-option value="2" label="不通过">不通过</el-option>
  31. </el-select></div>
  32. <div>
  33. <el-tree :data="data" @node-click="handleNodeClick" >
  34. <span class="custom-tree-node" slot-scope="{ node, data}">
  35. <span>{{ node.label }}</span>
  36. <span v-if="data.membCount != null && data.isUser == null">({{data.membCount}})</span>
  37. <div style="width:0%;float:right;">
  38. <span v-if="data.isUser == 1 && data.state == null" style="color:red;">
  39. 未填报
  40. </span>
  41. <span v-if="data.isUser == 1 && data.state == 0" style="color:orange;">
  42. 待审核
  43. </span>
  44. <span v-if="data.isUser == 1 && data.state == 1" style="color:green;">
  45. 已通过
  46. </span>
  47. <span v-if="data.isUser == 1 && data.state == 2" style="color:red;">
  48. 未通过
  49. </span>
  50. </div>
  51. </span>
  52. </el-tree>
  53. </div>
  54. </div>
  55. <div :style="'height:'+tableHeight+'px;width:0.5px;background:#eee;margin-right:10px;float:left;'" ></div>
  56. <div class="allDaily" style="float:left;">
  57. <div class="report_title"><span>工作日报 | {{depData.label}}</span> - 已填写<span style="margin-left:5px;margin-right:5px;color:red;">{{reportList.length}}</span>人,
  58. 未填写<span style="margin-left:5px;margin-right:5px;color:red;">{{(depData == null?data[0].membCount:(depData.isUser == 1?1:depData.membCount))-reportList.length}}</span>人
  59. <span style="float:right;">
  60. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1)">填写日报</el-link>
  61. <el-link type="primary" style="margin-right:10px;" :underline="false" v-if="user.role != 0" @click="exportReport">导出日报</el-link>
  62. <el-link type="primary" style="margin-right:10px;" :underline="false" v-if="user.role != 0" @click="batchApprove">批量审核</el-link>
  63. </span>
  64. </div>
  65. <div style="height:490px;overflow:scroll;padding-top:10px;">
  66. <div class="one_daily" v-for="(item1,index1) in reportList" :key="index1">
  67. <i class="fa fa-circle"></i>{{item1.name}}
  68. <span style="margin-left:30px;">
  69. <span style="margin-right:20px;">
  70. <!-- <i v-if="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5" style="color:red;margin-right:8px;" class="fa fa-exclamation-triangle"></i> -->
  71. 工作总时长:
  72. <!-- <span :style="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5?'color:red':''">{{item1.reportTime}}h</span> -->
  73. <span >{{item1.reportTime}}</span>h
  74. <span style="margin-left:10px;">成本:</span>
  75. <span >{{item1.cost}}</span>元
  76. </span>
  77. <!-- <el-link v-if="user.role != 0" type="primary" :underline="false" @click="junpToDeskTop(item1.id)">系统智能统计:{{item1.calculateTime}}h</el-link>
  78. <span v-else>系统智能统计:{{item1.calculateTime}}h</span> -->
  79. <span style="margin-left:15px;color:#DAA520;" v-if="item1.state == 0">[ 待审核 ]</span>
  80. <span style="margin-left:15px;color:#32CD32;" v-else-if="item1.state == 1">[ 已通过 ]</span>
  81. <span style="margin-left:15px;color:#FF0000;" v-else-if="item1.state == 2">[ 已驳回 ]</span>
  82. </span>
  83. <div class="checkbtn">
  84. <el-button v-if="user.role != 0 && item1.state == 0" type="primary" :loading="logining" size="small" @click="approve(item1.id)">通过</el-button>
  85. <el-button v-if="user.role != 0 && item1.state == 0" type="danger" :loading="logining" size="small" @click="deny(item1.id,0)">驳回</el-button>
  86. <el-button v-if="user.role != 0 && item1.state == 1" type="danger" :loading="logining" size="small" @click="deny(item1.id,1)">撤销</el-button>
  87. <el-button v-if="item1.state == 2 && user.id == item1.id" type="primary" size="small" @click="fillInReport(index1)">编辑日报</el-button>
  88. </div>
  89. <div class="one_daily_body">
  90. <el-timeline>
  91. <el-timeline-item v-for="(item2,index2) in item1.data" :key="index2">
  92. <el-card shadow="never">
  93. <p>项目:<b>{{item2.project}}</b></p>
  94. <p>时长:{{item2.time}}h ({{typeList[item2.timeType]}})</p>
  95. <p>事项:<span v-html="item2.content"></span></p>
  96. </el-card>
  97. </el-timeline-item>
  98. </el-timeline>
  99. </div>
  100. </div>
  101. <!-- 简陋的无报告提示 -->
  102. <div v-if="reportList.length==0" style="width:800px;font-size:17px;text-align:center;color:#aaa;">今日暂无报告</div>
  103. </div>
  104. </div>
  105. </div>
  106. </el-card>
  107. </div>
  108. <!-- 填写日报的dialog -->
  109. <el-dialog title="填写日报" :visible.sync="dialogVisible" width="60%">
  110. <el-form ref="workForm" :model="workForm" :rules="workRules" label-width="100px">
  111. <el-form-item label="工作日期" prop="createDate">
  112. <el-date-picker v-model="workForm.createDate" :editable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  113. @change="changeMonth()" :clearable="false" type="date" placeholder="选择工作日期" :disabled="isDisable"></el-date-picker>
  114. </el-form-item>
  115. <!-- <el-form-item label="待分配时长" prop="name">
  116. <span>{{report.time}}h</span>
  117. <el-link type="primary" :underline="false" @click="addDomain" style="margin-left:40px">添加项目</el-link>
  118. </el-form-item> -->
  119. <div v-for="(domain, index) in workForm.domains" :key="domain.id">
  120. <el-form-item label="工作时间" :prop="'domains.' + index + '.timeType'"
  121. :rules="{ required: true, message: '请选择工作时间', trigger: 'blur' }">
  122. <!-- <el-input v-model.number="domain.workingTime" placeholder="请输入投入时长" type='number' clearable style="width:200px;"
  123. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)"></el-input> -->
  124. <el-select v-model="domain.timeType" placeholder="请选择工作时间"
  125. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)"
  126. @change="onTimeTypeChange(domain.timeType)">
  127. <el-option
  128. v-for="item in timeType"
  129. :key="item.value"
  130. :label="item.label"
  131. :value="item.value">
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item label="投入项目" :prop="'domains.' + index + '.projectId'"
  136. :rules="{ required: true, message: '请选择投入项目', trigger: ['change','blur'] }">
  137. <el-select v-model="domain.projectId" placeholder="请选择" style="width:200px;"
  138. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)">
  139. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  140. </el-select>
  141. <el-link v-if="index >= 1" type="primary" :underline="false" @click="delDomain(index)" style="float:right;margin-right:10px;"
  142. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)">
  143. <i class="fa fa-trash" style="color: red;;font-size:18px;"></i>
  144. </el-link>
  145. </el-form-item>
  146. <el-form-item label="工作事项" :prop="'domains.' + index + '.content'" >
  147. <el-input v-model="domain.content" type="textarea" :rows="4" placeholder="请输入投入时长" clearable
  148. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)"></el-input>
  149. </el-form-item>
  150. <el-divider v-if="workForm.domains.length>1"></el-divider>
  151. </div>
  152. <el-link v-if="showAddMore" type="primary" :underline="false" @click="addDomain" style="margin-left:40px">添加更多</el-link>
  153. </el-form>
  154. <span slot="footer" class="dialog-footer">
  155. <el-button @click="dialogVisible = false">取消</el-button>
  156. <el-button type="primary" @click="submitDepartment"
  157. :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)" >提交</el-button>
  158. </span>
  159. </el-dialog>
  160. <!-- 批量日报审核 -->
  161. <el-dialog title="批量日报审核" :visible.sync="approveDialogVisible" width="500px">
  162. <el-checkbox v-model="isAllSelect" label="全选" style="margin-left:24px;" @change="selectAll" v-if="batchShowData.length > 0"></el-checkbox>
  163. <el-tree ref="approveTree" node-key="id" :data="batchShowData" show-checkbox="true" @check-change="handleCheckChange" >
  164. </el-tree>
  165. <span slot="footer" class="dialog-footer">
  166. <el-button @click="approveDialogVisible = false">取消</el-button>
  167. <el-button type="primary" @click="submitBatchApprove" :disabled="batchShowData.length == 0">审核通过</el-button>
  168. </span>
  169. </el-dialog>
  170. </section>
  171. </template>
  172. <script>
  173. import util from "../../common/js/util";
  174. export default {
  175. data() {
  176. return {
  177. isAllSelect: false,
  178. approveDialogVisible:false,
  179. deptId:null,
  180. targetUid: null,
  181. membCount:0,
  182. selectState:"-1",
  183. user: JSON.parse(sessionStorage.getItem("user")),
  184. showAddMore:false,
  185. allDate: [],
  186. typeList:['全天','上午','下午'],
  187. date: sessionStorage.msg?sessionStorage.msg.split('-')[0]+"-"+sessionStorage.msg.split('-')[1]:util.formatDate.format(new Date(new Date()), "yyyy-MM"),
  188. choseDay: 0,
  189. tableHeight: 0,
  190. listLoading: false,
  191. projectList: [], //项目列表
  192. reportList: [], //日报列表
  193. dialogVisible: false, //项目弹窗
  194. report: '',
  195. workForm: {
  196. createDate: sessionStorage.msg?sessionStorage.msg:util.formatDate.format(new Date(new Date()), "yyyy-MM-dd"),
  197. domains: [{
  198. id: null,
  199. projectId: "",
  200. workingTime: "",
  201. timeType:0,
  202. content: "",
  203. state: 2,
  204. }],
  205. },
  206. workRules: {
  207. createDate: [{ required: true, message: "请选择工作日期", trigger: "change" }],
  208. },
  209. logining: false,
  210. isDisable: false,
  211. timeType:[],
  212. //部门人员树状结构
  213. data: [
  214. {
  215. id: -1,
  216. label: '全部人员',
  217. membCount:0
  218. },
  219. {
  220. id: 0,
  221. label: '未分配',
  222. }
  223. ],
  224. allData:{},
  225. batchShowData:{},
  226. option: [],
  227. depData: {
  228. id: -1,
  229. label: '全部人员',
  230. },
  231. defaultProps: {
  232. children: 'children',
  233. label: 'label'
  234. },
  235. };
  236. },
  237. methods: {
  238. //提交批量审核数据
  239. submitBatchApprove() {
  240. console.log(this.$refs.approveTree.getCheckedNodes());
  241. var data = this.$refs.approveTree.getCheckedNodes();
  242. var ids = '';
  243. if (data.length == 0) {
  244. this.$message({
  245. message: '请选择要审核的人员',
  246. type: "error"
  247. });
  248. return;
  249. }
  250. for (var i=0;i<data.length; i++) {
  251. ids += data[i].id;
  252. if (i < data.length-1) {
  253. ids += ',';
  254. }
  255. }
  256. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  257. this.http.post("/report/batchApproveReport", {ids:ids, date:this.date + day},
  258. res => {
  259. if (res.code == "ok") {
  260. this.$message({
  261. message: '审核成功',
  262. type: "success"
  263. });
  264. this.getReportList();
  265. this.getDepartment();
  266. this.approveDialogVisible = false;
  267. } else {
  268. this.$message({
  269. message: res.msg,
  270. type: "error"
  271. });
  272. }
  273. },
  274. error => {
  275. this.$message({
  276. message: error,
  277. type: "error"
  278. });
  279. });
  280. },
  281. selectAll() {
  282. if (this.isAllSelect) {
  283. var keys = [];
  284. this.batchShowData.forEach(b=>{
  285. keys.push(b.id);
  286. })
  287. this.$refs.approveTree.setCheckedKeys(keys);
  288. } else {
  289. this.$refs.approveTree.setCheckedKeys([]);
  290. }
  291. },
  292. //批量审核
  293. batchApprove() {
  294. this.approveDialogVisible = true;
  295. console.log(this.allData);
  296. this.batchShowData = JSON.parse(JSON.stringify(this.allData));
  297. //去掉全部人员
  298. this.batchShowData.splice(0,1);
  299. //过滤。只显示待审核的
  300. this.filterState(0, this.batchShowData);
  301. this.calculateMembCount(this.batchShowData);
  302. //去掉空的部门
  303. this.removeEmptyNode(this.batchShowData);
  304. },
  305. removeEmptyNode(list) {
  306. for (var i=0;i<list.length;i++) {
  307. var cnt = 0;
  308. if (list[i].membCount == 0) {
  309. list.splice(i, 1);
  310. i--;
  311. } else if (list[i].children != null) {
  312. this.removeEmptyNode(list[i].children);
  313. }
  314. }
  315. },
  316. calculateMembCount(list) {
  317. for (var i in list) {
  318. var cnt = 0;
  319. if (list[i].children != null) {
  320. this.calculateMembCount(list[i].children);
  321. for (var m in list[i].children) {
  322. cnt += list[i].children[m].membCount;
  323. }
  324. }
  325. if (list[i].isUser == 1) {
  326. cnt++;
  327. this.membCount++;
  328. }
  329. list[i].membCount = cnt;
  330. }
  331. },
  332. stateChange() {
  333. this.membCount = 0;
  334. if (this.selectState == -1) {
  335. //全部状态
  336. this.data = this.allData;
  337. } else {
  338. //未填报
  339. var newData = JSON.parse(JSON.stringify(this.allData));
  340. this.filterState(this.selectState, newData);
  341. this.data = newData;
  342. }
  343. this.calculateMembCount(this.data);
  344. this.data[0].membCount = this.membCount;//总人数
  345. },
  346. //按状态过滤部门人员
  347. filterState(state, list) {
  348. for (var i =0;i<list.length; i++) {
  349. var obj = list[i];
  350. if (obj.isUser == 1) {
  351. var match = false;
  352. if (state == -2) {
  353. if (obj.state == null) {
  354. match = true;
  355. }
  356. } else {
  357. if (obj.state == state) {
  358. match = true;
  359. }
  360. }
  361. if (!match) {
  362. console.log("不匹配,删除="+obj.label+', state='+obj.state);
  363. list.splice(i, 1);
  364. i--;
  365. } else {
  366. console.log("匹配"+obj.label);
  367. }
  368. } else {
  369. if (obj.children != null) {
  370. this.filterState(state, obj.children);
  371. }
  372. }
  373. }
  374. },
  375. // 部门列表点击
  376. handleNodeClick(data) {
  377. console.log(data);
  378. // if(this.depData == null || data.id != this.depData.id) {
  379. // this.depData = data;
  380. // //this.getUser();
  381. // }
  382. this.depData = data;
  383. if (data.id == -1) {
  384. this.deptId = null;
  385. this.targetUid = null;
  386. } else if (data.isUser == 1) {
  387. this.deptId = null;
  388. this.targetUid = data.id;
  389. } else {
  390. this.deptId = data.id;
  391. this.targetUid = null;
  392. }
  393. this.getReportList();
  394. },
  395. // 获取部门列表
  396. getDepartment() {
  397. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  398. this.http.post("/report/getMembList", {date:this.date + day},
  399. res => {
  400. if (res.code == "ok") {
  401. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  402. list.splice(0,0,{
  403. id: -1,
  404. label: '全部人员',
  405. })
  406. list.push({
  407. id: 0,
  408. label: '未分配',
  409. })
  410. this.membCount = 0;
  411. //设置员工到部门下面
  412. this.setUserToDept(list);
  413. this.data = list;
  414. this.allData = list;
  415. this.option = this.changeArr(list1);
  416. list[0].membCount = this.membCount;
  417. if (this.depData.id == -1) {
  418. this.depData.membCount = this.membCount;
  419. }
  420. } else {
  421. this.$message({
  422. message: res.msg,
  423. type: "error"
  424. });
  425. }
  426. },
  427. error => {
  428. this.$message({
  429. message: error,
  430. type: "error"
  431. });
  432. });
  433. },
  434. setUserToDept(list) {
  435. for (var i in list) {
  436. var cnt = 0;
  437. if (list[i].children != null) {
  438. this.setUserToDept(list[i].children);
  439. for (var m in list[i].children) {
  440. cnt += list[i].children[m].membCount;
  441. }
  442. }
  443. if (list[i].userList != null) {
  444. if (list[i].children == null) {
  445. list[i].children = [];
  446. }
  447. list[i].userList.forEach(element => {
  448. var obj = {id: element.id, label:element.name, state:element.state, parentId:element.departmentId, isUser:1};
  449. list[i].children.push(obj);
  450. this.membCount++;
  451. cnt++;
  452. });
  453. }
  454. list[i].membCount = cnt;
  455. }
  456. },
  457. // 修改数组
  458. changeArr(arr) {
  459. for (var i = 0; i < arr.length; i++) {
  460. if(arr[i].id != -1 && arr[i].id != 0) {
  461. if (arr[i].children != null && arr[i].children.length>0) {
  462. arr[i].children = this.changeArr(arr[i].children);
  463. }
  464. arr[i].id && (arr[i].value = arr[i].id);
  465. delete arr[i].id;
  466. }
  467. }
  468. for(var i in arr) {
  469. if(arr[i].id == -1 || arr[i].id == 0) {
  470. arr.splice(i,1)
  471. }
  472. }
  473. return arr;
  474. },
  475. //时间段范围设置改动,监听
  476. onTimeTypeChange(timeType) {
  477. this.showAddMore = true;
  478. console.log("======" + timeType);
  479. for(var i in this.workForm.domains) {
  480. if (this.workForm.domains[i].timeType == 0) {
  481. this.showAddMore = false;
  482. break;
  483. }
  484. }
  485. if (this.showAddMore) {
  486. //检测数量
  487. if (this.workForm.domains.length == 2) {
  488. this.showAddMore = false;
  489. } else {
  490. this.showAddMore = true;
  491. }
  492. }
  493. },
  494. getTimeType() {
  495. this.http.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId},
  496. res => {
  497. if (res.code == "ok") {
  498. var t = res.data;
  499. //转化时间格式
  500. if (t.allday != null) {
  501. this.timeType.push({value:0, label:'全天 - '+t.allday+'小时', hours:t.allday});
  502. }
  503. if (t.am != null) {
  504. this.timeType.push({value:1, label:'上午 - '+t.am+'小时', hours: t.am});
  505. }
  506. if (t.pm != null) {
  507. this.timeType.push({value:2, label:'上午 - '+t.pm+'小时', hours: t.pm});
  508. }
  509. } else {
  510. this.$message({
  511. message: res.msg,
  512. type: "error"
  513. });
  514. }
  515. },
  516. error => {
  517. this.listLoading = false;
  518. this.$message({
  519. message: error,
  520. type: "error"
  521. });
  522. });
  523. },
  524. // 改变月份
  525. changeMonthOut() {
  526. console.log(sessionStorage.msg)
  527. this.getAllDate();
  528. this.getReportList();
  529. this.getDepartment();
  530. },
  531. // 选择日期
  532. choseDate(i) {
  533. this.choseDay = i;
  534. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  535. sessionStorage.msg = this.date + day,
  536. this.getReportList();
  537. this.getDepartment();
  538. },
  539. // 获取日期列表
  540. getAllDate() {
  541. var dayArry = [];
  542. var day = this.getCountDays();
  543. for (var k = 1; k <= day; k++) {
  544. var str = new Date(this.date.replace(/-/g, "/")).getMonth() + 1 + "月" + k + "日";
  545. if ( new Date(this.date.replace(/-/g, "/")).getFullYear() == new Date(new Date()).getFullYear() &&
  546. new Date(this.date.replace(/-/g, "/")).getMonth() == new Date(new Date()).getMonth()) {
  547. if(sessionStorage.msg) {
  548. if(parseInt(sessionStorage.msg.split("-")[2]) == k) {
  549. this.choseDay = k - 1;
  550. }
  551. } else {
  552. if (new Date().getDate() == k) {
  553. this.choseDay = k - 1;
  554. }
  555. }
  556. } else {
  557. this.choseDay = 0;
  558. }
  559. dayArry.push(str);
  560. }
  561. this.allDate = dayArry;
  562. },
  563. getCountDays() {
  564. var newstr = this.date.replace(/-/g, "/");
  565. var curDate = new Date(newstr);
  566. var curMonth = curDate.getMonth();
  567. curDate.setMonth(curMonth + 1);
  568. curDate.setDate(0);
  569. return curDate.getDate();
  570. },
  571. //获取日报列表
  572. getReportList() {
  573. this.listLoading = true;
  574. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  575. let param = {date: this.date + day};
  576. if (this.deptId != null) {
  577. param.deptId = this.deptId;
  578. }
  579. if (this.targetUid != null) {
  580. param.userId = this.targetUid;
  581. }
  582. this.http.post( this.port.report.list, param,
  583. res => {
  584. this.listLoading = false;
  585. if (res.code == "ok") {
  586. this.reportList = res.data;
  587. document.querySelector("#day"+this.choseDay).scrollIntoView(true);
  588. } else {
  589. this.$message({
  590. message: res.msg,
  591. type: "error"
  592. });
  593. }
  594. },
  595. error => {
  596. this.listLoading = false;
  597. this.$message({
  598. message: error,
  599. type: "error"
  600. });
  601. });
  602. },
  603. //导出日报
  604. exportReport() {
  605. if (this.reportList.length > 0) {
  606. this.listLoading = true;
  607. //首先处理日期
  608. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  609. this.http.post( this.port.report.export, { date: this.date + day },
  610. res => {
  611. this.listLoading = false;
  612. if (res.code == "ok") {
  613. location.href = res.data;
  614. } else {
  615. this.$message({
  616. message: res.msg,
  617. type: "error"
  618. });
  619. }
  620. },
  621. error => {
  622. this.listLoading = false;
  623. this.$message({
  624. message: error,
  625. type: "error"
  626. });
  627. });
  628. } else {
  629. this.$message({
  630. message: "当天没有报告 无法导出",
  631. type: "info"
  632. });
  633. }
  634. },
  635. //获取项目列表
  636. getProjectList() {
  637. this.listLoading = true;
  638. this.http.post( this.port.project.list, {},
  639. res => {
  640. this.listLoading = false;
  641. if (res.code == "ok") {
  642. this.projectList = res.data;
  643. } else {
  644. this.$message({
  645. message: res.msg,
  646. type: "error"
  647. });
  648. }
  649. },
  650. error => {
  651. this.listLoading = false;
  652. this.$message({
  653. message: error,
  654. type: "error"
  655. });
  656. });
  657. },
  658. // 获取个人某天的日报
  659. getReport(i) {
  660. this.http.post( this.port.report.getPort, {
  661. date: this.workForm.createDate
  662. },
  663. res => {
  664. if (res.code == "ok") {
  665. var list = res.data;
  666. this.report = list;
  667. if(list.report.length != 0) {
  668. var arr = [];
  669. for(var i in list.report) {
  670. arr.push({
  671. id: list.report[i].id,
  672. projectId: list.report[i].projectId,
  673. workingTime: list.report[i].workingTime,
  674. content: list.report[i].content,
  675. state: list.report[i].state,
  676. timeType: list.report[i].timeType
  677. })
  678. }
  679. this.workForm = {
  680. createDate: this.workForm.createDate,
  681. domains: arr,
  682. }
  683. } else {
  684. this.workForm = {
  685. createDate: this.workForm.createDate,
  686. domains: [{
  687. id: null,
  688. projectId: "",
  689. workingTime: "",
  690. content: "",
  691. state: 2,
  692. timeType:0,
  693. }],
  694. }
  695. }
  696. } else {
  697. this.$message({
  698. message: res.msg,
  699. type: "error"
  700. });
  701. }
  702. },
  703. error => {
  704. this.$message({
  705. message: error,
  706. type: "error"
  707. });
  708. });
  709. },
  710. // 打开日报填写
  711. fillInReport(i) {
  712. if(i == -1) {
  713. this.isDisable = false;
  714. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  715. this.workForm.createDate = this.date + day;
  716. } else {
  717. this.isDisable = true;
  718. }
  719. this.getReport(i);
  720. this.dialogVisible = true;
  721. },
  722. // 添加模块
  723. addDomain() {
  724. this.workForm.domains.push({
  725. projectId: "",
  726. workingTime: "",
  727. content: "",
  728. });
  729. //检测时间段数量,达到2个,不能再加了
  730. var length = this.workForm.domains.length;
  731. if (length == 2) {
  732. this.showAddMore = false;
  733. }
  734. },
  735. // 移除模块
  736. delDomain(i) {
  737. this.workForm.domains.splice(i,1)
  738. //检测当前剩下的一个,时间类型是否是全天
  739. if (this.workForm.domains[0].timeType == 0) {
  740. this.showAddMore = false;
  741. } else {
  742. this.showAddMore = true;
  743. }
  744. },
  745. // 改变月份
  746. changeMonth() {
  747. this.getReport()
  748. },
  749. // 保存日报
  750. submitDepartment() {
  751. this.$refs.workForm.validate(valid => {
  752. if (valid) {
  753. //检查时间,全天和上下午不能同时存在
  754. var alldayNum = 0;
  755. var amNum = 0;
  756. var pmNum = 0;
  757. for(var i in this.workForm.domains) {
  758. if (this.workForm.domains[i].timeType == 0) {
  759. alldayNum ++;
  760. } else if (this.workForm.domains[i].timeType == 1) {
  761. amNum++;
  762. } else if (this.workForm.domains[i].timeType == 2) {
  763. pmNum++;
  764. }
  765. }
  766. if (alldayNum > 1) {
  767. this.$message({
  768. message: "工作时间-全天,只能选择一次",
  769. type: "error"
  770. });
  771. return;
  772. }
  773. if (amNum > 1) {
  774. this.$message({
  775. message: "工作时间-上午,只能选择一次",
  776. type: "error"
  777. });
  778. return;
  779. }
  780. if (pmNum > 1) {
  781. this.$message({
  782. message: "工作时间-下午,只能选择一次",
  783. type: "error"
  784. });
  785. return;
  786. }
  787. if (alldayNum == 1 && (amNum > 0 || pmNum > 0)) {
  788. this.$message({
  789. message: "工作时间-全天,不能和上下午同时存在",
  790. type: "error"
  791. });
  792. return;
  793. }
  794. this.listLoading = true;
  795. let formData = new FormData();
  796. for(var i in this.workForm.domains) {
  797. if (this.workForm.domains[i].id != null) {
  798. formData.append("id", this.workForm.domains[i].id);
  799. } else {
  800. formData.append("id", -1);
  801. }
  802. formData.append("projectId", this.workForm.domains[i].projectId);
  803. formData.append("timeType", this.workForm.domains[i].timeType);
  804. var workingTime = this.timeType.filter(t=>t.value == this.workForm.domains[i].timeType)[0].hours;
  805. formData.append("workingTime", workingTime);
  806. if (this.workForm.domains[i].content == null || this.workForm.domains[i].content == '') {
  807. formData.append("content", '-');
  808. } else {
  809. formData.append("content", this.workForm.domains[i].content);
  810. }
  811. formData.append("createDate", this.workForm.createDate);
  812. }
  813. this.http.uploadFile( this.port.report.editPort, formData,
  814. res => {
  815. this.listLoading = false;
  816. if (res.code == "ok") {
  817. this.$message({
  818. message: "填报成功",
  819. type: "success"
  820. });
  821. this.dialogVisible = false;
  822. this.getReportList();
  823. this.getDepartment();
  824. } else {
  825. this.$message({
  826. message: res.msg,
  827. type: "error"
  828. });
  829. }
  830. },
  831. error => {
  832. this.listLoading = false;
  833. this.$message({
  834. message: error,
  835. type: "error"
  836. });
  837. });
  838. }
  839. });
  840. },
  841. // 跳转
  842. junpToDeskTop(id) {
  843. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  844. this.$router.push("/desktop/" + id + "/" + this.date +day);
  845. },
  846. // 通过日报
  847. approve(id) {
  848. this.logining = true;
  849. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  850. this.http.post( this.port.report.approve, {id: id , date: this.date +day},
  851. res => {
  852. this.logining = false;
  853. if (res.code == "ok") {
  854. this.$message({
  855. message: "审核成功",
  856. type: "success"
  857. });
  858. this.getReportList();
  859. this.getDepartment();
  860. } else {
  861. this.$message({
  862. message: res.msg,
  863. type: "error"
  864. });
  865. }
  866. },
  867. error => {
  868. this.logining = false;
  869. this.$message({
  870. message: error,
  871. type: "error"
  872. });
  873. });
  874. },
  875. // 未通过日报
  876. deny(id,i) {
  877. this.logining = true;
  878. let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  879. this.http.post( this.port.report.deny, {id: id , date: this.date +day},
  880. res => {
  881. this.logining = false;
  882. if (res.code == "ok") {
  883. this.$message({
  884. message: i==0?"驳回成功":"撤销成功",
  885. type: "success"
  886. });
  887. this.getReportList();
  888. this.getDepartment();
  889. } else {
  890. this.$message({
  891. message: res.msg,
  892. type: "error"
  893. });
  894. }
  895. },
  896. error => {
  897. this.logining = false;
  898. this.$message({
  899. message: error,
  900. type: "error"
  901. });
  902. });
  903. }
  904. },
  905. created() {
  906. let height = window.innerHeight;
  907. this.tableHeight = height - 233;
  908. const that = this;
  909. window.onresize = function temp() {
  910. that.tableHeight = window.innerHeight - 233;
  911. };
  912. },
  913. mounted() {
  914. this.getAllDate();
  915. this.getReportList();
  916. this.getProjectList();
  917. this.getTimeType();
  918. this.getDepartment();
  919. }
  920. };
  921. </script>
  922. <style lang="scss" scoped>
  923. .allDaily {
  924. width:82%;
  925. }
  926. .report_title {
  927. padding:10px 0;
  928. }
  929. .clearfix {
  930. overflow-x: auto;
  931. white-space: nowrap;
  932. padding: 15px 0;
  933. .date_item {
  934. padding: 0 15px;
  935. cursor: pointer;
  936. }
  937. .chooseDate {
  938. color: #20a0ff;
  939. }
  940. }
  941. .one_daily {
  942. i {
  943. color: #9ed0ff;
  944. margin-right: 5px;
  945. }
  946. .one_daily_body {
  947. padding: 15px 0px;
  948. p {
  949. margin: 0;
  950. line-height: 30px;
  951. }
  952. }
  953. ul {
  954. padding: 0;
  955. }
  956. }
  957. .checkbtn {
  958. float: right;
  959. margin-top: -10px;
  960. }
  961. </style>
  962. <style lang="scss">
  963. .daily {
  964. .el-card__body {
  965. height: 80%;
  966. overflow-y: auto;
  967. }
  968. .el-card__header {
  969. padding: 0 20px;
  970. }
  971. }
  972. </style>
  973. <style scoped>
  974. /* 项目标签的样式 */
  975. .el-tag + .el-tag {
  976. margin-left: 10px;
  977. }
  978. .button-new-tag {
  979. margin-left: 10px;
  980. height: 32px;
  981. line-height: 30px;
  982. padding-top: 0;
  983. padding-bottom: 0;
  984. }
  985. .input-new-tag {
  986. width: 90px;
  987. margin-left: 10px;
  988. vertical-align: bottom;
  989. }
  990. </style>