faultAdd.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="故障信息"
  4. @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-cell-group>
  7. <u-cell title="故障类型" arrow-direction="down">
  8. <uni-data-picker v-model="form.type" slot="value" placeholder="请选择" :localdata="typeOptions"
  9. @change="sourceCodeOnchange">
  10. </uni-data-picker>
  11. </u-cell>
  12. <u-cell title="故障现象" arrow-direction="down">
  13. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.faultPhenomenon"></u--input>
  14. </u-cell>
  15. <u-cell title="故障原因" arrow-direction="down">
  16. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.faultReason"></u--input>
  17. </u-cell>
  18. <u-cell title="维修过程" arrow-direction="down">
  19. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.maintenanceProcess"></u--input>
  20. </u-cell>
  21. <view class="photo">
  22. <PhotoBtn :imageUrl="form.imageUrl" ref="photoRef" />
  23. </view>
  24. <view class="footerButton">
  25. <u-button type="default" text="返回" @click="back"></u-button>
  26. <u-button type="primary" @click="save" text="保存"></u-button>
  27. </view>
  28. </u-cell-group>
  29. <u-toast ref="uToast"></u-toast>
  30. </view>
  31. </template>
  32. <script>
  33. import PhotoBtn from '@/pages/salesServiceManagement/workOrder/components/forWork/PhotoBtn.vue';
  34. export default {
  35. components: {
  36. PhotoBtn
  37. },
  38. data() {
  39. return {
  40. form: {
  41. type: '',
  42. faultPhenomenon: '',
  43. faultReason: '',
  44. maintenanceProcess: '',
  45. imageUrl: []
  46. },
  47. type: '',
  48. infoIdx: '',
  49. str: "",
  50. typeOptions: [{
  51. text: '维修',
  52. value: '1'
  53. },
  54. {
  55. text: '保养',
  56. value: '2'
  57. },
  58. {
  59. text: '安装',
  60. value: '3'
  61. }
  62. ],
  63. }
  64. },
  65. async onLoad(data) {
  66. this.infoIdx = data.index;
  67. this.str = data.str;
  68. this.type = data.type;
  69. if (data.data) {
  70. this.form = JSON.parse(data.data);
  71. }
  72. console.log(data.arr,'123')
  73. if(data.arr){
  74. const arr = JSON.parse(decodeURIComponent(data.arr));
  75. this.form.imageUrl = arr
  76. }
  77. },
  78. methods: {
  79. save() {
  80. if (!this.form.type) {
  81. this.$refs.uToast.show({
  82. type: "warning",
  83. message: "故障类型不能为空",
  84. })
  85. return;
  86. }
  87. if (!this.form.faultPhenomenon) {
  88. this.$refs.uToast.show({
  89. type: "warning",
  90. message: "故障现象不能为空",
  91. })
  92. return;
  93. }
  94. if (this.str == 'report') {
  95. if (!this.form.faultReason) {
  96. this.$refs.uToast.show({
  97. type: "warning",
  98. message: "故障原因不能为空",
  99. })
  100. return
  101. }
  102. if (!this.form.maintenanceProcess) {
  103. this.$refs.uToast.show({
  104. type: "warning",
  105. message: "维修过程不能为空",
  106. })
  107. return
  108. }
  109. }
  110. let data = JSON.parse(JSON.stringify(this.form));
  111. data.imageUrl = this.$refs.photoRef.getImageData();
  112. uni.$emit('updateFaultList', {
  113. data: data,
  114. type: this.type,
  115. index: this.infoIdx
  116. })
  117. this.back()
  118. },
  119. sourceCodeOnchange(e) {
  120. console.log(e);
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. /deep/.u-cell__body__content {
  127. flex: none;
  128. margin-right: 16rpx;
  129. }
  130. .mainBox {
  131. padding-bottom: 84rpx;
  132. .photo {
  133. box-sizing: border-box;
  134. width: calc(100% - 28rpx);
  135. padding: 20rpx 16rpx 10rpx 0;
  136. margin-left: 28rpx;
  137. }
  138. }
  139. .footerButton {
  140. width: 100%;
  141. height: 84rpx;
  142. display: flex;
  143. position: fixed;
  144. bottom: 0;
  145. /deep/.u-button {
  146. height: 100%;
  147. }
  148. >view {
  149. flex: 1;
  150. }
  151. }
  152. // /deep/.u-button {
  153. // height: 100%;
  154. // }
  155. /deep/.u-subsection__item__text {
  156. font-size: 28rpx !important;
  157. }
  158. </style>