codeTracing.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="card_code_tracing">
  3. <u-navbar border title="二维码溯源" autoBack placeholder></u-navbar>
  4. <view class="card_order_details">
  5. <view class="details_title">高频编码 <span class="line_title">*</span></view>
  6. <view class="card_search">
  7. <view class="card_sweep" @click="sweep">
  8. <u-icon name="scan" size="36"></u-icon>
  9. <view class="scan_title">扫一扫</view>
  10. </view>
  11. <view class="card_input">
  12. <u-input border="surround" v-model="frequencyCoding">
  13. <template slot="suffix">
  14. <u-icon name="search" size="26" @click="traceSource"></u-icon>
  15. </template>
  16. </u-input>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="card_basic_information" v-if="gasCylinderList.pro_name">
  21. <view class="headline">基础信息</view>
  22. <view style="padding: 20rpx;">
  23. <view class="card_basics" v-for="(item,index) in basicsList" :key="index">
  24. <view class="basics_title basics_left">{{item.title}}:</view>
  25. <view class="basics_title1 basics_right"
  26. v-if="['fill_media','location','status'].includes(item.field)">
  27. {{initDictvalue(gasCylinderList,item.options,item.field)}}
  28. </view>
  29. <view class="basics_title1 basics_right" v-else>{{gasCylinderList[`${item.field}`]}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="card_basic_information" v-if="operationLogList.length > 0">
  34. <view class="headline">物流信息</view>
  35. <view style="padding: 20rpx;">
  36. <step-bar :stepList="operationLogList" id="step"></step-bar>
  37. </view>
  38. </view>
  39. <view style="margin-top: 50rpx;" v-if="!gasCylinderList.pro_name && operationLogList.length === 0">
  40. <u-empty mode="search" text="没有搜索结果"></u-empty>
  41. </view>
  42. <view style="width: 100%; height: 50rpx;"></view>
  43. </view>
  44. </template>
  45. <script>
  46. import stepBar from '@/components/StepBar.vue'
  47. import {
  48. neurogen,
  49. attribution,
  50. cylinderCondition
  51. } from '@/static/js/blockSort.js'
  52. export default {
  53. components: {
  54. stepBar,
  55. },
  56. data() {
  57. return {
  58. frequencyCoding: '377825938847',
  59. gasCylinderList: {},
  60. operationLogList: [],
  61. basicsList: [{
  62. title: '设备品种',
  63. field: 'pro_variety',
  64. }, {
  65. title: '产品名称',
  66. field: 'pro_name',
  67. }, {
  68. title: '充装介质',
  69. field: 'fill_media',
  70. options: neurogen()
  71. }, {
  72. title: '制造单位',
  73. field: 'make_unit',
  74. }, {
  75. title: '下次检验日期',
  76. field: 'next_check_time',
  77. }, {
  78. title: '气瓶使用登记代码',
  79. field: 'chip_id',
  80. }, {
  81. title: '单位内编码',
  82. field: 'inner_code',
  83. }, {
  84. title: '归属地',
  85. field: 'location',
  86. options: attribution()
  87. }, {
  88. title: '气瓶状态',
  89. field: 'status',
  90. options: cylinderCondition()
  91. }, {
  92. title: '检测机构',
  93. field: 'check_organization',
  94. }, {
  95. title: '高频编码',
  96. field: 'uid',
  97. }, {
  98. title: '检测结果',
  99. field: 'result_code',
  100. }, {
  101. title: '使用年限',
  102. field: 'deadline_time',
  103. }, {
  104. title: '报废日期',
  105. field: 'scrap_time',
  106. }],
  107. }
  108. },
  109. onLoad(option) {
  110. console.log(option,265)
  111. },
  112. methods: {
  113. // 扫一扫
  114. sweep() {
  115. // 允许从相机和相册扫码
  116. uni.scanCode({
  117. scanType: ["qrCode"],
  118. success: (res) => {
  119. // console.log(res);
  120. if (res.result) {
  121. let url = res.result;
  122. this.frequencyCoding = url
  123. this.traceSource()
  124. } else {
  125. console.log('请重新扫描');
  126. return false;
  127. }
  128. },
  129. fail: (res) => {
  130. console.log('未识别到二维码');
  131. }
  132. })
  133. },
  134. // 扫码溯源
  135. traceSource() {
  136. if (this.frequencyCoding) {
  137. this.$api.get('/api/gas-cylinder/uid/' + this.frequencyCoding).then(res => {
  138. console.log(res, 24)
  139. if (res.code == 200) {
  140. this.gasCylinderList = res.data.gasCylinder
  141. this.operationLogList = res.data.operationLog
  142. }
  143. })
  144. } else {
  145. uni.$u.toast('请先完善信息')
  146. }
  147. },
  148. // 普通类型文字匹配
  149. initDictvalue(value, list, type) {
  150. let name = ''
  151. if (list) {
  152. list.forEach(item => {
  153. if (value[type] === item.value) {
  154. name = item.label
  155. }
  156. })
  157. }
  158. return name
  159. },
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .card_order_details {
  165. padding: 30rpx 40rpx 10rpx 40rpx;
  166. background-color: #fff;
  167. }
  168. .details_title {
  169. color: #333;
  170. font-size: 34rpx;
  171. font-weight: 500;
  172. margin-bottom: 10rpx;
  173. }
  174. .card_search {
  175. display: flex;
  176. align-items: center;
  177. margin: 20rpx 0rpx;
  178. }
  179. .scan_title {
  180. font-size: 20rpx;
  181. }
  182. .card_sweep {
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. flex: none;
  187. }
  188. .card_input {
  189. width: 100%;
  190. margin-left: 30rpx;
  191. }
  192. .line_title {
  193. color: red;
  194. }
  195. .card_basic_information {
  196. border-top: 10px solid #f5f5f5;
  197. padding: 20rpx;
  198. }
  199. .headline {
  200. font-size: 32rpx;
  201. color: #000;
  202. padding: 0rpx 10rpx 20rpx 10rpx;
  203. border-bottom: 1rpx solid #e7e6e4;
  204. }
  205. .card_basics {
  206. width: 100%;
  207. display: flex;
  208. margin-bottom: 14rpx;
  209. }
  210. .basics_title {
  211. color: #303133;
  212. font-size: 30rpx;
  213. }
  214. .basics_title1 {
  215. color: #606266;
  216. font-size: 30rpx;
  217. }
  218. .basics_left {
  219. width: 38%;
  220. text-align: right;
  221. font-size: 28rpx;
  222. color: #3eacef;
  223. }
  224. .basics_right {
  225. width: 62%;
  226. text-align: left;
  227. padding-left: 20rpx;
  228. font-size: 28rpx;
  229. }
  230. </style>