distributionOrder.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <!-- 分配订单 -->
  3. <view>
  4. <u-navbar title="分配订单" autoBack placeholder></u-navbar>
  5. <view class="space_between card_Address">
  6. <view class="title_waybill">收件人:</view>
  7. <view class="card_flex_il" @click="addressBook('consignee')">
  8. <u-icon name="order" size="22"></u-icon>
  9. <view class="title_sou">收件人簿</view>
  10. </view>
  11. </view>
  12. <x-form ref="recipients" :list="list" :model="recipientsModel" :rules="rules"></x-form>
  13. <x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules" :addloading="addloading"
  14. :productData="productData" @getSweep="getSweep"></x-form>
  15. <view class="safeBottom" style="width: 100%;height: 180rpx;"></view>
  16. <view class="btn_print" @click="printWaybill">
  17. <u-button type="primary" text="确定"></u-button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. allocationRulesil,
  24. allocationList
  25. } from "./waybill.js";
  26. export default {
  27. data() {
  28. return {
  29. list: allocationRulesil(),
  30. recipientsModel: {
  31. name: '',
  32. phone: '',
  33. address: '',
  34. },
  35. rules: {
  36. name: {
  37. required: false,
  38. message: '请输入姓名',
  39. trigger: ['blur', 'change']
  40. },
  41. phone: {
  42. required: true,
  43. message: '请输入电话',
  44. trigger: ['blur', 'change']
  45. },
  46. address: {
  47. required: false,
  48. message: '请输入地址',
  49. trigger: ['blur', 'change']
  50. },
  51. },
  52. goodsModel: {
  53. drugBarCode: '',
  54. prescription: [],
  55. },
  56. productData: [],
  57. goodsRules: {},
  58. goodsList: allocationList(),
  59. addloading: false,
  60. allocationSuccess: false,
  61. waybillNo: '',
  62. }
  63. },
  64. onUnload() {
  65. uni.$off('success')
  66. // console.log('页面销毁')
  67. uni.removeStorageSync('selectAddress')
  68. },
  69. onLoad(option) {
  70. if (option.flag == 'true') {
  71. this.allocationSuccess = true
  72. }
  73. this.waybillNo = option.waybillNo
  74. },
  75. onShow() {
  76. let address = uni.getStorageSync('selectAddress')
  77. if (address) {
  78. this.$nextTick(() => {
  79. this.$refs['recipients'].validateForm();
  80. })
  81. this.recipientsModel = address
  82. this.saveConsigneeAddress = false
  83. }
  84. },
  85. methods: {
  86. // 选择类型
  87. addressBook(type) {
  88. this.operationType = type
  89. uni.navigateTo({
  90. url: '/pages/order/addressBook?type=' + type
  91. });
  92. },
  93. // 确定分配订单
  94. async printWaybill() {
  95. let flag1 = await this.$refs['recipients'].validateForm();
  96. if (flag1) {
  97. if (this.productData.length > 0) {
  98. let params = {
  99. consigneeAddressName: this.recipientsModel.name,
  100. consigneeAddressPhone: this.recipientsModel.phone,
  101. consigneeAddressDetails: this.recipientsModel.address,
  102. drugs: this.productData,
  103. waybillNo: this.waybillNo,
  104. prescription: this.goodsModel.prescription,
  105. }
  106. this.$api.post('/api/waybill/assignment', params).then(res => {
  107. if (res.code == 200) {
  108. if (this.allocationSuccess) {
  109. uni.$emit('success', '成功');
  110. uni.navigateBack({
  111. delta: 1
  112. });
  113. } else {
  114. uni.$emit('success', '成功');
  115. uni.navigateBack({
  116. delta: 2
  117. });
  118. }
  119. }
  120. })
  121. } else {
  122. uni.$u.toast('请扫描分配药品条形码')
  123. }
  124. }
  125. },
  126. // 获取药品信息码上放心
  127. getSweep(event) {
  128. let idExists = this.productData.some(obj => obj.code === event);
  129. if (!idExists) {
  130. this.addloading = true
  131. uni.request({
  132. url: 'https://public.coldbaozhida.com/Ali_msfx/codedetail', //仅为示例,并非真实接口地址。
  133. method: 'GET',
  134. header: {
  135. 'content-type': 'application/x-www-form-urlencoded', // 默认值
  136. },
  137. data: {
  138. code: event,
  139. },
  140. success: (res) => {
  141. if (res.data.status == 200) {
  142. let arr = JSON.parse(res.data.data)
  143. if (arr.result.models.length > 0) {
  144. let drugList = {
  145. code: '',
  146. physic_name: '',
  147. physic_type_desc: '',
  148. pkg_spec_crit: '',
  149. ent_name: '',
  150. }
  151. drugList.code = arr.result.models[0].code
  152. drugList.physic_name = arr.result.models[0].drug_ent_base_d_t_o.physic_name
  153. drugList.physic_type_desc = arr.result.models[0].drug_ent_base_d_t_o
  154. .physic_type_desc
  155. drugList.pkg_spec_crit = arr.result.models[0].drug_ent_base_d_t_o
  156. .pkg_spec_crit
  157. drugList.ent_name = arr.result.models[0].p_user_ent_d_t_o.ent_name
  158. this.productData.push(drugList)
  159. this.productData = this.uniqueArray(this.productData)
  160. } else {
  161. uni.$u.toast('该商品不存在')
  162. }
  163. }
  164. this.addloading = false
  165. }
  166. });
  167. } else {
  168. uni.$u.toast('该商品已存在')
  169. }
  170. },
  171. // 去重
  172. uniqueArray(arr) {
  173. return [...new Set(arr)];
  174. },
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. page {
  180. background-color: #fff !important;
  181. }
  182. .card_Address {
  183. position: relative;
  184. }
  185. .card_flex_il {
  186. display: flex;
  187. align-items: center;
  188. padding: 20rpx;
  189. }
  190. .title_waybill {
  191. font-size: 32rpx;
  192. padding: 20rpx;
  193. }
  194. .title_sou {
  195. font-size: 32rpx;
  196. }
  197. .card_Address:before {
  198. content: " ";
  199. position: absolute;
  200. left: 0;
  201. bottom: 0;
  202. width: 100%;
  203. height: 1px;
  204. border-top: 1px solid #e7e6e4;
  205. -webkit-transform-origin: 0 0;
  206. transform-origin: 0 0;
  207. -webkit-transform: scaleY(0.5);
  208. transform: scaleY(0.5);
  209. }
  210. </style>