update.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. methods: {
  47. saoma1(){
  48. var that = this;
  49. // 允许从相机和相册扫码
  50. uni.scanCode({
  51. success(res) {
  52. that.machineCoding = res.result;
  53. }
  54. });
  55. },
  56. saoma2(){
  57. var that = this;
  58. // 允许从相机和相册扫码
  59. uni.scanCode({
  60. success(res) {
  61. that.oldCoding = res.result;
  62. }
  63. });
  64. },
  65. saoma3(){
  66. var that = this;
  67. // 允许从相机和相册扫码
  68. uni.scanCode({
  69. success(res) {
  70. that.coding = res.result;
  71. }
  72. });
  73. },
  74. update(event) {
  75. var serverUrl = this.serverurl;
  76. const {
  77. value: modules
  78. } = event.detail;
  79. var token = uni.getStorageSync("token");
  80. uni.request({
  81. url: serverUrl + "/TModules/replace",
  82. method: "POST",
  83. data:{
  84. "coding":modules.coding,
  85. "machineCoding":modules.machineCoding,
  86. "oldCoding":modules.oldCoding,
  87. "replaceReason":modules.replaceReason,
  88. "replacePersonnel":uni.getStorageSync("name"),
  89. },
  90. header: {
  91. 'token': token
  92. },
  93. success: (Result) => {
  94. var res = Result;
  95. if(res.data.code==true){
  96. }
  97. uni.showModal({
  98. title: '提示',
  99. content: res.data.message,
  100. });
  101. }
  102. });
  103. },
  104. }
  105. }
  106. </script>
  107. <style>
  108. .body {
  109. background-color: #FFFFFF;
  110. padding: 20upx 20upx 20upx 20upx;
  111. display: flex;
  112. flex-direction: row;
  113. justify-content: flex-start;
  114. }
  115. .input {
  116. /* padding: 10upx 20upx 10upx 0upx; */
  117. padding-left: 20upx;
  118. padding-top: 10upx;
  119. background-color: #FFFFFF;
  120. width: 400upx;
  121. height: 50upx;
  122. box-shadow: 0upx 0upx 20upx #D3D3D3;
  123. border-radius: 5upx;
  124. }
  125. .button {
  126. margin: auto;
  127. width: 60%;
  128. height: 100upx;
  129. }
  130. .button1 {
  131. margin: auto;
  132. width: 75upx;
  133. height: 50upx;
  134. }
  135. .p {
  136. /* #ifdef H5 */
  137. top: -13%;
  138. /* #endif */
  139. width: 50upx;
  140. height: 30upx;
  141. font-size: 25upx;
  142. padding-right: 9upx;
  143. padding-top: 6upx;
  144. /* #ifndef H5 */
  145. /* padding-top: 10upx; */
  146. /* #endif */
  147. position: absolute;
  148. /* 水平居中 */
  149. left: 50%;
  150. -webkit-transform: translateX(-50%);
  151. transform: translateX(-50%);
  152. }
  153. .input-two{
  154. padding-left: 20upx;
  155. width: 450upx;
  156. box-shadow: 0upx 0upx 20upx #D3D3D3;
  157. border-radius: 5upx;
  158. }
  159. .p1 {
  160. /* #ifdef H5 */
  161. top: -13%;
  162. /* #endif */
  163. width: 80upx;
  164. height: 60upx;
  165. font-size: 40upx;
  166. padding-top: 6upx;
  167. /* #ifndef H5 */
  168. padding-top: 10upx;
  169. /* #endif */
  170. position: absolute;
  171. /* 水平居中 */
  172. left: 50%;
  173. -webkit-transform: translateX(-50%);
  174. transform: translateX(-50%);
  175. }
  176. </style>