综合办公系统
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RepairDevicePicker.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <uni-popup ref="popup" type="center">
  3. <view class="popup-content">
  4. <view class="popup-header">
  5. <text class="title">选择需维修设备</text>
  6. <uni-icons type="closeempty" size="24" @click="close"></uni-icons>
  7. </view>
  8. <view class="popup-body">
  9. <view class="device-list">
  10. <view class="device-item"
  11. v-for="(item, index) in deviceList"
  12. :key="index"
  13. :class="{ 'selected': isSelected(item.deviceId) }"
  14. @click="toggleSelection(item)">
  15. <view class="device-info">
  16. <text class="device-name">{{ item.name }}</text>
  17. <text class="device-code">出厂编号:{{ item.code }}</text>
  18. </view>
  19. <uni-icons
  20. :type="isSelected(item.deviceId) ? 'checkbox-filled' : 'circle'"
  21. :color="isSelected(item.deviceId) ? '#67c23a' : '#999'"
  22. size="20">
  23. </uni-icons>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="popup-footer">
  28. <uv-button type="default" @click="close">取消</uv-button>
  29. <uv-button type="primary" @click="confirm">确认</uv-button>
  30. </view>
  31. </view>
  32. </uni-popup>
  33. </template>
  34. <script>
  35. export default {
  36. name: 'RepairDevicePicker',
  37. props: {
  38. visible: {
  39. type: Boolean,
  40. default: false
  41. },
  42. deviceList: {
  43. type: Array,
  44. default: () => []
  45. },
  46. selectedDevices: {
  47. type: Array,
  48. default: () => []
  49. }
  50. },
  51. data() {
  52. return {
  53. tempSelected: []
  54. }
  55. },
  56. watch: {
  57. visible(val) {
  58. if (val) {
  59. this.$refs.popup.open();
  60. this.tempSelected = [...this.selectedDevices];
  61. } else {
  62. this.$refs.popup.close();
  63. }
  64. },
  65. selectedDevices: {
  66. handler(val) {
  67. this.tempSelected = [...val];
  68. },
  69. immediate: true
  70. }
  71. },
  72. methods: {
  73. isSelected(deviceId) {
  74. return this.tempSelected.includes(deviceId);
  75. },
  76. toggleSelection(device) {
  77. const index = this.tempSelected.indexOf(device.deviceId);
  78. if (index === -1) {
  79. this.tempSelected.push(device.deviceId);
  80. } else {
  81. this.tempSelected.splice(index, 1);
  82. }
  83. },
  84. close() {
  85. this.$emit('update:visible', false);
  86. },
  87. confirm() {
  88. this.$emit('update:selectedDevices', this.tempSelected);
  89. this.close();
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .popup-content {
  96. width: 600rpx;
  97. background: #fff;
  98. border-radius: 12rpx;
  99. overflow: hidden;
  100. }
  101. .popup-header {
  102. padding: 20rpx;
  103. display: flex;
  104. justify-content: space-between;
  105. align-items: center;
  106. border-bottom: 1rpx solid #eee;
  107. .title {
  108. font-size: 32rpx;
  109. font-weight: bold;
  110. }
  111. }
  112. .popup-body {
  113. max-height: 600rpx;
  114. overflow-y: auto;
  115. padding: 20rpx;
  116. }
  117. .device-list {
  118. .device-item {
  119. display: flex;
  120. justify-content: space-between;
  121. align-items: center;
  122. padding: 20rpx;
  123. border-bottom: 1rpx solid #eee;
  124. &:last-child {
  125. border-bottom: none;
  126. }
  127. &.selected {
  128. background-color: rgba(103, 194, 58, 0.05);
  129. }
  130. .device-info {
  131. flex: 1;
  132. .device-name {
  133. font-size: 28rpx;
  134. color: #333;
  135. display: block;
  136. margin-bottom: 8rpx;
  137. }
  138. .device-code {
  139. font-size: 24rpx;
  140. color: #666;
  141. }
  142. }
  143. }
  144. }
  145. .popup-footer {
  146. padding: 20rpx;
  147. display: flex;
  148. justify-content: flex-end;
  149. gap: 20rpx;
  150. border-top: 1rpx solid #eee;
  151. }
  152. </style>