repair-reason-form.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="mx3" style="padding-bottom: 100rpx">
  3. <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
  4. <view
  5. class="p3 bg-color-white"
  6. style="margin-top: -50rpx; border-radius: 20rpx"
  7. >
  8. <u-form :model="form" ref="uForm" :label-width="180">
  9. <u-form-item label="编号" >
  10. <u-input disabled v-model="form.no" />
  11. </u-form-item>
  12. <u-form-item label="分析时间" required prop="analyzeTime">
  13. <my-calendar v-model="form.analyzeTime" />
  14. </u-form-item>
  15. <u-form-item label="故障部位">
  16. <view class="d-flex a-center j-between" style="width: 100%">
  17. <text>{{ form.sbPartName }}</text>
  18. <u-button
  19. @click="selectProject"
  20. type="primary"
  21. size="mini"
  22. >选择</u-button>
  23. </view>
  24. </u-form-item>
  25. <u-form-item label="故障现象" required prop="problemDesc">
  26. <u-input type="textarea" v-model="form.problemDesc" />
  27. </u-form-item>
  28. <u-form-item label="检查处理过程" required prop="checkProcess">
  29. <u-input type="textarea" v-model="form.checkProcess" />
  30. </u-form-item>
  31. <u-form-item label="原因分析" required prop="reasonAnalysis">
  32. <u-input type="textarea" v-model="form.reasonAnalysis" />
  33. </u-form-item>
  34. </u-form>
  35. <view class="p-fixed d-flex j-around a-center footer">
  36. <view
  37. class="main-color-bg text-color-white common"
  38. :loading="confirmLoading"
  39. @tap="submit"
  40. >提交</view
  41. >
  42. </view>
  43. </view>
  44. <u-toast ref="uToast" />
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. form: {
  52. id: '',
  53. sbId: '',
  54. repairId: '',
  55. sbPartId: '',
  56. no: '',
  57. analyzeTime: '',
  58. sbPartName: '',
  59. problemDesc: '',
  60. checkProcess: '',
  61. reasonAnalysis: ''
  62. },
  63. rules: {
  64. analyzeTime: [
  65. {
  66. required: true,
  67. message: '分析时间不能为空',
  68. // 可以单个或者同时写两个触发验证方式
  69. trigger: ['change', 'blur']
  70. }
  71. ],
  72. problemDesc: [
  73. {
  74. required: true,
  75. message: '故障现象不能为空',
  76. trigger: 'blur'
  77. }
  78. ],
  79. checkProcess: [
  80. {
  81. required: true,
  82. message: '检查处理过程不能为空',
  83. trigger: 'blur'
  84. }
  85. ],
  86. reasonAnalysis: [
  87. {
  88. required: true,
  89. message: '原因分析不能为空',
  90. trigger: 'blur'
  91. }
  92. ]
  93. },
  94. confirmLoading: false
  95. };
  96. },
  97. onReady() {
  98. this.$refs.uForm.setRules(this.rules);
  99. },
  100. onShow() {
  101. const pages = getCurrentPages();
  102. const currPage = pages[pages.length - 1];
  103. if (currPage.bom) {
  104. this.form.sbPartId = currPage.bom.sbPartId;
  105. this.form.sbPartName = currPage.bom.sbPartName;
  106. }
  107. },
  108. onLoad(options) {
  109. if (options.id) {
  110. this.getInfo(options.id)
  111. } else {
  112. this.form = {
  113. ...this.form,
  114. ...options
  115. }
  116. }
  117. },
  118. methods: {
  119. // 提交
  120. submit() {
  121. this.$refs.uForm.validate(valid => {
  122. if (valid) {
  123. if (!this.form.id) {
  124. this.$Http.addRepairReason(this.form)
  125. .then((res) => {
  126. this.confirmLoading = false
  127. this.$refs.uToast.show({
  128. title: '提交成功!',
  129. type: 'success',
  130. back : true
  131. })
  132. }).catch(() => {
  133. this.confirmLoading = false
  134. })
  135. } else {
  136. this.$Http.updateRepairReason(this.form)
  137. .then(() => {
  138. this.confirmLoading = false
  139. this.$refs.uToast.show({
  140. title: '提交成功!',
  141. type: 'success',
  142. back : true
  143. })
  144. }).catch(() => {
  145. this.confirmLoading = false
  146. })
  147. }
  148. } else {
  149. console.log('验证失败');
  150. }
  151. });
  152. },
  153. getInfo(id) {
  154. this.$Http.finishRepairReason({ id })
  155. .then((res) => {
  156. this.form = res.data
  157. })
  158. },
  159. selectProject() {
  160. uni.navigateTo({
  161. url: '/pages/repair-reason/repair-reason-select?sbId=' + this.form.sbId
  162. });
  163. }
  164. }
  165. };
  166. </script>
  167. <style lang="less">
  168. page {
  169. background-color: #f4f4f4;
  170. }
  171. .footer {
  172. bottom: 0;
  173. left: 0;
  174. right: 0;
  175. background-color: #fff;
  176. z-index: 10000;
  177. border-top: 1rpx solid #f4f4f4;
  178. height: 100rpx;
  179. .common {
  180. padding: 15rpx 200rpx;
  181. border-radius: 30rpx;
  182. background-color: #0082ff;
  183. color: #fff;
  184. }
  185. }
  186. </style>