rate.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <div class="condition">
  7. <el-date-picker
  8. v-model="startDate"
  9. type="date"
  10. value-format="yyyy-MM-dd"
  11. style="width: 200px;margin-top: 10px;margin-left: 17px"
  12. placeholder="开始日期"
  13. />
  14. <el-date-picker
  15. v-model="endDate"
  16. type="date"
  17. value-format="yyyy-MM-dd"
  18. style="width: 200px ;margin-top: 10px;margin-left: 17px"
  19. placeholder="结束日期"
  20. />
  21. <el-button
  22. class="filter-item"
  23. style="margin-left: 10px;"
  24. type="primary"
  25. @click="getLogs"
  26. round
  27. >搜索
  28. </el-button>
  29. </div>
  30. <y-page-list-layout>
  31. <el-table :data="tableData" slot="table" style="width: 100%;" border="border" height="900px" :row-style="{height:'100px'}">
  32. <el-table-column v-if="tableData.length>0" label="日期" width="150px" align="center" fixed>
  33. <template slot-scope="{row}">
  34. <span>{{row.logDate}}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column :label="name" v-for="(name,index) in userNames" :key="index" width="520px">
  38. <template slot-scope="{row}">
  39. <div v-for="(l,index) in row.list" :key="index">
  40. <div class="content" v-if = "g.userName===name" v-for="g in l.logs" :key="g.id">
  41. <el-tag effect="dark">{{g.itemName}}</el-tag>
  42. <el-tag type="success" effect="dark">{{g.stageName===null?'无':g.stageName}}</el-tag>
  43. <div class="info">
  44. <div id="info-item" type="info" effect="dark">
  45. {{g.taskSituation}}
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. </y-page-list-layout>
  54. <el-dialog
  55. width="600px"
  56. title="日志详情"
  57. :visible.sync="dialogFormVisible"
  58. :close-on-click-modal="false"
  59. custom-class="myDialog"
  60. >
  61. <el-form ref="postForm" :model="postForm" class="form-container">
  62. <div>
  63. <div class="postInfo-container">
  64. <el-row>
  65. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  66. <el-form-item
  67. label="项目名称:"
  68. prop="itemName"
  69. label-width="180px"
  70. class="postInfo-container-item"
  71. >
  72. <el-input :value="postForm.itemName" class="filter-item" readonly/>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. </div>
  77. </div>
  78. <div>
  79. <div class="postInfo-container">
  80. <el-row>
  81. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  82. <el-form-item
  83. label="阶段名称:"
  84. prop="stageName"
  85. label-width="180px"
  86. class="postInfo-container-item"
  87. >
  88. <el-input :value="postForm.stageName" class="filter-item" readonly disabled/>
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. </div>
  93. </div>
  94. <div>
  95. <div class="postInfo-container">
  96. <el-row>
  97. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  98. <el-form-item
  99. label="日期:"
  100. prop="logDate"
  101. label-width="180px"
  102. class="postInfo-container-item"
  103. >
  104. <el-date-picker
  105. :value="postForm.logDate"
  106. type="date"
  107. value-format="yyyy-MM-dd"
  108. style="width: 100%"
  109. placeholder="选择日期"
  110. readonly
  111. />
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. </div>
  116. </div>
  117. <div>
  118. <div class="postInfo-container">
  119. <el-row>
  120. <el-col :xs="24" :sm="12" :lg="18" :span="6">
  121. <el-form-item
  122. label="每日任务情况:"
  123. prop="taskSituation"
  124. :rules="{required: true, message: '请填写每日任务情况', trigger: 'blur'}"
  125. label-width="180px"
  126. class="postInfo-container-item"
  127. >
  128. <el-input type="textarea" :value="postForm.taskSituation" class="filter-item" readonly/>
  129. </el-form-item>
  130. </el-col>
  131. </el-row>
  132. </div>
  133. </div>
  134. </el-form>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import Breadcrumb from '@/components/Breadcrumb'
  140. import YDetailPageLayout from '@/components/YDetailPageLayout'
  141. export default {
  142. name: 'itemRate',
  143. components: {
  144. Breadcrumb,
  145. YDetailPageLayout
  146. },
  147. data() {
  148. return {
  149. type: 'detail',
  150. br: '<br/>',
  151. postForm: {
  152. itemId: this.$route.query.id,
  153. userId: this.$store.getters.userInfo.id,
  154. logDate:null
  155. },
  156. itemId: this.$route.query.id,
  157. itemName: this.$route.query.itemName,
  158. activeName: 'first',
  159. vLoading: false,
  160. listQuery:{},
  161. scope: true,
  162. tableData: [],
  163. dates:[],
  164. dialogFormVisible: false,
  165. userNames:[],
  166. startDate:null,
  167. endDate:null
  168. }
  169. },
  170. created() {
  171. this.endDate = this.timeDefault;
  172. this.startDate = this.getago(this.endDate, -10);
  173. this.getLogs();
  174. },
  175. mounted() {
  176. // const d = this.tableData;
  177. // console.log(d);
  178. // d.forEach(function (e) {
  179. // console.log(e.logDate);
  180. // })
  181. },
  182. computed:{
  183. timeDefault() {
  184. const date = new Date();
  185. const s1 = date.getFullYear() + "-" + (this.getZero(date.getMonth() + 1)) + "-" + this.getZero((date.getDate()));
  186. return s1;
  187. },
  188. },
  189. methods:{
  190. getago(startDate, valueTime){
  191. var date = new Date(startDate);
  192. var newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()+ +valueTime);
  193. var Y = newDate.getFullYear();
  194. var M = newDate.getMonth()+1;
  195. M = M<10?'0'+M:M;
  196. var D = newDate.getDate();
  197. D = D<10?'0'+D:D;
  198. return `${Y}-${M}-${D}`;
  199. },
  200. getZero(num) {
  201. // 单数前面加0
  202. if (parseInt(num) < 10) {
  203. num = '0' + num;
  204. }
  205. return num;
  206. },
  207. openDetail(id){
  208. const that = this;
  209. this.$api.itemLog.detail(id).then(res=>{
  210. this.postForm = res.data;
  211. setTimeout(() => {
  212. that.dialogFormVisible = true;
  213. }, 200)
  214. }).catch(
  215. that.dialogFormVisible = false
  216. )
  217. },
  218. getLogs(){
  219. this.$api.itemLog.collect({scope:this.scope, itemId:this.itemId, startDate:this.startDate, endDate:this.endDate}).then(res=>{
  220. this.tableData = res.data;
  221. const us = this.userNames;
  222. const d = this.tableData;
  223. d.forEach(function (e) {
  224. us.push(e.userName);
  225. });
  226. this.userNames = Array.from(new Set(us));
  227. this.tableData = this.groupByDate(d, 'logDate');
  228. });
  229. },
  230. groupByDate(list, key){
  231. var keysArr = list.map(item=>item[key])
  232. var keys = [...new Set(keysArr)]
  233. var newList = keys.map(item=> {
  234. return {
  235. [key]: item,
  236. list: list.filter(i=>i[key] === item)
  237. }
  238. })
  239. return newList;
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. div.content{
  246. margin-bottom: 5px;
  247. width: 520px;
  248. }
  249. .info {
  250. width: 500px;
  251. height: auto;
  252. }
  253. #info-item{
  254. text-overflow: ellipsis !important;
  255. white-space: pre-wrap !important;
  256. }
  257. /deep/.myDialog{
  258. border-radius: 20px;
  259. }
  260. </style>