update.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. <timeSelector showType="date" @btnConfirm="btnConfirm0" @btnCancel="btnCancel0">
  26. <view class="body">
  27. 更换日期:<input type="text" class="input" name="replateDate" :value="replateDate"/>
  28. </view>
  29. </timeSelector>
  30. <view class="body">
  31. 更换原因:<textarea class="input-two" name="replaceReason" />
  32. </view>
  33. <view class="">
  34. <button type="primary" formType="submit" class="button">
  35. <p class="p1">提交</p>
  36. </button>
  37. </view>
  38. </form>
  39. </view>
  40. </template>
  41. <script>
  42. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  43. export default {
  44. components: {
  45. timeSelector
  46. },
  47. data() {
  48. return {
  49. machineCoding: '',
  50. coding: '',
  51. oldCoding: '',
  52. replateDate:'',
  53. replaceReason: ''
  54. }
  55. },
  56. methods: {
  57. saoma1(){
  58. var that = this;
  59. // 允许从相机和相册扫码
  60. uni.scanCode({
  61. success(res) {
  62. that.machineCoding = res.result;
  63. }
  64. });
  65. },
  66. saoma2(){
  67. var that = this;
  68. // 允许从相机和相册扫码
  69. uni.scanCode({
  70. success(res) {
  71. that.oldCoding = res.result;
  72. }
  73. });
  74. },
  75. saoma3(){
  76. var that = this;
  77. // 允许从相机和相册扫码
  78. uni.scanCode({
  79. success(res) {
  80. that.coding = res.result;
  81. }
  82. });
  83. },
  84. btnConfirm0(e) {
  85. console.log('确定时间为:', new Date(e.key));
  86. this.replateDate = e.key;
  87. },
  88. btnCancel0() {
  89. this.replateDate = '';
  90. },
  91. update(event) {
  92. var serverUrl = this.serverurl;
  93. const {
  94. value: modules
  95. } = event.detail;
  96. var token = uni.getStorageSync("token");
  97. var replateDateObject = new Date(this.replateDate);
  98. var replateDateString = replateDateObject.getFullYear() + '-' +
  99. (replateDateObject.getMonth() + 1).toString().padStart(2, '0') + '-' +
  100. replateDateObject.getDate().toString().padStart(2, '0') + ' ' +
  101. replateDateObject.getHours().toString().padStart(2, '0') + ':' +
  102. replateDateObject.getMinutes().toString().padStart(2, '0') + ':' +
  103. replateDateObject.getSeconds().toString().padStart(2, '0');
  104. console.log('时间参数格式化为:', replateDateString);
  105. uni.request({
  106. url: serverUrl + "/TModules/replace",
  107. method: "POST",
  108. data:{
  109. "coding":modules.coding,
  110. "machineCoding":modules.machineCoding,
  111. "oldCoding":modules.oldCoding,
  112. "replateDate":replateDateString,
  113. "replaceReason":modules.replaceReason,
  114. "replacePersonnel":uni.getStorageSync("name"),
  115. },
  116. header: {
  117. 'token': token
  118. },
  119. success: (Result) => {
  120. var res = Result;
  121. if(res.data.code==true){
  122. }
  123. uni.showModal({
  124. title: '提示',
  125. content: res.data.message,
  126. });
  127. }
  128. });
  129. },
  130. }
  131. }
  132. </script>
  133. <style>
  134. .body {
  135. background-color: #FFFFFF;
  136. padding: 20upx 20upx 20upx 20upx;
  137. display: flex;
  138. flex-direction: row;
  139. justify-content: flex-start;
  140. }
  141. .input {
  142. /* padding: 10upx 20upx 10upx 0upx; */
  143. padding-left: 20upx;
  144. padding-top: 10upx;
  145. background-color: #FFFFFF;
  146. width: 400upx;
  147. height: 50upx;
  148. box-shadow: 0upx 0upx 20upx #D3D3D3;
  149. border-radius: 5upx;
  150. }
  151. .button {
  152. margin: auto;
  153. width: 60%;
  154. height: 100upx;
  155. }
  156. .button1 {
  157. margin: auto;
  158. width: 75upx;
  159. height: 50upx;
  160. }
  161. .p {
  162. /* #ifdef H5 */
  163. top: -13%;
  164. /* #endif */
  165. width: 50upx;
  166. height: 30upx;
  167. font-size: 25upx;
  168. padding-right: 9upx;
  169. padding-top: 6upx;
  170. /* #ifndef H5 */
  171. /* padding-top: 10upx; */
  172. /* #endif */
  173. position: absolute;
  174. /* 水平居中 */
  175. left: 50%;
  176. -webkit-transform: translateX(-50%);
  177. transform: translateX(-50%);
  178. }
  179. .input-two{
  180. padding-left: 20upx;
  181. width: 450upx;
  182. box-shadow: 0upx 0upx 20upx #D3D3D3;
  183. border-radius: 5upx;
  184. }
  185. .p1 {
  186. /* #ifdef H5 */
  187. top: -13%;
  188. /* #endif */
  189. width: 80upx;
  190. height: 60upx;
  191. font-size: 40upx;
  192. padding-top: 6upx;
  193. /* #ifndef H5 */
  194. padding-top: 10upx;
  195. /* #endif */
  196. position: absolute;
  197. /* 水平居中 */
  198. left: 50%;
  199. -webkit-transform: translateX(-50%);
  200. transform: translateX(-50%);
  201. }
  202. </style>