addModules.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 class="input">{{ produceDate }}</view>
  27. </view>
  28. </timeSelector>
  29. <view class="title">配件</view>
  30. <view class="lis" v-for="item in desList">
  31. {{item}}
  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 {
  43. mapState,
  44. mapActions,
  45. mapMutations
  46. } from 'vuex';
  47. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  48. export default {
  49. components: {
  50. timeSelector
  51. },
  52. data() {
  53. return {
  54. produceDate: '',
  55. coding: null,
  56. name: null,
  57. versions: null,
  58. producePersonnel: null,
  59. desList: {}
  60. }
  61. },
  62. methods: {
  63. btnConfirm0(e) {
  64. // console.log('确定时间为:', e);
  65. this.produceDate = e.key;
  66. },
  67. btnCancel0() {
  68. this.produceDate = '';
  69. },
  70. saoma() {
  71. var that = this;
  72. // 允许从相机和相册扫码
  73. uni.scanCode({
  74. success(res) {
  75. // console.log('条码类型:' + res.scanType);
  76. // console.log('条码内容:' + res.result);
  77. that.coding = res.result;
  78. }
  79. });
  80. },
  81. getMessage(coding) {
  82. console.log("a");
  83. var that = this;
  84. var serverUrl = that.serverurl;
  85. var token = uni.getStorageSync("token");
  86. uni.request({
  87. url: serverUrl + "/TModules/getMessage?coding=" + coding,
  88. method: "GET",
  89. header: {
  90. 'token': token
  91. },
  92. success: (Result) => {
  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. var token = uni.getStorageSync("token");
  115. uni.request({
  116. url: serverUrl + "/TModules/add",
  117. method: "POST",
  118. data: {
  119. "coding": modules.coding,
  120. "name": modules.name,
  121. "producePersonnel": modules.producePersonnel
  122. },
  123. header: {
  124. 'token': token
  125. },
  126. success: (Result) => {
  127. var res = Result;
  128. if (res.data.code == true) {
  129. }
  130. uni.showModal({
  131. title: '提示',
  132. content: res.data.message,
  133. });
  134. }
  135. });
  136. },
  137. }
  138. }
  139. </script>
  140. <style>
  141. .body {
  142. background-color: #FFFFFF;
  143. padding: 20upx 20upx 20upx 20upx;
  144. display: flex;
  145. flex-direction: row;
  146. justify-content: flex-start;
  147. }
  148. .input {
  149. /* padding: 10upx 20upx 10upx 0upx; */
  150. padding: 0 10upx;
  151. /* padding-top: 10upx; */
  152. background-color: #FFFFFF;
  153. width: 350upx;
  154. height: 50upx;
  155. box-shadow: 0upx 0upx 20upx #D3D3D3;
  156. border-radius: 5upx;
  157. }
  158. .button {
  159. margin: auto;
  160. width: 60%;
  161. height: 100upx;
  162. }
  163. .button1 {
  164. margin: auto;
  165. width: 90upx;
  166. height: 50upx;
  167. }
  168. .p {
  169. /* #ifdef H5 */
  170. top: -13%;
  171. /* #endif */
  172. width: 50upx;
  173. height: 30upx;
  174. font-size: 25upx;
  175. padding-right: 9upx;
  176. padding-top: 6upx;
  177. /* #ifndef H5 */
  178. /* padding-top: 10upx; */
  179. /* #endif */
  180. position: absolute;
  181. /* 水平居中 */
  182. left: 50%;
  183. -webkit-transform: translateX(-50%);
  184. transform: translateX(-50%);
  185. }
  186. .p1 {
  187. /* #ifdef H5 */
  188. top: -13%;
  189. /* #endif */
  190. width: 80upx;
  191. height: 60upx;
  192. font-size: 40upx;
  193. padding-top: 6upx;
  194. /* #ifndef H5 */
  195. padding-top: 10upx;
  196. /* #endif */
  197. position: absolute;
  198. /* 水平居中 */
  199. left: 50%;
  200. -webkit-transform: translateX(-50%);
  201. transform: translateX(-50%);
  202. }
  203. .radio {
  204. padding-top: 20upx;
  205. padding-left: 30upx;
  206. }
  207. .lis {
  208. padding-left: 90upx;
  209. font-size: 30upx;
  210. padding-top: 5upx;
  211. }
  212. .title {
  213. padding-left: 20upx;
  214. font-size: 35upx;
  215. }
  216. </style>