Recognition.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="Recognition">
  3. <u-list :height="666">
  4. <u-list-item v-for="(item, index) in listData" :key="index">
  5. <u-cell
  6. :title="`${item.deviceName} (${
  7. item.checkNum == '1'
  8. ? '第一次'
  9. : item.checkNum == '2'
  10. ? '第二次'
  11. : ''
  12. })`"
  13. @click="getSbClick(item)"
  14. >
  15. <u-avatar
  16. slot="icon"
  17. shape="square"
  18. size="35"
  19. :src="item.img"
  20. customStyle="margin: -3px 5px -3px 0"
  21. ></u-avatar>
  22. <view
  23. slot="value"
  24. style="display: flex; align-items: center; margin-left: 20px"
  25. >
  26. <text :class="item.status == '2' ? 'fail-text' : 'suc-text'">{{
  27. item.status == "0"
  28. ? "处理中"
  29. : item.status == "1"
  30. ? "识别成功"
  31. : item.status == "2"
  32. ? "识别失败"
  33. : ""
  34. }}</text>
  35. </view>
  36. </u-cell>
  37. </u-list-item>
  38. </u-list>
  39. </view>
  40. </template>
  41. <script>
  42. import api from "@/api/api";
  43. import configService from "@/common/service/config.service.js";
  44. export default {
  45. name: "Recognition",
  46. components: {},
  47. props: {
  48. recognitionData: {
  49. type: Array,
  50. default: () => {
  51. return [];
  52. },
  53. },
  54. },
  55. data() {
  56. return {
  57. listData: [],
  58. sbData: [], //识别数据
  59. sbParamData: {},
  60. };
  61. },
  62. computed: {
  63. username: function () {
  64. return uni.getStorageSync("login_user_info")["realname"];
  65. },
  66. searchTime: function () {
  67. return uni.getStorageSync("searchTime");
  68. },
  69. },
  70. watch: {
  71. recognitionData: {
  72. handler(newV, oldV) {
  73. if (newV && newV.length != 0) {
  74. this.listData = newV;
  75. this.processArray(this.listData);
  76. }
  77. },
  78. immediate: true,
  79. },
  80. },
  81. mounted() {},
  82. methods: {
  83. async processArray(array) {
  84. let that = this;
  85. for (const obj of array) {
  86. let findIndex = that.listData.findIndex(
  87. (v) => v.deviceId == obj.deviceId
  88. );
  89. //0:处理中,1:识别成功,2:识别失败
  90. that.listData[findIndex].status = "0";
  91. const result = await that.processObject(obj);
  92. that.$set(that.listData, findIndex, {
  93. ...obj,
  94. status: result[0].status,
  95. });
  96. that.sbData = that.listData.map((el) => {
  97. return {
  98. ...el,
  99. sbList: result,
  100. };
  101. });
  102. }
  103. uni.hideLoading();
  104. },
  105. async processObject(obj) {
  106. let that = this;
  107. let list = [];
  108. // 模拟异步操作,例如网络请求
  109. return new Promise((resolve) =>
  110. setTimeout(() => {
  111. let apiUrlImg = `${configService.apiUrlP}:6008`;
  112. uni.uploadFile({
  113. url: `${apiUrlImg}/gasIdentifyDs`,
  114. filePath: uni.getStorageSync(obj.deviceId),
  115. name: "img",
  116. formData: {
  117. user: that.username,
  118. order: obj.classType_dictText,
  119. reportdate: that.searchTime,
  120. checkpath: obj.deviceName,
  121. imgpath: uni.getStorageSync(obj.deviceId),
  122. },
  123. success: (res) => {
  124. if (res) {
  125. that.indexList = JSON.parse(res.data).data || [];
  126. list = that.indexList.map((el) => {
  127. return {
  128. ...el,
  129. status: "1",
  130. };
  131. });
  132. resolve(list);
  133. // that.deviceId = that.deviceID;
  134. }
  135. },
  136. fail: (error) => {
  137. list.push({ status: "2" });
  138. resolve(list);
  139. },
  140. });
  141. }, 1000)
  142. );
  143. },
  144. //识别跳转
  145. getSbClick(item) {
  146. this.sbParamData = this.sbData.filter(
  147. (v) => v.deviceId == item.deviceId
  148. )[0];
  149. console.log(this.sbParamData, "sbParam------");
  150. //跳转填报页面
  151. this.$emit("getRepport", this.sbParamData);
  152. },
  153. },
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .Recognition {
  158. position: relative;
  159. width: 100%;
  160. background-color: #fff;
  161. .suc-text {
  162. font-size: 12px;
  163. color: rgb(118, 236, 88);
  164. }
  165. .fail-text {
  166. font-size: 12px;
  167. color: rgb(240, 20, 4);
  168. }
  169. }
  170. ::v-deep .u-slot-title {
  171. display: flex;
  172. }
  173. </style>