WorkNotificationItem.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="work-notification-item">
  3. <div class="desc-group">
  4. <span class="yhimg"></span>
  5. <div class="content">
  6. <div class="work-notification-title">{{ info.messageTitle }}</div>
  7. <div class="work-notification-padding">{{ info. messageContent }}</div>
  8. </div>
  9. </div>
  10. <div class="right-group">
  11. <div class="warn-icon"
  12. v-if="isOutOfDate && isOutOfDateType">
  13. <img src="../../../assets/images/common/notification/limit.png">
  14. </div>
  15. <div class="right">
  16. <p class="notification-size">{{ info.showTime | dateFilter }}</p>
  17. </div>
  18. <div class="action">
  19. <el-button @click="showDialog = true">{{ $t('workNotification.handleLater') }}</el-button>
  20. <el-button type="primary"
  21. @click="handleNow">{{ $t('workNotification.handle') }}</el-button>
  22. </div>
  23. </div>
  24. <ws-dialog :title="$t('workNotification.handleLater')"
  25. :visible.sync="showDialog"
  26. @closed="days = '0'"
  27. width="500px">
  28. <div class="dialog-content">
  29. <ws-form label-width="180px"
  30. style="width: 100%">
  31. <ws-form-item :label="$t('workNotification.inputDelayDays')"
  32. required>
  33. <ws-input v-model="days"></ws-input>
  34. </ws-form-item>
  35. </ws-form>
  36. <ws-radio-group v-model="days">
  37. <ws-radio label="1">{{ $t('workNotification.oneDay') }}</ws-radio>
  38. <ws-radio label="7">{{ $t('workNotification.oneWeek') }}</ws-radio>
  39. <ws-radio label="30">{{ $t('workNotification.oneMonth') }}</ws-radio>
  40. </ws-radio-group>
  41. </div>
  42. <div slot="footer">
  43. <ws-button @click="showDialog = false">{{ $t('button.cancel') }}</ws-button>
  44. <ws-button @click="doHandleLater"
  45. type="primary">{{ $t('button.confirm') }}</ws-button>
  46. </div>
  47. </ws-dialog>
  48. </div>
  49. </template>
  50. <script>
  51. import notificationType from '../types/notificationType';
  52. import * as utils from '../utils';
  53. import { handleLater } from '@/model/indexRx';
  54. import XEUtils from 'xe-utils';
  55. import { EventBus, dayjs } from 'base-core-lib'
  56. export default {
  57. name: 'WorkNotificationItem',
  58. //filters: {
  59. // dateFilter(date) {
  60. // const now = new Date();
  61. // const targetDate = new Date(date);
  62. // now.setHours(now.getHours() + 8);
  63. // targetDate.setHours(targetDate.getHours() + 8);
  64. // // 如果时间差小于一天 17:30
  65. // if (now - targetDate < 24 * 60 * 60 * 1000) {
  66. // return `${targetDate.toISOString().slice(11, 16)} `
  67. // // eslint-disable-next-line brace-style
  68. // }
  69. // // 如果时间差小于一年 07-20 17:30
  70. // else if (now - targetDate < 24 * 60 * 60 * 1000 * 365) {
  71. // return `${targetDate.toISOString().slice(5, 10)} ${targetDate.toISOString().slice(11, 16)} `
  72. // // eslint-disable-next-line brace-style
  73. // }
  74. // 如果时间差大于一年 2019-07-20 17:30
  75. // else {
  76. // return `${targetDate.toISOString().slice(0, 10)} ${targetDate.toISOString().slice(11, 16)} `
  77. // }
  78. // }
  79. //},
  80. filters: {
  81. dateFilter (date) {
  82. let currDate = XEUtils.toStringDate(date);
  83. // let newDate = new Date();
  84. if (XEUtils.isDate(currDate)) {
  85. // if (newDate.getFullYear() === currDate.getFullYear() && newDate.getMonth() === currDate.getMonth() && newDate.getDay() === currDate.getDay()) {
  86. if (dayjs().year() === dayjs(currDate).year() && (dayjs().month() + 1) === (dayjs(currDate).month() + 1) && dayjs().day() === dayjs(currDate).day()) {
  87. return XEUtils.toDateString(currDate, 'HH:mm');
  88. // } else if (newDate.getFullYear() === currDate.getFullYear()) {
  89. } else if (dayjs().year() === dayjs(currDate).year()) {
  90. return XEUtils.toDateString(currDate, 'MM-dd HH:mm');
  91. } else {
  92. return XEUtils.toDateString(currDate, 'yyyy-MM-dd HH:mm');
  93. }
  94. } else {
  95. return '';
  96. }
  97. }
  98. },
  99. props: {
  100. info: Object,
  101. },
  102. data () {
  103. return {
  104. msgKey: 0,
  105. showDialog: false,
  106. days: '0',
  107. }
  108. },
  109. computed: {
  110. isOutOfDate () {
  111. // 任务超期时间
  112. // const behindTime = new Date(this.info.behindTime);
  113. // behindTime.setHours(23, 59, 59);
  114. const behindTime = dayjs(this.info.behindTime).format('YYYY-MM-DD') + ' 23:59:59'
  115. // 任务未在任务日期当天23:59前处理的,该任务被标识为超期
  116. // 现在时间过了任务日期当天23:59,并且任务状态处在未处理状态的 返回true
  117. return this.info.acceptanceType === 'NEED_HANDLE' && dayjs() > behindTime
  118. },
  119. isOutOfDateType () {
  120. return !(this.info.businessType !== notificationType.SEAFARERS_MANAGEMENT && this.info.businessType !== notificationType.SHIP_CERTIFICATE);
  121. }
  122. },
  123. methods: {
  124. handleNow () {
  125. const info = this.info;
  126. const id = info.businessId;
  127. const title = info.messageContent;
  128. const url = this.checkType(info);
  129. if (!url) {
  130. EventBus.$emit('error', this.$t('workNotification.noRelatedType'))
  131. } else {
  132. if (url === 'appPurDetail' || url === 'appPurDetailMa') {
  133. this.$router.push({ name: url, query: { id: id, applId: id, pageBtnShowType: false, title: title, code: info.businessCode } });
  134. } else if (url === 'systemOperation') {
  135. sessionStorage.setItem('ws-pf_systemFile', 2)
  136. this.$router.push({ name: url, query: { id: id, applId: id, pageBtnShowType: false, title: title, code: info.businessCode } });
  137. } else {
  138. this.$router.push({ name: url, query: { id: id, title: title, code: info.businessCode } });
  139. }
  140. }
  141. },
  142. async doHandleLater () {
  143. try {
  144. const info = this.info;
  145. const time = this.nowFormatDate('YYYY-MM-DD HH:mm:ss')
  146. await handleLater({
  147. id: info.id,
  148. time,
  149. delay: this.days,
  150. }).toPromise()
  151. EventBus.$emit('success', this.$t('workNotification.successDelay'))
  152. this.showDialog = false;
  153. this.$emit('handleLater');
  154. } catch (error) {
  155. EventBus.$emit('error', this.$t('workNotification.errorDelay'))
  156. this.showDialog = false;
  157. }
  158. },
  159. checkType () {
  160. return utils.code2Url(this.info.businessType, this.info.businessCode, this.info.acceptanceType);
  161. },
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. .work-notification-title {
  167. color: #333;
  168. font-size: 18px;
  169. font-weight: bold;
  170. }
  171. .yhimg:before {
  172. top: 3px;
  173. position: relative;
  174. display: inline-block;
  175. width: 18px;
  176. height: 18px;
  177. content: '';
  178. background: url(../../../assets/images/page/certificate/certificateBlue.png)
  179. no-repeat;
  180. }
  181. .work-notification-padding {
  182. margin-top: 16px;
  183. color: #666666;
  184. }
  185. .work-notification-item {
  186. margin-top: 10px;
  187. padding: 20px 0 20px 20px;
  188. background: #fff;
  189. position: relative;
  190. display: flex;
  191. font-size: 14px;
  192. color: grey;
  193. }
  194. .dialog-content {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. }
  199. .work-notification-divider {
  200. border-right: 1px solid gray;
  201. }
  202. .right {
  203. text-align: right;
  204. line-height: 20px;
  205. }
  206. .padding-right {
  207. padding-right: 15px;
  208. color: #999999;
  209. }
  210. .notification-size {
  211. color: #999;
  212. font-size: 14px;
  213. text-align: right;
  214. border-right: 1px solid #ccc;
  215. padding-right: 20px;
  216. line-height: 28px;
  217. white-space: nowrap;
  218. text-overflow: ellipsis;
  219. overflow: hidden;
  220. }
  221. .warn-icon {
  222. position: absolute;
  223. right: 300px;
  224. }
  225. .desc-group {
  226. flex: 1;
  227. text-align: left;
  228. display: flex;
  229. .content {
  230. margin-left: 8px;
  231. }
  232. }
  233. .right-group {
  234. flex: none;
  235. display: flex;
  236. align-items: center;
  237. margin-left: 16px;
  238. .action {
  239. padding: 0 16px;
  240. }
  241. }
  242. </style>