index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <div class="instr-container">
  3. <div class="search-wrap">
  4. <div class="search-item">
  5. <div class="input-item">
  6. <el-input
  7. class="mr20"
  8. v-model="searchForm.searchText"
  9. placeholder="请输入仪器名称"
  10. clearable
  11. style="height: 48px"
  12. />
  13. <el-button type="primary" style="width: 90px" @click="globalSearch">
  14. 搜索
  15. </el-button>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="common-container">
  20. <section class="section-container">
  21. <div class="filter-wrap">
  22. <div class="filter-item dept-wrap">
  23. <!-- 实验室管理的实验室 -->
  24. <div class="left-tit">所属平台</div>
  25. <div class="right-filter-content">
  26. <div
  27. class="more-item"
  28. @click="handleExpandFilter('plat')"
  29. v-if="laboratoryNameOptions.length > 8"
  30. >
  31. <span>{{ platFilterExpand ? "收起" : "更多" }}</span>
  32. <i v-if="!platFilterExpand" class="el-icon-caret-top"></i>
  33. <i v-else class="el-icon-caret-bottom"></i>
  34. </div>
  35. <div class="list">
  36. <div
  37. @click="selectFilterItem(v.name, 'laboratoryName')"
  38. class="name"
  39. :class="{ avtive: searchForm.laboratoryName == v.name }"
  40. v-for="(v, i) in laboratoryNameOptions"
  41. v-show="!platFilterExpand ? i < 8 : i > -1"
  42. :key="i"
  43. >
  44. {{ `${v.name}(${v.count}台)` }}
  45. </div>
  46. <!-- <div class="dragger-container" v-if="platFilterExpand">
  47. <div class="dragger-bar"></div>
  48. </div> -->
  49. </div>
  50. </div>
  51. </div>
  52. <div class="filter-item address">
  53. <!-- 仪器类别 -->
  54. <div class="left-tit">仪器类别</div>
  55. <div class="right-filter-content">
  56. <div
  57. class="more-item"
  58. @click="handleExpandFilter('instrType')"
  59. v-if="instClassDescOptions.length > 8"
  60. >
  61. <span>{{ instrTypeFilterExpand ? "收起" : "更多" }}</span>
  62. <i v-if="!instrTypeFilterExpand" class="el-icon-caret-top"></i>
  63. <i v-else class="el-icon-caret-bottom"></i>
  64. </div>
  65. <div class="list">
  66. <div
  67. @click="selectFilterItem(v.name, 'instClassDesc')"
  68. class="name"
  69. :class="{ avtive: searchForm.instClassDesc == v.name }"
  70. v-for="(v, i) in instClassDescOptions"
  71. v-show="!instrTypeFilterExpand ? i < 8 : i > -1"
  72. :key="i"
  73. >
  74. {{ `${v.name}(${v.count}台)` }}
  75. </div>
  76. <!-- <div class="dragger-container" v-if="instrTypeFilterExpand">
  77. <div class="dragger-bar"></div>
  78. </div> -->
  79. </div>
  80. </div>
  81. </div>
  82. <div class="filter-item type">
  83. <!-- 从前两个查询条件查询 -->
  84. <div class="left-tit">仪器型号</div>
  85. <div class="right-filter-content">
  86. <div class="list">
  87. <div
  88. @click="selectFilterItem(v.name, 'instNameEn')"
  89. class="name"
  90. :class="{ avtive: searchForm.instNameEn == v.name }"
  91. v-for="(v, i) in instNameEnOptions"
  92. v-show="!instrTypeFilterExpand ? i < 8 : i > -1"
  93. :key="i"
  94. >
  95. {{ `${v.name}(${v.count}台)` }}
  96. </div>
  97. <!-- <div class="dragger-container" v-if="instrTypeFilterExpand">
  98. <div class="dragger-bar"></div>
  99. </div> -->
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="instr-list">
  105. <div class="filter-result">
  106. <h4 class="title">已选条件</h4>
  107. <div class="filter-wrap">
  108. <el-tag
  109. v-if="searchForm.laboratoryName"
  110. type="primary"
  111. size="normal"
  112. closable
  113. @close="closeTag('laboratoryName')"
  114. class="mr20"
  115. >
  116. {{ searchForm.laboratoryName }}
  117. </el-tag>
  118. <el-tag
  119. v-if="searchForm.instClassDesc"
  120. type="success"
  121. size="normal"
  122. closable
  123. @close="closeTag('instClassDesc')"
  124. class="mr20"
  125. >
  126. {{ searchForm.instClassDesc }}
  127. </el-tag>
  128. <el-tag
  129. v-if="searchForm.instNameEn"
  130. type="warning"
  131. size="normal"
  132. closable
  133. @close="closeTag('instNameEn')"
  134. >
  135. {{ searchForm.instNameEn }}
  136. </el-tag>
  137. </div>
  138. </div>
  139. <el-empty
  140. v-if="instrDataList.length == 0"
  141. description="很抱歉,没有找到相关的仪器~"
  142. ></el-empty>
  143. <div v-else>
  144. <div class="instr-item" v-for="v in instrDataList" :key="v.id">
  145. <div class="img-item">
  146. <img :src="v.instPicture" style="width: 100%" alt="" />
  147. </div>
  148. <div class="text-item">
  149. <p class="name">{{ v.instName }}</p>
  150. <div class="info">
  151. <div class="info-title">型号</div>
  152. <div class="info-txt">{{ v.instNameEn }}</div>
  153. </div>
  154. <div class="info">
  155. <div class="info-title">状态</div>
  156. <div class="info-txt">
  157. <span v-if="v.instStatus == '10'">正常</span>
  158. <span v-if="v.instStatus == '20'">故障</span>
  159. <span v-if="v.instStatus == '30'">报废</span>
  160. </div>
  161. </div>
  162. <div class="info">
  163. <div class="info-title">仪器负责人</div>
  164. <div class="info-txt">{{ v.instHeadName }}</div>
  165. </div>
  166. <div class="info">
  167. <div class="info-title">放置地点</div>
  168. <div class="info-txt">
  169. <span :title="v.placeAddress">
  170. {{ v.placeAddress || "-" }}
  171. <span v-if="v.laboratoryName">
  172. ({{ v.laboratoryName }})
  173. </span>
  174. </span>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="appoint-item">
  179. <div class="mb20">
  180. <el-button
  181. type="primary"
  182. size="default"
  183. v-if="v.instStatus == '10' && v.isAppointment == '10'"
  184. @click="handleAppoint(v)"
  185. >
  186. 使用预约
  187. </el-button>
  188. </div>
  189. <div>
  190. <el-button
  191. type="primary"
  192. plain
  193. size="default"
  194. @click="linkToDetails(v)"
  195. >
  196. 查看详情
  197. </el-button>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="pagination">
  203. <el-pagination
  204. background
  205. @size-change="handleSizeChange"
  206. @current-change="handleCurrentChange"
  207. :current-page="searchForm.pageNum"
  208. :page-sizes="[10, 50, 100]"
  209. :page-size="searchForm.pageSize"
  210. layout="total, sizes, prev, pager, next, jumper"
  211. :total="total"
  212. ></el-pagination>
  213. </div>
  214. </div>
  215. </section>
  216. </div>
  217. <appoint ref="appointRef"></appoint>
  218. </div>
  219. </template>
  220. <script>
  221. import to from "await-to-js";
  222. import { getToken } from "@/utils/auth";
  223. import { Loading } from "element-ui";
  224. import { getInstrList, getInstNameEnCount } from "@/api/instr/index";
  225. import appoint from "./components/appoint.vue";
  226. export default {
  227. name: "equipment",
  228. components: { appoint },
  229. data() {
  230. return {
  231. platFilterExpand: false,
  232. instrTypeFilterExpand: false,
  233. searchForm: {
  234. searchText: "",
  235. laboratoryName: "",
  236. instClassDesc: "",
  237. instNameEn: "",
  238. pageNum: 1,
  239. pageSize: 10,
  240. },
  241. total: 0,
  242. instrDataList: [],
  243. laboratoryNameOptions: [],
  244. instClassDescOptions: [],
  245. instNameEnOptions: [],
  246. options: {
  247. text: "正在加载中,请稍后...",
  248. background: "rgba(0, 0, 0, 0.6)",
  249. },
  250. };
  251. },
  252. created() {},
  253. mounted() {
  254. this.getInstrData();
  255. },
  256. methods: {
  257. handleAppoint(row) {
  258. const token = getToken();
  259. if (!token) {
  260. return this.$router.push("/login");
  261. }
  262. this.$refs.appointRef.openDialog(row);
  263. },
  264. // 获取型号数量
  265. async getInstNameEnCountData() {
  266. const params = {
  267. instClassDesc: this.searchForm.instClassDesc,
  268. laboratoryName: this.searchForm.laboratoryName,
  269. searchText: this.searchForm.searchText,
  270. };
  271. const [err, res] = await to(getInstNameEnCount(params));
  272. if (err) return;
  273. if (res.code == 200) {
  274. this.instNameEnOptions = res.data;
  275. }
  276. },
  277. // 上方搜索查询
  278. async globalSearch() {
  279. this.searchForm.pageNum = 1;
  280. this.searchForm.instClassDesc = "";
  281. this.searchForm.laboratoryName = "";
  282. this.searchForm.instNameEn = "";
  283. this.getInstrData();
  284. },
  285. async getInstrData() {
  286. Loading.service(this.loadingOption);
  287. const [err, res] = await to(getInstrList(this.searchForm));
  288. if (err) return;
  289. if (res.code == 200) {
  290. this.instrDataList = res.data.list;
  291. this.total = res.data.total;
  292. this.laboratoryNameOptions = this.objTransforArr(
  293. res.data.count.laboratoryName
  294. );
  295. this.instClassDescOptions = this.objTransforArr(
  296. res.data.count.instClassDesc
  297. );
  298. this.getInstNameEnCountData();
  299. }
  300. setTimeout(() => {
  301. Loading.service(this.loadingOption).close();
  302. });
  303. },
  304. // 对象转数组
  305. objTransforArr(obj) {
  306. const arr = Object.entries(obj).map(([key, value]) => ({
  307. name: key,
  308. count: value,
  309. }));
  310. return arr;
  311. },
  312. // 删除查询条件
  313. closeTag(type) {
  314. switch (type) {
  315. case "laboratoryName":
  316. this.searchForm.laboratoryName = "";
  317. break;
  318. case "instClassDesc":
  319. this.searchForm.instClassDesc = "";
  320. break;
  321. case "instNameEn":
  322. this.searchForm.instNameEn = "";
  323. break;
  324. }
  325. this.searchForm.pageNum = 1;
  326. this.getInstrData();
  327. },
  328. // 展开 合并
  329. handleExpandFilter(type = "plat" | "instrType") {
  330. if (type === "plat") {
  331. this.platFilterExpand = !this.platFilterExpand;
  332. } else if (type === "instrType") {
  333. this.instrTypeFilterExpand = !this.instrTypeFilterExpand;
  334. }
  335. },
  336. // 选择查询条件
  337. selectFilterItem(name, val) {
  338. switch (val) {
  339. case "laboratoryName":
  340. if (this.searchForm.laboratoryName != name) {
  341. this.searchForm.laboratoryName = name;
  342. this.searchForm.pageNum = 1;
  343. this.getInstrData();
  344. }
  345. break;
  346. case "instClassDesc":
  347. if (this.searchForm.instClassDesc != name) {
  348. this.searchForm.instClassDesc = name;
  349. this.searchForm.pageNum = 1;
  350. this.getInstrData();
  351. }
  352. break;
  353. case "instNameEn":
  354. if (this.searchForm.instNameEn != name) {
  355. this.searchForm.instNameEn = name;
  356. this.searchForm.pageNum = 1;
  357. this.getInstrData();
  358. }
  359. break;
  360. }
  361. },
  362. handleSizeChange(val) {
  363. this.searchForm.pageSize = val;
  364. this.getInstrData();
  365. },
  366. handleCurrentChange(val) {
  367. this.searchForm.pageNum = val;
  368. this.getInstrData();
  369. },
  370. linkToDetails(v) {
  371. this.$router.push("/appointment/equipment-details?id=" + v.id);
  372. },
  373. },
  374. };
  375. </script>
  376. <style lang="scss" scoped>
  377. .search-wrap {
  378. width: 100%;
  379. height: 240px;
  380. position: relative;
  381. &::after {
  382. display: block;
  383. content: "";
  384. width: 100%;
  385. height: 100%;
  386. position: absolute;
  387. top: 0;
  388. left: 0;
  389. background: url("../../assets/img/equipment-banner.png") center;
  390. }
  391. .search-item {
  392. width: 800px;
  393. height: 240px;
  394. margin: 0 auto;
  395. position: relative;
  396. z-index: 1;
  397. display: flex;
  398. align-items: center;
  399. justify-content: center;
  400. .input-item {
  401. width: 100%;
  402. height: 40px;
  403. display: flex;
  404. }
  405. }
  406. }
  407. .section-container {
  408. width: 1200px;
  409. margin: 0 auto;
  410. }
  411. .filter-wrap {
  412. width: 100%;
  413. .filter-item {
  414. width: 100%;
  415. min-height: 48px;
  416. display: flex;
  417. border-bottom: 2px dashed rgba(112, 112, 112, 0.18);
  418. &:last-child {
  419. border-bottom: none;
  420. }
  421. }
  422. .left-tit {
  423. width: 120px;
  424. background: #f1f1f1;
  425. display: flex;
  426. align-items: center;
  427. justify-content: center;
  428. font-weight: bold;
  429. }
  430. .right-filter-content {
  431. flex: 1;
  432. padding: 9px 24px 9px 36px;
  433. display: flex;
  434. flex-wrap: wrap;
  435. position: relative;
  436. .list {
  437. max-height: 120px;
  438. overflow: auto;
  439. width: 100%;
  440. display: flex;
  441. flex-wrap: wrap;
  442. // &::-webkit-scrollbar {
  443. // display: none;
  444. // }
  445. .dragger-container {
  446. position: absolute;
  447. width: 6px;
  448. top: 36px;
  449. right: 34px;
  450. height: 84px;
  451. background: #ccc;
  452. border-radius: 20px;
  453. .dragger-bar {
  454. position: absolute;
  455. width: 6px;
  456. height: 60px;
  457. top: 0px;
  458. border-radius: 20px;
  459. background: rgba(0, 0, 0, 0.75);
  460. }
  461. }
  462. }
  463. .name {
  464. font-size: 14px;
  465. margin: 5px 30px 5px 0;
  466. cursor: pointer;
  467. &:hover {
  468. text-decoration: underline;
  469. color: #1677ff;
  470. }
  471. &.avtive {
  472. text-decoration: underline;
  473. color: #1677ff;
  474. }
  475. }
  476. .more-item {
  477. position: absolute;
  478. top: 12px;
  479. right: 0;
  480. padding-right: 16px;
  481. font-size: 14px;
  482. cursor: pointer;
  483. z-index: 2;
  484. i {
  485. color: #b1b1b1;
  486. }
  487. }
  488. }
  489. }
  490. .filter-result {
  491. padding: 15px 18px 0 18px;
  492. display: flex;
  493. border: 1px solid rgba(112, 112, 112, 0.06);
  494. position: relative;
  495. .title {
  496. width: 120px;
  497. font-size: 16px;
  498. color: #666;
  499. font-weight: 700;
  500. padding-right: 18px;
  501. padding-top: 3px;
  502. flex: 0 0 120px;
  503. }
  504. .filter-wrap {
  505. min-height: 45px;
  506. padding-right: 80px;
  507. }
  508. }
  509. .instr-list {
  510. background: #fff;
  511. border-radius: 6px;
  512. margin-top: 20px;
  513. min-height: 200px;
  514. .instr-item {
  515. padding: 24px 30px;
  516. margin: 0 30px;
  517. display: flex;
  518. border-bottom: 1px solid rgba(112, 112, 112, 0.06);
  519. .img-item {
  520. width: 180px;
  521. height: 180px;
  522. border-radius: 6px;
  523. overflow: hidden;
  524. margin-right: 18px;
  525. position: relative;
  526. background: #f3f6fb;
  527. }
  528. .text-item {
  529. flex: 1;
  530. width: 0;
  531. font-size: 14px;
  532. padding-top: 6px;
  533. .name {
  534. font-weight: bold;
  535. font-size: 20px;
  536. margin-bottom: 12px;
  537. }
  538. .info {
  539. color: #666;
  540. display: flex;
  541. font-size: 14px;
  542. margin-bottom: 8px;
  543. .info-title {
  544. width: 80px;
  545. }
  546. .info-txt {
  547. width: 0;
  548. flex: 1;
  549. }
  550. }
  551. }
  552. .appoint-item {
  553. width: 120px;
  554. padding: 0 0 0 18px;
  555. display: flex;
  556. flex-direction: column;
  557. align-items: center;
  558. justify-content: center;
  559. }
  560. }
  561. }
  562. .pagination {
  563. width: 100%;
  564. height: 50px;
  565. display: flex;
  566. align-items: center;
  567. justify-content: center;
  568. }
  569. div {
  570. color: #333;
  571. }
  572. </style>