Recognition.vue 4.7 KB

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