selectMachine.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. 机器名称:{{name}}
  23. </t-tr>
  24. <t-tr class="tr">
  25. 总装开始时间:{{startDate}}
  26. </t-tr>
  27. <t-tr class="tr">
  28. 总装结束时间:{{endDate}}
  29. </t-tr>
  30. </t-table>
  31. </view>
  32. <view class="">
  33. <view v-for="(item,index) in modulesList" :key="index">
  34. <t-table class="table">
  35. <t-tr class="tr table">
  36. 名称:{{item.name}}
  37. </t-tr>
  38. <t-tr class="tr">
  39. <t-td >编码:{{item.coding}}</t-td>
  40. <t-td class="td">
  41. <button type="primary" @click="tran(item.coding)" class="button1">
  42. <p class="p">详情</p>
  43. </button>
  44. </t-td>
  45. </t-tr>
  46. </t-table>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. mapState,
  54. mapActions,
  55. mapMutations
  56. } from 'vuex';
  57. export default {
  58. data() {
  59. return {
  60. code: '',
  61. coding: '',
  62. nameplate: '',
  63. name: '',
  64. startDate: '',
  65. endDate: '',
  66. modulesList: []
  67. }
  68. },
  69. methods: {
  70. saoma() {
  71. var that = this;
  72. // 允许从相机和相册扫码
  73. uni.scanCode({
  74. success(res) {
  75. that.code = res.result;
  76. }
  77. });
  78. },
  79. getMessage(coding) {
  80. var that = this;
  81. var serverUrl = that.serverurl;
  82. var token = uni.getStorageSync("token");
  83. uni.request({
  84. url: serverUrl + "/TMachine/selectMachine?coding=" + coding,
  85. method: "GET",
  86. header: {
  87. 'token': token
  88. },
  89. success: (Result) => {
  90. console.log(Result);
  91. var res = Result;
  92. if (res.data.code == true) {
  93. //当机器已录入时,会先把所有录入模块给列出来
  94. if (res.data.message == 'all') {
  95. var tmachine = res.data.data.tmachine;
  96. that.name = tmachine.name;
  97. that.nameplate = tmachine.nameplate;
  98. that.coding = tmachine.coding;
  99. that.startDate = tmachine.startDate;
  100. that.endDate = tmachine.endDate;
  101. that.modulesList = res.data.data.modulesList;
  102. } else {
  103. var codes = res.data.data;
  104. that.name = codes.name;
  105. that.nameplate = codes.nameplate;
  106. that.producePersonnel = uni.getStorageSync("name");
  107. }
  108. } else {
  109. uni.showModal({
  110. title: '提示',
  111. content: res.data.message,
  112. });
  113. }
  114. }
  115. });
  116. },
  117. tran(coding){
  118. uni.setStorageSync("selectCoding",coding);
  119. uni.navigateTo({
  120. url: 'selectModules',
  121. });
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. .body {
  128. background-color: #FFFFFF;
  129. padding: 20upx 20upx 20upx 20upx;
  130. font-size: 30upx;
  131. display: flex;
  132. flex-direction: row;
  133. justify-content: flex-start;
  134. }
  135. .table{
  136. padding-top: 30upx;
  137. }
  138. .tr {
  139. padding-left: 30upx;
  140. padding-top: 13upx;
  141. font-size: 30upx;
  142. padding-bottom: 13upx;
  143. }
  144. .td{
  145. padding-left: 280upx;
  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. text-align:right
  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>