search.vue 21 KB

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