update.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view>
  3. <form @submit="update">
  4. <view class="body">
  5. <input class="input" style="display:none;" name="machineCoding" :value=machineCoding />
  6. 所属机器编码:<input class="input" v-model="machineCoding" />
  7. <button type="primary" @click="saoma1()" class="button1">
  8. <p class="p">扫码</p>
  9. </button>
  10. </view>
  11. <view class="body">
  12. <input class="input" style="display:none;" name="oldCoding" :value=oldCoding />
  13. 旧模块编码:<input class="input" v-model="oldCoding" />
  14. <button type="primary" @click="saoma2()" class="button1">
  15. <p class="p">扫码</p>
  16. </button>
  17. </view>
  18. <view class="body">
  19. <input class="input" style="display:none;" name="coding" :value=coding />
  20. 新模块编码:<input class="input" v-model="coding" />
  21. <button type="primary" @click="saoma3()" class="button1">
  22. <p class="p">扫码</p>
  23. </button>
  24. </view>
  25. <view class="body">
  26. 更换原因:<textarea class="input-two" name="replaceReason" />
  27. </view>
  28. <view class="">
  29. <button type="primary" formType="submit" class="button">
  30. <p class="p1">提交</p>
  31. </button>
  32. </view>
  33. </form>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. machineCoding: '',
  41. coding: '',
  42. oldCoding: '',
  43. replaceReason: ''
  44. }
  45. },
  46. onLoad: function(option) {
  47. const coding = option.coding;
  48. const machineCoding = option.machineCoding;
  49. this.machineCoding = machineCoding;
  50. this.oldCoding = coding;
  51. },
  52. methods: {
  53. saoma1(){
  54. var that = this;
  55. // 允许从相机和相册扫码
  56. uni.scanCode({
  57. success(res) {
  58. that.machineCoding = res.result;
  59. }
  60. });
  61. },
  62. saoma2(){
  63. var that = this;
  64. // 允许从相机和相册扫码
  65. uni.scanCode({
  66. success(res) {
  67. that.oldCoding = res.result;
  68. }
  69. });
  70. },
  71. saoma3(){
  72. var that = this;
  73. // 允许从相机和相册扫码
  74. uni.scanCode({
  75. success(res) {
  76. that.coding = res.result;
  77. }
  78. });
  79. },
  80. update(event) {
  81. var serverUrl = this.serverurl;
  82. const {
  83. value: modules
  84. } = event.detail;
  85. var token = uni.getStorageSync("token");
  86. uni.request({
  87. url: serverUrl + "/TModules/replace",
  88. method: "POST",
  89. data:{
  90. "coding":modules.coding,
  91. "machineCoding":modules.machineCoding,
  92. "oldCoding":modules.oldCoding,
  93. "replaceReason":modules.replaceReason,
  94. "replacePersonnel":uni.getStorageSync("name"),
  95. },
  96. header: {
  97. 'token': token
  98. },
  99. success: (Result) => {
  100. var res = Result;
  101. if(res.data.code==true){
  102. }
  103. uni.showModal({
  104. title: '提示',
  105. content: res.data.message,
  106. });
  107. }
  108. });
  109. },
  110. }
  111. }
  112. </script>
  113. <style>
  114. .body {
  115. background-color: #FFFFFF;
  116. padding: 20upx 20upx 20upx 20upx;
  117. display: flex;
  118. flex-direction: row;
  119. justify-content: flex-start;
  120. }
  121. .input {
  122. /* padding: 10upx 20upx 10upx 0upx; */
  123. padding-left: 20upx;
  124. padding-top: 10upx;
  125. background-color: #FFFFFF;
  126. width: 400upx;
  127. height: 50upx;
  128. box-shadow: 0upx 0upx 20upx #D3D3D3;
  129. border-radius: 5upx;
  130. }
  131. .button {
  132. margin: auto;
  133. width: 60%;
  134. height: 100upx;
  135. }
  136. .button1 {
  137. margin: auto;
  138. width: 75upx;
  139. height: 50upx;
  140. }
  141. .p {
  142. /* #ifdef H5 */
  143. top: -13%;
  144. /* #endif */
  145. width: 50upx;
  146. height: 30upx;
  147. font-size: 25upx;
  148. padding-right: 9upx;
  149. padding-top: 6upx;
  150. /* #ifndef H5 */
  151. /* padding-top: 10upx; */
  152. /* #endif */
  153. position: absolute;
  154. /* 水平居中 */
  155. left: 50%;
  156. -webkit-transform: translateX(-50%);
  157. transform: translateX(-50%);
  158. }
  159. .input-two{
  160. padding-left: 20upx;
  161. width: 450upx;
  162. box-shadow: 0upx 0upx 20upx #D3D3D3;
  163. border-radius: 5upx;
  164. }
  165. .p1 {
  166. /* #ifdef H5 */
  167. top: -13%;
  168. /* #endif */
  169. width: 80upx;
  170. height: 60upx;
  171. font-size: 40upx;
  172. padding-top: 6upx;
  173. /* #ifndef H5 */
  174. padding-top: 10upx;
  175. /* #endif */
  176. position: absolute;
  177. /* 水平居中 */
  178. left: 50%;
  179. -webkit-transform: translateX(-50%);
  180. transform: translateX(-50%);
  181. }
  182. </style>