addGoods.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="container">
  3. <!-- 输入框区域 -->
  4. <view class="search">
  5. <img src="../../static/images/repairsImg/search.png" />
  6. <input type="text" placeholder="请输入搜索内容" v-model="searchValue" />
  7. </view>
  8. <!-- 耗材区域 -->
  9. <view class="body">
  10. <view class="body_left">
  11. <view class="left_item" :class="{ active: activeIndex === index }" v-for="(item, index) in list" :key="index" @click="handleChange(index)">{{ item }}</view>
  12. </view>
  13. <view class="body_right">
  14. <view class="right_item" :class="{ active: activeIndex2 === index2 }" v-for="(ele, index2) in List2" :key="index2" @click="handleChange2(index2)">{{ ele }}</view>
  15. </view>
  16. </view>
  17. <!-- 备注区域 -->
  18. <view class="notes" v-if="list[activeIndex] === '其他'">
  19. <view class="notes_title">备注</view>
  20. <view class="notes_textarea">
  21. <textarea placeholder-style="color:#CCCCCC" placeholder="请输入您的备注" maxlength="150" v-model="textareaValue" @input="handleInput"></textarea>
  22. <view class="notes_num">{{ textLength }}/150</view>
  23. </view>
  24. </view>
  25. <view class="btn" v-if="list[activeIndex] === '其他'" @click="handleAffirm">确认</view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. // 搜索框绑定数据
  33. searchValue: '',
  34. // 备注输入框绑定数据
  35. textareaValue: '',
  36. // 输入框当前输入数据的长度
  37. textLength: 0,
  38. // 左边数组的索引
  39. activeIndex: 0,
  40. // 左边数组
  41. list: ['水电', '木工类', '行政楼', '泥工类', '其他'],
  42. // 右边数组的索引
  43. activeIndex2: 0,
  44. // 右边数组
  45. List2: ['下水道', '安全指示牌', '消费应急灯', '排水管道', '吊顶', '风扇', '没电']
  46. }
  47. },
  48. methods: {
  49. // 确认按钮回调
  50. handleAffirm() {
  51. if (this.textareaValue) {
  52. this.List2.push(this.textareaValue)
  53. this.textareaValue = ''
  54. } else {
  55. uni.showToast({
  56. title: '请输入备注',
  57. icon: 'none'
  58. })
  59. }
  60. },
  61. // 左边数组切换回调
  62. handleChange(index) {
  63. this.activeIndex = index
  64. },
  65. // 右边数组切换回调
  66. handleChange2(index) {
  67. this.activeIndex2 = index
  68. uni.$emit('addConsumable', {
  69. data: this.List2[this.activeIndex2]
  70. })
  71. uni.navigateBack(1)
  72. },
  73. // 输入框输入值变化回调
  74. handleInput(e) {
  75. // console.log(e.detail.value.length)
  76. this.textLength = e.detail.value.length
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .container {
  83. display: flex;
  84. flex-direction: column;
  85. width: 100vw;
  86. height: 100vh;
  87. overflow-y: auto;
  88. .search {
  89. display: flex;
  90. align-items: center;
  91. margin: 30rpx auto 30rpx;
  92. width: 690rpx;
  93. height: 80rpx;
  94. border-radius: 4rpx;
  95. background-color: #f2f2f2;
  96. img {
  97. margin: 0 20rpx;
  98. width: 40rpx;
  99. height: 40rpx;
  100. }
  101. input {
  102. flex: 1;
  103. padding: 10rpx;
  104. }
  105. }
  106. .body {
  107. display: flex;
  108. height: 686rpx;
  109. border-top: 1rpx solid #e5e5e5;
  110. .body_left {
  111. box-sizing: border-box;
  112. padding: 30rpx;
  113. width: 199rpx;
  114. border-right: 1rpx solid #cccccc;
  115. overflow-y: auto;
  116. .left_item {
  117. height: 80rpx;
  118. font-size: 28rpx;
  119. font-weight: bold;
  120. }
  121. .active {
  122. color: #6fb6b8;
  123. }
  124. }
  125. .body_right {
  126. flex: 1;
  127. box-sizing: border-box;
  128. padding: 35rpx 30rpx;
  129. overflow-y: auto;
  130. .right_item {
  131. float: left;
  132. box-sizing: border-box;
  133. padding: 10rpx 30rpx;
  134. margin: 0 20rpx 37rpx 0;
  135. height: 50rpx;
  136. line-height: 30rpx;
  137. text-align: center;
  138. color: #808080;
  139. font-size: 28rpx;
  140. border-radius: 53rpx;
  141. background-color: #e6e6e6;
  142. overflow: hidden;
  143. white-space: nowrap;
  144. text-overflow: ellipsis;
  145. }
  146. .active {
  147. color: #fff;
  148. background-color: #6fb6b8;
  149. }
  150. }
  151. }
  152. .notes {
  153. box-sizing: border-box;
  154. padding: 0 30rpx;
  155. border-top: 1rpx solid #e5e5e5;
  156. .notes_title {
  157. display: flex;
  158. align-items: center;
  159. height: 88rpx;
  160. font-size: 32rpx;
  161. font-weight: bold;
  162. }
  163. .notes_textarea {
  164. position: relative;
  165. height: 284rpx;
  166. border: 1rpx solid #e5e5e5;
  167. textarea {
  168. box-sizing: border-box;
  169. padding: 16rpx 20rpx 75rpx;
  170. width: 100%;
  171. font-size: 32rpx;
  172. }
  173. .notes_num {
  174. position: absolute;
  175. right: 20rpx;
  176. bottom: 14rpx;
  177. color: #a6a6a6;
  178. font-size: 32rpx;
  179. }
  180. }
  181. }
  182. .btn {
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. margin: 55rpx auto 65rpx;
  187. width: 690rpx;
  188. height: 100rpx;
  189. color: #fff;
  190. font-size: 32rpx;
  191. border-radius: 12rpx;
  192. background-color: #6fb6b8;
  193. }
  194. }
  195. </style>