mySuggestByLeader.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <template>
  2. <div class="detail">
  3. <mt-header class="detail_head" fixed title="TA的建议">
  4. <router-link to="" slot="left">
  5. <mt-button icon="back" v-on:click="jumpBack()"></mt-button>
  6. </router-link>
  7. <mt-button class="timePicker" slot="right" id="dateTime" v-on:click="timePicker()"><span class="dateTime">{{chooseTime}}</span> <img src="../../assets/image/pull_down.png"></mt-button>
  8. </mt-header>
  9. <div class="detail_body">
  10. <div class="noList" v-if="ideaList.length==0">
  11. <img src="../../assets/image/noList.png">
  12. </div>
  13. <ul v-else class="recordBox">
  14. <li v-for="(item,index) in ideaList" class="one_recordBox detailBox">
  15. <div>
  16. <div class="one_suggest_title">
  17. {{item.name}}
  18. <span v-if="item.ideaComment != null" class="areaday">已打分</span>
  19. <span v-if="power.indexOf('scoring')>-1 && item.isEvaluated == 0" class="edit" v-on:click="openSugPop(index)">打分</span>
  20. </div>
  21. <div style="color: #aaa;text-align:left;font-size:0.13rem;margin-bottom:0.12rem;">
  22. {{item.indate}}
  23. </div>
  24. <div class="one_suggest_body">
  25. {{item.content}}
  26. </div>
  27. <div class="one_suggest_reply" v-if="item.ideaComment != null">
  28. <div class="reply_title">来自领导的回复</div>
  29. <div class="reply_body">
  30. {{item.ideaComment.content}}
  31. <div>{{item.ideaComment.responder}} <span class="score">得分:<span>{{item.score==null?'0分':item.score + '分'}}</span></span></div>
  32. <div>{{item.ideaComment.indate}}
  33. <div v-if="power.indexOf('scoring')>-1" class="showMoreBtn" v-on:click.stop="showBtnList(item.id)">
  34. <img src="../../assets/image/loadMore.png">
  35. <div :id="'btn' + item.id" class="btn_list hide">
  36. <div v-on:click="openSugPop(index)"><img src="../../assets/image/register.png"><span>编辑</span></div>
  37. <div v-on:click="deleteScore(index)"><img src="../../assets/image/delete.png"><span>删除</span></div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </li>
  45. <div class="order" v-if="haveMore">
  46. <span class="line"></span>
  47. <span class="txt">没有更多了</span>
  48. <span class="line"></span>
  49. </div>
  50. </ul>
  51. </div>
  52. <mt-popup v-model="sugScorePop" position="middle" popup-transition="popup-fade">
  53. <div class="mint-popup-div">
  54. <h4>打分</h4>
  55. <mt-field label="" class="input" placeholder="请输入建议分" type="number" disableClear v-model="sugScore"></mt-field>
  56. <mt-field label="" class="input" placeholder="请输入得分原因" type="textarea" rows="4" v-model="sugContent"></mt-field>
  57. <div class="btns">
  58. <mt-button class="btn" size="small" v-on:click.native="submit(3)">确定</mt-button>
  59. <mt-button class="btn" size="small" v-on:click.native="closePop()">取消</mt-button>
  60. </div>
  61. </div>
  62. </mt-popup>
  63. </div>
  64. </template>
  65. <script>
  66. import { MessageBox } from 'mint-ui';
  67. export default {
  68. data() {
  69. return {
  70. user: JSON.parse(sessionStorage.getItem("user")),
  71. power: sessionStorage.getItem("power"),
  72. ideaList: [],
  73. pageNum: 1,
  74. pages: 1,
  75. haveMore: false,
  76. date: [],
  77. chooseTime: '',
  78. sugScore: 0,
  79. sugContent: '',
  80. sugScorePop: false,
  81. chooseSugNum: 0,
  82. canEdit: true,
  83. }
  84. },
  85. methods: {
  86. // 时间筛选
  87. timePicker() {
  88. var _this = this;
  89. var dataShippingSpace = this.date;
  90. var pickerDiv = document.getElementById("dateTime");
  91. var pickerView = new PickerView({
  92. bindElem: pickerDiv,
  93. data: dataShippingSpace,
  94. title: "时间选择",
  95. leftText: "取消",
  96. rightText: "确定",
  97. rightFn: function(selectArr) {
  98. _this.chooseTime = selectArr[0].name;
  99. _this.getList();
  100. if(_this.chooseTime == _this.date[0].name) {
  101. _this.canEdit = true
  102. } else {
  103. _this.canEdit = false
  104. }
  105. }
  106. });
  107. },
  108. // 消息列表
  109. getList() {
  110. this.$indicator.open();
  111. this.http.post(this.port.my.ideaListByUid, {
  112. 'uid': this.user.id,
  113. 'time': this.chooseTime,
  114. // 'pageNum': 1,
  115. } ,
  116. res => {
  117. this.$indicator.close();
  118. if (res.code == "ok") {
  119. // this.ideaList = res.data.list;
  120. this.ideaList = res.data;
  121. this.pages = res.data.pages==0?1:res.data.pages;
  122. } else {
  123. this.$toast({
  124. message: res.msg,
  125. duration: 2000
  126. });
  127. }
  128. }, error => {
  129. this.$indicator.close();
  130. this.$toast({
  131. message: error,
  132. duration: 2000
  133. });
  134. })
  135. },
  136. loadMore() {
  137. if(this.pageNum == this.pages) {
  138. this.haveMore = true;
  139. } else if(this.pageNum < this.pages) {
  140. this.$indicator.open();
  141. this.http.post(this.port.my.ideaListByUid, {
  142. 'uid': this.user.id,
  143. 'time': this.chooseTime,
  144. 'pageNum': ++this.pageNum
  145. } ,
  146. res => {
  147. this.$indicator.close();
  148. if (res.code == "ok") {
  149. this.pages = res.data.pages==0?1:res.data.pages;
  150. if(res.data.ideaList.length != 0) {
  151. for(var i in res.data.ideaList) {
  152. this.ideaList.push(res.data.list[i]);
  153. }
  154. }
  155. } else {
  156. this.$toast({
  157. message: res.msg,
  158. duration: 2000
  159. });
  160. }
  161. }, error => {
  162. this.$indicator.close();
  163. this.$toast({
  164. message: error,
  165. duration: 2000
  166. });
  167. })
  168. }
  169. },
  170. jumpBack() {
  171. this.$router.go(-1);
  172. },
  173. getDate() {
  174. const dateData = [];
  175. const date1 = new Date();
  176. for (let i = 0; i < 36; i++) {
  177. let cur = '';
  178. let tempYear = date1.getFullYear();
  179. let tempMonth = date1.getMonth() - i + 1;
  180. if (tempMonth <= 0) {
  181. tempYear = date1.getFullYear() - Math.floor(tempMonth / -12) - 1;
  182. tempMonth += (Math.floor(tempMonth / -12) + 1) * 12;
  183. }
  184. if (tempMonth < 10) {
  185. cur = tempYear+ '-0' + tempMonth;
  186. } else {
  187. cur = tempYear+ '-' + tempMonth;
  188. }
  189. dateData.push({
  190. name: cur
  191. });
  192. if(i == 0) {
  193. this.chooseTime = cur;
  194. }
  195. }
  196. this.date = dateData;
  197. this.getList();
  198. },
  199. openPop(type) {
  200. if(type == 1) {
  201. this.personalScore = this.detail.personalScore==null?0:this.detail.personalScore;
  202. this.score = true;
  203. } else if(type == 2) {
  204. this.reason = this.detail.reason==null?'':this.detail.reason;
  205. this.reasonPop = true;
  206. }
  207. },
  208. submit(type) {
  209. var reg = /^([0-9]|10)(\.\d)?$/;
  210. var scoreNum = 0;
  211. for(var i in this.ideaList) {
  212. if(this.ideaList[this.chooseSugNum].uid == this.ideaList[i].uid && this.ideaList[this.chooseSugNum].id != this.ideaList[i].id) {
  213. scoreNum += this.ideaList[i].score;
  214. }
  215. }
  216. if(!reg.test(this.sugScore)) {
  217. this.$toast({
  218. message: '分数区间为0 ~ 10',
  219. duration: 2000
  220. });
  221. return false;
  222. } else if((parseFloat(scoreNum) + parseFloat(this.sugScore)) > 10){
  223. this.$toast({
  224. message: '当前人员建议分总分不能超过10分',
  225. duration: 2000
  226. });
  227. return false;
  228. } else {
  229. var from = {};
  230. if(this.ideaList[this.chooseSugNum].ideaComment != null) {
  231. from = {
  232. "ideaId": this.ideaList[this.chooseSugNum].id,
  233. "score": this.sugScore,
  234. "content": this.sugContent,
  235. "responderId": this.user.id,
  236. "scoreId": this.ideaList[this.chooseSugNum].scoreId,
  237. "id": this.ideaList[this.chooseSugNum].ideaComment.id,
  238. }
  239. } else {
  240. from = {
  241. "ideaId": this.ideaList[this.chooseSugNum].id,
  242. "score": this.sugScore,
  243. "content": this.sugContent,
  244. "responderId": this.user.id,
  245. "scoreId": this.ideaList[this.chooseSugNum].scoreId,
  246. }
  247. }
  248. this.$indicator.open();
  249. this.http.post(this.port.my.leaderScore, from ,
  250. res => {
  251. this.$indicator.close();
  252. if (res.code == "ok") {
  253. this.$toast({
  254. message: "打分成功",
  255. duration: 2000
  256. });
  257. this.sugScorePop = false;
  258. this.getList();
  259. } else {
  260. this.$toast({
  261. message: res.msg,
  262. duration: 2000
  263. });
  264. }
  265. }, error => {
  266. this.$indicator.close();
  267. this.sugScorePop = false;
  268. this.$toast({
  269. message: error,
  270. duration: 2000
  271. });
  272. })
  273. }
  274. },
  275. closePop() {
  276. this.sugScorePop = false;
  277. },
  278. openSugPop(i) {
  279. this.sugScore = this.ideaList[i].score == null? 0 : this.ideaList[i].score;
  280. this.sugContent = this.ideaList[i].ideaComment == null? '' : this.ideaList[i].ideaComment.content;
  281. this.sugScorePop = true;
  282. this.chooseSugNum = i;
  283. },
  284. showBtnList(id) {
  285. if($("#btn" + id).attr("class").indexOf("hide") == -1) {
  286. $("#btn" + id).slideUp().addClass("hide");
  287. } else {
  288. $(".one_suggest_reply .showMoreBtn .btn_list").addClass("hide").slideUp();
  289. $("#btn" + id).slideDown().removeClass("hide");
  290. }
  291. },
  292. deleteScore(index) {
  293. MessageBox.confirm('', { 
  294. message: '是否删除该分数、评论?', 
  295. title: '', 
  296. confirmButtonText: '确定', 
  297. cancelButtonText: '取消' 
  298.  }).then(action => { 
  299. if (action == 'confirm') {     //确认的回调
  300. this.http.post(this.port.my.delScore, {
  301. 'id': this.ideaList[index].ideaComment.id,
  302. } ,
  303. res => {
  304. if (res.code == "ok") {
  305. this.$toast({
  306. message: "删除成功",
  307. duration: 2000
  308. });
  309. this.getList();
  310. } else {
  311. this.$toast({
  312. message: res.msg,
  313. duration: 2000
  314. });
  315. }
  316. }, error => {
  317. this.$toast({
  318. message: error,
  319. duration: 2000
  320. });
  321. })
  322. }
  323.  }).catch(err => { 
  324.  });
  325. },
  326. globalClick(callback) {
  327. document.getElementById('allocation').onclick = function () {
  328. $(".one_suggest_reply .showMoreBtn .btn_list").addClass("hide").slideUp();
  329. }
  330. }
  331. },
  332. created() {
  333. this.getDate();
  334. },
  335. mounted() {
  336. }
  337. }
  338. </script>
  339. <style scoped>
  340. body {
  341. background: #EFEFEF!important;
  342. }
  343. .context_router {
  344. background: #EFEFEF;
  345. }
  346. .detail {
  347. background: #EFEFEF;
  348. }
  349. .detail_head {
  350. background: #fff;
  351. color: #333;
  352. height: 0.4rem;
  353. }
  354. .detail_body {
  355. margin-top: 0.4rem;
  356. padding-bottom: 0.15rem;
  357. background: #efefef;
  358. }
  359. .detailBox {
  360. background: #fff;
  361. margin-bottom: 0.1rem;
  362. }
  363. .one_recordBox {
  364. padding: 0.12rem 0.2rem;
  365. }
  366. .record_head {
  367. padding: 0 0 0.1rem 0;
  368. line-height: 0.25rem;
  369. border-bottom: 1px solid #ccc;
  370. }
  371. .record_head > div {
  372. width: 100%;
  373. display: inline-block;
  374. vertical-align: middle;
  375. line-height: 0.4rem;
  376. }
  377. .record_head > div img {
  378. width:0.12rem;
  379. float:right;
  380. margin: 0.135rem 0 0 0;
  381. }
  382. .record_head > div span {
  383. color: #5FA1F0;
  384. margin-left: 0.2rem;
  385. float: right;
  386. margin-right: 0.05rem;
  387. }
  388. .record_body {
  389. color: #5FA1F0;
  390. font-size: 0.14rem;
  391. margin: 0.12rem 0 0 0;
  392. }
  393. .record_body .toDetail {
  394. float: right;
  395. margin-right: 0.05rem;
  396. }
  397. .record_body .toDetail img {
  398. width: 0.12rem;
  399. }
  400. .one_suggest_title {
  401. line-height: 0.3rem;
  402. }
  403. .one_suggest_title span {
  404. float: right;
  405. font-size: 0.13rem;
  406. }
  407. .one_suggest_title span.areaday {
  408. color: #ccc;
  409. }
  410. .one_suggest_title span.edit {
  411. color:#5FA1F0;
  412. }
  413. .one_suggest_body {
  414. font-size: 0.13rem;
  415. line-height: 0.2rem;
  416. color: #333;
  417. }
  418. .one_suggest_reply {
  419. margin-top: 0.12rem;
  420. }
  421. .reply_title {
  422. font-size: 0.12rem;
  423. color: #999;
  424. margin-bottom: 0.08rem;
  425. }
  426. .reply_body {
  427. padding: 0.1rem;
  428. background: #EEE;
  429. color: #333;
  430. }
  431. .reply_body > div {
  432. color: #333;
  433. line-height: 0.2rem;
  434. font-size: 0.13rem;
  435. color: #777;
  436. }
  437. .reply_body > div:nth-child(1) {
  438. margin-top: 0.1rem;
  439. }
  440. .reply_body .score {
  441. float: right;
  442. }
  443. .reply_body .score span {
  444. color: #5FA1F0;
  445. }
  446. .mint-popup {
  447. width: 70%;
  448. box-sizing: content-box;
  449. }
  450. .mint-popup-div {
  451. padding: 0.12rem;
  452. background: #fff;
  453. }
  454. .mint-popup-div h4 {
  455. margin: 0;
  456. padding: 0;
  457. }
  458. .mint-popup-div .mint-cell {
  459. margin: 0.2rem 0;
  460. }
  461. .mint-popup-div > div.btns {
  462. height: 0.3rem;
  463. }
  464. .mint-popup-div .btn {
  465. float: right;
  466. margin-right: 0.1rem;
  467. background: #fff;
  468. box-shadow: none;
  469. width: 50%;
  470. margin: 0;
  471. }
  472. .mint-popup-div .btn:nth-child(1) {
  473. color: #f00;
  474. }
  475. .allocation {
  476. width: 100%;
  477. height: 100%;
  478. }
  479. .noList {
  480. text-align: center;
  481. padding: 1.5rem 0;
  482. }
  483. .noList img {
  484. width: 1.2rem;
  485. height: 1.2rem;
  486. }
  487. .order {
  488. height: 0.6rem;
  489. line-height: 0.6rem;
  490. text-align: center;
  491. }
  492. .order .line {
  493. display: inline-block;
  494. width: 1.2rem;
  495. border-top: 1px solid #ccc ;
  496. vertical-align: middle;
  497. }
  498. .order .txt {
  499. color: #ccc;
  500. font-size: 0.13rem;
  501. vertical-align: middle;
  502. }
  503. .showMoreBtn {
  504. display: inline-block;
  505. float: right;
  506. position: relative;
  507. }
  508. .showMoreBtn img {
  509. width: 0.23rem;
  510. }
  511. .btn_list {
  512. position: absolute;
  513. right: -0.04rem;
  514. top: 0.30rem;
  515. border:#aaa;
  516. background: #fcfcfc;
  517. box-shadow: 5px 5px 10px #ccc;
  518. z-index: 105;
  519. }
  520. .btn_list:before {
  521. display: inline-block;
  522. width: 0;
  523. height: 0;
  524. border: solid transparent;
  525. border-width: 10px;
  526. border-bottom-color: #fcfcfc;
  527. content: "";
  528. position: absolute;
  529. top: -20px;
  530. right: 0.06rem;
  531. }
  532. .btn_list > div {
  533. width: 0.6rem;
  534. font-size: 0.13rem;
  535. padding: 0.1rem 0.15rem;
  536. border-bottom: 1px solid #efefef;
  537. text-align: center;
  538. }
  539. .btn_list > div img {
  540. width: 0.14rem;
  541. height: 0.14rem;
  542. vertical-align: middle;
  543. margin-right: 0.05rem;
  544. }
  545. .btn_list > div span {
  546. height: 0.15rem;
  547. line-height: 0.15rem;
  548. vertical-align: middle;
  549. }
  550. .hide {
  551. display: none;
  552. }
  553. </style>
  554. <style>
  555. .mint-popup-div input {
  556. border: 1px solid #ddd;
  557. border-radius: 5px;
  558. padding: 0.08rem;
  559. }
  560. </style>