addGoods.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. font-size: 32rpx;
  88. overflow-y: auto;
  89. .search {
  90. display: flex;
  91. align-items: center;
  92. margin: 30rpx auto 30rpx;
  93. width: 690rpx;
  94. height: 80rpx;
  95. border-radius: 4rpx;
  96. background-color: #f2f2f2;
  97. img {
  98. margin: 0 20rpx;
  99. width: 40rpx;
  100. height: 40rpx;
  101. }
  102. input {
  103. flex: 1;
  104. padding: 10rpx;
  105. }
  106. }
  107. .body {
  108. display: flex;
  109. height: 686rpx;
  110. border-top: 1rpx solid #e5e5e5;
  111. .body_left {
  112. box-sizing: border-box;
  113. padding: 30rpx;
  114. width: 199rpx;
  115. border-right: 1rpx solid #cccccc;
  116. overflow-y: auto;
  117. .left_item {
  118. height: 80rpx;
  119. // font-size: 28rpx;
  120. font-weight: bold;
  121. }
  122. .active {
  123. color: #6fb6b8;
  124. }
  125. }
  126. .body_right {
  127. flex: 1;
  128. box-sizing: border-box;
  129. padding: 35rpx 30rpx;
  130. overflow-y: auto;
  131. .right_item {
  132. float: left;
  133. box-sizing: border-box;
  134. padding: 10rpx 30rpx;
  135. margin: 0 20rpx 37rpx 0;
  136. height: 50rpx;
  137. line-height: 30rpx;
  138. text-align: center;
  139. color: #808080;
  140. // font-size: 28rpx;
  141. border-radius: 53rpx;
  142. background-color: #e6e6e6;
  143. overflow: hidden;
  144. white-space: nowrap;
  145. text-overflow: ellipsis;
  146. }
  147. .active {
  148. color: #fff;
  149. background-color: #6fb6b8;
  150. }
  151. }
  152. }
  153. .notes {
  154. box-sizing: border-box;
  155. padding: 0 30rpx;
  156. border-top: 1rpx solid #e5e5e5;
  157. .notes_title {
  158. display: flex;
  159. align-items: center;
  160. height: 88rpx;
  161. font-size: 32rpx;
  162. font-weight: bold;
  163. }
  164. .notes_textarea {
  165. position: relative;
  166. height: 284rpx;
  167. border: 1rpx solid #e5e5e5;
  168. textarea {
  169. box-sizing: border-box;
  170. padding: 16rpx 20rpx 75rpx;
  171. width: 100%;
  172. font-size: 32rpx;
  173. }
  174. .notes_num {
  175. position: absolute;
  176. right: 20rpx;
  177. bottom: 14rpx;
  178. color: #a6a6a6;
  179. font-size: 32rpx;
  180. }
  181. }
  182. }
  183. .btn {
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. margin: 55rpx auto 65rpx;
  188. width: 690rpx;
  189. height: 100rpx;
  190. color: #fff;
  191. font-size: 32rpx;
  192. border-radius: 12rpx;
  193. background-color: #6fb6b8;
  194. }
  195. }
  196. </style>