selectMachine.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view>
  3. <view class="body">
  4. <input class="input" style="display:none;" name="code" :value=code />
  5. 编码:<input class="input" v-model="code" />
  6. <button type="primary" @click="saoma()" class="button1">
  7. <p class="p">扫码</p>
  8. </button>
  9. <button type="primary" @click="getMessage(code)" class="button1">
  10. <p class="p">获取</p>
  11. </button>
  12. </view>
  13. <view class="">
  14. <t-table>
  15. <t-tr class="tr">
  16. 机器编码:{{coding}}
  17. </t-tr>
  18. <t-tr class="tr">
  19. 机器铭牌:{{nameplate}}
  20. </t-tr>
  21. <t-tr class="tr">
  22. 设备编码:{{clientId}}
  23. </t-tr>
  24. <t-tr class="tr">
  25. 机器名称:{{name}}
  26. </t-tr>
  27. <t-tr class="tr">
  28. 总装开始时间:{{startDate}}
  29. </t-tr>
  30. <t-tr class="tr">
  31. 总装结束时间:{{endDate}}
  32. </t-tr>
  33. </t-table>
  34. </view>
  35. <view class="">
  36. <view v-for="(item,index) in modulesList" :key="index">
  37. <t-table class="table">
  38. <t-tr class="tr table">
  39. 名称:{{item.name}}
  40. </t-tr>
  41. <t-tr class="tr">
  42. <t-td>编码:{{item.coding}}</t-td>
  43. <t-td class="td">
  44. <button type="primary" @click="tran(item.coding)" class="button1">
  45. <p class="p">详情</p>
  46. </button>
  47. </t-td>
  48. </t-tr>
  49. </t-table>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. mapState,
  57. mapActions,
  58. mapMutations
  59. } from 'vuex';
  60. export default {
  61. data() {
  62. return {
  63. code: '',
  64. coding: '',
  65. nameplate: '',
  66. name: '',
  67. startDate: '',
  68. clientId: '',
  69. endDate: '',
  70. modulesList: []
  71. }
  72. },
  73. onShow() {
  74. },
  75. methods: {
  76. saoma() {
  77. var that = this;
  78. // 允许从相机和相册扫码
  79. uni.scanCode({
  80. success(res) {
  81. that.code = res.result;
  82. }
  83. });
  84. },
  85. getMessage(coding) {
  86. var that = this;
  87. var serverUrl = that.serverurl;
  88. var token = uni.getStorageSync("token");
  89. uni.request({
  90. url: serverUrl + "/TMachine/selectMachine?coding=" + coding,
  91. method: "GET",
  92. header: {
  93. 'token': token
  94. },
  95. success: (Result) => {
  96. // console.log(Result);
  97. var res = Result;
  98. if (res.data.code == true) {
  99. //当机器已录入时,会先把所有录入模块给列出来
  100. if (res.data.message == 'all') {
  101. var tmachine = res.data.data.tmachine;
  102. that.name = tmachine.name;
  103. that.nameplate = tmachine.nameplate;
  104. that.clientId = tmachine.clientId;
  105. that.coding = tmachine.coding;
  106. that.startDate = tmachine.startDate;
  107. that.endDate = tmachine.endDate;
  108. that.modulesList = res.data.data.modulesList;
  109. } else {
  110. var codes = res.data.data;
  111. that.name = codes.name;
  112. that.nameplate = codes.nameplate;
  113. that.clientId = tmachine.clientId;
  114. that.producePersonnel = uni.getStorageSync("name");
  115. }
  116. } else {
  117. uni.showModal({
  118. title: '提示',
  119. content: res.data.message,
  120. });
  121. }
  122. }
  123. });
  124. },
  125. tran(coding) {
  126. uni.setStorageSync("selectCoding", coding);
  127. uni.navigateTo({
  128. url: 'selectModules',
  129. });
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. .body {
  136. background-color: #FFFFFF;
  137. padding: 20upx 20upx 20upx 20upx;
  138. font-size: 30upx;
  139. display: flex;
  140. flex-direction: row;
  141. justify-content: flex-start;
  142. }
  143. .table {
  144. padding-top: 30upx;
  145. }
  146. .tr {
  147. padding-left: 30upx;
  148. padding-top: 13upx;
  149. font-size: 30upx;
  150. padding-bottom: 13upx;
  151. }
  152. .td {
  153. padding-left: 280upx;
  154. }
  155. .input {
  156. /* padding: 10upx 20upx 10upx 0upx; */
  157. padding-left: 20upx;
  158. padding-top: 10upx;
  159. background-color: #FFFFFF;
  160. width: 400upx;
  161. height: 50upx;
  162. box-shadow: 0upx 0upx 20upx #D3D3D3;
  163. border-radius: 5upx;
  164. }
  165. .button {
  166. margin: auto;
  167. width: 60%;
  168. height: 100upx;
  169. }
  170. .button1 {
  171. margin: auto;
  172. width: 75upx;
  173. height: 50upx;
  174. text-align: right
  175. }
  176. .p {
  177. /* #ifdef H5 */
  178. top: -13%;
  179. /* #endif */
  180. width: 50upx;
  181. height: 30upx;
  182. font-size: 25upx;
  183. padding-right: 9upx;
  184. padding-top: 6upx;
  185. /* #ifndef H5 */
  186. /* padding-top: 10upx; */
  187. /* #endif */
  188. position: absolute;
  189. /* 水平居中 */
  190. left: 50%;
  191. -webkit-transform: translateX(-50%);
  192. transform: translateX(-50%);
  193. }
  194. .p1 {
  195. /* #ifdef H5 */
  196. top: -13%;
  197. /* #endif */
  198. width: 80upx;
  199. height: 60upx;
  200. font-size: 40upx;
  201. padding-top: 6upx;
  202. /* #ifndef H5 */
  203. padding-top: 10upx;
  204. /* #endif */
  205. position: absolute;
  206. /* 水平居中 */
  207. left: 50%;
  208. -webkit-transform: translateX(-50%);
  209. transform: translateX(-50%);
  210. }
  211. .radio {
  212. padding-top: 20upx;
  213. padding-left: 30upx;
  214. }
  215. .lis {
  216. padding-left: 90upx;
  217. font-size: 30upx;
  218. padding-top: 5upx;
  219. }
  220. .title {
  221. padding-left: 20upx;
  222. font-size: 35upx;
  223. }
  224. </style>