task.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="content">
  3. <view class="" v-for="(obj, index) in tabList" :key="index">
  4. <view class="title">
  5. <text>设备ID:</text>
  6. <text :style="obj.status == 1 ? 'color: #00ff08;' : 'color: #ff0000;'">
  7. {{ obj.deviceId }}
  8. </text>
  9. </view>
  10. <view class="">
  11. <view class="content_boby">
  12. <view class="content_boby_view">
  13. <text>简称:</text>
  14. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  15. {{ obj.abbreviation }}
  16. </text>
  17. </view>
  18. <view class="content_boby_view">
  19. <text>设备名称:</text>
  20. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  21. {{ obj.deviceName }}
  22. </text>
  23. </view>
  24. </view>
  25. <view class="content_boby">
  26. <view class="content_boby_view">
  27. <text>连接类型:</text>
  28. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  29. {{ obj.connectionType }}
  30. </text>
  31. </view>
  32. <view class="content_boby_view">
  33. <text>生产线:</text>
  34. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  35. {{ obj.productionLine }}
  36. </text>
  37. </view>
  38. </view>
  39. <view class="content_boby">
  40. <view class="content_boby_view">
  41. <text>状态:</text>
  42. <text
  43. :class="obj.status == 1 ? 'showFalw' : 'showTres'"
  44. v-if="obj.status == 1">
  45. 连接正常
  46. </text>
  47. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'" v-else>
  48. 连接中断
  49. </text>
  50. </view>
  51. </view>
  52. <view class="content_boby" style="justify-content: end">
  53. <view class="content_boby_view">
  54. <view class="content_boby_button">
  55. <u-button
  56. style="margin: 0 2vw; width: 63px"
  57. v-show="isCodeReadDevice(obj.deviceName)"
  58. @click="readingFrame(obj)"
  59. size="mini"
  60. type="warning">
  61. 读码
  62. </u-button>
  63. <u-button
  64. style="width: 113px"
  65. @click="logReter(obj.deviceId)"
  66. size="mini"
  67. type="error">
  68. 查看设备日志
  69. </u-button>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="hr"></view>
  74. </view>
  75. </view>
  76. <u-modal v-model="show" :content="content"></u-modal>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. components: {},
  82. data() {
  83. return {
  84. show: true,
  85. content: "东临碣石,以观沧海",
  86. obj: {},
  87. statusType: [
  88. {
  89. name: "开始",
  90. id: 1,
  91. },
  92. {
  93. name: "完成",
  94. id: 2,
  95. },
  96. {
  97. name: "开始取货",
  98. id: 3,
  99. },
  100. {
  101. name: "取货完成",
  102. id: 4,
  103. },
  104. {
  105. name: "开始卸货",
  106. id: 5,
  107. },
  108. {
  109. name: "卸货完成",
  110. id: 6,
  111. },
  112. {
  113. name: "取消",
  114. id: 7,
  115. },
  116. {
  117. name: "异常",
  118. id: 8,
  119. },
  120. {
  121. name: "待下发",
  122. id: 9,
  123. },
  124. {
  125. name: "已下发",
  126. id: 10,
  127. },
  128. {
  129. name: "取消并归于起点",
  130. id: 11,
  131. },
  132. {
  133. name: "取消并归于终点",
  134. id: 12,
  135. },
  136. {
  137. name: "生成",
  138. id: 13,
  139. },
  140. {
  141. name: "卸货待确认",
  142. id: 14,
  143. },
  144. ],
  145. page: 1,
  146. tabList: [],
  147. host: "",
  148. };
  149. },
  150. onLoad(option) {
  151. let _this = this;
  152. uni.getStorage({
  153. key: "hostappst",
  154. success(res) {
  155. console.log("获取成功", res.data);
  156. _this.host = res.data;
  157. },
  158. });
  159. this.getData();
  160. },
  161. onShow() {},
  162. created() {},
  163. mounted() {},
  164. onReachBottom() {
  165. this.page++;
  166. this.getData("addList");
  167. },
  168. methods: {
  169. logReter(id) {
  170. uni.navigateTo({
  171. url: "/pages/index/me/log/log?id=" + id,
  172. });
  173. },
  174. isCodeReadDevice(name) {
  175. let pattern = /^CodeReader/;
  176. return pattern.test(name);
  177. },
  178. readingFrame(data) {
  179. let that = this;
  180. uni.showModal({
  181. title: "读码",
  182. content: "你确定要读码这个数据吗?",
  183. confirmColor: "red",
  184. success: function (res) {
  185. if (res.confirm) {
  186. uni.getStorage({
  187. key: "GetPhone_Token",
  188. success: function (res) {
  189. uni.request({
  190. url: `http://${that.host}` + "/device/triggerCodeRead",
  191. header: {
  192. Authorization: res.data,
  193. },
  194. data: data,
  195. method: "POST",
  196. success(respenon) {
  197. console.log("chaoShiPanDuan", respenon);
  198. if (respenon.data.code == 200) {
  199. uni.showToast({
  200. title: respenon.data.msg,
  201. icon: "none",
  202. });
  203. } else if (respenon.data.code == 401) {
  204. uni.reLaunch({
  205. url: "/pages/index/login",
  206. });
  207. } else {
  208. uni.showToast({
  209. title: respenon.data.msg,
  210. icon: "none",
  211. });
  212. }
  213. },
  214. });
  215. },
  216. });
  217. } else if (res.cancel) {
  218. console.log("用户点击了取消按钮");
  219. }
  220. },
  221. });
  222. },
  223. getData(type) {
  224. let that = this;
  225. let data = {
  226. pageNum: this.page,
  227. pageSize: 10,
  228. };
  229. uni.getStorage({
  230. key: "GetPhone_Token",
  231. success: function (res) {
  232. uni.request({
  233. url: `http://${that.host}` + "/device/list",
  234. header: {
  235. Authorization: res.data,
  236. "content-type": "application/x-www-form-urlencoded",
  237. },
  238. data: data,
  239. method: "GET",
  240. success(respenon) {
  241. console.log("chaoShiPanDuan", respenon);
  242. if (respenon.data.code == 200) {
  243. if (type == "addList") {
  244. that.tabList = [...that.tabList, ...respenon.data.rows];
  245. } else {
  246. that.tabList = respenon.data.data;
  247. }
  248. } else if (respenon.data.code == 401) {
  249. uni.reLaunch({
  250. url: "/pages/index/login",
  251. });
  252. } else {
  253. uni.showToast({
  254. title: respenon.data.msg,
  255. icon: "none",
  256. });
  257. }
  258. },
  259. });
  260. },
  261. });
  262. },
  263. },
  264. };
  265. </script>
  266. <style scoped lang="scss">
  267. .content {
  268. color: #787878;
  269. font-size: 14px;
  270. font-weight: 400;
  271. .title {
  272. height: 44px;
  273. padding: 12px 15px;
  274. }
  275. .content_boby {
  276. padding: 0 15px;
  277. display: flex;
  278. justify-content: space-between;
  279. margin-bottom: 10px;
  280. .showFalw {
  281. color: #00ff08;
  282. }
  283. .showTres {
  284. color: red;
  285. }
  286. .content_boby_button {
  287. display: flex;
  288. }
  289. }
  290. .hr {
  291. width: 100%;
  292. height: 1px;
  293. background: #cfcfcf;
  294. }
  295. }
  296. </style>