index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <view class="HMfilterDropdown" :class="{'setDropdownBottom':maskVisibility}" :style="{'top':menuTop+'rpx'}"
  4. @touchmove.stop.prevent="discard" @tap.stop="discard">
  5. <!-- 顶部菜单 -->
  6. <view class="nav">
  7. <block v-for="(item,index) in menu" :key="index">
  8. <view class="first-menu" :class="{'on':showPage==index}" @tap="togglePage(index)">
  9. <text class="name">{{item}}</text>
  10. <text class="iconfont triangle" :style="'transform:rotate('+getDeg(index)+'deg);'"></text>
  11. </view>
  12. </block>
  13. </view>
  14. </view>
  15. <!-- 弹框 -->
  16. <xpopup :show="popShow" @close="close" @confirm="submit" :showBtn="false" :title="'请选择区域'">
  17. <!-- 区域选择 -->
  18. <scroll-view style="height: 600rpx;" scroll-y scroll-with-animation>
  19. <view class="popup-content">
  20. <tki-tree v-if="areaList&&areaList.length>0" style="width:100%;" :range="areaList" :foldAll="false"
  21. rangeKey="name" idKey="name" buttonName="选中" @btnClick="areaSubmit">
  22. </tki-tree>
  23. <view class="empty" v-else>
  24. <u-empty mode="data" text="您还未规划区域~"></u-empty>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. </xpopup>
  29. <!-- 线路/标签 -->
  30. <u-picker :show="pickerShow" @confirm="pickerConfirm" :closeOnClickOverlay="true" :columns="columns"
  31. keyName="label" @close="pickerClose" @cancel="pickerClose"></u-picker>
  32. </view>
  33. </template>
  34. <script>
  35. import tkiTree from "@/components/tki-tree/tki-tree.vue";
  36. import {
  37. areaTree
  38. } from "@/api/point/area"
  39. import {
  40. linePage
  41. } from "@/api/point/line"
  42. export default {
  43. name: 'FilterDrop',
  44. components: {
  45. tkiTree
  46. },
  47. data() {
  48. return {
  49. menu: ['类型', '缺货状态', '区域', '线路'], //顶部菜单数据
  50. showPage: -1, //菜单页面显示/隐藏动画控制
  51. popShow: false,
  52. areaList: [], //区域
  53. areaId: undefined, //区域id
  54. regionName: undefined, //区域名称
  55. lineId: undefined, //线路id
  56. columns: [], //options
  57. pickerShow: false,
  58. confirmData: ['', '', '', '']
  59. }
  60. },
  61. props: {
  62. menuTop: {
  63. type: Number,
  64. require: false,
  65. default: 0
  66. }
  67. },
  68. created() {
  69. //获取区域树
  70. this.getTree()
  71. },
  72. methods: {
  73. //获取区域树
  74. getTree() {
  75. areaTree().then(res => {
  76. this.areaList = res.data
  77. })
  78. },
  79. //菜单开关
  80. togglePage(index) {
  81. this.showPage = this.showPage == index ? -1 : index;
  82. switch (index) {
  83. case 0:
  84. this.pickerShow = true;
  85. this.columns = [
  86. [{
  87. name: '',
  88. label: '全部'
  89. },
  90. {
  91. name: 1,
  92. label: '开门柜'
  93. },
  94. {
  95. name: 2,
  96. label: '重力柜'
  97. }
  98. ]
  99. ]
  100. break
  101. case 1:
  102. this.columns = [
  103. [{
  104. name: '',
  105. label: '全部'
  106. },
  107. {
  108. name: 1,
  109. label: '缺货'
  110. },
  111. {
  112. name: 2,
  113. label: '不缺'
  114. }
  115. ]
  116. ]
  117. this.pickerShow = true;
  118. break
  119. case 2:
  120. this.popShow = true;
  121. break
  122. case 3:
  123. if (this.areaId) {
  124. this.pickerShow = true;
  125. } else {
  126. this.showPage = -1;
  127. this.$modal.msg('请先选择线路~')
  128. }
  129. break
  130. default:
  131. }
  132. },
  133. //获取三角形角度
  134. getDeg(index) {
  135. let deg = 0;
  136. deg = this.showPage == index ? 180 : 0;
  137. return deg
  138. },
  139. //区域选择提交
  140. areaSubmit(res) {
  141. this.menu[this.showPage] = res.name;
  142. this.regionName = res.name;
  143. this.areaId = res.key; //id
  144. this.confirmData[2] = res.key;
  145. this.popShow = false;
  146. this.showPage = -1;
  147. this.columns = [];
  148. this.menu[3] = '线路';
  149. this.getLineOption()
  150. this.confirm()
  151. },
  152. //获取线路options
  153. getLineOption() {
  154. linePage({
  155. page: {
  156. current: 1,
  157. size: 1000,
  158. },
  159. regionName: this.regionName
  160. }).then(res => {
  161. let data = res.data.records;
  162. let newData = data.map(i => {
  163. return {
  164. id: i.id,
  165. label: i.lineName
  166. }
  167. })
  168. this.columns = [newData];
  169. })
  170. },
  171. //弹框关闭
  172. close() {
  173. this.popShow = false;
  174. this.showPage = -1;
  175. },
  176. //picker弹框确认
  177. pickerConfirm(e) {
  178. console.log('eeeeeeeeeeeee', e)
  179. this.menu[this.showPage] = e.value[0].label;
  180. this.confirmData[this.showPage] = e.value[0].name;
  181. if (this.showPage == 3) {
  182. this.menu[this.showPage] = e.value[0].label;
  183. this.confirmData[this.showPage] = e.value[0].id;
  184. }
  185. this.pickerShow = false;
  186. this.showPage = -1;
  187. this.confirm()
  188. },
  189. //picker关闭
  190. pickerClose() {
  191. this.pickerShow = false;
  192. this.showPage = -1;
  193. },
  194. confirm() {
  195. // 输出
  196. this.$emit('confirm', this.confirmData);
  197. },
  198. discard() {
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. .HMfilterDropdown {
  205. flex-shrink: 0;
  206. width: 100%;
  207. position: fixed;
  208. // position: sticky;
  209. z-index: 997;
  210. flex-wrap: nowrap;
  211. display: flex;
  212. flex-direction: row;
  213. top: var(--window-top);
  214. left: 0;
  215. // top:100px;
  216. overflow-y: hidden;
  217. &.setDropdownBottom {
  218. // height: 345px;
  219. bottom: 0;
  220. }
  221. view {
  222. display: flex;
  223. flex-wrap: nowrap;
  224. }
  225. }
  226. .region {
  227. flex: 1;
  228. height: 44px;
  229. }
  230. .nav {
  231. width: 100%;
  232. height: 44px;
  233. border-bottom: solid 1rpx #eee;
  234. z-index: 12;
  235. background-color: #ffffff;
  236. flex-direction: row;
  237. .first-menu {
  238. width: 100%;
  239. font-size: 13px;
  240. color: #757575;
  241. flex-direction: row;
  242. align-items: center;
  243. justify-content: center;
  244. transition: color .2s linear;
  245. &.on {
  246. color: #2C6FF3;
  247. .iconfont {
  248. color: #2C6FF3;
  249. }
  250. }
  251. .name {
  252. height: 20px;
  253. text-align: center;
  254. text-overflow: clip;
  255. overflow: hidden;
  256. }
  257. .iconfont {
  258. width: 13px;
  259. height: 13px;
  260. align-items: center;
  261. justify-content: center;
  262. transition: transform .2s linear, color .2s linear;
  263. }
  264. }
  265. }
  266. @font-face {
  267. font-family: "HM-FD-font";
  268. src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAALAAAsAAAAABpQAAAJzAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgp4gQIBNgIkAwwLCAAEIAWEbQc5G8sFERWMIbIfCbbzqA4hp7InSBibVsYGb4J42o82b3e/nJlHMw/NHbGOlwKJRCRpwzPtpAECCOZubdqxjYpQLMlVg+70/08edrgQOtx2ukpVyApZn+dyehPoQObHo3O85rYx9vOjXoBxQIHugW2yIkqIW2QXcScu4jwE8CSWbKSmrqUHFwOaJoCsLM5P4haSGIxRcRHshrUGucLCVcfqI3AZfV/+USguKCwNmtsxVztDxU/n55C+3W0Z4QQpEOTNFqCBbMCAjDUWB9CIwWk87aa70cYgqLkyd3dEmm+18R8eKATEBrV7A5CulBT8dKiWOYZk412XNcDdKSEKSGODnyKIDl+dmVt9/Dx4pu/xyeutkMlHISGPTsPCnoTNP9nOT6wTtDdlO6dPr47efvj942lkYuQzrhMKEjq9N6y98P3340gmlJ/RStUD6F31CAEEPtUW94/7rf+7XgaAz57X0ZHXAGsFFwVgw38yALuMb0IBbVyNamFYEw4oKMDTj3AHRQP5Pt4dci9VwSVkRNQh5r7CLskZadhsWHhRDBsXczk8ZYk3ewnCxmQeQKa3BOHvA8XXO2j+vqRhf7CE+sPmn4anvoL29JLa4qqaUQkmoK+QG2osCckq7txi2leK86aIPyJ3eQZ8xytXYmyQ51jQndJAxIJlqiGSLsOqImiZCjTiZCJt6Lq26U2OoXqwUo0hRaAE0K5AziANy/uLVeXzWyjVqyjcoeupjxDr5MMDn8MDkLG9Aenu5ZrOSSoghAUsRmogkkahSoWAtnlUARnCkY3It0Iu7mWhdmd9Z/19BwBP6GidEi0G56opckXTGZVSPxgAAAA=');
  269. }
  270. .iconfont {
  271. font-family: "HM-FD-font" !important;
  272. font-size: 13px;
  273. font-style: normal;
  274. color: #757575;
  275. &.triangle {
  276. &:before {
  277. content: "\e65a";
  278. }
  279. }
  280. &.selected {
  281. &:before {
  282. content: "\e607";
  283. }
  284. }
  285. }
  286. .popup-content {
  287. padding: 36rpx 24rpx;
  288. display: flex;
  289. flex-flow: row nowrap;
  290. justify-content: flex-start;
  291. align-items: center;
  292. position: relative;
  293. input {
  294. border: 1rpx solid #999;
  295. border-radius: 6rpx;
  296. width: 530rpx;
  297. padding: 0 24rpx;
  298. }
  299. &.edit-point {
  300. flex-direction: column;
  301. >view {
  302. display: flex;
  303. flex-flow: row nowrap;
  304. justify-content: flex-start;
  305. align-items: center;
  306. &+view {
  307. margin-top: 12rpx;
  308. }
  309. >view {
  310. width: 170rpx;
  311. }
  312. }
  313. }
  314. .empty {
  315. margin: 0 auto;
  316. }
  317. }
  318. </style>