addModules.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. var res = Result;
  93. if(res.data.code==true){
  94. var codes = res.data.data;
  95. that.name = codes.name;
  96. that.versions = codes.versions
  97. that.produceDate = codes.createDate;
  98. that.producePersonnel = uni.getStorageSync("name");
  99. that.desList = codes.flagCode.split(",");
  100. }else{
  101. uni.showModal({
  102. content: res.data.message,
  103. });
  104. }
  105. }
  106. });
  107. },
  108. add(event) {
  109. var serverUrl = this.serverurl;
  110. const {
  111. value: modules
  112. } = event.detail;
  113. var token = uni.getStorageSync("token");
  114. uni.request({
  115. url: serverUrl + "/TModules/add",
  116. method: "POST",
  117. data:{
  118. "coding":modules.coding,
  119. "name":modules.name,
  120. "producePersonnel":modules.producePersonnel
  121. },
  122. header: {
  123. 'token': token
  124. },
  125. success: (Result) => {
  126. var res = Result;
  127. if(res.data.code==true){
  128. }
  129. uni.showModal({
  130. title: '提示',
  131. content: res.data.message,
  132. });
  133. }
  134. });
  135. },
  136. }
  137. }
  138. </script>
  139. <style>
  140. .body {
  141. background-color: #FFFFFF;
  142. padding: 20upx 20upx 20upx 20upx;
  143. display: flex;
  144. flex-direction: row;
  145. justify-content: flex-start;
  146. }
  147. .input {
  148. /* padding: 10upx 20upx 10upx 0upx; */
  149. padding-left: 20upx;
  150. padding-top: 10upx;
  151. background-color: #FFFFFF;
  152. width: 400upx;
  153. height: 50upx;
  154. box-shadow: 0upx 0upx 20upx #D3D3D3;
  155. border-radius: 5upx;
  156. }
  157. .button {
  158. margin: auto;
  159. width: 60%;
  160. height: 100upx;
  161. }
  162. .button1 {
  163. margin: auto;
  164. width: 75upx;
  165. height: 50upx;
  166. }
  167. .p {
  168. /* #ifdef H5 */
  169. top: -13%;
  170. /* #endif */
  171. width: 50upx;
  172. height: 30upx;
  173. font-size: 25upx;
  174. padding-right: 9upx;
  175. padding-top: 6upx;
  176. /* #ifndef H5 */
  177. /* padding-top: 10upx; */
  178. /* #endif */
  179. position: absolute;
  180. /* 水平居中 */
  181. left: 50%;
  182. -webkit-transform: translateX(-50%);
  183. transform: translateX(-50%);
  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. .radio {
  203. padding-top: 20upx;
  204. padding-left: 30upx;
  205. }
  206. .lis{
  207. padding-left: 90upx;
  208. font-size: 30upx;
  209. padding-top: 5upx;
  210. }
  211. .title {
  212. padding-left: 20upx;
  213. font-size: 35upx;
  214. }
  215. </style>