fjj-condition.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <view>
  3. <uni-drawer :visible="visibleDrawer" mode="right" @close="closeDrawer()">
  4. <scroll-view class="drawer-list" scroll-y :style="{'height': '100%'}">
  5. <block v-for="(item, index) in menuList" :key="index">
  6. <!-- 单选、多选 isMutiple是否支持多选-->
  7. <view v-if="item.type == 'custom' && item.detailList.length">
  8. <view class="drawer-list-title flex justify-between">
  9. <view>
  10. {{item.title}}
  11. </view>
  12. <text v-if="item.detailList.length>showLenght"
  13. @tap="showMore(index)">{{item.showMoreList ? '收起' : '更多'}}</text>
  14. </view>
  15. <view class="draer-list-con">
  16. <template v-if="!item.showMoreList">
  17. <text
  18. :style="{background: textItem.isSelected ? color : '', color: textItem.isSelected ? '#ffffff' : ''}"
  19. v-if="idx<showLenght" v-for="(textItem, idx) in item.detailList" :key="idx"
  20. :class="textItem.isSelected ? 'on' : ''" @tap="itemTap(idx,item.detailList,item.key, item.isMutiple)">
  21. {{textItem.title}}
  22. </text>
  23. </template>
  24. <template v-else>
  25. <text
  26. :style="{background: textItem.isSelected ? color : '', color: textItem.isSelected ? '#ffffff' : ''}"
  27. v-for="(textItem, idx) in item.detailList" :key="idx" :class="textItem.isSelected ? 'on' : ''"
  28. @tap="itemTap(idx,item.detailList,item.key, item.isMutiple)">
  29. {{textItem.title}}
  30. </text>
  31. </template>
  32. </view>
  33. </view>
  34. <!-- 时间带时分秒范围选择 -->
  35. <view v-if="item.type == 'rangetime'">
  36. <view class="drawer-list-title flex justify-between">
  37. <view>
  38. {{item.title}}
  39. </view>
  40. </view>
  41. <view class="dateContent" @click="onShowDatePicker('rangetime', item.key)">
  42. <view>
  43. <template v-if="result[item.key] && result[item.key].length > 0">
  44. {{rangetime[0]}}
  45. </template>
  46. </view>
  47. <view>
  48. <template v-if="result[item.key] && result[item.key].length > 0">
  49. {{rangetime[1]}}
  50. </template>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 时间不带时分秒范围选择 -->
  55. <view v-if="item.type == 'range'">
  56. <view class="drawer-list-title flex justify-between">
  57. <view>
  58. {{item.title}}
  59. </view>
  60. </view>
  61. <view class="dateContent" @click="onShowDatePicker('range', item.key)">
  62. <view>
  63. <template v-if="result[item.key] && result[item.key].length > 0">
  64. {{range[0]}}-{{range[1]}}
  65. </template>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 时间不带时分秒单个选择 -->
  70. <view v-if="item.type == 'single'">
  71. <view class="drawer-list-title flex justify-between">
  72. <view>
  73. {{item.title}}
  74. </view>
  75. </view>
  76. <view class="dateContent" @click="onShowDatePicker('single', item.key)">
  77. <view>
  78. <!-- <template v-if="result[item.key] && result[item.key].length > 0"> -->
  79. <view style="margin-left:16rpx;color:#666;">{{single[0]}}</view>
  80. <!-- </template> -->
  81. <!-- <template v-else>
  82. <view style="margin-left:16rpx;color:#666;">请选择时间</view>
  83. </template> -->
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 数值范围选择 -->
  88. <view v-if="item.type == 'rangenumber'">
  89. <view class="drawer-list-title flex justify-between">
  90. <view>
  91. {{item.title}}
  92. </view>
  93. </view>
  94. <view class="dateContent rangenumber-content flex">
  95. <view class="rangenumber-input">
  96. <input class="m-input" type="number" clearable v-model="minNumber"
  97. :placeholder="item.minPlaceholder || '最小值'" @blur="numberInputBlur(item.key)"></input>
  98. </view>
  99. <text>-</text>
  100. <view class="rangenumber-input">
  101. <input class="m-input" type="number" clearable v-model="maxNumber"
  102. :placeholder="item.maxPlaceholder || '最大值'" @blur="numberInputBlur(item.key)"></input>
  103. </view>
  104. </view>
  105. </view>
  106. <!-- 关键词 -->
  107. <view v-if="item.type == 'keyWord'">
  108. <view class="drawer-list-title flex justify-between">
  109. <view>{{item.title}}</view>
  110. </view>
  111. <view class="dateContent text-content flex">
  112. <view class="text-input">
  113. <input class="m-input" type="text" clearable v-model="keyWord" :placeholder="'请输入'+item.title"
  114. @blur="keyWordInputBlur(item.key)"></input>
  115. </view>
  116. </view>
  117. </view>
  118. <!-- 按床号排序 -->
  119. <view v-if="item.type == 'bedNumSort'">
  120. <view class="drawer-list-title flex justify-between">
  121. <view>
  122. {{item.title}}
  123. </view>
  124. </view>
  125. <view class="dateContent sort-content flex">
  126. <checkbox-group @change="bedNumSortInputBlur">
  127. <checkbox value="bedNumSort" :checked="bedNumSort" color="#49b856" id="bedNumSort" /><label for="bedNumSort">按床号排序</label>
  128. </checkbox-group>
  129. </view>
  130. </view>
  131. <!-- 检查信息状态 -->
  132. <view v-if="item.type == 'inspectState'">
  133. <view class="drawer-list-title flex justify-between">
  134. <view>
  135. {{item.title}}
  136. </view>
  137. </view>
  138. <view class="dateContent inspectState-content flex">
  139. <!-- https://ext.dcloud.net.cn/plugin?id=1873#detail -->
  140. <ld-select :multiple="true" :list="inspectStateList" label-key="label" value-key="value" placeholder="请选择"
  141. v-model="result.inspectState" @change="inspectStateChange"></ld-select>
  142. </view>
  143. </view>
  144. <!-- 异常数据筛选 -->
  145. <view v-if="item.type == 'abnormal'">
  146. <view class="drawer-list-title flex justify-between">
  147. <view>
  148. {{item.title}}
  149. </view>
  150. </view>
  151. <view class="checkContent">
  152. <view class="">
  153. <checkbox-group @change="noneEndDeptInputBlur">
  154. <checkbox value="noneEndDept" :checked="noneEndDept" color="#49b856" id="noneEndDept" /><label for="noneEndDept">未标记检查科室</label>
  155. </checkbox-group>
  156. </view>
  157. <view class="">
  158. <checkbox-group @change="noneYytimeInputBlur">
  159. <checkbox value="noneYytime" :checked="noneYytime" color="#49b856" id="noneYytime" /><label for="noneYytime">无预约时间检查</label>
  160. </checkbox-group>
  161. </view>
  162. </view>
  163. </view>
  164. </block>
  165. <view class="foot_btn_spe">
  166. <view class="btn3" style="background-image: none;background-color: #AFAFAF;" @tap="closeDrawer">取消</view>
  167. <view class="btn1" @tap="sureClick">保存</view>
  168. </view>
  169. </scroll-view>
  170. </uni-drawer>
  171. <mx-date-picker :show="showPicker" :color="color" :type="dateType" :value="dateValue" :show-tips="true"
  172. :show-seconds="true" @confirm="onSelected" @cancel="onSelected" />
  173. </view>
  174. </template>
  175. <script>
  176. /***
  177. * 筛选组件,当前支持多选、单选
  178. * list、visibleDrawer(是否显示)参数必填
  179. * item.type (custom 单选、多选、rangetime 时间范围带时分秒、range 时间范围不带时分秒、rangenumber 数字范围)
  180. * item.isMutiple 是否支持多选
  181. * 筛选后返回格式{"listName1":[value,value](多选),"listName2":"value"(单选),...}
  182. * rangenumber形式-可能为["",1]或[1,""]表示只有一个最大值或最小值
  183. ***/
  184. import uniDrawer from "@/components/uni-drawer/uni-drawer.vue";
  185. import ldSelect from "@/components/ld-select/ld-select.vue";
  186. import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue";
  187. export default {
  188. props: {
  189. inspectStateList: {
  190. type: Array,
  191. default () {
  192. return [];
  193. },
  194. },
  195. keyWordGvie: {
  196. type: String,
  197. },
  198. keyWordOld: {
  199. type: String,
  200. },
  201. bedNumSortGvie: {
  202. type: Boolean,
  203. },
  204. noneEndDeptGvie: {
  205. type: Boolean,
  206. },
  207. noneYytimeGvie: {
  208. type: Boolean,
  209. },
  210. list: {
  211. required: true,
  212. type: Array,
  213. default () {
  214. return [];
  215. },
  216. },
  217. visibleDrawer: {
  218. required: true,
  219. type: Boolean,
  220. default: false,
  221. },
  222. color: {
  223. type: String,
  224. default: "#49b856",
  225. },
  226. },
  227. components: {
  228. uniDrawer,
  229. MxDatePicker,
  230. ldSelect,
  231. },
  232. created() {
  233. this.keyWord = this.keyWordGvie || '';
  234. this.bedNumSort = this.bedNumSortGvie;
  235. this.noneEndDept = this.noneEndDeptGvie;
  236. this.noneYytime = this.noneYytimeGvie;
  237. this.resetResult();
  238. uni.getSystemInfo({
  239. success: (res) => {
  240. this.drawerHeight = res.windowHeight - uni.upx2px(240) + "px";
  241. },
  242. });
  243. },
  244. computed: {
  245. defaultSelectedObj() {
  246. // 保存初始状态
  247. return this.getSelectedObj();
  248. },
  249. selectedObj: {
  250. get() {
  251. return this.getSelectedObj();
  252. },
  253. set(newObj) {
  254. return newObj;
  255. },
  256. },
  257. menuList() {
  258. return this.list;
  259. },
  260. },
  261. data() {
  262. return {
  263. menuKey: 1,
  264. showLenght: 6,
  265. drawerHeight: "500px",
  266. selectDetailList: [],
  267. result: {},
  268. showPicker: false,
  269. date: "",
  270. time: "",
  271. datetime: "",
  272. single: [new Date().Format("yyyy/MM/dd")],
  273. range: [
  274. new Date(new Date().getTime() - 24 * 60 * 60 * 1000).Format(
  275. "yyyy/MM/dd"
  276. ),
  277. new Date().Format("yyyy/MM/dd"),
  278. ],
  279. rangetime: [
  280. new Date(new Date().getTime() - 24 * 60 * 60 * 1000).Format(
  281. "yyyy/MM/dd hh:mm"
  282. ),
  283. new Date().Format("yyyy/MM/dd hh:mm"),
  284. ],
  285. dateType: "rangetime",
  286. dateValue: "",
  287. minNumber: "",
  288. maxNumber: "",
  289. keyWord: "",
  290. bedNumSort: false,
  291. noneEndDept: false,
  292. noneYytime: false,
  293. };
  294. },
  295. methods: {
  296. getSelectedObj() {
  297. return this.commonResultObj();
  298. },
  299. resetResult() {
  300. this.result = this.commonResultObj();
  301. },
  302. commonResultObj() {
  303. let obj = {};
  304. console.log(this.menuList)
  305. this.menuList.map((item) => {
  306. item.isMutiple ?
  307. (obj[item.key] = []) :
  308. item.type === "range" || item.type === "rangetime" ?
  309. (obj[item.key] = []) :
  310. item.type === "bedNumSort" ?
  311. (obj[item.key] = false) :
  312. item.type === "abnormal" ?
  313. (obj['noneEndDept'] = obj['noneYytime'] = false) :
  314. item.type === "inspectState" ?
  315. (obj[item.key] = ['1', '30']) :
  316. item.type === "single" ?
  317. (obj[item.key] = [new Date().Format("yyyy/MM/dd")]) :
  318. item.type === "keyWord" ?
  319. (obj[item.key] = this.keyWord ? [this.keyWord] : []) :
  320. (obj[item.key] = "");
  321. });
  322. return obj;
  323. },
  324. //筛选项选中或取消
  325. itemTap(index, list, key, isMutiple) {
  326. if (isMutiple == true) {
  327. list[index].isSelected = !list[index].isSelected;
  328. if (list[index].isSelected) {
  329. this.selectedObj[key].push(list[index].value);
  330. } else {
  331. list[index].isSelected = false;
  332. var idx = this.selectedObj[key].indexOf(list[index].value);
  333. this.selectedObj[key].splice(idx, 1);
  334. }
  335. this.result[key] = this.selectedObj[key];
  336. } else {
  337. this.result[key] = list[index].isSelected ? "" : list[index].value;
  338. for (let i = 0; i < list.length; i++) {
  339. if (index == i && !list[i].isSelected) {
  340. list[i].isSelected = true;
  341. } else {
  342. list[i].isSelected = false;
  343. }
  344. }
  345. }
  346. // #ifdef H5
  347. this.$forceUpdate();
  348. // #endif
  349. },
  350. sureClick() {
  351. let str_result = {};
  352. let hasChoose = false;
  353. for (let key in this.result) {
  354. if (typeof this.result[key] == "object") {
  355. str_result[key] = this.result[key].join(",");
  356. if (!hasChoose) {
  357. hasChoose = this.result[key].join(",") !== "" ? true : false;
  358. }
  359. } else {
  360. str_result[key] = this.result[key];
  361. if (!hasChoose) {
  362. hasChoose = this.result[key] !== "" ? true : false;
  363. }
  364. }
  365. }
  366. this.$emit("result", {
  367. str_result: str_result,
  368. result: this.result,
  369. hasChoose: hasChoose,
  370. visibleDrawer: false,
  371. });
  372. },
  373. resetClick() {
  374. console.log(this.result, this.keyWordOld);
  375. this.minNumber = "";
  376. this.maxNumber = "";
  377. this.keyWord = this.keyWordOld || '';
  378. this.bedNumSort = false;
  379. this.noneEndDept = false;
  380. this.noneYytime = false;
  381. this.single = [new Date().Format("yyyy/MM/dd")];
  382. for (let key in this.result) {
  383. if ((typeof this.result[key] == "object") && key != "inspectState") {
  384. if (key == "yyTime") {
  385. this.result[key] = [new Date().Format("yyyy/MM/dd")];
  386. } else if (key == "keyWord") {
  387. this.result[key] = this.keyWordOld ? [this.keyWordOld] : [];
  388. } else {
  389. this.result[key] = [];
  390. }
  391. } else {
  392. if (key == "bedNumSort") {
  393. this.result[key] = false;
  394. } else if (key == "abnormal") {
  395. this.result['noneEndDept'] = false;
  396. this.result['noneYytime'] = false;
  397. } else if (key == "inspectState") {
  398. this.result[key] = ['1', '30'];
  399. } else {
  400. this.result[key] = "";
  401. }
  402. }
  403. }
  404. for (let i = 0; i < this.menuList.length; i++) {
  405. if (this.menuList[i].type == "custom") {
  406. for (let j = 0; j < this.menuList[i].detailList.length; j++) {
  407. this.menuList[i].detailList[j].isSelected = false;
  408. }
  409. }
  410. }
  411. // #ifdef H5
  412. this.$forceUpdate();
  413. // #endif
  414. },
  415. closeDrawer() {
  416. this.$emit("result", {
  417. changeStatus: true,
  418. visibleDrawer: false,
  419. });
  420. },
  421. showMore(index) {
  422. this.menuList[index].showMoreList = !this.menuList[index].showMoreList;
  423. ++this.menuKey;
  424. // #ifdef H5
  425. this.$forceUpdate();
  426. // #endif
  427. },
  428. onShowDatePicker(type, key) {
  429. //显示
  430. this.dateType = type;
  431. this.dateValue = this[type];
  432. this.showPicker = true;
  433. this.tempKey = key;
  434. },
  435. onSelected(e, key) {
  436. //选择
  437. this.showPicker = false;
  438. if (e) {
  439. this[this.dateType] = e.value;
  440. this.result[this.tempKey] = e.value;
  441. //选择的值
  442. console.log("value => " + e.value);
  443. //原始的Date对象
  444. console.log("date => " + e.date);
  445. }
  446. },
  447. numberInputBlur(key) {
  448. if (
  449. this.minNumber != "" &&
  450. this.maxNumber != "" &&
  451. parseFloat(this.minNumber) > parseFloat(this.maxNumber)
  452. ) {
  453. let temp = this.minNumber;
  454. this.minNumber = this.maxNumber;
  455. this.maxNumber = temp;
  456. }
  457. this.result[key] = [];
  458. this.result[key].push(this.minNumber && parseFloat(this.minNumber));
  459. this.result[key].push(this.maxNumber && parseFloat(this.maxNumber));
  460. },
  461. keyWordInputBlur(key) {
  462. this.result[key] = [];
  463. this.result[key].push(this.keyWord);
  464. },
  465. bedNumSortInputBlur(e) {
  466. this.result.bedNumSort = e.detail.value.length > 0;
  467. this.bedNumSort = e.detail.value.length > 0;
  468. },
  469. noneEndDeptInputBlur(e) {
  470. this.result.noneEndDept = e.detail.value.length > 0;
  471. this.noneEndDept = e.detail.value.length > 0;
  472. },
  473. noneYytimeInputBlur(e) {
  474. this.result.noneYytime = e.detail.value.length > 0;
  475. this.noneYytime = e.detail.value.length > 0;
  476. },
  477. inspectStateChange(val) {
  478. this.result.inspectState = val;
  479. },
  480. },
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .foot_btn_spe {
  485. line-height: 88rpx;
  486. height: 100rpx;
  487. margin-top: 40rpx;
  488. text-align: center;
  489. display: flex;
  490. justify-content: space-between;
  491. flex-wrap: wrap;
  492. &::after {
  493. content: '';
  494. flex: 1;
  495. }
  496. view {
  497. height: 88rpx;
  498. width: 48%;
  499. margin: 0 1%;
  500. background-image: linear-gradient(to right, #72c172, #3bb197);
  501. color: #fff;
  502. border-radius: 8rpx;
  503. font-size: 32rpx;
  504. margin-top: 16rpx;
  505. }
  506. }
  507. .flex {
  508. display: flex;
  509. }
  510. .justify-between {
  511. justify-content: space-between;
  512. }
  513. view,
  514. scroll-view,
  515. swiper,
  516. button,
  517. input,
  518. textarea,
  519. label,
  520. navigator,
  521. image {
  522. box-sizing: border-box;
  523. }
  524. /* 筛选样式 */
  525. .drawer-list {
  526. padding: 0 20rpx;
  527. font-size: 26rpx;
  528. }
  529. input {
  530. font-size: 26rpx;
  531. }
  532. .drawer-list .drawer-list-title {
  533. font-size: 34rpx;
  534. font-weight: 400;
  535. line-height: 48rpx;
  536. padding: 38rpx 0 18rpx;
  537. color: rgba(34, 34, 34, 1);
  538. }
  539. .drawer-list .drawer-list-title>text {
  540. font-size: 26rpx;
  541. color: #666666;
  542. }
  543. .drawer-list .draer-list-con>text {
  544. background: rgba(93, 92, 254, 0.1);
  545. border-radius: 28px;
  546. color: #666666;
  547. font-size: 28rpx;
  548. padding: 10rpx 28rpx;
  549. margin: 10rpx 10rpx 10rpx 0;
  550. display: inline-block;
  551. }
  552. .filter-content-footer-item {
  553. width: 160rpx;
  554. height: 72rpx;
  555. line-height: 72rpx;
  556. text-align: center;
  557. box-shadow: 0rpx 4rpx 16rpx rgba(0, 0, 0, 0.18);
  558. border-radius: 12rpx;
  559. margin: 24rpx;
  560. }
  561. .filter-content-footer-item:first-child {
  562. color: #49b856;
  563. }
  564. .picker {
  565. z-index: 99999 !important;
  566. }
  567. .dateContent {
  568. &>view {
  569. border: 2rpx solid #ECECEC;
  570. border-radius: 8rpx;
  571. width: 100%;
  572. height: 64rpx;
  573. line-height: 64rpx;
  574. margin-bottom: 12rpx;
  575. }
  576. }
  577. .checkContent {
  578. &>view {
  579. font-size: 15px !important;
  580. border-radius: 8rpx;
  581. width: 100%;
  582. height: 64rpx;
  583. line-height: 64rpx;
  584. margin-bottom: 12rpx;
  585. }
  586. }
  587. .rangenumber-content {
  588. &>text {
  589. display: inline-block;
  590. width: 10%;
  591. text-align: center;
  592. height: 64rpx;
  593. line-height: 64rpx;
  594. }
  595. .rangenumber-input {
  596. width: 45%;
  597. display: inline-block;
  598. padding: 0 12rpx;
  599. .m-input {
  600. height: 64rpx;
  601. line-height: 64rpx;
  602. }
  603. }
  604. }
  605. .text-content {
  606. &>text {
  607. display: inline-block;
  608. width: 10%;
  609. text-align: center;
  610. height: 64rpx;
  611. line-height: 64rpx;
  612. }
  613. .text-input {
  614. width: 100%;
  615. display: inline-block;
  616. padding: 0 12rpx;
  617. .m-input {
  618. height: 64rpx;
  619. line-height: 64rpx;
  620. }
  621. }
  622. }
  623. .sort-content {
  624. font-size: 15px !important;
  625. display: flex;
  626. align-items: center;
  627. /deep/ uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  628. border-color: #49b856 !important;
  629. }
  630. }
  631. .inspectState-content {
  632. border-radius: 4px;
  633. width: 100%;
  634. height: 32px;
  635. line-height: 32px;
  636. margin-bottom: 6px;
  637. uni-picker {
  638. width: 100%;
  639. }
  640. .uni-input {
  641. padding-left: 16rpx;
  642. }
  643. }
  644. /deep/.picker {
  645. z-index: 999;
  646. }
  647. </style>