equipment-status.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="mx3" style="padding-bottom: 100rpx">
  3. <u-toast ref="uToast" />
  4. <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
  5. <view class="p3 bg-color-white" style="margin-top: -50rpx; border-radius: 20rpx">
  6. <u-form :model="form" ref="uForm">
  7. <view class="main-color-text f-size-32 f-weight-6 mt-2">设备信息</view>
  8. <u-form-item label="设备名称" :label-width="150">
  9. <u-input v-model="form.sbName" disabled />
  10. </u-form-item>
  11. <u-form-item label="设备编号" :label-width="150">
  12. <u-input v-model="form.sbNo" disabled />
  13. </u-form-item>
  14. <view class="main-color-text f-size-32 f-weight-6 mt-2">变更信息</view>
  15. <u-form-item label="变更时间" required prop="changeTime" :label-width="150">
  16. <u-input v-model="form.changeTime" @click="handleClick" :cursor-spacing="cursorSpacing" />
  17. </u-form-item>
  18. <u-form-item label="变更原因" :label-width="150">
  19. <u-input v-model="form.changeReason" :cursor-spacing="cursorSpacing" />
  20. </u-form-item>
  21. <u-form-item label="变更人" required prop="actualUser" :label-width="150">
  22. <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
  23. </u-form-item>
  24. <u-form-item label="变更前状态" required :label-width="150">
  25. <text class="f-size-26 mr-3 state-r">{{ statusMap[form.preStatus] }}</text>
  26. </u-form-item>
  27. <u-form-item label="变更后状态" required :label-width="150">
  28. <text class="f-size-26 mr-3 state-r">{{ statusMap[form.afterStatus] }}</text>
  29. </u-form-item>
  30. </u-form>
  31. <u-picker @confirm="confirm" @cancel="cancel" mode="time" v-model="isShow"
  32. :params="pickerParams"></u-picker>
  33. <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
  34. <view class="p-fixed d-flex j-around a-center footer">
  35. <view class="main-color-bg text-color-white common" @tap="handleSubmit">提交</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import BaseTool from '../../utils/tool';
  42. export default {
  43. data() {
  44. return {
  45. isShow: false,
  46. form: {
  47. sbId: '',
  48. sbNo: '',
  49. sbName: '',
  50. changeUserId: '',
  51. actualUser: '',
  52. preStatus: '',
  53. afterStatus: '',
  54. changeTime: '',
  55. changeReason: '',
  56. remarks: ''
  57. },
  58. pickerParams: {
  59. year: true,
  60. month: true,
  61. day: true,
  62. hour: true,
  63. minute: true,
  64. second: true,
  65. timestamp: true
  66. },
  67. statusMap: {},
  68. rules: {
  69. changeTime: [
  70. {
  71. required: true,
  72. message: '请选择变更时间',
  73. trigger: ['blur', 'change']
  74. }
  75. ],
  76. actualUser: [
  77. {
  78. required: true,
  79. message: '请输入变更人',
  80. trigger: ['blur', 'change']
  81. }
  82. ]
  83. },
  84. // #ifdef MP-WEIXIN
  85. cursorSpacing: 50,
  86. // #endif
  87. // #ifndef MP-WEIXIN
  88. cursorSpacing: 0,
  89. // #endif
  90. sbBackId: '',
  91. aShow: false,
  92. address: '',
  93. sbId: null,
  94. aList: [
  95. ]
  96. };
  97. },
  98. onShow() {
  99. },
  100. onLoad(options) {
  101. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  102. this.$DictCache.TYPE.SB_INFO_STATUS
  103. );
  104. if (options && options.sbId) {
  105. console.log(options)
  106. this.form.sbId = options.sbId;
  107. this.form.sbNo = options.sbNo;
  108. this.form.sbName = options.sbName;
  109. this.form.preStatus = options.preStatus;
  110. this.form.afterStatus = options.afterStatus;
  111. this.form.actualUser = this.$BaseTool.UserUtil.getUserInfo().realName;
  112. }
  113. },
  114. onReady() {
  115. this.$refs.uForm.setRules(this.rules);
  116. },
  117. methods: {
  118. handleClick() {
  119. this.isShow = !this.isShow
  120. },
  121. confirm(values) {
  122. console.log(values)
  123. this.form.changeTime = values.year + '-' + values.month + '-' + values.day + ' ' + values.hour + ':' + values.minute + ':' + values.second
  124. console.log(this.form.changeTime)
  125. },
  126. cancel(values) {
  127. console.log(values)
  128. this.form.changeTime = null
  129. },
  130. handleSubmit() {
  131. console.log('点击')
  132. let time = null;
  133. if (this.form.changeTime != null) {
  134. time = this.$BaseTool.Date.formatter(this.form.changeTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN);
  135. }
  136. console.log(this.form)
  137. const params = {
  138. sbId: this.form.sbId,
  139. actualUser: this.form.actualUser,
  140. preStatus: this.form.preStatus,
  141. afterStatus: this.form.afterStatus,
  142. changeTime: time,
  143. remarks: this.form.remarks,
  144. changeReason: this.form.changeReason
  145. };
  146. console.log(params)
  147. // this.form.photo = a.join(',');
  148. var that = this;
  149. this.$refs.uForm.validate((valid) => {
  150. console.log(valid)
  151. if (valid) {
  152. this.$Http.addSbStatusLogIgnores(params).then((res) => {
  153. uni.showToast({ icon: 'none', title: '变更记录已提交!', duration: 2000 });
  154. setTimeout(function () {
  155. uni.navigateTo({
  156. url: '/pages/equipment-detail/equipment-detail?detailId=' + that.form.sbId
  157. });
  158. }, 2000)
  159. });
  160. } else {
  161. console.log(valid)
  162. }
  163. });
  164. }
  165. }
  166. };
  167. </script>
  168. <style lang="less">
  169. .footer {
  170. bottom: 0;
  171. left: 0;
  172. right: 0;
  173. background-color: #fff;
  174. z-index: 10000;
  175. border-top: 1rpx solid #f4f4f4;
  176. height: 100rpx;
  177. .common {
  178. padding: 15rpx 200rpx;
  179. border-radius: 30rpx;
  180. background-color: #0082ff;
  181. color: #fff;
  182. }
  183. }
  184. </style>