update.vue 5.2 KB

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