faultAdd.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="afterSalesType==3?'质量问题信息':'故障信息'" @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-cell-group>
  7. <u-cell :title="afterSalesType==3?'质量类型':'故障类型'" arrow-direction="down">
  8. <uni-data-picker v-model="form.type" slot="value" placeholder="请选择" :localdata="afterSalesType==3?after_sale_quality_type:typeOptions"
  9. @change="sourceCodeOnchange">
  10. </uni-data-picker>
  11. </u-cell>
  12. <u-cell :title="afterSalesType==3?'质量问题反馈':'故障现象'" arrow-direction="down">
  13. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.faultPhenomenon"></u--input>
  14. </u-cell>
  15. <u-cell :title="afterSalesType==3?'质量问题分析':'故障原因'" arrow-direction="down">
  16. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.faultReason"></u--input>
  17. </u-cell>
  18. <u-cell :title="afterSalesType==3?'质量处理方式':'维修过程'" 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. import {
  35. getByCode
  36. } from '@/api/pda/common.js'
  37. export default {
  38. components: {
  39. PhotoBtn
  40. },
  41. data() {
  42. return {
  43. afterSalesType: '',
  44. form: {
  45. type: '',
  46. faultPhenomenon: '',
  47. faultReason: '',
  48. maintenanceProcess: '',
  49. imageUrl: []
  50. },
  51. type: '',
  52. infoIdx: '',
  53. str: "",
  54. after_sale_quality_type:[],
  55. typeOptions: [{
  56. text: '维修',
  57. value: '1'
  58. },
  59. {
  60. text: '保养',
  61. value: '2'
  62. },
  63. {
  64. text: '安装',
  65. value: '3'
  66. }
  67. ],
  68. }
  69. },
  70. async onLoad(data) {
  71. this.infoIdx = data.index;
  72. this.str = data.str;
  73. this.type = data.type;
  74. this.afterSalesType = data.afterSalesType
  75. if (data.data) {
  76. this.form = JSON.parse(data.data);
  77. }
  78. console.log(data.arr, '123')
  79. if (data.arr) {
  80. const arr = JSON.parse(decodeURIComponent(data.arr));
  81. this.form.imageUrl = arr
  82. }
  83. this.getByCode()
  84. },
  85. methods: {
  86. getByCode() {
  87. const codeS = ['after_sale_quality_type']
  88. codeS.forEach(async (code) => {
  89. const codeValue = await getByCode(code);
  90. this[code] = codeValue.map(item => {
  91. const key = Object.keys(item)[0]
  92. return {
  93. value: key,
  94. text: item[key]
  95. }
  96. })
  97. })
  98. },
  99. save() {
  100. if (!this.form.type) {
  101. this.$refs.uToast.show({
  102. type: "warning",
  103. message: (this.afterSalesType == 3 ? '质量类型' : '故障类型') + "不能为空",
  104. })
  105. return;
  106. }
  107. if (!this.form.faultPhenomenon) {
  108. this.$refs.uToast.show({
  109. type: "warning",
  110. message: (this.afterSalesType == 3 ? '质量问题反馈' : '故障现象') + "不能为空",
  111. })
  112. return;
  113. }
  114. if (this.str == 'report') {
  115. if (!this.form.faultReason) {
  116. this.$refs.uToast.show({
  117. type: "warning",
  118. message: (this.afterSalesType == 3 ? '质量问题分析' : '故障原因') + "不能为空",
  119. })
  120. return
  121. }
  122. if (!this.form.maintenanceProcess) {
  123. this.$refs.uToast.show({
  124. type: "warning",
  125. message: (this.afterSalesType == 3 ? '质量处理方式' : '维修过程') + "不能为空",
  126. })
  127. return
  128. }
  129. }
  130. let data = JSON.parse(JSON.stringify(this.form));
  131. data.imageUrl = this.$refs.photoRef.getImageData();
  132. uni.$emit('updateFaultList', {
  133. data: data,
  134. type: this.type,
  135. index: this.infoIdx
  136. })
  137. this.back()
  138. },
  139. sourceCodeOnchange(e) {
  140. console.log(e);
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. /deep/.u-cell__body__content {
  147. flex: none;
  148. margin-right: 16rpx;
  149. }
  150. .mainBox {
  151. padding-bottom: 84rpx;
  152. .photo {
  153. box-sizing: border-box;
  154. width: calc(100% - 28rpx);
  155. padding: 20rpx 16rpx 10rpx 0;
  156. margin-left: 28rpx;
  157. }
  158. }
  159. .footerButton {
  160. width: 100%;
  161. height: 84rpx;
  162. display: flex;
  163. position: fixed;
  164. bottom: 0;
  165. /deep/.u-button {
  166. height: 100%;
  167. }
  168. >view {
  169. flex: 1;
  170. }
  171. }
  172. // /deep/.u-button {
  173. // height: 100%;
  174. // }
  175. /deep/.u-subsection__item__text {
  176. font-size: 28rpx !important;
  177. }
  178. </style>