item.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.stop="
  11. openUpdateStateDialog(data, '1')
  12. return false
  13. "
  14. v-if="data.status != '1' && data.orgId == orgId"
  15. >布防登记</van-button
  16. >
  17. <van-button
  18. size="mini"
  19. color="#008cd6"
  20. type="info"
  21. @click.stop="
  22. openUpdateStateDialog(data, '0')
  23. return false
  24. "
  25. v-if="data.status != '0' && data.orgId == orgId"
  26. >撤防登记</van-button
  27. >
  28. </template>
  29. </van-cell>
  30. <van-cell title="布撤防状态">
  31. <template #right-icon>
  32. <!-- <span v-if="data.status==1" style="color:rgb(0,164,46)">布防</span>
  33. <span v-else-if="data.status==0" style="color:rgb(215,0,15)">撤防</span> -->
  34. <span>{{ getDictLabel(data.status, 'protection_status', '未上报') }}</span>
  35. </template>
  36. </van-cell>
  37. <van-cell
  38. v-if="data.status == '0' || data.status == '1'"
  39. :title="data.status == '0' ? '撤防时间' : '布防时间'"
  40. value-class="time-cell-default"
  41. >
  42. <template #default>
  43. <van-tag type="primary" color="rgb(184,159,113)" v-if="data.statusUpdatorName!=null">人工登记</van-tag>
  44. <van-tag type="primary" v-else>自动获取</van-tag>
  45. <span style="margin-left:10px">{{data.statusChangeTime}}</span>
  46. </template>
  47. </van-cell>
  48. </van-cell-group>
  49. <state-change-diaolog ref="stateChangeDiaolog" @success="updateStatus"/>
  50. </div>
  51. </template>
  52. <script>
  53. import { mapGetters } from 'vuex'
  54. import * as api from '@/api/protection.js'
  55. import { Dialog } from 'vant'
  56. import StateChangeDiaolog from './dialog.stateChange.vue'
  57. import dayjs from 'dayjs'
  58. export default {
  59. components: { StateChangeDiaolog },
  60. data() {
  61. return {}
  62. },
  63. computed: {
  64. ...mapGetters(['orgName', 'orgId', 'dictionary'])
  65. },
  66. watch: {},
  67. props: {
  68. data: {},
  69. statusOptions: {}
  70. },
  71. methods: {
  72. formatDate(dateStr) {
  73. return toFormatStr(dateStr)
  74. },
  75. openUpdateStateDialog(data, status) {
  76. this.$refs.stateChangeDiaolog.open(data,status, this.getDictLabel(status, 'protection_status', '未知'))
  77. // Dialog.confirm({
  78. // message: `是否更新${this.getDictLabel(status, 'protection_status', '未上报')}时间?`
  79. // })
  80. // .then(() => {
  81. // api.updateStatus(data.id, status).then(r => {
  82. // if (r.data) {
  83. // data.status = status
  84. // data.statusUpdateTime = dayjs(r.data).format('YYYY-MM-DD HH:mm')
  85. // }
  86. // })
  87. // })
  88. // .catch(() => {
  89. // // on cancel
  90. // })
  91. },
  92. updateStatus(data, status,changeTime) {
  93. api.updateStatus(data.id, status,dayjs(changeTime).format('YYYY-MM-DD HH:mm:00')).then(r => {
  94. if (r.data) {
  95. data.status = status
  96. data.statusChangeTime = dayjs(changeTime).format('YYYY-MM-DD HH:mm')
  97. data.statusUpdatorName=this.$store.getters.userName
  98. }
  99. })
  100. },
  101. itemClick() {
  102. this.$router.push('/iot/subsystem/detail?id=' + this.data.id)
  103. }
  104. },
  105. async created() {},
  106. async mounted() {}
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .k-app-protection-list__item {
  111. // height: 11.85rem;
  112. background: #ffffff;
  113. margin: 0.3rem 0.325rem 0;
  114. font-size: 3.733333vw;
  115. .top {
  116. // min-height: 3rem;
  117. padding: 0.05rem 0.05rem;
  118. display: flex;
  119. flex-direction: row;
  120. align-items: center;
  121. border-bottom: 1px solid #f3f4f5;
  122. > label {
  123. // height: 1.38rem;
  124. // font-size: 1rem;
  125. // line-height: 1.25rem;
  126. color: #323233;
  127. opacity: 1;
  128. }
  129. }
  130. .bottom {
  131. min-height: 7.75rem;
  132. padding: 0 1rem;
  133. span {
  134. height: 1.25rem;
  135. font-size: 0.88rem;
  136. line-height: 1.25rem;
  137. color: #000000;
  138. opacity: 0.61;
  139. }
  140. }
  141. }
  142. .wrapper {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. height: 100%;
  147. }
  148. .time-cell-default{
  149. min-width: 60vw;
  150. }
  151. </style>