index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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 { Loading } from "element-ui";
  223. import { getInstrList, getInstNameEnCount } from "@/api/instr/index";
  224. import appoint from "./components/appoint.vue";
  225. export default {
  226. name: "equipment",
  227. components: { appoint },
  228. data() {
  229. return {
  230. platFilterExpand: false,
  231. instrTypeFilterExpand: false,
  232. searchForm: {
  233. searchText: "",
  234. laboratoryName: "",
  235. instClassDesc: "",
  236. instNameEn: "",
  237. pageNum: 1,
  238. pageSize: 10,
  239. },
  240. total: 0,
  241. instrDataList: [],
  242. laboratoryNameOptions: [],
  243. instClassDescOptions: [],
  244. instNameEnOptions: [],
  245. options: {
  246. text: "正在加载中,请稍后...",
  247. background: "rgba(0, 0, 0, 0.6)",
  248. },
  249. };
  250. },
  251. created() {},
  252. mounted() {
  253. this.getInstrData();
  254. },
  255. methods: {
  256. handleAppoint(row) {
  257. this.$refs.appointRef.openDialog(row);
  258. },
  259. // 获取型号数量
  260. async getInstNameEnCountData() {
  261. const params = {
  262. instClassDesc: this.searchForm.instClassDesc,
  263. laboratoryName: this.searchForm.laboratoryName,
  264. searchText: this.searchForm.searchText,
  265. };
  266. const [err, res] = await to(getInstNameEnCount(params));
  267. if (err) return;
  268. if (res.code == 200) {
  269. this.instNameEnOptions = res.data;
  270. }
  271. },
  272. // 上方搜索查询
  273. async globalSearch() {
  274. this.searchForm.pageNum = 1;
  275. this.searchForm.instClassDesc = "";
  276. this.searchForm.laboratoryName = "";
  277. this.searchForm.instNameEn = "";
  278. this.getInstrData();
  279. },
  280. async getInstrData() {
  281. Loading.service(this.loadingOption);
  282. const [err, res] = await to(getInstrList(this.searchForm));
  283. if (err) return;
  284. if (res.code == 200) {
  285. this.instrDataList = res.data.list;
  286. this.total = res.data.total;
  287. this.laboratoryNameOptions = this.objTransforArr(
  288. res.data.count.laboratoryName
  289. );
  290. this.instClassDescOptions = this.objTransforArr(
  291. res.data.count.instClassDesc
  292. );
  293. this.getInstNameEnCountData();
  294. }
  295. setTimeout(() => {
  296. Loading.service(this.loadingOption).close();
  297. });
  298. },
  299. // 对象转数组
  300. objTransforArr(obj) {
  301. const arr = Object.entries(obj).map(([key, value]) => ({
  302. name: key,
  303. count: value,
  304. }));
  305. return arr;
  306. },
  307. // 删除查询条件
  308. closeTag(type) {
  309. switch (type) {
  310. case "laboratoryName":
  311. this.searchForm.laboratoryName = "";
  312. break;
  313. case "instClassDesc":
  314. this.searchForm.instClassDesc = "";
  315. break;
  316. case "instNameEn":
  317. this.searchForm.instNameEn = "";
  318. break;
  319. }
  320. this.searchForm.pageNum = 1;
  321. this.getInstrData();
  322. },
  323. // 展开 合并
  324. handleExpandFilter(type = "plat" | "instrType") {
  325. if (type === "plat") {
  326. this.platFilterExpand = !this.platFilterExpand;
  327. } else if (type === "instrType") {
  328. this.instrTypeFilterExpand = !this.instrTypeFilterExpand;
  329. }
  330. },
  331. // 选择查询条件
  332. selectFilterItem(name, val) {
  333. switch (val) {
  334. case "laboratoryName":
  335. if (this.searchForm.laboratoryName != name) {
  336. this.searchForm.laboratoryName = name;
  337. this.searchForm.pageNum = 1;
  338. this.getInstrData();
  339. }
  340. break;
  341. case "instClassDesc":
  342. if (this.searchForm.instClassDesc != name) {
  343. this.searchForm.instClassDesc = name;
  344. this.searchForm.pageNum = 1;
  345. this.getInstrData();
  346. }
  347. break;
  348. case "instNameEn":
  349. if (this.searchForm.instNameEn != name) {
  350. this.searchForm.instNameEn = name;
  351. this.searchForm.pageNum = 1;
  352. this.getInstrData();
  353. }
  354. break;
  355. }
  356. },
  357. handleSizeChange(val) {
  358. this.searchForm.pageSize = val;
  359. this.getInstrData();
  360. },
  361. handleCurrentChange(val) {
  362. this.searchForm.pageNum = val;
  363. this.getInstrData();
  364. },
  365. linkToDetails(v) {
  366. this.$router.push("/appointment/equipment-details?id=" + v.id);
  367. },
  368. },
  369. };
  370. </script>
  371. <style lang="scss" scoped>
  372. .search-wrap {
  373. width: 100%;
  374. height: 240px;
  375. position: relative;
  376. &::after {
  377. display: block;
  378. content: "";
  379. width: 100%;
  380. height: 100%;
  381. position: absolute;
  382. top: 0;
  383. left: 0;
  384. background: url("../../assets/img/equipment-banner.png") center;
  385. }
  386. .search-item {
  387. width: 800px;
  388. height: 240px;
  389. margin: 0 auto;
  390. position: relative;
  391. z-index: 1;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. .input-item {
  396. width: 100%;
  397. height: 40px;
  398. display: flex;
  399. }
  400. }
  401. }
  402. .section-container {
  403. width: 1200px;
  404. margin: 0 auto;
  405. }
  406. .filter-wrap {
  407. width: 100%;
  408. .filter-item {
  409. width: 100%;
  410. min-height: 48px;
  411. display: flex;
  412. border-bottom: 2px dashed rgba(112, 112, 112, 0.18);
  413. &:last-child {
  414. border-bottom: none;
  415. }
  416. }
  417. .left-tit {
  418. width: 120px;
  419. background: #f1f1f1;
  420. display: flex;
  421. align-items: center;
  422. justify-content: center;
  423. font-weight: bold;
  424. }
  425. .right-filter-content {
  426. flex: 1;
  427. padding: 9px 24px 9px 36px;
  428. display: flex;
  429. flex-wrap: wrap;
  430. position: relative;
  431. .list {
  432. max-height: 120px;
  433. overflow: auto;
  434. width: 100%;
  435. display: flex;
  436. flex-wrap: wrap;
  437. // &::-webkit-scrollbar {
  438. // display: none;
  439. // }
  440. .dragger-container {
  441. position: absolute;
  442. width: 6px;
  443. top: 36px;
  444. right: 34px;
  445. height: 84px;
  446. background: #ccc;
  447. border-radius: 20px;
  448. .dragger-bar {
  449. position: absolute;
  450. width: 6px;
  451. height: 60px;
  452. top: 0px;
  453. border-radius: 20px;
  454. background: rgba(0, 0, 0, 0.75);
  455. }
  456. }
  457. }
  458. .name {
  459. font-size: 14px;
  460. margin: 5px 30px 5px 0;
  461. cursor: pointer;
  462. &:hover {
  463. text-decoration: underline;
  464. color: #1677ff;
  465. }
  466. &.avtive {
  467. text-decoration: underline;
  468. color: #1677ff;
  469. }
  470. }
  471. .more-item {
  472. position: absolute;
  473. top: 12px;
  474. right: 0;
  475. padding-right: 16px;
  476. font-size: 14px;
  477. cursor: pointer;
  478. z-index: 2;
  479. i {
  480. color: #b1b1b1;
  481. }
  482. }
  483. }
  484. }
  485. .filter-result {
  486. padding: 15px 18px 0 18px;
  487. display: flex;
  488. border: 1px solid rgba(112, 112, 112, 0.06);
  489. position: relative;
  490. .title {
  491. width: 120px;
  492. font-size: 16px;
  493. color: #666;
  494. font-weight: 700;
  495. padding-right: 18px;
  496. padding-top: 3px;
  497. flex: 0 0 120px;
  498. }
  499. .filter-wrap {
  500. min-height: 45px;
  501. padding-right: 80px;
  502. }
  503. }
  504. .instr-list {
  505. background: #fff;
  506. border-radius: 6px;
  507. margin-top: 20px;
  508. min-height: 200px;
  509. .instr-item {
  510. padding: 24px 30px;
  511. margin: 0 30px;
  512. display: flex;
  513. .img-item {
  514. width: 180px;
  515. height: 180px;
  516. border-radius: 6px;
  517. overflow: hidden;
  518. margin-right: 18px;
  519. position: relative;
  520. background: #f3f6fb;
  521. }
  522. .text-item {
  523. flex: 1;
  524. width: 0;
  525. font-size: 14px;
  526. padding-top: 6px;
  527. .name {
  528. font-weight: bold;
  529. font-size: 20px;
  530. margin-bottom: 12px;
  531. }
  532. .info {
  533. color: #666;
  534. display: flex;
  535. font-size: 14px;
  536. margin-bottom: 8px;
  537. .info-title {
  538. width: 80px;
  539. }
  540. .info-txt {
  541. width: 0;
  542. flex: 1;
  543. }
  544. }
  545. }
  546. .appoint-item {
  547. width: 120px;
  548. padding: 0 0 0 18px;
  549. display: flex;
  550. flex-direction: column;
  551. align-items: center;
  552. justify-content: center;
  553. }
  554. }
  555. }
  556. .pagination {
  557. width: 100%;
  558. height: 50px;
  559. display: flex;
  560. align-items: center;
  561. justify-content: center;
  562. }
  563. div {
  564. color: #333;
  565. }
  566. </style>