edit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="container" v-if="info">
  3. <view class="title">成员基本信息</view>
  4. <view class="box">
  5. 手机
  6. <view class="box_input">
  7. <input type="number" maxlength="11" placeholder="请输入手机号码" v-model="info.userPhone" />
  8. </view>
  9. </view>
  10. <view class="box">
  11. 状态
  12. <picker @change="bindPickerChange" :value="index" range-key="name" :range="array">
  13. <view class="box_input">
  14. {{ array[index].name }}
  15. <img src="../../static/images/repairsImg/bottom.png" />
  16. </view>
  17. </picker>
  18. </view>
  19. <view class="box">
  20. 工种
  21. <picker @change="bindPickerChange2" :value="index2" range-key="name" :range="array2">
  22. <view class="box_input">
  23. {{ array2[index2].name }}
  24. <img src="../../static/images/repairsImg/bottom.png" />
  25. </view>
  26. </picker>
  27. </view>
  28. <view class="title">接单考核时间</view>
  29. <view class="box_time">
  30. <view class="time">
  31. <input type="text" v-model="info.acceptanceTime" />
  32. <img src="../../static/images/repairsImg/clock.png" />
  33. </view>
  34. 分钟
  35. </view>
  36. <view class="title">维修考核时间</view>
  37. <view class="box_time">
  38. <view class="time">
  39. <input type="text" v-model="info.maintenanceTime" />
  40. <img src="../../static/images/repairsImg/clock.png" />
  41. </view>
  42. 分钟
  43. </view>
  44. <!-- 提交按钮区域 -->
  45. <view class="btn" @click="handleSub">确认提交</view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. // 状态数组
  53. array: [],
  54. // 状态数组当前索引
  55. index: 0,
  56. // 工种数组
  57. array2: [],
  58. // 工种数组当前索引
  59. index2: 0,
  60. info: null
  61. }
  62. },
  63. onLoad(options) {
  64. this.getStateList()
  65. this.getTypeList()
  66. this.info = JSON.parse(options.info)
  67. this.index = this.info.state - 1
  68. this.index2 = this.info.workType - 1
  69. },
  70. methods: {
  71. async getStateList() {
  72. const res = await this.$myRequest_repairs({
  73. url: '/repairWorkType/getReceivingState'
  74. })
  75. // console.log(res)
  76. if (res.code === '200') {
  77. this.array = res.data
  78. }
  79. },
  80. async getTypeList() {
  81. const res = await this.$myRequest_repairs({
  82. url: '/repairWorkType/getRepairWorkTypes'
  83. })
  84. // console.log(res)
  85. if (res.code === '200') {
  86. this.array2 = res.data
  87. }
  88. },
  89. // 确认提交按钮回调
  90. handleSub() {
  91. if (!this.info.userPhone) {
  92. uni.showToast({
  93. title: '请输入手机号码',
  94. icon: 'none'
  95. })
  96. return
  97. }
  98. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  99. if (!rePhone.test(this.info.userPhone)) {
  100. uni.showToast({
  101. title: '手机号码格式有误',
  102. icon: 'none'
  103. })
  104. return
  105. }
  106. if (!this.info.acceptanceTime) {
  107. uni.showToast({
  108. title: '请输入接单考核时间',
  109. icon: 'none'
  110. })
  111. return
  112. }
  113. if (!this.info.maintenanceTime) {
  114. uni.showToast({
  115. title: '请输入维修考核时间',
  116. icon: 'none'
  117. })
  118. return
  119. }
  120. uni.showModal({
  121. title: '提示',
  122. content: '确认提交吗?',
  123. success: (res) => {
  124. if (res.confirm) {
  125. this.handleEdit()
  126. }
  127. }
  128. })
  129. },
  130. async handleEdit() {
  131. const res = await this.$myRequest_repairs({
  132. url: '/repairUser/updateAddressBook',
  133. method: 'post',
  134. data: {
  135. id: this.info.id,
  136. state: this.array[this.index].id,
  137. workType: this.array2[this.index2].id,
  138. acceptanceTime: this.info.acceptanceTime,
  139. maintenanceTime: this.info.maintenanceTime,
  140. phone: this.info.userPhone
  141. }
  142. })
  143. // console.log(res)
  144. if (res.code === '200') {
  145. uni.showToast({
  146. title: '编辑成功',
  147. icon: 'success'
  148. })
  149. setTimeout(() => {
  150. uni.redirectTo({
  151. url: '/pagesRepairs/box/box'
  152. })
  153. }, 1500)
  154. }
  155. },
  156. // 状态选择框选择回调
  157. bindPickerChange(e) {
  158. this.index = e.detail.value
  159. },
  160. // 工种选择框选择回调
  161. bindPickerChange2(e) {
  162. this.index2 = e.detail.value
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .container {
  169. box-sizing: border-box;
  170. padding: 0 30rpx;
  171. width: 100vw;
  172. height: 100vh;
  173. .title {
  174. display: flex;
  175. align-items: center;
  176. height: 112rpx;
  177. font-size: 36rpx;
  178. font-weight: bold;
  179. }
  180. .box {
  181. display: flex;
  182. align-items: center;
  183. margin-bottom: 30rpx;
  184. height: 94rpx;
  185. color: #808080;
  186. font-size: 32rpx;
  187. .box_input {
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. box-sizing: border-box;
  192. margin-left: 33rpx;
  193. padding: 0 33rpx;
  194. width: 542rpx;
  195. height: 94rpx;
  196. color: #000000;
  197. border-radius: 10rpx;
  198. border: 1rpx solid #cccccc;
  199. input {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. img {
  204. width: 54rpx;
  205. height: 54rpx;
  206. }
  207. }
  208. }
  209. .box_time {
  210. display: flex;
  211. align-items: center;
  212. height: 100rpx;
  213. font-size: 32rpx;
  214. font-weight: bold;
  215. .time {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. box-sizing: border-box;
  220. padding: 0 23rpx;
  221. margin-right: 25rpx;
  222. width: 237rpx;
  223. height: 68rpx;
  224. font-weight: 400;
  225. border-radius: 4rpx;
  226. border: 1rpx solid #a6a6a6;
  227. input {
  228. flex: 1;
  229. }
  230. img {
  231. width: 40rpx;
  232. height: 40rpx;
  233. }
  234. }
  235. }
  236. .btn {
  237. position: absolute;
  238. bottom: 66rpx;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. margin: auto;
  243. width: 690rpx;
  244. height: 100rpx;
  245. color: #fff;
  246. font-size: 32rpx;
  247. border-radius: 12rpx;
  248. background-color: #6fb6b8;
  249. }
  250. }
  251. </style>