update.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 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. replaceReason: '',
  59. replateDate: replateDateString
  60. }
  61. },
  62. onLoad: function(option) {
  63. const coding = option.coding;
  64. const machineCoding = option.machineCoding;
  65. this.machineCoding = machineCoding;
  66. this.oldCoding = coding;
  67. },
  68. methods: {
  69. saoma1() {
  70. var that = this;
  71. // 允许从相机和相册扫码
  72. uni.scanCode({
  73. success(res) {
  74. that.machineCoding = res.result.replace(/\s+/g, '');
  75. }
  76. });
  77. },
  78. saoma2() {
  79. var that = this;
  80. // 允许从相机和相册扫码
  81. uni.scanCode({
  82. success(res) {
  83. that.oldCoding = res.result.replace(/\s+/g, '');
  84. }
  85. });
  86. },
  87. saoma3() {
  88. var that = this;
  89. // 允许从相机和相册扫码
  90. uni.scanCode({
  91. success(res) {
  92. that.coding = res.result.replace(/\s+/g, '');
  93. }
  94. });
  95. },
  96. btnConfirm0(e) {
  97. console.log('确定时间为:', new Date(e.key));
  98. this.replateDate = e.key;
  99. },
  100. btnCancel0() {
  101. this.replateDate = '';
  102. },
  103. update(event) {
  104. var serverUrl = this.serverurl;
  105. const {
  106. value: modules
  107. } = event.detail;
  108. var token = uni.getStorageSync("token");
  109. var replateDateObject = new Date(this.replateDate);
  110. var replateDateString = replateDateObject.getFullYear() + '-' +
  111. (replateDateObject.getMonth() + 1).toString().padStart(2, '0') + '-' +
  112. replateDateObject.getDate().toString().padStart(2, '0') + ' ' +
  113. replateDateObject.getHours().toString().padStart(2, '0') + ':' +
  114. replateDateObject.getMinutes().toString().padStart(2, '0') + ':' +
  115. replateDateObject.getSeconds().toString().padStart(2, '0');
  116. uni.request({
  117. url: serverUrl + "/TModules/replace",
  118. method: "POST",
  119. data: {
  120. "coding": modules.coding,
  121. "machineCoding": modules.machineCoding,
  122. "oldCoding": modules.oldCoding,
  123. "replateDate": replateDateString,
  124. "replaceReason": modules.replaceReason,
  125. "replacePersonnel": uni.getStorageSync("name"),
  126. },
  127. header: {
  128. 'token': token
  129. },
  130. success: (Result) => {
  131. var res = Result;
  132. if (res.data.code == true) {}
  133. uni.showModal({
  134. title: '提示',
  135. content: res.data.message,
  136. });
  137. }
  138. });
  139. },
  140. }
  141. }
  142. </script>
  143. <style>
  144. .body {
  145. background-color: #FFFFFF;
  146. padding: 20upx 20upx 20upx 20upx;
  147. display: flex;
  148. flex-direction: row;
  149. justify-content: flex-start;
  150. }
  151. .input {
  152. /* padding: 10upx 20upx 10upx 0upx; */
  153. padding-left: 20upx;
  154. padding-top: 10upx;
  155. background-color: #FFFFFF;
  156. width: 400upx;
  157. height: 50upx;
  158. box-shadow: 0upx 0upx 20upx #D3D3D3;
  159. border-radius: 5upx;
  160. }
  161. .button {
  162. margin: auto;
  163. width: 60%;
  164. height: 100upx;
  165. }
  166. .button1 {
  167. margin: auto;
  168. width: 75upx;
  169. height: 50upx;
  170. }
  171. .p {
  172. /* #ifdef H5 */
  173. top: -13%;
  174. /* #endif */
  175. width: 50upx;
  176. height: 30upx;
  177. font-size: 25upx;
  178. padding-right: 9upx;
  179. padding-top: 6upx;
  180. /* #ifndef H5 */
  181. /* padding-top: 10upx; */
  182. /* #endif */
  183. position: absolute;
  184. /* 水平居中 */
  185. left: 50%;
  186. -webkit-transform: translateX(-50%);
  187. transform: translateX(-50%);
  188. }
  189. .input-two {
  190. padding-left: 20upx;
  191. width: 450upx;
  192. box-shadow: 0upx 0upx 20upx #D3D3D3;
  193. border-radius: 5upx;
  194. }
  195. .p1 {
  196. /* #ifdef H5 */
  197. top: -13%;
  198. /* #endif */
  199. width: 80upx;
  200. height: 60upx;
  201. font-size: 40upx;
  202. padding-top: 6upx;
  203. /* #ifndef H5 */
  204. padding-top: 10upx;
  205. /* #endif */
  206. position: absolute;
  207. /* 水平居中 */
  208. left: 50%;
  209. -webkit-transform: translateX(-50%);
  210. transform: translateX(-50%);
  211. }
  212. </style>