get_task.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div>
  3. <div class="box">
  4. <el-tabs v-model="active" type="card">
  5. <el-tab-pane label="待领取" name="unclaimed">
  6. </el-tab-pane>
  7. <el-tab-pane label="已领取" name="received">
  8. </el-tab-pane>
  9. </el-tabs>
  10. <div v-show="active === 'unclaimed'">
  11. <el-table :data="list" style="width: 100%" v-loading="loading" @row-click="openDetail" >
  12. <el-table-column label="任务内容" prop="task_name"></el-table-column>
  13. <el-table-column label="积分" prop="base_point"></el-table-column>
  14. <el-table-column label="截止时间" prop="expire_time"></el-table-column>
  15. <el-table-column label="操作" prop="owner_id">
  16. <template slot-scope="scope">
  17. <el-link type="primary" :underline='false'>领取任务</el-link>
  18. <!-- <span>{{scope.row.receiver_id == owner_id?'(发布人)':''}}</span> -->
  19. </template>
  20. </el-table-column>
  21. <template slot="empty">
  22. <noData></noData>
  23. </template>
  24. </el-table>
  25. </div>
  26. <div v-show="active === 'received'">
  27. <el-table :data="list" style="width: 100%" v-loading="loading" @row-click="openDetail" >
  28. <el-table-column label="执行人" prop="receiver_id">
  29. <template slot-scope="scope">
  30. <div style="display:flex">
  31. <userImage class="fl" :id="scope.row.receiver_id" :user_name="scope.row.receiver_name" :img_url="scope.row.receiver_img_url" width="50px" height="50px" ></userImage>
  32. <span style="line-height: 50px; padding-left: 10px;">{{scope.row.receiver_name}}</span>
  33. </div>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="任务内容" prop="task_name"></el-table-column>
  37. <el-table-column label="积分" prop="base_point"></el-table-column>
  38. <el-table-column label="截止时间" prop="expire_time"></el-table-column>
  39. <template slot="empty">
  40. <noData></noData>
  41. </template>
  42. </el-table>
  43. </div>
  44. <center style="padding: 20px 0;">
  45. <el-pagination
  46. background
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :page-sizes="[10, 20, 30, 40, 50, 100]"
  50. layout="total, sizes, prev, pager, next"
  51. :current-page="formData.page"
  52. :page-size="formData.page_size"
  53. :total="total">
  54. </el-pagination>
  55. </center>
  56. <el-drawer
  57. title="我是标题"
  58. :custom-class="'drawer_details'"
  59. :visible.sync="detailShow"
  60. :with-header="false"
  61. size="500px">
  62. <div class="details_title">任务详情</div>
  63. <div class="details_content" v-loading="detail_loading">
  64. <el-row style="padding-bottom:10px;border-bottom:1px #f8f8f8 solid;">
  65. <el-col :span="24">
  66. <div class="flex-box flex-v-ce">
  67. <userImage :user_name="active=='unclaimed'?detailInfo.owner_name:detailInfo.receiver_name" :id="active=='unclaimed'?detailInfo.owner_id:detailInfo.receiver_id" :img_url="active=='unclaimed'?detailInfo.owner_img_url:detailInfo.receiver_img_url" class="fl" width="50px" height="50px" fontSize="1.1"></userImage>
  68. <span style="line-height:50px; margin-left:10px;margin-right:4px;">{{active=='unclaimed'?detailInfo.owner_name:detailInfo.receiver_name}}</span>
  69. <span class="color_red point" v-show="detailInfo.point_config.base_point >= 0"> +{{detailInfo.point_config.base_point}}</span>
  70. <span class="color_green point" v-show="detailInfo.point_config.base_point < 0"> {{detailInfo.point_config.base_point}}</span>
  71. </div>
  72. <!-- {{point_name(detailInfo.pt_id)}} -->
  73. <!-- {{point_name(detailInfo.pt_id)}} -->
  74. </el-col>
  75. </el-row>
  76. <el-row v-if="detailInfo.task_name!==''">
  77. <el-col :span="4">任务内容</el-col>
  78. <el-col :span="20">{{detailInfo.task_name}}</el-col>
  79. </el-row>
  80. <el-row v-if="detailInfo.task_remark!==''">
  81. <el-col :span="4">任务描述</el-col>
  82. <el-col :span="20">{{detailInfo.task_remark}}</el-col>
  83. </el-row>
  84. <el-row v-if="detailInfo.type_mark!==''">
  85. <el-col :span="4">任务类型</el-col>
  86. <el-col :span="20">{{detailInfo.type_mark}}</el-col>
  87. </el-row>
  88. <el-row v-if="get_point_name(detailInfo.pt_id)!==''">
  89. <el-col :span="4">积分类型</el-col>
  90. <el-col :span="20">{{get_point_name(detailInfo.pt_id)}}</el-col>
  91. </el-row>
  92. <el-row v-if="detailInfo.expire_time!==''">
  93. <el-col :span="4">截止时间</el-col>
  94. <el-col :span="20">{{detailInfo.expire_time}}</el-col>
  95. </el-row>
  96. <!-- <el-row v-if="active =='unclaimed'">
  97. <el-col :span="4">审批人</el-col>
  98. <el-col :span="20">{{detailInfo.reviewer_name}}</el-col>
  99. </el-row>
  100. <el-row v-if="active !=='unclaimed'">
  101. <el-col :span="4">发布人</el-col>
  102. <el-col :span="20">{{detailInfo.owner_name}}</el-col>
  103. </el-row> -->
  104. <el-row v-if="detailInfo.reviewer_name">
  105. <el-col :span="4">审批人</el-col>
  106. <el-col :span="20">{{detailInfo.reviewer_name}}</el-col>
  107. </el-row>
  108. <el-row v-if="detailInfo.owner_name">
  109. <el-col :span="4">发布人</el-col>
  110. <el-col :span="20">{{detailInfo.owner_name}}</el-col>
  111. </el-row>
  112. <el-row v-if="detailInfo.task_file_list !== null && detailInfo.task_file_list.length !== 0">
  113. <el-col :span="4">图片附件</el-col>
  114. <el-col :span="20">
  115. <el-image
  116. style="width: 100px; height: 100px"
  117. :src="detailInfo.task_file_list[0]"
  118. :preview-src-list="detailInfo.task_file_list">
  119. </el-image>
  120. </el-col>
  121. </el-row>
  122. <div style="position: absolute; bottom: 20px; display: block; right: 20px;" v-if="detailInfo.status == '1' && user_id != detailInfo.owner_id && detailInfo.reviewer_id != user_id && !this.$authoritys('creator')">
  123. <el-button plain @click="detailShow = false">取消</el-button>
  124. <el-button type="primary" @click="collectTask" :loading="receiveLoad">领取任务</el-button>
  125. </div>
  126. </div>
  127. </el-drawer>
  128. </div>
  129. </div>
  130. </template>
  131. <script>
  132. import noData from '@/components/noData';
  133. export default {
  134. name: 'get_task',
  135. data() {
  136. return {
  137. active: 'unclaimed',
  138. list: [],
  139. loading: false,
  140. receiveLoad: false,
  141. total: null,
  142. formData: {
  143. page: 1,
  144. page_size: 10
  145. },
  146. detailShow: false,
  147. detail_loading: false,
  148. detailInfo: {
  149. point_config:{},
  150. task_file_list: []
  151. },
  152. point_types: JSON.parse(localStorage.getItem('types')),
  153. user_id: this.$getUserData().id
  154. }
  155. },
  156. mounted() {
  157. this.get_list()
  158. },
  159. components: {noData},
  160. watch:{
  161. active(val){
  162. this.list = []
  163. this.get_list()
  164. }
  165. },
  166. methods: {
  167. // 领取任务
  168. collectTask(){
  169. let self = this
  170. self.receiveLoad = true
  171. self.$axios('POST','/api/integral/task',{task_id: this.detailInfo.id}).then((res) => {
  172. if (res.data.code == 1) {
  173. self.$message.success('领取成功')
  174. self.list.forEach((element,index) => {
  175. if (element.id == self.detailInfo.id) {
  176. self.list.splice(index, 1)
  177. }
  178. });
  179. self.detailShow = false
  180. }else{
  181. self.$message.error(res.data.msg)
  182. }
  183. }).finally(()=>{
  184. self.receiveLoad = false
  185. })
  186. },
  187. // 页面变更
  188. handleCurrentChange(val) {
  189. this.formData.page = val
  190. this.get_list()
  191. },
  192. handleSizeChange(val){
  193. this.formData.page_size = val
  194. this.get_list()
  195. },
  196. // 打开详情弹窗
  197. openDetail(item){
  198. this.detailShow = true
  199. this.getDetailInfo(item)
  200. },
  201. // 获取详情信息
  202. getDetailInfo(item){
  203. let self = this
  204. self.detail_loading = true
  205. let data = {task_id: item.id}
  206. self.$axios('get','/api/integral/task',data).then((res) => {
  207. if (res.data.code == 1) {
  208. self.detailInfo = JSON.parse(JSON.stringify(res.data.data))
  209. }else{
  210. self.$message.error(res.data.data.msg)
  211. }
  212. }).finally(() => {
  213. self.detail_loading = false
  214. })
  215. },
  216. // 获取列表信息
  217. get_list(){
  218. let self = this
  219. self.loading = true
  220. let data = JSON.parse(JSON.stringify(this.formData))
  221. if (self.active == 'unclaimed') {
  222. data.hall_type = 'waiting'
  223. }else{
  224. data.hall_type = 'catch'
  225. }
  226. self.$axios('get','/api/integral/task/hall',data).then((res) => {
  227. if (res.data.code == 1) {
  228. self.list = res.data.data.list
  229. self.total = res.data.data.total
  230. }else{
  231. self.$message.error(res.data.data.msg)
  232. }
  233. }).finally(() => {
  234. self.loading = false
  235. })
  236. },
  237. // point_name(id){
  238. // return this.point_types.find((item)=>{if (item.id == id) {return item.name}}).name
  239. // },
  240. // 获取积分名称
  241. get_point_name(id){
  242. let name = ''
  243. this.point_types.forEach(element => {
  244. if (element.id == id) {
  245. name = element.name
  246. }
  247. });
  248. return name
  249. },
  250. }
  251. }
  252. </script>
  253. <style scoped lang="scss">
  254. .box{
  255. min-height: calc(100vh - 184px);
  256. min-width: 800px;
  257. background-color: #fff;
  258. padding: 20px;
  259. }
  260. .color_red{
  261. color: #F56C6C;
  262. }
  263. .color_green{
  264. color: #67C23A;
  265. }
  266. .details_content{
  267. .row_title{
  268. position:relative;
  269. margin:0 0 20px 0;
  270. padding-top: 12px;
  271. font-size: 16px;
  272. color: #303133;
  273. line-height: 22px;
  274. }
  275. .row_title:before{
  276. position: absolute;
  277. top: 0;
  278. content: " ";
  279. width: 100%;
  280. border-top: 1px #f8f8f8 solid;
  281. }
  282. .el-row {
  283. margin-bottom:10px;
  284. font-size: 14px;
  285. .el-col-4{
  286. color: #606266;
  287. }
  288. }
  289. }
  290. ::v-deep .el-table tr:hover{
  291. cursor:pointer
  292. }
  293. .details_content {
  294. padding: 20px;
  295. height: calc(100vh - 60px);
  296. overflow: auto;
  297. .row_title {
  298. position: relative;
  299. margin: 0 0 20px 0;
  300. padding-top: 12px;
  301. font-size: 16px;
  302. color: #303133;
  303. line-height: 22px;
  304. }
  305. .row_title:before {
  306. position: absolute;
  307. top: 0;
  308. content: ' ';
  309. width: 100%;
  310. border-top: 1px #f8f8f8 solid;
  311. }
  312. .el-row {
  313. margin-bottom: 10px;
  314. font-size: 14px;
  315. .el-col-4 {
  316. color: #606266;
  317. }
  318. }
  319. }
  320. .details_title {
  321. font-size: 18px;
  322. padding: 20px;
  323. border-bottom: 1px #efefef solid;
  324. }
  325. </style>