rate.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-page-list-layout>
  7. <el-table :data="tableData" slot="table" style="width: 100%;" border="border" height="900px" :row-style="{height:'100px'}">
  8. <el-table-column v-if="tableData.length>0" label="日期" width="150px" align="center" fixed>
  9. <template slot-scope="{row}">
  10. <span>{{row.logDate}}</span>
  11. </template>
  12. </el-table-column>
  13. <el-table-column :label="name" v-for="(name,index) in userNames" :key="index" width="520px">
  14. <template slot-scope="{row}">
  15. <div v-for="(l,index) in row.list" :key="index">
  16. <div class="content" v-if = "g.userName===name" v-for="g in l.logs" :key="g.id" @click="openDetail(g.id)">
  17. <el-tag effect="dark">{{g.itemName}}</el-tag>
  18. <el-tag type="success" effect="dark">{{g.stageName===null?'无':g.stageName}}</el-tag>
  19. <el-tooltip content="查看详情" placement="bottom" effect="light">
  20. <el-tag class="info" type="info" effect="dark">{{g.taskSituation}}</el-tag>
  21. </el-tooltip>
  22. </div>
  23. </div>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </y-page-list-layout>
  28. <el-dialog
  29. width="600px"
  30. title="日志详情"
  31. :visible.sync="dialogFormVisible"
  32. :close-on-click-modal="false"
  33. custom-class="myDialog"
  34. >
  35. <el-form ref="postForm" :model="postForm" class="form-container">
  36. <div>
  37. <div class="postInfo-container">
  38. <el-row>
  39. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  40. <el-form-item
  41. label="项目名称:"
  42. prop="itemName"
  43. label-width="180px"
  44. class="postInfo-container-item"
  45. >
  46. <el-input :value="postForm.itemName" class="filter-item" readonly/>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. </div>
  52. <div>
  53. <div class="postInfo-container">
  54. <el-row>
  55. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  56. <el-form-item
  57. label="阶段名称:"
  58. prop="stageName"
  59. label-width="180px"
  60. class="postInfo-container-item"
  61. >
  62. <el-input :value="postForm.stageName" class="filter-item" readonly disabled/>
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. </div>
  67. </div>
  68. <div>
  69. <div class="postInfo-container">
  70. <el-row>
  71. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  72. <el-form-item
  73. label="日期:"
  74. prop="logDate"
  75. label-width="180px"
  76. class="postInfo-container-item"
  77. >
  78. <el-date-picker
  79. :value="postForm.logDate"
  80. type="date"
  81. value-format="yyyy-MM-dd"
  82. style="width: 100%"
  83. placeholder="选择日期"
  84. readonly
  85. />
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. </div>
  90. </div>
  91. <div>
  92. <div class="postInfo-container">
  93. <el-row>
  94. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  95. <el-form-item
  96. label="每日任务情况:"
  97. prop="taskSituation"
  98. :rules="{required: true, message: '请填写每日任务情况', trigger: 'blur'}"
  99. label-width="180px"
  100. class="postInfo-container-item"
  101. >
  102. <el-input type="textarea" :value="postForm.taskSituation" class="filter-item" readonly/>
  103. </el-form-item>
  104. </el-col>
  105. </el-row>
  106. </div>
  107. </div>
  108. </el-form>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import Breadcrumb from '@/components/Breadcrumb'
  114. import YDetailPageLayout from '@/components/YDetailPageLayout'
  115. export default {
  116. name: 'itemRate',
  117. components: {
  118. Breadcrumb,
  119. YDetailPageLayout
  120. },
  121. data() {
  122. return {
  123. type: 'detail',
  124. br: '<br/>',
  125. postForm: {
  126. itemId: this.$route.query.id,
  127. userId: this.$store.getters.userInfo.id,
  128. logDate:null
  129. },
  130. itemId: this.$route.query.id,
  131. itemName: this.$route.query.itemName,
  132. activeName: 'first',
  133. vLoading: false,
  134. listQuery:{},
  135. scope: true,
  136. tableData: [],
  137. dates:[],
  138. dialogFormVisible: false,
  139. userNames:[],
  140. stageName: "第二阶段",
  141. }
  142. },
  143. created() {
  144. this.getLogs();
  145. },
  146. mounted() {
  147. // const d = this.tableData;
  148. // console.log(d);
  149. // d.forEach(function (e) {
  150. // console.log(e.logDate);
  151. // })
  152. },
  153. computed:{
  154. },
  155. methods:{
  156. openDetail(id){
  157. const that = this;
  158. this.$api.itemLog.detail(id).then(res=>{
  159. this.postForm = res.data;
  160. setTimeout(() => {
  161. that.dialogFormVisible = true;
  162. }, 200)
  163. }).catch(
  164. that.dialogFormVisible = false
  165. )
  166. },
  167. getLogs(){
  168. this.$api.itemLog.collect({scope:this.scope, itemId: this.itemId}).then(res=>{
  169. this.tableData = res.data;
  170. const us = this.userNames;
  171. const d = this.tableData;
  172. d.forEach(function (e) {
  173. us.push(e.userName);
  174. });
  175. this.userNames = Array.from(new Set(us));
  176. this.tableData = this.groupByDate(d, 'logDate');
  177. });
  178. },
  179. groupByDate(list, key){
  180. var keysArr = list.map(item=>item[key])
  181. var keys = [...new Set(keysArr)]
  182. var newList = keys.map(item=> {
  183. return {
  184. [key]: item,
  185. list: list.filter(i=>i[key] === item)
  186. }
  187. })
  188. return newList;
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. div.content{
  195. margin-bottom: 5px;
  196. }
  197. .info:hover{
  198. cursor: pointer;
  199. }
  200. /deep/.myDialog{
  201. border-radius: 20px;
  202. }
  203. </style>