addModules.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view>
  3. <form @submit="add">
  4. <view class="body">
  5. <input class="input" style="display:none;" name="coding" :value=coding />
  6. 编码:<input class="input" v-model="coding" />
  7. <button type="primary" @click="saoma()" class="button1">
  8. <p class="p">扫码</p>
  9. </button>
  10. <button type="primary" @click="getMessage(coding)" class="button1">
  11. <p class="p">获取</p>
  12. </button>
  13. </view>
  14. <view class="body">
  15. 名称:<input class="input" name="name" :value="name" />
  16. </view>
  17. <view class="body">
  18. 版本号:<input class="input" name="versions" :value="versions" />
  19. </view>
  20. <view class="body">
  21. 生产人员:<input class="input" name="producePersonnel" :value="producePersonnel" readonly="readonly"/>
  22. </view>
  23. <timeSelector showType="date" @btnConfirm="btnConfirm0" @btnCancel="btnCancel0">
  24. <view class="body">
  25. 生产日期:<input type="text" class="input" name="produceDate" :value="produceDate" />
  26. </view>
  27. </timeSelector>
  28. <view class="title">配件</view>
  29. <view class="lis" v-for="item in desList" >
  30. {{item}}
  31. </view>
  32. <view class="">
  33. <button type="primary" formType="submit" class="button">
  34. <p class="p1">提交</p>
  35. </button>
  36. </view>
  37. </form>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. mapState,
  43. mapActions,
  44. mapMutations
  45. } from 'vuex';
  46. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  47. export default {
  48. components: {
  49. timeSelector
  50. },
  51. data() {
  52. return {
  53. produceDate:'',
  54. coding:null,
  55. name:null,
  56. versions:null,
  57. producePersonnel:null,
  58. desList:{}
  59. }
  60. },
  61. methods: {
  62. btnConfirm0(e) {
  63. // console.log('确定时间为:', e);
  64. this.produceDate = e.key;
  65. },
  66. btnCancel0() {
  67. this.produceDate = '';
  68. },
  69. saoma(){
  70. var that = this;
  71. // 允许从相机和相册扫码
  72. uni.scanCode({
  73. success(res) {
  74. // console.log('条码类型:' + res.scanType);
  75. // console.log('条码内容:' + res.result);
  76. that.coding = res.result;
  77. }
  78. });
  79. },
  80. getMessage(coding){
  81. console.log("a");
  82. var that = this;
  83. var serverUrl = that.serverurl;
  84. var token = uni.getStorageSync("token");
  85. uni.request({
  86. url: serverUrl + "/TModules/getMessage?coding="+coding,
  87. method: "GET",
  88. header: {
  89. 'token': token
  90. },
  91. success: (Result) => {
  92. console.log("1");
  93. var res = Result;
  94. if(res.data.code==true){
  95. var codes = res.data.data;
  96. that.name = codes.name;
  97. that.versions = codes.versions
  98. that.produceDate = codes.createDate;
  99. that.producePersonnel = uni.getStorageSync("name");
  100. that.desList = codes.flagCode.split(",");
  101. }else{
  102. uni.showModal({
  103. content: res.data.message,
  104. });
  105. }
  106. }
  107. });
  108. },
  109. add(event) {
  110. var serverUrl = this.serverurl;
  111. const {
  112. value: modules
  113. } = event.detail;
  114. console.log("2");
  115. var token = uni.getStorageSync("token");
  116. uni.request({
  117. url: serverUrl + "/TModules/add",
  118. method: "POST",
  119. data:{
  120. "coding":modules.coding,
  121. "name":modules.name,
  122. "producePersonnel":modules.producePersonnel
  123. },
  124. header: {
  125. 'token': token
  126. },
  127. success: (Result) => {
  128. var res = Result;
  129. if(res.data.code==true){
  130. }
  131. uni.showModal({
  132. title: '提示',
  133. content: res.data.message,
  134. });
  135. }
  136. });
  137. },
  138. }
  139. }
  140. </script>
  141. <style>
  142. .body {
  143. background-color: #FFFFFF;
  144. padding: 20upx 20upx 20upx 20upx;
  145. display: flex;
  146. flex-direction: row;
  147. justify-content: flex-start;
  148. }
  149. .input {
  150. /* padding: 10upx 20upx 10upx 0upx; */
  151. padding-left: 20upx;
  152. padding-top: 10upx;
  153. background-color: #FFFFFF;
  154. width: 400upx;
  155. height: 50upx;
  156. box-shadow: 0upx 0upx 20upx #D3D3D3;
  157. border-radius: 5upx;
  158. }
  159. .button {
  160. margin: auto;
  161. width: 60%;
  162. height: 100upx;
  163. }
  164. .button1 {
  165. margin: auto;
  166. width: 75upx;
  167. height: 50upx;
  168. }
  169. .p {
  170. /* #ifdef H5 */
  171. top: -13%;
  172. /* #endif */
  173. width: 50upx;
  174. height: 30upx;
  175. font-size: 25upx;
  176. padding-right: 9upx;
  177. padding-top: 6upx;
  178. /* #ifndef H5 */
  179. /* padding-top: 10upx; */
  180. /* #endif */
  181. position: absolute;
  182. /* 水平居中 */
  183. left: 50%;
  184. -webkit-transform: translateX(-50%);
  185. transform: translateX(-50%);
  186. }
  187. .p1 {
  188. /* #ifdef H5 */
  189. top: -13%;
  190. /* #endif */
  191. width: 80upx;
  192. height: 60upx;
  193. font-size: 40upx;
  194. padding-top: 6upx;
  195. /* #ifndef H5 */
  196. padding-top: 10upx;
  197. /* #endif */
  198. position: absolute;
  199. /* 水平居中 */
  200. left: 50%;
  201. -webkit-transform: translateX(-50%);
  202. transform: translateX(-50%);
  203. }
  204. .radio {
  205. padding-top: 20upx;
  206. padding-left: 30upx;
  207. }
  208. .lis{
  209. padding-left: 90upx;
  210. font-size: 30upx;
  211. padding-top: 5upx;
  212. }
  213. .title {
  214. padding-left: 20upx;
  215. font-size: 35upx;
  216. }
  217. </style>