cannibalize.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view>
  3. <u-navbar :title="headTile" autoBack placeholder></u-navbar>
  4. <view class="card_cannibalize">
  5. <view class="card_erweima_af">
  6. <canvas id="qrcode" canvas-id="qrcode" style="width: 140px;height:140px;" />
  7. <view class="title_balize">调拨码</view>
  8. </view>
  9. <view v-if="transferFlag">
  10. <view class="subheading_title">调拨人</view>
  11. <view style="display: flex;align-items: center;">
  12. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  13. <view class="card_user_title">
  14. <view class="mine_phone" v-if="transferList.allotUser">{{transferList.allotUser.nickName}}
  15. </view>
  16. <view class="mine_phone" v-if="transferList.allotCompany">{{transferList.allotCompany.name}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="subheading_title1">单位内编号</view>
  21. <view class="card_innercode" v-for="(item1,index1) in transferList.innerCodeList" :key="index1">
  22. <view style="color: #82848a;">{{ index1 + 1 }}</view>
  23. <view class="title_innerCode">{{ item1 }}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="btn_cannibalize" v-if="transferFlag">
  28. <view style="flex: 1;">
  29. <u-button style="width: 90%;" type="error" @click="cancelAllocation">取消</u-button>
  30. </view>
  31. <view style="flex: 1;">
  32. <u-button style="width: 90%;" type="primary" @click="submit">确定</u-button>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import UQRCode from "static/js/uqrcode.js";
  39. export default {
  40. data() {
  41. return {
  42. orderId: '',
  43. headTile: '',
  44. transferList: {},
  45. transferFlag: false,
  46. timer: null,
  47. }
  48. },
  49. onUnload() {
  50. clearTimeout(this.timer)
  51. this.timer = null
  52. },
  53. beforeDestroy() {
  54. clearTimeout(this.timer)
  55. this.timer = null
  56. },
  57. onLoad(value) {
  58. this.orderId = value.type
  59. this.headTile = value.title
  60. },
  61. mounted() {
  62. var userInfo = this.$cache.getCache('userInfo')
  63. this.userInfo = userInfo
  64. const qr = new UQRCode();
  65. let numarr = 'dialCode?' + this.orderId + ',' + userInfo.id + ',' + userInfo.nickName + ',' + userInfo.dept
  66. .id + ',' +
  67. userInfo.dept.name + ',' + this.headTile
  68. qr.data = numarr;
  69. qr.size = 140;
  70. qr.make();
  71. const ctx = uni.createCanvasContext('qrcode', this);
  72. qr.canvasContext = ctx;
  73. qr.drawCanvas();
  74. this.getallot()
  75. },
  76. methods: {
  77. getallot() {
  78. this.$api.get('/api/gas-cylinder-allot/opt-type/' + this.orderId).then(res => {
  79. if (res.code == 200) {
  80. this.transferFlag = true
  81. this.transferList = res.data
  82. } else {
  83. this.timer = setTimeout(() => {
  84. this.getallot()
  85. }, 6000);
  86. // setTimeout(() => {
  87. // this.getallot()
  88. // }, 60000);
  89. }
  90. })
  91. },
  92. // 取消调拨
  93. cancelAllocation() {
  94. uni.showLoading({
  95. mask: true,
  96. });
  97. this.$api.post('/api/gas-cylinder-allot/cancel', {
  98. id: this.transferList.id,
  99. }).then(res => {
  100. uni.hideLoading();
  101. if (res.code == 200) {
  102. this.transferFlag = false
  103. this.transferList = {}
  104. uni.$u.toast(res.msg)
  105. }
  106. }).catch(() => {
  107. uni.hideLoading();
  108. })
  109. },
  110. // 确定调拨钢瓶
  111. submit() {
  112. uni.showLoading({
  113. mask: true,
  114. });
  115. this.$api.post('/api/gas-cylinder-allot/submit', {
  116. id: this.transferList.id,
  117. optType: this.transferList.optType,
  118. allotUserId: this.transferList.allotUserId,
  119. acceptUserId: this.transferList.acceptUserId,
  120. allotCompanyId: this.transferList.allotCompanyId,
  121. acceptCompanyId: this.transferList.acceptCompanyId,
  122. innerCodeList: this.transferList.innerCodeList,
  123. }).then(res => {
  124. if (res.code == 200) {
  125. this.transferFlag = false
  126. this.transferList = {}
  127. uni.$u.toast(res.msg)
  128. setTimeout(() => {
  129. if (this.userInfo.provUser.isorders == 0 && this.userInfo.provUser.userType ==
  130. 3) {
  131. uni.redirectTo({
  132. url: '/pages/indexRouter?page=2'
  133. });
  134. } else {
  135. uni.redirectTo({
  136. url: '/pages/indexRouter?page=1'
  137. });
  138. }
  139. }, 1500)
  140. } else {
  141. uni.$u.toast(res.data.msg)
  142. }
  143. uni.hideLoading();
  144. }).catch(() => {
  145. uni.hideLoading();
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. page {
  153. background-color: #f4f4f5;
  154. }
  155. .card_cannibalize {
  156. display: flex;
  157. flex-direction: column;
  158. background-color: #fff;
  159. margin: 30rpx;
  160. padding: 30rpx;
  161. border-radius: 10rpx;
  162. }
  163. .card_erweima_af {
  164. display: flex;
  165. align-items: center;
  166. justify-content: center;
  167. flex-direction: column;
  168. }
  169. .title_balize {
  170. font-size: 40rpx;
  171. margin-top: 10rpx;
  172. font-weight: 600;
  173. }
  174. .mine_image {
  175. width: 100rpx;
  176. height: 100rpx;
  177. border-radius: 50%;
  178. }
  179. .card_user_title {
  180. display: flex;
  181. flex-direction: column;
  182. align-items: flex-start;
  183. }
  184. .mine_phone {
  185. margin-left: 20rpx;
  186. font-size: 30rpx;
  187. }
  188. .card_innercode {
  189. display: flex;
  190. padding: 20rpx;
  191. border-bottom: 1rpx solid #d7d7d7;
  192. }
  193. .subheading_title {
  194. font-size: 34rpx;
  195. font-weight: 600;
  196. margin: 20rpx 0rpx;
  197. }
  198. .subheading_title1 {
  199. font-size: 34rpx;
  200. font-weight: 600;
  201. margin-top: 20rpx;
  202. padding-bottom: 20rpx;
  203. border-bottom: 1rpx solid #d7d7d7;
  204. }
  205. .title_innerCode {
  206. font-size: 30rpx;
  207. margin-left: 10rpx;
  208. }
  209. .btn_cannibalize {
  210. position: fixed;
  211. bottom: 0;
  212. left: 0;
  213. right: 0;
  214. background-color: #fff;
  215. display: flex;
  216. align-items: center;
  217. padding: 20rpx 0rpx;
  218. }
  219. </style>