daily.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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
  8. v-model="date"
  9. :editable="false"
  10. format="yyyy-MM"
  11. value-format="yyyy-MM"
  12. @change="changeMonth()"
  13. :clearable="false"
  14. type="month"
  15. placeholder="选择月份"
  16. ></el-date-picker>
  17. </el-form-item>
  18. <el-form-item style="float:right;">
  19. <el-link type="primary" :underline="false" @click="exportReport">导出日报</el-link>
  20. </el-form-item>
  21. <!-- <el-form-item style="float:right;">
  22. <el-link type="primary" :underline="false" @click="projectDialogVisible=true">项目管理</el-link>
  23. </el-form-item> -->
  24. </el-form>
  25. </el-col>
  26. <!--列表-->
  27. <div>
  28. <el-card class="box-card daily" shadow="never" :style="'height:'+tableHeight +'px'">
  29. <div slot="header" class="clearfix">
  30. <span>日期:</span>
  31. <span
  32. v-for="(item,index) in allDate"
  33. :id="'day'+index"
  34. :class="index==choseDay?'chooseDate date_item':'date_item'"
  35. @click="choseDate(index)"
  36. :key="index"
  37. >{{item}}</span>
  38. </div>
  39. <div class="allDaily">
  40. <div class="one_daily" v-for="(item1,index1) in reportList" :key="index1">
  41. <el-link>
  42. <i class="fa fa-circle"></i>
  43. {{item1.name}}
  44. </el-link>
  45. <div class="one_daily_body">
  46. <el-timeline>
  47. <el-timeline-item v-for="(item2,index2) in item1.data" :key="index2">
  48. <el-card shadow="never">
  49. <p>
  50. 项目:
  51. <b>{{item2.project}}</b>
  52. </p>
  53. <p>时长:{{item2.time}}h</p>
  54. <p>
  55. 事项:
  56. <span v-html="item2.content"></span>
  57. </p>
  58. </el-card>
  59. </el-timeline-item>
  60. </el-timeline>
  61. </div>
  62. </div>
  63. <!-- 简陋的无报告提示 -->
  64. <span v-if="reportList.length==0">本日暂无报告</span>
  65. </div>
  66. </el-card>
  67. </div>
  68. <!-- 项目管理的dialog -->
  69. <el-dialog title="项目管理" :visible.sync="projectDialogVisible" width="50%">
  70. <!-- 现在原生的CSS 有按钮跳动和下边距的问题 -->
  71. <div>
  72. <el-tag
  73. :key="index"
  74. v-for="(item,index) in projectList"
  75. closable
  76. :disable-transitions="false"
  77. @close="handleClose(item)"
  78. >{{item.projectName}}</el-tag>
  79. <el-input
  80. class="input-new-tag"
  81. v-if="inputVisible"
  82. v-model="inputValue"
  83. ref="saveTagInput"
  84. size="small"
  85. @keyup.enter.native="handleInputConfirm"
  86. @blur="handleInputConfirm"
  87. ></el-input>
  88. <el-button v-else class="button-new-tag" size="small" @click="showInput">新增项目</el-button>
  89. </div>
  90. <span slot="footer" class="dialog-footer">
  91. <el-button @click="projectDialogVisible = false">关闭</el-button>
  92. </span>
  93. </el-dialog>
  94. </section>
  95. </template>
  96. <script>
  97. import util from "../../common/js/util";
  98. export default {
  99. data() {
  100. return {
  101. user: JSON.parse(sessionStorage.getItem("user")),
  102. allDate: [],
  103. date: util.formatDate.format(new Date(new Date()), "yyyy-MM"),
  104. choseDay: 0,
  105. tableHeight: 0,
  106. listLoading: false,
  107. projectList: [], //项目列表
  108. reportList: [], //日报列表
  109. projectDialogVisible: false, //项目弹窗
  110. inputVisible: false, //项目新增输入
  111. inputValue: "" //项目新增值
  112. };
  113. },
  114. methods: {
  115. changeMonth() {
  116. this.getAllDate();
  117. this.getReportList();
  118. },
  119. choseDate(i) {
  120. this.choseDay = i;
  121. this.getReportList();
  122. },
  123. getAllDate() {
  124. var dayArry = [];
  125. var day = this.getCountDays();
  126. for (var k = 1; k <= day; k++) {
  127. var str =
  128. new Date(this.date.replace(/-/g, "/")).getMonth() +
  129. 1 +
  130. "月" +
  131. k +
  132. "日";
  133. if (
  134. new Date(this.date.replace(/-/g, "/")).getFullYear() ==
  135. new Date(new Date()).getFullYear() &&
  136. new Date(this.date.replace(/-/g, "/")).getMonth() ==
  137. new Date(new Date()).getMonth()
  138. ) {
  139. if (new Date().getDate() == k) {
  140. this.choseDay = k - 1;
  141. }
  142. } else {
  143. this.choseDay = 0;
  144. }
  145. dayArry.push(str);
  146. }
  147. this.allDate = dayArry;
  148. },
  149. getCountDays() {
  150. var newstr = this.date.replace(/-/g, "/");
  151. var curDate = new Date(newstr);
  152. var curMonth = curDate.getMonth();
  153. curDate.setMonth(curMonth + 1);
  154. curDate.setDate(0);
  155. return curDate.getDate();
  156. },
  157. //获取项目列表
  158. getProjectList() {
  159. this.listLoading = true;
  160. this.http.post(
  161. this.port.project.list,
  162. {},
  163. res => {
  164. this.listLoading = false;
  165. if (res.code == "ok") {
  166. this.projectList = res.data;
  167. } else {
  168. this.$message({
  169. message: res.msg,
  170. type: "error"
  171. });
  172. }
  173. },
  174. error => {
  175. this.listLoading = false;
  176. this.$message({
  177. message: error,
  178. type: "error"
  179. });
  180. }
  181. );
  182. },
  183. //删除项目
  184. handleClose(item) {
  185. this.$confirm("确定要删除项目" + item.projectName + "吗?", "删除项目", {
  186. confirmButtonText: "确定",
  187. cancelButtonText: "取消",
  188. type: "warning"
  189. })
  190. .then(() => {
  191. this.listLoading = true;
  192. this.http.post(
  193. this.port.project.delete,
  194. { id: item.id },
  195. res => {
  196. this.listLoading = false;
  197. if (res.code == "ok") {
  198. this.$message({
  199. type: "success",
  200. message: "项目删除成功"
  201. });
  202. this.getProjectList();
  203. } else {
  204. this.$message({
  205. message: res.msg,
  206. type: "error"
  207. });
  208. }
  209. },
  210. error => {
  211. this.listLoading = false;
  212. this.$message({
  213. message: error,
  214. type: "error"
  215. });
  216. }
  217. );
  218. })
  219. .catch(() => {});
  220. },
  221. //显示输入
  222. showInput() {
  223. this.inputVisible = true;
  224. this.$nextTick(_ => {
  225. this.$refs.saveTagInput.$refs.input.focus();
  226. });
  227. },
  228. //处理输入信息
  229. handleInputConfirm() {
  230. let inputValue = this.inputValue;
  231. if (inputValue) {
  232. this.$confirm("确定要新增项目" + inputValue + "吗?", "新增项目", {
  233. confirmButtonText: "确定",
  234. cancelButtonText: "取消",
  235. type: "warning"
  236. })
  237. .then(() => {
  238. this.listLoading = true;
  239. this.http.post(
  240. this.port.project.add,
  241. { name: inputValue },
  242. res => {
  243. this.listLoading = false;
  244. if (res.code == "ok") {
  245. this.$message({
  246. type: "success",
  247. message: "新增项目成功"
  248. });
  249. this.getProjectList();
  250. } else {
  251. this.$message({
  252. message: res.msg,
  253. type: "error"
  254. });
  255. }
  256. },
  257. error => {
  258. this.listLoading = false;
  259. this.$message({
  260. message: error,
  261. type: "error"
  262. });
  263. }
  264. );
  265. })
  266. .catch(() => {});
  267. }
  268. this.inputVisible = false;
  269. this.inputValue = "";
  270. },
  271. //获取日报列表
  272. getReportList() {
  273. this.listLoading = true;
  274. //首先处理日期
  275. let day =
  276. this.choseDay > 9
  277. ? "-" + (this.choseDay + 1)
  278. : "-0" + (this.choseDay + 1);
  279. this.http.post(
  280. this.port.report.list,
  281. {
  282. date: this.date + day
  283. },
  284. res => {
  285. this.listLoading = false;
  286. if (res.code == "ok") {
  287. this.reportList = res.data;
  288. } else {
  289. this.$message({
  290. message: res.msg,
  291. type: "error"
  292. });
  293. }
  294. },
  295. error => {
  296. this.listLoading = false;
  297. this.$message({
  298. message: error,
  299. type: "error"
  300. });
  301. }
  302. );
  303. },
  304. //导出日报
  305. exportReport() {
  306. if (this.reportList.length > 0) {
  307. this.listLoading = true;
  308. //首先处理日期
  309. let day =
  310. this.choseDay > 9
  311. ? "-" + (this.choseDay + 1)
  312. : "-0" + (this.choseDay + 1);
  313. this.http.post(
  314. this.port.report.export,
  315. {
  316. date: this.date + day
  317. },
  318. res => {
  319. this.listLoading = false;
  320. if (res.code == "ok") {
  321. location.href = res.data;
  322. } else {
  323. this.$message({
  324. message: res.msg,
  325. type: "error"
  326. });
  327. }
  328. },
  329. error => {
  330. this.listLoading = false;
  331. this.$message({
  332. message: error,
  333. type: "error"
  334. });
  335. }
  336. );
  337. } else {
  338. this.$message({
  339. message: "当天没有报告 无法导出",
  340. type: "info"
  341. });
  342. }
  343. },
  344. // 获取异常列表
  345. getUnusual() {
  346. this.listLoading = true;
  347. this.http.post(
  348. this.port.project.projectList,
  349. {},
  350. res => {
  351. this.listLoading = false;
  352. if (res.code == "ok") {
  353. } else {
  354. this.$message({
  355. message: res.msg,
  356. type: "error"
  357. });
  358. }
  359. },
  360. error => {
  361. this.listLoading = false;
  362. this.$message({
  363. message: error,
  364. type: "error"
  365. });
  366. }
  367. );
  368. }
  369. },
  370. created() {
  371. let height = window.innerHeight;
  372. this.tableHeight = height - 170;
  373. const that = this;
  374. window.onresize = function temp() {
  375. that.tableHeight = window.innerHeight - 170;
  376. };
  377. },
  378. mounted() {
  379. this.getAllDate();
  380. this.getReportList();
  381. this.getProjectList();
  382. }
  383. };
  384. </script>
  385. <style lang="scss" scoped>
  386. .clearfix {
  387. overflow-x: auto;
  388. white-space: nowrap;
  389. padding: 15px 0;
  390. .date_item {
  391. padding: 0 15px;
  392. cursor: pointer;
  393. }
  394. .chooseDate {
  395. color: #20a0ff;
  396. }
  397. }
  398. .one_daily {
  399. i {
  400. color: #9ed0ff;
  401. margin-right: 5px;
  402. }
  403. .one_daily_body {
  404. padding: 15px 0px;
  405. p {
  406. margin: 0;
  407. line-height: 30px;
  408. }
  409. }
  410. ul {
  411. padding: 0;
  412. }
  413. }
  414. </style>
  415. <style lang="scss">
  416. .daily {
  417. .el-card__body {
  418. height: 82%;
  419. overflow-y: auto;
  420. }
  421. }
  422. </style>
  423. <style scoped>
  424. /* 项目标签的样式 */
  425. .el-tag + .el-tag {
  426. margin-left: 10px;
  427. }
  428. .button-new-tag {
  429. margin-left: 10px;
  430. height: 32px;
  431. line-height: 30px;
  432. padding-top: 0;
  433. padding-bottom: 0;
  434. }
  435. .input-new-tag {
  436. width: 90px;
  437. margin-left: 10px;
  438. vertical-align: bottom;
  439. }
  440. </style>