search.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view class="content">
  3. <view class="search-box">
  4. <!-- mSearch组件 如果使用原样式,删除组件元素-->
  5. <mSearch class="mSearch-input-box" :mode="2" button="inside" :placeholder="defaultKeyword"
  6. @search="doSearch(false)" @input="changeInp" @confirm="doSearch(false)" v-model="keyword"></mSearch>
  7. </view>
  8. <view class="search-keyword">
  9. <scroll-view class="keyword-list-box" v-show="isShowKeywordList" scroll-y>
  10. <block v-for="(row, index) in keywordList" :key="index">
  11. <view class="keyword-entry" hover-class="keyword-entry-tap">
  12. <view class="keyword-text" @tap.stop="doSearch(keywordList[index].keyword)">
  13. <rich-text :nodes="row.htmlStr"></rich-text>
  14. </view>
  15. <view class="keyword-img" @tap.stop="doSearch(keywordList[index].keyword)">
  16. <image src="/static/HM-search/back.png"></image>
  17. </view>
  18. </view>
  19. </block>
  20. </scroll-view>
  21. <scroll-view class="keyword-box" v-show="!isShowKeywordList" scroll-y>
  22. <view class="keyword-block" v-if="oldKeywordList.length > 0">
  23. <view class="keyword-list-header">
  24. <view>历史搜索</view>
  25. <view>
  26. <image @tap="oldDelete" src="/static/HM-search/delete.png"></image>
  27. </view>
  28. </view>
  29. <view class="keyword">
  30. <view v-for="(keyword, index) in oldKeywordList" @tap="changeInp(keyword)" :key="index">{{ keyword }}
  31. </view>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. //引用mSearch组件,如不需要删除即可
  40. import mSearch from "@/components/mehaotian-search-revision/mehaotian-search-revision.vue";
  41. import {
  42. post,
  43. webHandle
  44. } from "../../http/http.js";
  45. export default {
  46. data() {
  47. return {
  48. type: "", //进入该页面的类型
  49. configName: "", //快速组合名称
  50. id: "", //快速组合id
  51. changedept: 0, //是否从列表过来的切换负责科室
  52. hosId: "",
  53. defaultKeyword: "",
  54. keyword: "",
  55. oldKeywordList: [],
  56. keywordList: [],
  57. isShowKeywordList: false,
  58. deptList: [],
  59. //送回病房扫码 start
  60. code: '',
  61. infoDATA: '',
  62. patientOrders: '',
  63. workData: '',
  64. //送回病房扫码 end
  65. //送回病房-患者列表 start
  66. cid: '',
  67. cdept: '',
  68. currentItem: '',
  69. scrollYY: '',
  70. //送回病房-患者列表 end
  71. // 设置科室二维码 start
  72. uniName: '',
  73. queryDept: '',
  74. queryDeptId: '',
  75. qrCode: '',
  76. // 设置科室二维码 end
  77. // 选择血制品送达科室 start
  78. bloodDTO: {},
  79. // 选择血制品送达科室 end
  80. timer: null, //定时器
  81. searchText: '', //搜索文本
  82. searchData: [], //搜索结果
  83. //系统设置的科室类型
  84. sysDeptType: 0,
  85. };
  86. },
  87. onUnload() {
  88. if (this.timer) {
  89. clearTimeout(this.timer);
  90. this.timer = null;
  91. }
  92. },
  93. onLoad(options) {
  94. console.log(options, 'options');
  95. this.type = options.type;
  96. if (this.type == "setDept") {
  97. this.configName = options.configName;
  98. this.id = options.id;
  99. this.changedept = options.changedept;
  100. this.getSysDeptType();
  101. } else if (this.type == "sendBack") {
  102. this.code = options.code;
  103. this.infoDATA = options.infoDATA;
  104. this.patientOrders = options.patientOrders;
  105. this.workData = options.workData;
  106. this.sysDeptType = -1;
  107. } else if (this.type == "sendBackPatientList") {
  108. this.cid = options.cid;
  109. this.cdept = options.cdept;
  110. this.currentItem = options.currentItem;
  111. this.scrollYY = options.scrollYY;
  112. this.sysDeptType = -1;
  113. } else if (this.type == "settingCode") { //设置科室二维码
  114. this.uniName = options.uniName;
  115. this.queryDept = options.queryDept;
  116. this.queryDeptId = options.queryDeptId;
  117. this.qrCode = options.qrCode;
  118. this.sysDeptType = -1;
  119. } else if (this.type == "pharmacy") { //药房切换科室
  120. this.sysDeptType = 386;
  121. } else if (this.type == "bloodSelect") { //选择血制品送达科室
  122. this.bloodDTO = JSON.parse(options.bloodDTO);
  123. } else {
  124. this.getSysDeptType();
  125. }
  126. this.init();
  127. // #ifdef APP-PLUS
  128. webHandle("no", "app");
  129. // #endif
  130. // #ifdef H5
  131. webHandle("no", "wx");
  132. // #endif
  133. },
  134. components: {
  135. //引用mSearch组件,如不需要删除即可
  136. mSearch,
  137. },
  138. methods: {
  139. init() {
  140. this.hosId = uni.getStorageSync("userData").user.currentHospital.id;
  141. this.loadDefaultKeyword();
  142. this.loadOldKeyword();
  143. },
  144. blur() {
  145. uni.hideKeyboard();
  146. },
  147. //加载默认搜索关键字
  148. loadDefaultKeyword() {
  149. //定义默认搜索关键字,可以自己实现ajax请求数据再赋值,用户未输入时,以水印方式显示在输入框,直接不输入内容搜索会搜索默认关键字
  150. this.defaultKeyword = "请输入科室名称";
  151. },
  152. //加载历史搜索,自动读取本地Storage
  153. loadOldKeyword() {
  154. uni.getStorage({
  155. key: "OldKeys",
  156. success: (res) => {
  157. var OldKeys = JSON.parse(res.data);
  158. this.oldKeywordList = OldKeys;
  159. },
  160. });
  161. },
  162. //防抖搜索
  163. changeInp(event) {
  164. this.searchText = event;
  165. clearTimeout(this.timer);
  166. this.timer = setTimeout(() => {
  167. this.inputChange(event);
  168. }, 500)
  169. },
  170. //获取系统设置的科室类型baba sysDeptType
  171. getSysDeptType() {
  172. let postData = {
  173. "idx": 0,
  174. "sum": 1,
  175. systemConfiguration: {
  176. keyconfig: "busiViewDeptId"
  177. }
  178. }
  179. post("/simple/data/fetchDataList/systemConfiguration", postData).then((res) => {
  180. if (res.status == 200) {
  181. this.sysDeptType = res.list[0].valueconfig
  182. }
  183. })
  184. },
  185. //监听输入
  186. inputChange(event) {
  187. //兼容引入组件时传入参数情况
  188. var keyword = event.detail ? event.detail.value : event;
  189. if (!keyword) {
  190. this.keywordList = [];
  191. this.isShowKeywordList = false;
  192. return;
  193. }
  194. this.keyword = keyword;
  195. this.isShowKeywordList = true;
  196. let postData = {
  197. idx: 0,
  198. sum: 20,
  199. department: {
  200. hospital: {
  201. id: this.hosId,
  202. },
  203. dept: keyword,
  204. },
  205. };
  206. if(this.type == 'setDept'){
  207. postData = {
  208. idx: 0,
  209. sum: 20,
  210. department: {
  211. cascadeHosId: this.hosId,
  212. dept: keyword,
  213. },
  214. }
  215. }
  216. //不是送回病房
  217. if (this.type != "sendBack" && this.type != "sendBackPatientList" && this.type != "settingCode" && this.type != "bloodSelect") {
  218. if (this.sysDeptType === 0) {
  219. return;
  220. } else {
  221. postData.department.type = {
  222. id: this.sysDeptType
  223. }
  224. }
  225. }
  226. uni.showLoading({
  227. title: "加载中",
  228. });
  229. post("/data/fetchDataList/department", postData).then((res) => {
  230. if (res.status == 200) {
  231. this.searchData.push({
  232. name: keyword,
  233. list: res.list
  234. });
  235. let searchText = this.searchText.detail ? this.searchText.detail.value : this.searchText;
  236. let index = this.searchData.findIndex(item => item.name === searchText);
  237. this.deptList = index >= 0 ? this.searchData[index].list : [];
  238. this.keywordList = this.drawCorrelativeKeyword(this.deptList, keyword);
  239. uni.hideLoading();
  240. } else {
  241. uni.hideLoading();
  242. uni.showToast({
  243. icon: "none",
  244. title: "请求失败!",
  245. });
  246. }
  247. });
  248. },
  249. //高亮关键字
  250. drawCorrelativeKeyword(keywords, keyword) {
  251. var len = keywords.length,
  252. keywordArr = [];
  253. for (var i = 0; i < len; i++) {
  254. var row = keywords[i];
  255. //定义高亮#9f9f9f
  256. var html = row.dept.replace(
  257. keyword,
  258. "<span style='color: #9f9f9f;'>" + keyword + "</span>"
  259. );
  260. html = "<div>" + html + "</div>";
  261. var tmpObj = {
  262. keyword: row.dept,
  263. htmlStr: html,
  264. };
  265. keywordArr.push(tmpObj);
  266. }
  267. return keywordArr;
  268. },
  269. //清除历史搜索
  270. oldDelete() {
  271. uni.showModal({
  272. content: "确定清除历史搜索记录?",
  273. success: (res) => {
  274. if (res.confirm) {
  275. console.log("用户点击确定");
  276. this.oldKeywordList = [];
  277. uni.removeStorage({
  278. key: "OldKeys",
  279. });
  280. } else if (res.cancel) {
  281. console.log("用户点击取消");
  282. }
  283. },
  284. });
  285. },
  286. // 建单并签到-指定科室
  287. buildOrderAndSign(deptDto) {
  288. uni.showModal({
  289. title: "提示",
  290. content: `您当前选择的科室为【${deptDto.dept}】,请确认是否建单并签到?`,
  291. success: (result) => {
  292. if (result.confirm) {
  293. console.log("用户点击确定");
  294. let postData = {
  295. type: 'blood',
  296. id: this.bloodDTO.id,
  297. applyDept: deptDto.id,
  298. };
  299. uni.showLoading({
  300. title: "加载中",
  301. mask: true,
  302. });
  303. post("/transflow/createOrTakeOrder", postData).then((ress) => {
  304. uni.hideLoading();
  305. if (ress.state == 200) {
  306. uni.navigateTo({
  307. url: `../scanning_blood_process/scanning_blood_process?orderId=${ress.data.orderId}&bloodDTO=${encodeURIComponent(JSON.stringify(this.bloodDTO))}&scanCount=${ress.data.scanCount}&status=${ress.state}`,
  308. });
  309. } else {
  310. uni.showToast({
  311. icon: "none",
  312. title: "请求失败!",
  313. });
  314. }
  315. });
  316. } else if (result.cancel) {
  317. console.log("用户点击取消");
  318. }
  319. },
  320. });
  321. },
  322. //执行搜索
  323. doSearch(keyword) {
  324. keyword = keyword === false ? this.keyword : keyword;
  325. this.keyword = keyword;
  326. this.saveKeyword(keyword); //保存为历史
  327. let arr = this.deptList.filter((item) => item.dept === keyword);
  328. if (arr.length) {
  329. let msg = "";
  330. if (this.type == "patientInformationList" || this.type == "inspectList" || this.type == "pharmacy") {
  331. msg = "切换科室成功";
  332. uni.showToast({
  333. title: msg,
  334. icon: "none",
  335. duration: 2000,
  336. });
  337. } else if (this.type == "setDept") {
  338. msg = "添加科室成功";
  339. uni.showToast({
  340. title: msg,
  341. icon: "none",
  342. duration: 2000,
  343. });
  344. }
  345. if (this.type == "patientInformationList") {
  346. //患者列表进入
  347. uni.setStorageSync("patientCurrentDept", arr[0]); //科室切换存本地
  348. uni.navigateTo({
  349. url: `../patientInformationList/patientInformationList?id=${arr[0].id}&dept=${arr[0].dept}`,
  350. });
  351. } else if (this.type == "inspectList") {
  352. //患者列表进入
  353. uni.setStorageSync("patientCurrentDept", arr[0]); //科室切换存本地
  354. uni.navigateTo({
  355. url: `../inspectList/inspectList?id=${arr[0].id}&dept=${arr[0].dept}`,
  356. });
  357. } else if (this.type == "bloodSelect") {
  358. //血制品建单进入
  359. this.buildOrderAndSign(arr[0]);
  360. } else if (this.type == "pharmacy") {
  361. //药房进入
  362. uni.navigateTo({
  363. url: `../pharmacy/pharmacy?id=${arr[0].id}&dept=${arr[0].dept}`,
  364. });
  365. } else if (this.type == "setDept") {
  366. //上班添加科室进入
  367. let obj = uni.getStorageSync("setDepts");
  368. console.log(arr,obj)
  369. if (obj) {
  370. let i = obj.findIndex((item) => item.id == arr[0].id);
  371. if (i < 0) {
  372. uni.setStorageSync("setDepts", [arr[0], ...obj]);
  373. }
  374. } else {
  375. uni.setStorageSync("setDepts", [arr[0]]);
  376. }
  377. uni.navigateTo({
  378. url: `../setDept/setDept?configName=${this.configName}&id=${this.id}&changedept=${this.changedept}`,
  379. });
  380. } else if (this.type == "sendBack") {
  381. uni.navigateTo({
  382. url: `../scanning_ins/scanning_ins?id=${arr[0].id}&dept=${arr[0].dept}&code=${this.code}&infoDATA=${this.infoDATA}&patientOrders=${this.patientOrders}&workData=${this.workData}`,
  383. });
  384. } else if (this.type == "sendBackPatientList") {
  385. uni.navigateTo({
  386. url: `../patientInformationList/patientInformationList?did=${arr[0].id}&ddept=${arr[0].dept}&currentItem=${this.currentItem}&id=${this.cid}&dept=${this.cdept}&scrollYY=${this.scrollYY}`,
  387. });
  388. } else if (this.type == "settingCode") {
  389. if (this.queryDept) { //替换
  390. uni.navigateTo({
  391. url: `../settingCode/settingCode?targetId=${arr[0].id}&targetDept=${arr[0].dept}&uniName=${this.uniName}&queryDept=${this.queryDept}&queryDeptId=${this.queryDeptId}&qrCode=${this.qrCode}`,
  392. });
  393. } else { //设置
  394. uni.navigateTo({
  395. url: `../settingCode/settingCode?targetId=${arr[0].id}&targetDept=${arr[0].dept}&uniName=${this.uniName}&qrCode=${this.qrCode}`,
  396. });
  397. }
  398. }
  399. }
  400. },
  401. //保存关键字到历史记录
  402. saveKeyword(keyword) {
  403. uni.getStorage({
  404. key: "OldKeys",
  405. success: (res) => {
  406. var OldKeys = JSON.parse(res.data);
  407. var findIndex = OldKeys.indexOf(keyword);
  408. if (findIndex == -1) {
  409. OldKeys.unshift(keyword);
  410. } else {
  411. OldKeys.splice(findIndex, 1);
  412. OldKeys.unshift(keyword);
  413. }
  414. //最多10个纪录
  415. OldKeys.length > 10 && OldKeys.pop();
  416. uni.setStorage({
  417. key: "OldKeys",
  418. data: JSON.stringify(OldKeys),
  419. });
  420. this.oldKeywordList = OldKeys; //更新历史搜索
  421. },
  422. fail: (e) => {
  423. var OldKeys = [keyword];
  424. uni.setStorage({
  425. key: "OldKeys",
  426. data: JSON.stringify(OldKeys),
  427. });
  428. this.oldKeywordList = OldKeys; //更新历史搜索
  429. },
  430. });
  431. },
  432. },
  433. };
  434. </script>
  435. <style>
  436. view {
  437. display: block;
  438. }
  439. .search-box {
  440. width: 95%;
  441. background-color: rgb(242, 242, 242);
  442. padding: 15upx 2.5%;
  443. display: flex;
  444. justify-content: space-between;
  445. position: sticky;
  446. top: 0;
  447. }
  448. .search-box .mSearch-input-box {
  449. width: 100%;
  450. }
  451. .search-box .input-box {
  452. width: 85%;
  453. flex-shrink: 1;
  454. display: flex;
  455. justify-content: center;
  456. align-items: center;
  457. }
  458. .search-box .search-btn {
  459. width: 15%;
  460. margin: 0 0 0 2%;
  461. display: flex;
  462. justify-content: center;
  463. align-items: center;
  464. flex-shrink: 0;
  465. font-size: 28upx;
  466. color: #fff;
  467. background: linear-gradient(to right, #ff9801, #ff570a);
  468. border-radius: 60upx;
  469. }
  470. .search-box .input-box>input {
  471. width: 100%;
  472. height: 60upx;
  473. font-size: 32upx;
  474. border: 0;
  475. border-radius: 60upx;
  476. -webkit-appearance: none;
  477. -moz-appearance: none;
  478. appearance: none;
  479. padding: 0 3%;
  480. margin: 0;
  481. background-color: #ffffff;
  482. }
  483. .placeholder-class {
  484. color: #9e9e9e;
  485. }
  486. .search-keyword {
  487. width: 100%;
  488. background-color: rgb(242, 242, 242);
  489. }
  490. .keyword-list-box {
  491. height: calc(100vh - 110upx);
  492. padding-top: 10upx;
  493. border-radius: 20upx 20upx 0 0;
  494. background-color: #fff;
  495. }
  496. .keyword-entry-tap {
  497. background-color: #eee;
  498. }
  499. .keyword-entry {
  500. width: 94%;
  501. height: 80upx;
  502. margin: 0 3%;
  503. font-size: 30upx;
  504. color: #333;
  505. display: flex;
  506. justify-content: space-between;
  507. align-items: center;
  508. border-bottom: solid 1upx #e7e7e7;
  509. }
  510. .keyword-entry image {
  511. width: 60upx;
  512. height: 60upx;
  513. }
  514. .keyword-entry .keyword-text,
  515. .keyword-entry .keyword-img {
  516. height: 80upx;
  517. display: flex;
  518. align-items: center;
  519. }
  520. .keyword-entry .keyword-text {
  521. width: 90%;
  522. }
  523. .keyword-entry .keyword-img {
  524. width: 10%;
  525. justify-content: center;
  526. }
  527. .keyword-box {
  528. height: calc(100vh - 110upx);
  529. border-radius: 20upx 20upx 0 0;
  530. background-color: #fff;
  531. }
  532. .keyword-box .keyword-block {
  533. padding: 10upx 0;
  534. }
  535. .keyword-box .keyword-block .keyword-list-header {
  536. width: 94%;
  537. padding: 10upx 3%;
  538. font-size: 27upx;
  539. color: #333;
  540. display: flex;
  541. justify-content: space-between;
  542. }
  543. .keyword-box .keyword-block .keyword-list-header image {
  544. width: 40upx;
  545. height: 40upx;
  546. }
  547. .keyword-box .keyword-block .keyword {
  548. width: 94%;
  549. padding: 3px 3%;
  550. display: flex;
  551. flex-flow: wrap;
  552. justify-content: flex-start;
  553. }
  554. .keyword-box .keyword-block .hide-hot-tis {
  555. display: flex;
  556. justify-content: center;
  557. font-size: 28upx;
  558. color: #6b6b6b;
  559. }
  560. .keyword-box .keyword-block .keyword>view {
  561. display: flex;
  562. justify-content: center;
  563. align-items: center;
  564. border-radius: 60upx;
  565. padding: 0 20upx;
  566. margin: 10upx 20upx 10upx 0;
  567. height: 60upx;
  568. font-size: 28upx;
  569. background-color: rgb(242, 242, 242);
  570. color: #6b6b6b;
  571. }
  572. </style>