item.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="flex flex-col justify-center k-app-protection-list__item van-clearfix">
  3. <van-cell-group clickable @click="itemClick">
  4. <van-cell :title="data.name">
  5. <template #right-icon>
  6. <van-button
  7. size="mini"
  8. color="#008cd6"
  9. type="info"
  10. @click="updateStatus(data, '1')"
  11. v-if="data.status != '1' && data.orgId == orgId"
  12. >布防时间登记</van-button
  13. >
  14. <van-button
  15. size="mini"
  16. color="#008cd6"
  17. type="info"
  18. @click="updateStatus(data, '0')"
  19. v-if="data.status != '0' && data.orgId == orgId"
  20. >撤防时间登记</van-button
  21. >
  22. </template>
  23. </van-cell>
  24. <van-cell title="防区状态" :value="getLabel(statusOptions, data.status, '未知')" />
  25. <van-cell
  26. v-if="data.status == '0' || data.status == '1'"
  27. :title="data.status == '0' ? '撤防时间' : '布防时间'"
  28. :value="data.statusUpdateTime"
  29. />
  30. </van-cell-group>
  31. </div>
  32. </template>
  33. <script>
  34. import { mapGetters } from 'vuex'
  35. import { getLabel } from '@/utils/optionEx.js'
  36. import * as api from '@/api/protection.js'
  37. import { Dialog } from 'vant'
  38. import dayjs from 'dayjs'
  39. export default {
  40. components: {},
  41. data() {
  42. return {}
  43. },
  44. computed: {
  45. ...mapGetters(['orgName', 'orgId'])
  46. },
  47. watch: {},
  48. props: {
  49. data: {},
  50. statusOptions: {}
  51. },
  52. methods: {
  53. getLabel,
  54. formatDate(dateStr) {
  55. return toFormatStr(dateStr)
  56. },
  57. updateStatus(data, status) {
  58. Dialog.confirm({
  59. message: `是否更新${this.getLabel(this.statusOptions, status)}时间?`
  60. })
  61. .then(() => {
  62. api.updateStatus(data.id, status).then(r => {
  63. if (r.data) {
  64. data.status = status
  65. data.statusUpdateTime = dayjs(r.data).format('YYYY-MM-DD HH:MM:ss')
  66. }
  67. })
  68. })
  69. .catch(() => {
  70. // on cancel
  71. })
  72. },
  73. itemClick() {
  74. this.$router.push('/protection/detail?id=' + this.data.id)
  75. }
  76. },
  77. async created() {},
  78. async mounted() {}
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .k-app-protection-list__item {
  83. // height: 11.85rem;
  84. background: #ffffff;
  85. margin: 0.3rem 0.325rem 0;
  86. font-size: 3.733333vw;
  87. .top {
  88. // min-height: 3rem;
  89. padding: 0.05rem 0.05rem;
  90. display: flex;
  91. flex-direction: row;
  92. align-items: center;
  93. border-bottom: 1px solid #f3f4f5;
  94. > label {
  95. // height: 1.38rem;
  96. // font-size: 1rem;
  97. // line-height: 1.25rem;
  98. color: #323233;
  99. opacity: 1;
  100. }
  101. }
  102. .bottom {
  103. min-height: 7.75rem;
  104. padding: 0 1rem;
  105. span {
  106. height: 1.25rem;
  107. font-size: 0.88rem;
  108. line-height: 1.25rem;
  109. color: #000000;
  110. opacity: 0.61;
  111. }
  112. }
  113. }
  114. .wrapper {
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. height: 100%;
  119. }
  120. </style>