update.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. replaceReason: '',
  53. replateDate: ''
  54. }
  55. },
  56. onLoad: function(option) {
  57. const coding = option.coding;
  58. const machineCoding = option.machineCoding;
  59. this.machineCoding = machineCoding;
  60. this.oldCoding = coding;
  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. uni.request({
  111. url: serverUrl + "/TModules/replace",
  112. method: "POST",
  113. data:{
  114. "coding":modules.coding,
  115. "machineCoding":modules.machineCoding,
  116. "oldCoding":modules.oldCoding,
  117. "replateDate":replateDateString,
  118. "replaceReason":modules.replaceReason,
  119. "replacePersonnel":uni.getStorageSync("name"),
  120. },
  121. header: {
  122. 'token': token
  123. },
  124. success: (Result) => {
  125. var res = Result;
  126. if(res.data.code==true){
  127. }
  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>