finish.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 class="p3 bg-color-white" style="margin-top: -50rpx; border-radius: 20rpx">
  5. <u-form :model="form" ref="uForm" :label-width="150">
  6. <u-form-item label="上传图片" :label-width="150">
  7. <m-upload-img v-model="form.imgList" :maxSize="20"></m-upload-img>
  8. </u-form-item>
  9. <u-form-item label="上传文件" :label-width="150">
  10. <m-upload v-model="form.fileList"></m-upload>
  11. </u-form-item>
  12. <u-form-item label="检查结果" prop="checkContent">
  13. <u-input v-model="form.feedback" type="textarea" :height="50" />
  14. </u-form-item>
  15. </u-form>
  16. <view class="py3 border-bottom">
  17. <view class="f-size-30 text-color-3 w200">检查项目</view>
  18. <view class="f-size-28 text-color-3 border py2" v-for="(item, index) in requirementList" :key="index">
  19. <view class="d-flex text-color-6">
  20. <view class="w180">保养周期:</view>
  21. <view class="text-color-3">{{ item.period }}</view>
  22. </view>
  23. <view class="d-flex text-color-6">
  24. <view class="w180">管理项目:</view>
  25. <view class="text-color-3">{{ item.manageItem }}</view>
  26. </view>
  27. <view class="d-flex text-color-6">
  28. <view class="w180">检查项目:</view>
  29. <view class="text-color-3">{{ item.checkItem }}</view>
  30. </view>
  31. <view class="d-flex text-color-6">
  32. <view class="w160">方法工具:</view>
  33. <view class="text-color-3">{{ item.method }}</view>
  34. </view>
  35. <view class="d-flex text-color-6">
  36. <view class="w160">保养级别:</view>
  37. <view class="text-color-3">{{ item.checkLevel }}</view>
  38. </view>
  39. <view class="d-flex text-color-6">
  40. <view class="w160">标准类型:</view>
  41. <view class="text-color-3">{{ item.sbTypeName }}</view>
  42. </view>
  43. <view class="d-flex text-color-6">
  44. <view class="w160">内容:</view>
  45. <view class="text-color-3">{{ item.remark }}</view>
  46. </view>
  47. <view class="d-flex text-color-6 items-center">
  48. <view class="w160">填报信息:</view>
  49. <view class="text-color-3" style="flex: 1">
  50. <u-input v-if="item.type == 0" v-model="item.value" :border="true" />
  51. <view v-else class="select">
  52. <my-select style="width: 100%" v-model="item.value" :list="item.options" />
  53. </view>
  54. </view>
  55. </view>
  56. <view class="d-flex text-color-6 items-center" style="margin-top: 10rpx">
  57. <view class="w160">备注:</view>
  58. <view class="text-color-3" style="flex: 1">
  59. <u-input v-model="item.text" :border="true" />
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="p-fixed d-flex a-center footer">
  65. <view class="finish-action-btn finish-action-btn-danger" @tap="handleSubmit(1)">完成并报修</view>
  66. <view class="finish-action-btn finish-action-btn-primary" @tap="handleSubmit()">完成</view>
  67. </view>
  68. </view>
  69. <u-toast ref="uToast" />
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. requirementList: [],
  77. displayTime: 0,
  78. form: {
  79. checkContent: '',
  80. imgList: [],
  81. fileList: []
  82. },
  83. rules: {}
  84. }
  85. },
  86. onLoad(options) {
  87. this.form = options
  88. this.$Http.fetchCheckStandard({ id: options.standardId }).then(res => {
  89. this.requirementList =
  90. res.data.requirementList &&
  91. res.data.requirementList.map((item, index) => {
  92. return {
  93. ...item,
  94. value: null,
  95. options:
  96. item.type == '1'
  97. ? item.scope.split('-').map(item => ({
  98. label: item,
  99. value: item
  100. }))
  101. : []
  102. }
  103. })
  104. this.$Http.timerAccumulatedTime({ referenceId: options.id }).then(res => {
  105. this.form.workHours = Math.floor(res.data / 60000)
  106. this.displayTime = res.data
  107. })
  108. })
  109. },
  110. onReady() {
  111. this.$refs.uForm.setRules(this.rules)
  112. },
  113. methods: {
  114. handleSubmit(type) {
  115. this.$refs.uForm.validate(valid => {
  116. if (valid) {
  117. let isReturn = false
  118. this.requirementList.forEach(item => {
  119. if (!item.value && item.type == 1) {
  120. isReturn = true
  121. }
  122. })
  123. if (isReturn) {
  124. this.confirmLoading = false
  125. this.$refs.uToast.show({
  126. title: '请填写检查结果'
  127. })
  128. return
  129. }
  130. this.form.conTask = JSON.stringify(
  131. this.requirementList
  132. )
  133. // 提交实际完成时间,保证已完成任务展示完成时间
  134. this.form.actualEndTime = this.$BaseTool.Date.formatter(new Date(), this.$BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  135. this.$Http.finishJob(this.form).then(res => {
  136. this.$refs.uToast.show({
  137. title: '操作成功'
  138. })
  139. this.$Http.timerStop({ referenceId: this.form.id, finalAccumulatedTime: this.displayTime })
  140. if (type === 1) {
  141. // 完成并报修:直接进入该设备的报修填写页(与 PC 端“完成并报修”一致)
  142. uni.redirectTo({
  143. url: '/pages/repair-add/repair-add?detailId=' + this.form.sbId
  144. })
  145. } else {
  146. // 仅完成:返回保养详情页
  147. uni.navigateBack({
  148. delta: 1
  149. })
  150. }
  151. })
  152. }
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="less">
  159. .footer {
  160. bottom: 0;
  161. left: 0;
  162. right: 0;
  163. background-color: #fff;
  164. z-index: 10000;
  165. border-top: 1rpx solid #f4f4f4;
  166. height: 100rpx;
  167. .common {
  168. padding: 15rpx 200rpx;
  169. border-radius: 30rpx;
  170. background-color: #0082ff;
  171. color: #fff;
  172. }
  173. .finish-action-btn {
  174. flex: 1;
  175. margin: 0 20rpx;
  176. padding: 15rpx 0;
  177. text-align: center;
  178. border-radius: 30rpx;
  179. color: #fff;
  180. }
  181. .finish-action-btn-danger {
  182. background-color: #fa3534;
  183. }
  184. .finish-action-btn-primary {
  185. background-color: #0082ff;
  186. }
  187. }
  188. .select {
  189. width: 100%;
  190. height: 40px;
  191. border-radius: 4px;
  192. border: 1px solid #dcdfe6;
  193. display: flex;
  194. align-items: center;
  195. }
  196. .w160 {
  197. width: 160rpx;
  198. }
  199. .border {
  200. border: 1rpx solid #0082ff;
  201. border-radius: 10rpx;
  202. padding: 10rpx;
  203. margin-top: 10rpx;
  204. }
  205. </style>