rotationItems.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view
  3. class="rotation-wrapper"
  4. :style="{ height: tktype === 1 ? '176rpx' : '450rpx' }"
  5. >
  6. <view class="rotation-item" v-for="(item, index) in list" :key="index">
  7. <view class="rotation-item__label">{{ item.label }}</view>
  8. <view class="rotation-item__value">
  9. <u-number-box
  10. v-model="item.value"
  11. :min="1"
  12. :max="9999"
  13. maxlength="4"
  14. @change="() => valChange(item)"
  15. v-if="item.isNumber"
  16. ></u-number-box>
  17. <view class="rotation-item__value__input">
  18. <u-input
  19. v-model="item.value"
  20. type="number"
  21. maxlength="6"
  22. :max="999999"
  23. input-align="right"
  24. @blur="valChange(item)"
  25. v-if="!item.isNumber && !item.isSelect"
  26. />
  27. <text
  28. style="margin-left: 16rpx; width: 80rpx"
  29. v-if="!item.isNumber && !item.isSelect"
  30. >分钟</text
  31. >
  32. </view>
  33. <view
  34. v-if="!item.isNumber && item.isSelect"
  35. class="rotation-item__value__select"
  36. @click="show = true"
  37. >
  38. <text
  39. style="color: #9ba6a3; margin-right: 16rpx"
  40. :style="{ color: formData.sfmode ? '#666' : '#9ba6a3' }"
  41. >{{ selectText }}</text
  42. >
  43. <u-icon name="arrow-right" color="#4E5969" size="24rpx"></u-icon>
  44. </view>
  45. </view>
  46. </view>
  47. <u-action-sheet
  48. :list="actionSheetList"
  49. v-model="show"
  50. @click="actionSheetCallback"
  51. ></u-action-sheet>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. name: 'rotationItem',
  57. props: {
  58. formData: {
  59. type: Object,
  60. default: () => {},
  61. },
  62. tktype: {
  63. type: Number,
  64. default: 1,
  65. },
  66. },
  67. watch: {
  68. tktype: {
  69. handler(val) {
  70. if (val !== 1) {
  71. this.list = [
  72. {
  73. label: '轮灌次数',
  74. isNumber: true,
  75. value: this.formData['lgcs'] || 1,
  76. key: 'lgcs',
  77. },
  78. {
  79. label: '轮灌间隔',
  80. isNumber: false,
  81. value: this.formData['lgjg'] || '',
  82. key: 'lgjg',
  83. },
  84. {
  85. label: '肥前水',
  86. isNumber: false,
  87. value: this.formData['fqcx'] || '',
  88. key: 'fqcx',
  89. },
  90. {
  91. label: '肥后水',
  92. isNumber: false,
  93. value: this.formData['fhcx'] || '',
  94. key: 'fhcx',
  95. },
  96. {
  97. label: '模式选择',
  98. isNumber: false,
  99. value: this.formData['sfmode'] || '',
  100. key: 'sfmode',
  101. isSelect: true,
  102. },
  103. ];
  104. } else {
  105. this.list = [
  106. {
  107. label: '轮灌次数',
  108. isNumber: true,
  109. value: this.formData['lgcs'] || 1,
  110. key: 'lgcs',
  111. },
  112. {
  113. label: '轮灌间隔',
  114. isNumber: false,
  115. value: this.formData['lgjg'] || '',
  116. key: 'lgjg',
  117. },
  118. ];
  119. }
  120. },
  121. deep: true,
  122. immediate: true,
  123. },
  124. formData: {
  125. handler(val) {},
  126. deep: true,
  127. immediate: true,
  128. },
  129. },
  130. data() {
  131. return {
  132. list: [],
  133. selectText: '请选择',
  134. show: false,
  135. actionSheetList: [
  136. {
  137. text: '定时',
  138. id: 1,
  139. },
  140. {
  141. text: '定量',
  142. id: 2,
  143. },
  144. {
  145. text: 'EC调配',
  146. id: 3,
  147. },
  148. {
  149. text: '混肥比例',
  150. id: 4,
  151. },
  152. ],
  153. };
  154. },
  155. methods: {
  156. valChange(item) {
  157. this.formData[item.key] = item.value;
  158. this.$emit('formDataHandler', { key: [item.key], value: item.value });
  159. },
  160. actionSheetCallback(index) {
  161. this.formData['sfmode'] = this.actionSheetList[index].id;
  162. this.selectText = this.actionSheetList[index].text;
  163. },
  164. },
  165. };
  166. </script>
  167. <style scoped lang="scss">
  168. .rotation-wrapper {
  169. height: 450rpx;
  170. border-radius: 16rpx;
  171. background-color: #ffffff;
  172. position: relative;
  173. width: calc(100% - 64rpx);
  174. margin: 0 32rpx;
  175. margin-top: 32rpx;
  176. .rotation-item {
  177. height: 88rpx;
  178. width: calc(100% - 32rpx);
  179. margin: 0 32rpx;
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. border-bottom: 4rpx solid #f0f0f0;
  184. .rotation-item__label {
  185. width: 50%;
  186. text-align: left;
  187. color: #042118;
  188. font-family: 'Source Han Sans CN VF';
  189. font-size: 28rpx;
  190. font-weight: 400;
  191. }
  192. .rotation-item__value {
  193. width: 50%;
  194. text-align: right;
  195. padding-right: 16rpx;
  196. .rotation-item__value__input {
  197. display: flex;
  198. align-items: center;
  199. }
  200. }
  201. }
  202. }
  203. </style>