123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- <template>
- <section>
- <!--工具条-->
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true">
- <el-form-item>
- <el-date-picker v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM"
- @change="changeMonth()" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
- </el-form-item>
- <el-form-item style="float:right;">
- <el-link type="primary" :underline="false" v-if="user.role != 0" @click="exportReport">导出日报</el-link>
- </el-form-item>
- <el-form-item style="float:right;">
- <el-link type="primary" :underline="false" @click="fillInReport">填写日报</el-link>
- </el-form-item>
- </el-form>
- </el-col>
- <!--列表-->
- <div>
- <el-card class="box-card daily" shadow="never" :style="'height:'+tableHeight +'px'">
- <div slot="header" class="clearfix">
- <span>日期:</span>
- <span v-for="(item,index) in allDate" :id="'day'+index" :class="index==choseDay?'chooseDate date_item':'date_item'"
- @click="choseDate(index)" :key="index">{{item}}</span>
- </div>
- <div class="allDaily">
- <div class="one_daily" v-for="(item1,index1) in reportList" :key="index1">
- <i class="fa fa-circle"></i>{{item1.name}}
- <span style="margin-left:30px;">
- <span style="margin-right:20px;">
- <i v-if="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5" style="color:red;margin-right:8px;" class="fa fa-exclamation-triangle"></i>
- 总填报:
- <span :style="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5?'color:red':''">{{item1.reportTime}}h</span>
- </span>
- <el-link v-if="user.role != 0" type="primary" :underline="false" @click="junpToDeskTop(item1.id)">系统智能统计:{{item1.calculateTime}}h</el-link>
- <span v-else>系统智能统计:{{item1.calculateTime}}h</span>
- </span>
- <div class="checkbtn">
- <el-button v-if="user.role != 0 && item1.state == 0" type="primary" :loading="logining" size="small" @click="approve(item1.id)">通过</el-button>
- <el-button v-if="user.role != 0 && item1.state == 0" type="danger" :loading="logining" size="small" @click="deny(item1.id,0)">驳回</el-button>
- <el-button v-if="user.role != 0 && item1.state == 1" type="danger" :loading="logining" size="small" @click="deny(item1.id,1)">撤销</el-button>
- </div>
- <div class="one_daily_body">
- <el-timeline>
- <el-timeline-item v-for="(item2,index2) in item1.data" :key="index2">
- <el-card shadow="never">
- <p>项目:<b>{{item2.project}}</b></p>
- <p>时长:{{item2.time}}h</p>
- <p>事项:<span v-html="item2.content"></span></p>
- </el-card>
- </el-timeline-item>
- </el-timeline>
- </div>
- </div>
- <!-- 简陋的无报告提示 -->
- <span v-if="reportList.length==0">本日暂无报告</span>
- </div>
- </el-card>
- </div>
- <!-- 项目管理的dialog -->
- <el-dialog title="填写日报" :visible.sync="dialogVisible" width="60%">
- <el-form ref="workForm" :model="workForm" :rules="workRules" label-width="100px">
- <el-form-item label="工作日期" prop="createDate">
- <el-date-picker v-model="workForm.createDate" :editable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
- @change="changeMonth()" :clearable="false" type="date" placeholder="选择工作日期"></el-date-picker>
- </el-form-item>
- <el-form-item label="待分配时长" prop="name">
- <span>{{report.time}}h</span>
- <el-link type="primary" :underline="false" @click="addDomain" style="margin-left:40px">添加项目</el-link>
- </el-form-item>
- <div v-for="(domain, index) in workForm.domains" :key="domain.id">
- <el-form-item label="投入项目" :prop="'domains.' + index + '.projectId'"
- :rules="{ required: true, message: '请选择投入项目', trigger: ['change','blur'] }">
- <el-select v-model="domain.projectId" placeholder="请选择" style="width:200px;"
- :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)">
- <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
- </el-select>
- <el-link v-if="index >= 1" type="primary" :underline="false" @click="delDomain(index)" style="float:right;margin-right:10px;"
- :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)">
- <i class="fa fa-trash" style="color: red;;font-size:18px;"></i>
- </el-link>
- </el-form-item>
- <el-form-item label="投入时长" :prop="'domains.' + index + '.workingTime'"
- :rules="{ required: true, message: '请输入投入时长', trigger: 'blur' }">
- <el-input v-model.number="domain.workingTime" placeholder="请输入投入时长" type='number' clearable style="width:200px;"
- :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)"></el-input>
- </el-form-item>
- <el-form-item label="工作事项" :prop="'domains.' + index + '.content'" :rules="{ required: true, message: '请输入工作事项', trigger: 'blur' }">
- <el-input v-model="domain.content" type="textarea" :rows="4" placeholder="请输入投入时长" clearable
- :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)"></el-input>
- </el-form-item>
- <el-divider v-if="workForm.domains.length>1"></el-divider>
- </div>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取消</el-button>
- <el-button type="primary" @click="submitDepartment"
- :disabled="workForm.domains.length==0?true:(workForm.domains[0].state==2?false:true)" >提交</el-button>
- </span>
- </el-dialog>
- </section>
- </template>
- <script>
- import util from "../../common/js/util";
- export default {
- data() {
- return {
- user: JSON.parse(sessionStorage.getItem("user")),
- allDate: [],
- date: util.formatDate.format(new Date(new Date()), "yyyy-MM"),
- choseDay: 0,
- tableHeight: 0,
- listLoading: false,
- projectList: [], //项目列表
- reportList: [], //日报列表
- dialogVisible: false, //项目弹窗
- report: '',
- workForm: {
- createDate: util.formatDate.format(new Date(new Date()), "yyyy-MM-dd"),
- domains: [{
- id: null,
- projectId: "",
- workingTime: "",
- content: "",
- state: 2,
- }],
- },
- workRules: {
- createDate: [{ required: true, message: "请选择工作日期", trigger: "change" }],
- },
- logining: false,
- };
- },
- methods: {
- // 改变月份
- changeMonth() {
- this.getAllDate();
- this.getReportList();
- },
- // 选择日期
- choseDate(i) {
- this.choseDay = i;
- this.getReportList();
- },
- // 获取日期列表
- getAllDate() {
- var dayArry = [];
- var day = this.getCountDays();
- for (var k = 1; k <= day; k++) {
- var str = new Date(this.date.replace(/-/g, "/")).getMonth() + 1 + "月" + k + "日";
- if ( new Date(this.date.replace(/-/g, "/")).getFullYear() == new Date(new Date()).getFullYear() &&
- new Date(this.date.replace(/-/g, "/")).getMonth() == new Date(new Date()).getMonth()) {
- if (new Date().getDate() == k) {
- this.choseDay = k - 1;
- }
- } else {
- this.choseDay = 0;
- }
- dayArry.push(str);
- }
- this.allDate = dayArry;
- },
- getCountDays() {
- var newstr = this.date.replace(/-/g, "/");
- var curDate = new Date(newstr);
- var curMonth = curDate.getMonth();
- curDate.setMonth(curMonth + 1);
- curDate.setDate(0);
- return curDate.getDate();
- },
- //获取日报列表
- getReportList() {
- this.listLoading = true;
- let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
- this.http.post( this.port.report.list, { date: this.date + day },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.reportList = res.data;
- document.querySelector("#day"+this.choseDay).scrollIntoView(true);
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- //导出日报
- exportReport() {
- if (this.reportList.length > 0) {
- this.listLoading = true;
- //首先处理日期
- let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
- this.http.post( this.port.report.export, { date: this.date + day },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- location.href = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- } else {
- this.$message({
- message: "当天没有报告 无法导出",
- type: "info"
- });
- }
- },
- //获取项目列表
- getProjectList() {
- this.listLoading = true;
- this.http.post( this.port.project.list, {},
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.projectList = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- // 获取个人某天的日报
- getReport() {
- this.http.post( this.port.report.getPort, {
- date: this.workForm.createDate
- },
- res => {
- if (res.code == "ok") {
- var list = res.data;
- this.report = list;
- if(list.report.length != 0) {
- var arr = [];
- for(var i in list.report) {
- arr.push({
- id: list.report[i].id,
- projectId: list.report[i].projectId,
- workingTime: list.report[i].workingTime,
- content: list.report[i].content,
- state: list.report[i].state
- })
- }
- this.workForm = {
- createDate: this.workForm.createDate,
- domains: arr,
- }
- } else {
- this.workForm = {
- createDate: this.workForm.createDate,
- domains: [{
- id: null,
- projectId: "",
- workingTime: "",
- content: "",
- state: 2,
- }],
- }
- }
- console.log(this.workForm)
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- // 打开日报填写
- fillInReport() {
- this.getReport();
- this.dialogVisible = true;
- },
- // 添加模块
- addDomain() {
- this.workForm.domains.push({
- projectId: "",
- workingTime: "",
- content: ""
- });
- },
- // 移除模块
- delDomain(i) {
- this.workForm.domains.splice(i,1)
- },
- // 改变月份
- changeMonth() {
- this.getReport()
- },
- // 保存日报
- submitDepartment() {
- this.$refs.workForm.validate(valid => {
- if (valid) {
- this.listLoading = true;
- let formData = new FormData();
- for(var i in this.workForm.domains) {
- if (this.workForm.domains[i].id != null) {
- formData.append("id", this.workForm.domains[i].id);
- } else {
- formData.append("id", -1);
- }
- formData.append("projectId", this.workForm.domains[i].projectId);
- formData.append("workingTime", this.workForm.domains[i].workingTime);
- formData.append("content", this.workForm.domains[i].content);
- formData.append("createDate", this.workForm.createDate);
- }
- this.http.uploadFile( this.port.report.editPort, formData,
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: "填报成功",
- type: "success"
- });
- this.dialogVisible = false;
- this.getReportList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- });
- },
- // 跳转
- junpToDeskTop(id) {
- let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
- this.$router.push("/desktop/" + id + "/" + this.date +day);
- },
- // 通过日报
- approve(id) {
- this.logining = true;
- let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
- this.http.post( this.port.report.approve, {id: id , date: this.date +day},
- res => {
- this.logining = false;
- if (res.code == "ok") {
- this.$message({
- message: "审核成功",
- type: "success"
- });
- this.getReportList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.logining = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- // 未通过日报
- deny(id,i) {
- this.logining = true;
- let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
- this.http.post( this.port.report.deny, {id: id , date: this.date +day},
- res => {
- this.logining = false;
- if (res.code == "ok") {
- this.$message({
- message: i==0?"驳回成功":"撤销成功",
- type: "success"
- });
- this.getReportList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.logining = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- created() {
- let height = window.innerHeight;
- this.tableHeight = height - 150;
- const that = this;
- window.onresize = function temp() {
- that.tableHeight = window.innerHeight - 150;
- };
- },
- mounted() {
- this.getAllDate();
- this.getReportList();
- this.getProjectList();
- }
- };
- </script>
- <style lang="scss" scoped>
- .clearfix {
- overflow-x: auto;
- white-space: nowrap;
- padding: 15px 0;
- .date_item {
- padding: 0 15px;
- cursor: pointer;
- }
- .chooseDate {
- color: #20a0ff;
- }
- }
- .one_daily {
- i {
- color: #9ed0ff;
- margin-right: 5px;
- }
- .one_daily_body {
- padding: 15px 0px;
- p {
- margin: 0;
- line-height: 30px;
- }
- }
- ul {
- padding: 0;
- }
- }
- .checkbtn {
- float: right;
- margin-top: -10px;
- }
- </style>
- <style lang="scss">
- .daily {
- .el-card__body {
- height: 82%;
- overflow-y: auto;
- }
- .el-card__header {
- padding: 0 20px;
- }
- }
- </style>
- <style scoped>
- /* 项目标签的样式 */
- .el-tag + .el-tag {
- margin-left: 10px;
- }
- .button-new-tag {
- margin-left: 10px;
- height: 32px;
- line-height: 30px;
- padding-top: 0;
- padding-bottom: 0;
- }
- .input-new-tag {
- width: 90px;
- margin-left: 10px;
- vertical-align: bottom;
- }
- </style>
|