Tcm.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div class="tcm">
  3. <!-- 顶部筛选 -->
  4. <div class="screening flex-plane-start-b flex-wrap">
  5. <div class="screening-form flex-vertical-center-l flex-wrap">
  6. <div class="screening-item flex-vertical-center-l">
  7. <span>中药名称:</span>
  8. <div class="input">
  9. <el-input size="mini" v-model="form.name" placeholder="请输入"></el-input>
  10. </div>
  11. </div>
  12. <div class="screening-item flex-vertical-center-l">
  13. <span>功效:</span>
  14. <div class="input">
  15. <el-input size="mini" v-model="form.gongxiao" placeholder="请输入"></el-input>
  16. </div>
  17. </div>
  18. <div class="screening-item flex-vertical-center-l">
  19. <span>分类:</span>
  20. <div class="input">
  21. <el-select size="mini" v-model="form.other" placeholder="请选择">
  22. <el-option
  23. :label="item.name"
  24. :value="item.effectid"
  25. v-for="(item,index) in classify"
  26. :key="index"
  27. ></el-option>
  28. </el-select>
  29. </div>
  30. </div>
  31. <el-button size="mini" type="primary" @click="search">搜索</el-button>
  32. <el-button size="mini" type="warning" @click="clearFilter">清空</el-button>
  33. </div>
  34. <!-- <div class="total">
  35. 中药共 <span>123</span>味
  36. </div>-->
  37. </div>
  38. <!-- -->
  39. <div class="body flex-wrap flex-vertical-center-l">
  40. <div v-for="(item,index) in tcmList" :key="index">
  41. <div class="item" v-if="item.medList.length>0">
  42. <div class="title">{{item.name}}</div>
  43. <div class="banner-body flex-vertical-around">
  44. <div class="left-btn flex-center" @click="lastPage(index)">
  45. <img src="../../assets/green-left.png" alt />
  46. </div>
  47. <div class="center">
  48. <!-- <el-carousel indicator-position="none" arrow='never' :autoplay='false' height='160px'>
  49. <el-carousel-item v-for="item1 in medList" :key="item1.matid">-->
  50. <ul class="flex-vertical-center-l flex-wrap">
  51. <li class="flex-vertical-center-l" v-for="item1 in item.medList" :key="item1.matid">
  52. <span></span>
  53. <div
  54. @click="$router.push({path:'/index/tcmd?matid='+item1.matid})"
  55. >{{item1.matname}}</div>
  56. </li>
  57. </ul>
  58. <!-- </el-carousel-item>
  59. </el-carousel>-->
  60. </div>
  61. <div class="left-btn flex-center" @click="nextPage(index)">
  62. <img src="../../assets/green-right.png" alt />
  63. </div>
  64. </div>
  65. <div class="findMore" @click="findMore(item)">查看更多</div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import { getEffectQuery, getMedList } from "@/api/knowledge.js";
  73. export default {
  74. data() {
  75. return {
  76. form: {
  77. name: "",
  78. other: "",
  79. gongxiao: ""
  80. },
  81. classify: [],
  82. tcmList: []
  83. };
  84. },
  85. created() {
  86. this.getEffectQuery(1);
  87. this.getEffectQuery(2);
  88. },
  89. methods: {
  90. findMore(item) {
  91. this.$router.push({
  92. path: "/index/tcmmore?fname=" + item.name + "&fid=" + item.effectid
  93. });
  94. },
  95. search() {
  96. // if (this.form.other == '') {
  97. // this.$message({
  98. // type: 'error',
  99. // showClose: true,
  100. // message: '请先选择分类'
  101. // })
  102. // return
  103. // }
  104. this.tcmList = [];
  105. this.getEffectQuery(2);
  106. },
  107. clearFilter() {
  108. this.form = {
  109. name: "",
  110. other: "",
  111. gongxiao: ""
  112. };
  113. this.getEffectQuery(2);
  114. },
  115. // 下一页
  116. nextPage(index) {
  117. let effectid = this.tcmList[index].effectid;
  118. let page = this.tcmList[index].page;
  119. let load = this.tcmList[index].loadMore;
  120. if (!load) return;
  121. page += 1;
  122. this.tcmList[index].page = page;
  123. this.getMedList(effectid, page, index);
  124. },
  125. // 上一页
  126. lastPage(index) {
  127. let effectid = this.tcmList[index].effectid;
  128. let page = this.tcmList[index].page;
  129. let load = this.tcmList[index].loadMore;
  130. if (page == 1) return;
  131. page -= 1;
  132. this.tcmList[index].page = page;
  133. this.getMedList(effectid, page, index);
  134. },
  135. // 获取标准 功效接口
  136. async getEffectQuery(type) {
  137. let res = await getEffectQuery({
  138. effecttype: "2",
  139. effictId: this.form.other
  140. });
  141. if (res.code == 0) {
  142. if (type == 1) {
  143. this.classify = res.data.effects;
  144. } else {
  145. res.data.effects.forEach((item, index) => {
  146. let obj = {
  147. page: 1,
  148. loadMore: true,
  149. name: item.name,
  150. effectid: item.effectid,
  151. medList: []
  152. };
  153. this.tcmList.push(obj);
  154. this.getMedList(item.effectid, 1, index);
  155. });
  156. }
  157. }
  158. },
  159. async getMedList(effectid, pageid, index, load = true) {
  160. if (!load) return;
  161. let params = {
  162. effectid,
  163. pagesize: 12,
  164. pageid,
  165. searchtype: "",
  166. keyword: this.form.name,
  167. efficacy: this.form.gongxiao
  168. };
  169. let res = await getMedList(params);
  170. if (res.code == 0) {
  171. if (pageid <= res.data.TotalPageCount) {
  172. this.tcmList[index].loadMore = true;
  173. this.tcmList[index].medList = res.data.mats;
  174. } else {
  175. this.tcmList[index].loadMore = false;
  176. }
  177. }
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="scss" scoped>
  183. @import "../../style/common.scss";
  184. @import "../../style/base.scss";
  185. .tcm {
  186. .total {
  187. font-size: 14px;
  188. font-family: PingFang SC;
  189. font-weight: 400;
  190. color: #333333;
  191. margin-bottom: 20px;
  192. span {
  193. color: #ff3a3a;
  194. }
  195. }
  196. .body {
  197. margin-top: 5px;
  198. padding: 10px 20px;
  199. background: #ffffff;
  200. border-radius: 5px;
  201. box-sizing: border-box;
  202. height: 74vh;
  203. overflow: auto;
  204. .item {
  205. width: 250px;
  206. margin-right: 30px;
  207. margin-bottom: 20px;
  208. background: #f9f9f9;
  209. border: 2px solid #9F643A;
  210. border-radius: 8px;
  211. .title {
  212. padding: 26px 0 19px;
  213. text-align: center;
  214. font-size: 26px;
  215. font-family: PingFang SC;
  216. font-weight: 400;
  217. color: #333333;
  218. }
  219. .banner-body {
  220. height: 220px;
  221. background: #9F643A;
  222. color: #fff;
  223. padding: 0 32px;
  224. .left-btn {
  225. width: 10px;
  226. height: 150px;
  227. background: rgba($color: #fff, $alpha: 0.9);
  228. border-radius: 5px;
  229. img {
  230. width: 6px;
  231. }
  232. }
  233. .center {
  234. flex: 1;
  235. height: 180px;
  236. padding: 0 14px;
  237. ul {
  238. li {
  239. width: 50%;
  240. cursor: pointer;
  241. margin-bottom: 10px;
  242. span {
  243. width: 5px;
  244. height: 5px;
  245. background: #fff;
  246. border-radius: 50%;
  247. margin-right: 5px;
  248. }
  249. div {
  250. flex: 1;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. div:hover {
  256. color: #ff3a3a;
  257. }
  258. font-size: 16px;
  259. font-family: PingFang SC;
  260. font-weight: 400;
  261. color: #ffffff;
  262. list-style: square;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .findMore {
  269. background-color: #9F643A;
  270. color: #fff;
  271. text-align: center;
  272. padding-bottom: 20px;
  273. cursor: pointer;
  274. }
  275. }
  276. }
  277. </style>
  278. <style lang="scss" scoped>
  279. @media screen and (min-width: 1681px) and (max-width: 1920px) {
  280. .tcm {
  281. .body {
  282. height: 84vh;
  283. }
  284. }
  285. }
  286. @media screen and (min-width: 1601px) and (max-width: 1680px) {
  287. .tcm {
  288. .body {
  289. height: 83vh;
  290. }
  291. }
  292. }
  293. @media screen and (min-width: 1361px) and (max-width: 1600px) {
  294. .tcm {
  295. .body {
  296. height: 76vh;
  297. }
  298. }
  299. }
  300. @media screen and(min-width:1281px) and (max-width: 1360px) {
  301. .tcm {
  302. .body {
  303. height: 76vh;
  304. }
  305. }
  306. }
  307. </style>