faultAdd.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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="footerButton">
  22. <u-button type="default" text="返回" @click="back"></u-button>
  23. <u-button type="primary" @click="save" text="保存"></u-button>
  24. </view>
  25. </u-cell-group>
  26. <u-toast ref="uToast"></u-toast>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. components: {},
  32. data() {
  33. return {
  34. form: {
  35. type: '',
  36. faultPhenomenon: '',
  37. faultReason: '',
  38. maintenanceProcess: '',
  39. },
  40. type: '',
  41. infoIdx:'',
  42. str:"",
  43. typeOptions: [{
  44. text: '维修',
  45. value: '1'
  46. },
  47. {
  48. text: '保养',
  49. value: '2'
  50. },
  51. {
  52. text: '安装',
  53. value: '3'
  54. }
  55. ],
  56. }
  57. },
  58. async onLoad(data) {
  59. this.infoIdx = data.index;
  60. this.str = data.str;
  61. this.type = data.type
  62. if (data.data) {
  63. this.form = JSON.parse(data.data)
  64. }
  65. },
  66. methods: {
  67. save() {
  68. if (!this.form.type) {
  69. this.$refs.uToast.show({
  70. type: "warning",
  71. message: "故障类型不能为空",
  72. })
  73. return;
  74. }
  75. if (!this.form.faultPhenomenon) {
  76. this.$refs.uToast.show({
  77. type: "warning",
  78. message: "故障现象不能为空",
  79. })
  80. return;
  81. }
  82. if(this.str == 'report'){
  83. if (!this.form.faultReason) {
  84. this.$refs.uToast.show({
  85. type: "warning",
  86. message: "故障原因不能为空",
  87. })
  88. return
  89. }
  90. if (!this.form.maintenanceProcess) {
  91. this.$refs.uToast.show({
  92. type: "warning",
  93. message: "维修过程不能为空",
  94. })
  95. return
  96. }
  97. }
  98. uni.$emit('updateFaultList', {
  99. data: this.form,
  100. type: this.type,
  101. index:this.infoIdx
  102. })
  103. this.back()
  104. },
  105. sourceCodeOnchange(e){
  106. console.log(e);
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. /deep/.u-cell__body__content {
  113. flex: none;
  114. margin-right: 16rpx;
  115. }
  116. .mainBox {
  117. padding-bottom: 84rpx;
  118. }
  119. .footerButton {
  120. width: 100%;
  121. height: 84rpx;
  122. display: flex;
  123. position: fixed;
  124. bottom: 0;
  125. /deep/.u-button {
  126. height: 100%;
  127. }
  128. >view {
  129. flex: 1;
  130. }
  131. }
  132. // /deep/.u-button {
  133. // height: 100%;
  134. // }
  135. /deep/.u-subsection__item__text {
  136. font-size: 28rpx !important;
  137. }
  138. </style>