creatOrder.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="pages flex flex_column">
  3. <view class="forms">
  4. <view class="flex align_center">
  5. <view class="labes">扫描唯一码:</view>
  6. <view class="inputs"><image style="width: 100%;height: 35px;background: #eaeaea;" :src="tempImg"></image></view>
  7. <view class="btns" @click="openCamera"><image src="../../static/tab/tab_scan_normal.png"></image></view>
  8. </view>
  9. <view class="flex align_center">
  10. <view class="labes">识别唯一码:</view>
  11. <view class="inputs"><u-input :focus="focusInput" v-model="uuidCode" maxlength="10" border clearable type="text" placeholder="请输入唯一码"></u-input></view>
  12. <view class="btns"><u-button type="primary" size="mini" @click="addTags">添加</u-button></view>
  13. </view>
  14. </view>
  15. <view class="tags-box">
  16. <u-tag v-for="item in uuid" :key="item.code" :text="item.code" closeable @close="tagClick(item)" />
  17. </view>
  18. <view class="buttons">
  19. <u-button type="primary" @click="saveForm">确定</u-button>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. tempImg: '',
  28. uuidCode: '',
  29. uuid: [],
  30. focusInput: false
  31. }
  32. },
  33. onShow() {
  34. const uuidTemp = this.$store.state.vuex_uuidTempData
  35. // 如果有未完成的质保单
  36. if(uuidTemp && uuidTemp.uuid){
  37. this.uuid = uuidTemp.uuid
  38. }
  39. // 识别结束
  40. const ret = this.$store.state.vuex_tempData
  41. if(ret&&ret.retCode){
  42. this.tempImg = ret.filePath
  43. this.uuidCode = ret.retCode
  44. }
  45. this.focusInput = ret&&ret=="inputCode"
  46. },
  47. onHide() {
  48. this.$store.state.vuex_tempData = null
  49. },
  50. methods: {
  51. tagClick(item){
  52. const index = this.uuid.findIndex(k => k.code == item.code)
  53. if(index>=0){
  54. this.uuid.splice(index,1)
  55. }
  56. },
  57. addTags(){
  58. if(this.uuid.length>=4){
  59. uni.showToast({
  60. icon: 'none',
  61. title: '唯一码一次最多可添加4个,请进行删减后再添加。'
  62. })
  63. return
  64. }
  65. if(this.uuidCode){
  66. this.uuid.push({
  67. code: this.uuidCode,
  68. name: '箭冠轮胎雪胎RT-8000',
  69. state: ['inhand','outof'][Math.random() < 0.5 ? 0 : 1]
  70. })
  71. this.uuidCode = ''
  72. }else{
  73. uni.showToast({
  74. icon: 'none',
  75. title: '请扫描或手动输入唯一码'
  76. })
  77. }
  78. },
  79. openCamera(){
  80. uni.navigateTo({
  81. url: "/pages/scan-frame/scan-frame?pageType=UUID"
  82. })
  83. },
  84. saveForm(){
  85. if(this.uuid.length){
  86. this.$store.state.vuex_uuidTempData = {uuid:this.uuid}
  87. uni.redirectTo({
  88. url: "/pagesA/qualityPolicy/creatCarInfo"
  89. })
  90. }else{
  91. uni.showToast({
  92. icon: 'none',
  93. title: '请扫描或手动输入唯一码'
  94. })
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="less">
  101. .pages{
  102. height: 100vh;
  103. background: #fff;
  104. .tags-box{
  105. flex-grow: 1;
  106. padding: 1rem;
  107. /deep/ .u-tag{
  108. margin: 0.5rem 1rem;
  109. }
  110. }
  111. .buttons{
  112. padding: 1rem 6rem 3rem;
  113. }
  114. }
  115. .forms{
  116. padding: 1rem 0 0;
  117. > view{
  118. border-bottom: 1px solid #eee;
  119. padding: 0.6rem 1rem;
  120. }
  121. .labes{
  122. width: 5rem;
  123. }
  124. .inputs{
  125. flex-grow: 1;
  126. }
  127. .btns{
  128. width: 3rem;
  129. text-align: center;
  130. image{
  131. width: 1.6rem;
  132. height: 1.6rem;
  133. }
  134. }
  135. }
  136. </style>