search.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. if(workAllocationQuickConfig.deptTypeList){
  208. this.quickCombinationDeptType = workAllocationQuickConfig.deptTypeList.map(v => v.id).toString();
  209. }else{
  210. // 没有获取到配置,则获取之前的
  211. this.getSysDeptType();
  212. }
  213. }else{
  214. this.getSysDeptType();
  215. }
  216. }
  217. })
  218. },
  219. //监听输入
  220. inputChange(event) {
  221. //兼容引入组件时传入参数情况
  222. var keyword = event.detail ? event.detail.value : event;
  223. if (!keyword) {
  224. this.keywordList = [];
  225. this.isShowKeywordList = false;
  226. return;
  227. }
  228. this.keyword = keyword;
  229. this.isShowKeywordList = true;
  230. let postData = {
  231. idx: 0,
  232. sum: 20,
  233. department: {
  234. hospital: {
  235. id: this.hosId,
  236. },
  237. dept: keyword,
  238. },
  239. };
  240. if(this.type == 'setDept'){
  241. postData = {
  242. idx: 0,
  243. sum: 20,
  244. department: {
  245. cascadeHosId: this.hosId,
  246. dept: keyword,
  247. },
  248. }
  249. }
  250. //不是送回病房
  251. if (this.type != "sendBack" && this.type != "sendBackPatientList" && this.type != "settingCode" && this.type != "bloodSelect" && this.type != "showDepartmentQrcode") {
  252. if(this.quickCombinationDeptType){
  253. postData.department.deptTypeIds = this.quickCombinationDeptType;
  254. } else if (this.sysDeptType === 0) {
  255. return;
  256. } else {
  257. postData.department.type = {
  258. id: this.sysDeptType
  259. }
  260. }
  261. }
  262. // 设置二维码
  263. if(this.type == "settingCode"){
  264. postData = {
  265. hosId: this.hosId,
  266. searchKey: keyword,
  267. }
  268. }
  269. uni.showLoading({
  270. title: "加载中",
  271. });
  272. post(this.type == "settingCode" ? "/dept/queryChangeDept" : "/data/fetchDataList/department", postData).then((res) => {
  273. if (res.status == 200 || res.state == 200) {
  274. if(this.type == "settingCode"){
  275. let deptList = res.deptList.map(v => ({...v, sign: 'dept'}));
  276. let qrList = res.qrList.map(v => ({...v.deptDTO, sign: 'qr', qrId: v.id, name: v.name}));
  277. this.searchData.push({
  278. name: keyword,
  279. list: deptList.concat(qrList)
  280. });
  281. }else{
  282. this.searchData.push({
  283. name: keyword,
  284. list: res.list
  285. });
  286. }
  287. let searchText = this.searchText.detail ? this.searchText.detail.value : this.searchText;
  288. let index = this.searchData.findIndex(item => item.name === searchText);
  289. this.deptList = index >= 0 ? this.searchData[index].list : [];
  290. this.keywordList = this.drawCorrelativeKeyword(this.deptList, keyword);
  291. uni.hideLoading();
  292. } else {
  293. uni.hideLoading();
  294. uni.showToast({
  295. icon: "none",
  296. title: res.msg || "接口获取数据失败!",
  297. });
  298. }
  299. });
  300. },
  301. //高亮关键字
  302. drawCorrelativeKeyword(keywords, keyword) {
  303. var len = keywords.length,
  304. keywordArr = [];
  305. for (var i = 0; i < len; i++) {
  306. var row = keywords[i];
  307. //定义高亮#9f9f9f
  308. var html = row.dept.replace(
  309. keyword,
  310. "<span style='color: #9f9f9f;'>" + keyword + "</span>"
  311. );
  312. html = "<div>" + html + (row.sign == 'qr' ? '('+ row.name +')' : '') + (row.sign == 'qr' ? '<span class="red">(配置)</span>' : '') + "</div>";
  313. var tmpObj = {
  314. id: row.id,
  315. qrId: row.qrId,
  316. keyword: row.dept,
  317. htmlStr: html,
  318. };
  319. keywordArr.push(tmpObj);
  320. }
  321. return keywordArr;
  322. },
  323. //清除历史搜索
  324. oldDelete() {
  325. uni.showModal({
  326. content: "确定清除历史搜索记录?",
  327. success: (res) => {
  328. if (res.confirm) {
  329. console.log("用户点击确定");
  330. this.oldKeywordList = [];
  331. uni.removeStorage({
  332. key: "OldKeys",
  333. });
  334. } else if (res.cancel) {
  335. console.log("用户点击取消");
  336. }
  337. },
  338. });
  339. },
  340. // 建单并签到-指定科室
  341. buildOrderAndSign(deptDto) {
  342. uni.showModal({
  343. title: "提示",
  344. content: `您当前选择的科室为【${deptDto.dept}】,请确认是否建单并签到?`,
  345. success: (result) => {
  346. if (result.confirm) {
  347. console.log("用户点击确定");
  348. let postData = {
  349. type: 'blood',
  350. id: this.bloodDTO.id,
  351. applyDept: deptDto.id,
  352. };
  353. uni.showLoading({
  354. title: "加载中",
  355. mask: true,
  356. });
  357. post("/transflow/createOrTakeOrder", postData).then((ress) => {
  358. uni.hideLoading();
  359. if (ress.state == 200) {
  360. uni.navigateTo({
  361. url: `../scanning_blood_process/scanning_blood_process?orderId=${ress.data.orderId}&bloodDTO=${encodeURIComponent(JSON.stringify(this.bloodDTO))}&scanCount=${ress.data.scanCount}&status=${ress.state}`,
  362. });
  363. } else {
  364. uni.showToast({
  365. icon: "none",
  366. title: ress.msg || "接口获取数据失败!",
  367. });
  368. }
  369. });
  370. } else if (result.cancel) {
  371. console.log("用户点击取消");
  372. }
  373. },
  374. });
  375. },
  376. //执行搜索
  377. doSearch(data) {
  378. console.log(data);
  379. let keyword = keyword === false ? this.keyword : data.keyword;
  380. this.keyword = keyword;
  381. this.saveKeyword(keyword); //保存为历史
  382. let arr = this.deptList.filter((item) => data.qrId ? (item.qrId === data.qrId) : (item.dept === keyword));
  383. if (arr.length) {
  384. let msg = "";
  385. if (this.type == "patientInformationList" || this.type == "inspectList" || this.type == "pharmacy" || this.type == "showDepartmentQrcode") {
  386. msg = "切换科室成功";
  387. uni.showToast({
  388. title: msg,
  389. icon: "none",
  390. duration: 2000,
  391. });
  392. } else if (this.type == "setDept") {
  393. msg = "添加科室成功";
  394. uni.showToast({
  395. title: msg,
  396. icon: "none",
  397. duration: 2000,
  398. });
  399. }
  400. if (this.type == "patientInformationList") {
  401. //患者列表进入
  402. uni.setStorageSync("patientCurrentDept", arr[0]); //科室切换存本地
  403. uni.navigateTo({
  404. url: `../patientInformationList/patientInformationList?id=${arr[0].id}&dept=${arr[0].dept}`,
  405. });
  406. } else if (this.type == "inspectList") {
  407. //患者列表进入
  408. uni.setStorageSync("patientCurrentDept", arr[0]); //科室切换存本地
  409. uni.navigateTo({
  410. url: `../inspectList/inspectList?id=${arr[0].id}&dept=${arr[0].dept}`,
  411. });
  412. } else if (this.type == "bloodSelect") {
  413. //血制品建单进入
  414. this.buildOrderAndSign(arr[0]);
  415. } else if (this.type == "pharmacy") {
  416. //药房进入
  417. uni.navigateTo({
  418. url: `../pharmacy/pharmacy?id=${arr[0].id}&dept=${arr[0].dept}`,
  419. });
  420. } else if (this.type == "showDepartmentQrcode") {
  421. //科室二维码进入
  422. uni.navigateTo({
  423. url: `../receiptpage/receiptpage?showDepartmentQrcodeId=${arr[0].id}&showDepartmentQrcodeDept=${arr[0].dept}`,
  424. });
  425. } else if (this.type == "setDept") {
  426. //上班添加科室进入
  427. let obj = uni.getStorageSync("setDepts");
  428. console.log(arr,obj)
  429. if (obj) {
  430. let i = obj.findIndex((item) => item.id == arr[0].id);
  431. if (i < 0) {
  432. uni.setStorageSync("setDepts", [arr[0], ...obj]);
  433. }
  434. } else {
  435. uni.setStorageSync("setDepts", [arr[0]]);
  436. }
  437. uni.navigateTo({
  438. url: `../setDept/setDept?configName=${this.configName}&id=${this.id}&changedept=${this.changedept}`,
  439. });
  440. } else if (this.type == "sendBack") {
  441. uni.navigateTo({
  442. 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}`,
  443. });
  444. } else if (this.type == "sendBackPatientList") {
  445. uni.navigateTo({
  446. url: `../patientInformationList/patientInformationList?did=${arr[0].id}&ddept=${arr[0].dept}&currentItem=${this.currentItem}&id=${this.cid}&dept=${this.cdept}&scrollYY=${this.scrollYY}`,
  447. });
  448. } else if (this.type == "settingCode") {
  449. if (this.queryDept) { //替换
  450. console.log(arr);
  451. uni.navigateTo({
  452. 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}`,
  453. });
  454. } else { //设置
  455. uni.navigateTo({
  456. url: `../settingCode/settingCode?qrId=${arr[0].qrId || ''}&targetId=${arr[0].id}&targetDept=${arr[0].dept}&uniName=${this.uniName}&qrCode=${this.qrCode}`,
  457. });
  458. }
  459. }
  460. }
  461. },
  462. //保存关键字到历史记录
  463. saveKeyword(keyword) {
  464. uni.getStorage({
  465. key: "OldKeys",
  466. success: (res) => {
  467. var OldKeys = JSON.parse(res.data);
  468. var findIndex = OldKeys.indexOf(keyword);
  469. if (findIndex == -1) {
  470. OldKeys.unshift(keyword);
  471. } else {
  472. OldKeys.splice(findIndex, 1);
  473. OldKeys.unshift(keyword);
  474. }
  475. //最多10个纪录
  476. OldKeys.length > 10 && OldKeys.pop();
  477. uni.setStorage({
  478. key: "OldKeys",
  479. data: JSON.stringify(OldKeys),
  480. });
  481. this.oldKeywordList = OldKeys; //更新历史搜索
  482. },
  483. fail: (e) => {
  484. var OldKeys = [keyword];
  485. uni.setStorage({
  486. key: "OldKeys",
  487. data: JSON.stringify(OldKeys),
  488. });
  489. this.oldKeywordList = OldKeys; //更新历史搜索
  490. },
  491. });
  492. },
  493. },
  494. };
  495. </script>
  496. <style>
  497. view {
  498. display: block;
  499. }
  500. .search-box {
  501. width: 95%;
  502. background-color: rgb(242, 242, 242);
  503. padding: 15upx 2.5%;
  504. display: flex;
  505. justify-content: space-between;
  506. position: sticky;
  507. top: 0;
  508. }
  509. .search-box .mSearch-input-box {
  510. width: 100%;
  511. }
  512. .search-box .input-box {
  513. width: 85%;
  514. flex-shrink: 1;
  515. display: flex;
  516. justify-content: center;
  517. align-items: center;
  518. }
  519. .search-box .search-btn {
  520. width: 15%;
  521. margin: 0 0 0 2%;
  522. display: flex;
  523. justify-content: center;
  524. align-items: center;
  525. flex-shrink: 0;
  526. font-size: 28upx;
  527. color: #fff;
  528. background: linear-gradient(to right, #ff9801, #ff570a);
  529. border-radius: 60upx;
  530. }
  531. .search-box .input-box>input {
  532. width: 100%;
  533. height: 60upx;
  534. font-size: 32upx;
  535. border: 0;
  536. border-radius: 60upx;
  537. -webkit-appearance: none;
  538. -moz-appearance: none;
  539. appearance: none;
  540. padding: 0 3%;
  541. margin: 0;
  542. background-color: #ffffff;
  543. }
  544. .placeholder-class {
  545. color: #9e9e9e;
  546. }
  547. .search-keyword {
  548. width: 100%;
  549. background-color: rgb(242, 242, 242);
  550. }
  551. .keyword-list-box {
  552. height: calc(100vh - 110upx);
  553. padding-top: 10upx;
  554. border-radius: 20upx 20upx 0 0;
  555. background-color: #fff;
  556. }
  557. .keyword-entry-tap {
  558. background-color: #eee;
  559. }
  560. .keyword-entry {
  561. width: 94%;
  562. height: 80upx;
  563. margin: 0 3%;
  564. font-size: 30upx;
  565. color: #333;
  566. display: flex;
  567. justify-content: space-between;
  568. align-items: center;
  569. border-bottom: solid 1upx #e7e7e7;
  570. }
  571. .keyword-entry image {
  572. width: 60upx;
  573. height: 60upx;
  574. }
  575. .keyword-entry .keyword-text,
  576. .keyword-entry .keyword-img {
  577. height: 80upx;
  578. display: flex;
  579. align-items: center;
  580. }
  581. .keyword-entry .keyword-text {
  582. width: 90%;
  583. }
  584. .keyword-entry .keyword-img {
  585. width: 10%;
  586. justify-content: center;
  587. }
  588. .keyword-box {
  589. height: calc(100vh - 110upx);
  590. border-radius: 20upx 20upx 0 0;
  591. background-color: #fff;
  592. }
  593. .keyword-box .keyword-block {
  594. padding: 10upx 0;
  595. }
  596. .keyword-box .keyword-block .keyword-list-header {
  597. width: 94%;
  598. padding: 10upx 3%;
  599. font-size: 27upx;
  600. color: #333;
  601. display: flex;
  602. justify-content: space-between;
  603. }
  604. .keyword-box .keyword-block .keyword-list-header image {
  605. width: 40upx;
  606. height: 40upx;
  607. }
  608. .keyword-box .keyword-block .keyword {
  609. width: 94%;
  610. padding: 3px 3%;
  611. display: flex;
  612. flex-flow: wrap;
  613. justify-content: flex-start;
  614. }
  615. .keyword-box .keyword-block .hide-hot-tis {
  616. display: flex;
  617. justify-content: center;
  618. font-size: 28upx;
  619. color: #6b6b6b;
  620. }
  621. .keyword-box .keyword-block .keyword>view {
  622. display: flex;
  623. justify-content: center;
  624. align-items: center;
  625. border-radius: 60upx;
  626. padding: 0 20upx;
  627. margin: 10upx 20upx 10upx 0;
  628. height: 60upx;
  629. font-size: 28upx;
  630. background-color: rgb(242, 242, 242);
  631. color: #6b6b6b;
  632. }
  633. </style>