distributionOrder.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. // console.log('页面销毁')
  66. uni.removeStorageSync('selectAddress')
  67. },
  68. onLoad(option) {
  69. if (option.flag == 'true') {
  70. this.allocationSuccess = true
  71. }
  72. this.waybillNo = option.waybillNo
  73. },
  74. onShow() {
  75. let address = uni.getStorageSync('selectAddress')
  76. if (address) {
  77. this.$nextTick(() => {
  78. this.$refs['recipients'].validateForm();
  79. })
  80. this.recipientsModel = address
  81. this.saveConsigneeAddress = false
  82. }
  83. },
  84. methods: {
  85. // 选择类型
  86. addressBook(type) {
  87. this.operationType = type
  88. uni.navigateTo({
  89. url: '/pages/order/addressBook?type=' + type
  90. });
  91. },
  92. // 确定分配订单
  93. async printWaybill() {
  94. let flag1 = await this.$refs['recipients'].validateForm();
  95. if (flag1) {
  96. if (this.productData.length > 0) {
  97. let params = {
  98. consigneeAddressName: this.recipientsModel.name,
  99. consigneeAddressPhone: this.recipientsModel.phone,
  100. consigneeAddressDetails: this.recipientsModel.address,
  101. drugs: this.productData,
  102. waybillNo: this.waybillNo,
  103. prescription: this.goodsModel.prescription,
  104. }
  105. this.$api.post('/api/waybill/assignment', params).then(res => {
  106. if (res.code == 200) {
  107. uni.$emit('success', '成功');
  108. if (this.allocationSuccess) {
  109. uni.navigateBack({
  110. delta: 1
  111. });
  112. } else {
  113. uni.navigateBack({
  114. delta: 2
  115. });
  116. }
  117. }
  118. })
  119. } else {
  120. uni.$u.toast('请扫描分配药品条形码')
  121. }
  122. }
  123. },
  124. // 获取药品信息码上放心
  125. getSweep(event) {
  126. let idExists = this.productData.some(obj => obj.code === event);
  127. if (!idExists) {
  128. this.addloading = true
  129. uni.request({
  130. url: 'https://public.coldbaozhida.com/Ali_msfx/codedetail', //仅为示例,并非真实接口地址。
  131. method: 'GET',
  132. header: {
  133. 'content-type': 'application/x-www-form-urlencoded', // 默认值
  134. },
  135. data: {
  136. code: event,
  137. },
  138. success: (res) => {
  139. if (res.data.status == 200) {
  140. let arr = JSON.parse(res.data.data)
  141. if (arr.result.models.length > 0) {
  142. let drugList = {
  143. code: '',
  144. physic_name: '',
  145. physic_type_desc: '',
  146. pkg_spec_crit: '',
  147. ent_name: '',
  148. }
  149. drugList.code = arr.result.models[0].code
  150. drugList.physic_name = arr.result.models[0].drug_ent_base_d_t_o.physic_name
  151. drugList.physic_type_desc = arr.result.models[0].drug_ent_base_d_t_o
  152. .physic_type_desc
  153. drugList.pkg_spec_crit = arr.result.models[0].drug_ent_base_d_t_o
  154. .pkg_spec_crit
  155. drugList.ent_name = arr.result.models[0].p_user_ent_d_t_o.ent_name
  156. this.productData.push(drugList)
  157. this.productData = this.uniqueArray(this.productData)
  158. } else {
  159. uni.$u.toast('该商品不存在')
  160. }
  161. }
  162. this.addloading = false
  163. }
  164. });
  165. } else {
  166. uni.$u.toast('该商品已存在')
  167. }
  168. },
  169. // 去重
  170. uniqueArray(arr) {
  171. return [...new Set(arr)];
  172. },
  173. }
  174. }
  175. </script>
  176. <style lang="scss">
  177. page {
  178. background-color: #fff !important;
  179. }
  180. .card_Address {
  181. position: relative;
  182. }
  183. .card_flex_il {
  184. display: flex;
  185. align-items: center;
  186. padding: 20rpx;
  187. }
  188. .title_waybill {
  189. font-size: 32rpx;
  190. padding: 20rpx;
  191. }
  192. .title_sou {
  193. font-size: 32rpx;
  194. }
  195. .card_Address:before {
  196. content: " ";
  197. position: absolute;
  198. left: 0;
  199. bottom: 0;
  200. width: 100%;
  201. height: 1px;
  202. border-top: 1px solid #e7e6e4;
  203. -webkit-transform-origin: 0 0;
  204. transform-origin: 0 0;
  205. -webkit-transform: scaleY(0.5);
  206. transform: scaleY(0.5);
  207. }
  208. </style>