daily.vue 11 KB

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