transferWorkOrderUser.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="transferWorkOrder">
  3. <mSearch class="search" :mode="2" button="inside" placeholder="请搜索人员名称、工号" @input="changeInp" @search="doSearch()" v-model="keyword" searchButtonType="icon" searchButtonName="newicon-saoma"></mSearch>
  4. <scroll-view scroll-y class="list">
  5. <view class="item" v-for="item in list" :key="item.id" @click="selectItem(item)">{{item.name}}({{item.account}})</view>
  6. </scroll-view >
  7. <view class="footer">
  8. <view class="btn" hover-class="seimin-btn-hover" @click="goBack()">返回</view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import { get, post, SM, webHandle } from "../../http/http.js";
  14. import debounce from 'lodash-es/debounce'
  15. import mSearch from "@/components/mehaotian-search-revision/mehaotian-search-revision.vue";
  16. export default {
  17. onLoad(options) {
  18. console.log('options', options);
  19. this.options = options || {};
  20. this.getList();
  21. },
  22. onShow() {
  23. this.SMFlag = true;
  24. },
  25. components: {
  26. //引用mSearch组件,如不需要删除即可
  27. mSearch,
  28. },
  29. data() {
  30. return {
  31. options: {},
  32. keyword: '',
  33. hosId: uni.getStorageSync('userData').user.currentHospital.id,
  34. list: [],
  35. SMFlag: true,
  36. };
  37. },
  38. methods:{
  39. goBack() {
  40. uni.navigateBack();
  41. },
  42. //防抖搜索
  43. changeInp(event) {
  44. this.inputChange(event);
  45. },
  46. //监听输入
  47. inputChange(event) {
  48. let keyword = event.detail ? event.detail.value : event;
  49. this.handleSearch(keyword);
  50. },
  51. doSearch(){
  52. // 扫码
  53. if (!this.SMFlag) {
  54. return;
  55. }
  56. this.SMFlag = false;
  57. SM().then((content) => {
  58. this.scanQrcode(content);
  59. }).catch(err => {
  60. this.SMFlag = true;
  61. });
  62. },
  63. //扫码
  64. scanQrcode(content){
  65. let userHandoverCode = '';
  66. uni.showLoading({
  67. title: "加载中",
  68. mask: true,
  69. });
  70. //检验二维码的有效性(扫码前必须验证)
  71. post("/dept/scanning", {
  72. content,
  73. })
  74. .then((result) => {
  75. try{
  76. userHandoverCode = JSON.parse(result.code);
  77. }catch(e){
  78. userHandoverCode = '';
  79. }
  80. this.SMFlag = true;
  81. uni.hideLoading();
  82. // 200检测通过,201没有有效期也通过。
  83. if (result.state == 200 || result.state == 201) {
  84. if(Object.prototype.toString.call(userHandoverCode) === '[object Object]' && userHandoverCode.name){
  85. uni.redirectTo({
  86. url: `/pages/transferWorkOrder/transferWorkOrderPatient?userId=${userHandoverCode.id}&userName=${userHandoverCode.name}&userAccount=${userHandoverCode.account}&selectPatientList=${this.options.selectPatientList}`,
  87. });
  88. }else{
  89. uni.showToast({
  90. icon: "none",
  91. title: "请扫描正确的二维码!",
  92. });
  93. }
  94. } else {
  95. uni.hideLoading();
  96. uni.showToast({
  97. icon: "none",
  98. title: result.info || "接口获取数据失败!",
  99. });
  100. }
  101. })
  102. },
  103. selectItem(user){
  104. // let userList = uni.getStorageSync('transferWorkOrderUserList') || [];
  105. // // 移除
  106. // userList = userList.filter(v => v.id != user.id);
  107. // // 添加
  108. // userList = [user, ...userList];
  109. // userList = userList.map(v => ({...v, timeStamp: +new Date()}))
  110. // uni.setStorageSync('transferWorkOrderUserList', userList);
  111. uni.redirectTo({
  112. url: `/pages/transferWorkOrder/transferWorkOrderPatient?userId=${user.id}&userName=${user.name}&userAccount=${user.account}&selectPatientList=${this.options.selectPatientList}`,
  113. });
  114. },
  115. handleSearch: debounce(function(keyword) {
  116. this.getList(keyword);
  117. }, 500),
  118. getList(keyword){
  119. // if(!keyword){
  120. // let userList = uni.getStorageSync('transferWorkOrderUserList') || [];
  121. // userList = userList.filter(v => +new Date() - v.timeStamp < 4 * 60 * 60 * 1000);//4小时内选择过的用户
  122. // uni.setStorageSync('transferWorkOrderUserList', userList);
  123. // this.list = userList;
  124. // return;
  125. // }
  126. uni.showLoading({
  127. title: "加载中",
  128. });
  129. post("/simple/data/fetchDataList/user", {
  130. idx: 0,
  131. sum: 25,
  132. user: {
  133. hosId: this.hosId,
  134. name: keyword || undefined,
  135. online: true,
  136. }
  137. }).then((result) => {
  138. uni.hideLoading();
  139. if (result.status == 200) {
  140. this.list = result.list || [];
  141. } else {
  142. uni.showToast({
  143. icon: "none",
  144. title: result.msg || "接口获取数据失败!",
  145. });
  146. }
  147. });
  148. },
  149. }
  150. }
  151. </script>
  152. <style lang="less" scoped>
  153. .transferWorkOrder{
  154. width: 100%;
  155. height: 100vh;
  156. display: flex;
  157. flex-direction: column;
  158. .search{
  159. padding: 10rpx 24rpx;
  160. }
  161. .list{
  162. flex: 1;
  163. min-height: 0;
  164. background-color: #fff;
  165. .item{
  166. height: 100rpx;
  167. line-height: 100rpx;
  168. text-align: center;
  169. font-size: 26rpx;
  170. border-bottom: 1rpx solid #D5D5D5;
  171. }
  172. }
  173. .footer{
  174. margin-top: 24rpx;
  175. margin-bottom: 24rpx;
  176. line-height: 80rpx;
  177. height: 80rpx;
  178. background: #fff;
  179. display: flex;
  180. align-items: center;
  181. .btn {
  182. height: 80rpx;
  183. flex: 1;
  184. margin: 0 24rpx;
  185. background-color: #49B856;
  186. color: #fff;
  187. border-radius: 8rpx;
  188. font-size: 34rpx;
  189. text-align: center;
  190. }
  191. }
  192. }
  193. </style>