index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <view :class="['lb-picker', inline ? 'lb-picker-inline' : '']">
  3. <!-- 默认插槽 -->
  4. <view v-if="!inline"
  5. class="lb-picker-default-slot"
  6. @tap="show">
  7. <slot></slot>
  8. </view>
  9. <!-- 遮罩层 -->
  10. <view v-if="visible && showMask && !inline"
  11. :class="['lb-picker-mask', animation ? 'lb-picker-mask-animation' : '']"
  12. :style="{
  13. backgroundColor: maskBgColor,
  14. zIndex: zIndex - 1
  15. }"
  16. @tap.stop="handleMaskTap"
  17. @touchmove.stop.prevent="moveHandle">
  18. </view>
  19. <view v-if="visible || inline"
  20. ref="container"
  21. :class="[
  22. 'lb-picker-container',
  23. !inline ? 'lb-picker-container-fixed' : '',
  24. animation ? 'lb-picker-container-animation' : '',
  25. containerVisible ? 'lb-picker-container-show' : ''
  26. ]"
  27. :style="{
  28. borderRadius: `${radius} ${radius} 0 0`,
  29. zIndex: zIndex
  30. }">
  31. <view v-if="showHeader"
  32. class="lb-picker-header">
  33. <!-- 头部顶部插槽 -->
  34. <slot name="header-top"></slot>
  35. <view class="lb-picker-header-actions">
  36. <!-- 取消 -->
  37. <view class="lb-picker-action lb-picker-action-cancel"
  38. @tap.stop="handleCancel">
  39. <slot v-if="$slots['cancel-text']"
  40. name="cancel-text">
  41. </slot>
  42. <text v-else
  43. class="lb-picker-action-cancel-text"
  44. :style="{ color: cancelColor }">{{ cancelText }}</text>
  45. </view>
  46. <!-- 中间 -->
  47. <view class="lb-picker-action lb-picker-center"
  48. v-if="$slots['action-center']">
  49. <slot name="action-center"></slot>
  50. </view>
  51. <!-- 确定 -->
  52. <view class="lb-picker-action lb-picker-action-confirm"
  53. @tap.stop="handleConfirm">
  54. <slot v-if="$slots['confirm-text']"
  55. name="confirm-text"> </slot>
  56. <text v-else
  57. class="lb-picker-action-confirm-text"
  58. :style="{ color: confirmColor }">{{ confirmText }}</text>
  59. </view>
  60. </view>
  61. <!-- 头部底部插槽 -->
  62. <slot name="header-bottom"></slot>
  63. </view>
  64. <view :class="[
  65. 'lb-picker-content',
  66. safeAreaInsetBottom ? 'lb-picker-content-safe-buttom' : ''
  67. ]">
  68. <!-- 选择器顶部插槽 -->
  69. <slot name="picker-top"></slot>
  70. <view class="lb-picker-content-main"
  71. :style="{ height: pickerContentHeight }">
  72. <!-- loading -->
  73. <view v-if="loading"
  74. class="lb-picker-loading">
  75. <slot name="loading">
  76. <image class="lb-picker-loading-img"
  77. src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAPFklEQVR4Xu2dTXbUOBeGpToHF7OGFTSsAFhBJytoWAFkUnKNoFdAWEGHUVmZJKygwwpIVkB6BYQVdDIj4Ry5zw3210W++pFtSb6S3pqWpHv9Xj2WZMtXUuAHBaDAWgUktIECUGC9AgAEvQMKbFAAgKB7QAEAgj4ABfopgBGkn26olYkCACSTQOMy+ykAQPrphlqZKABARg700dHRg+vr69+klE/run5E7kgpL+q6Pp9Op2d7e3uXI7uYtXkAMmL4tdZvhRBvhBAP1rhBcBwopd6N6GbWpgHICOGnUePm5uaTEOKppfnzoih2MZpYquWwGABxKK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RgPABJQbEemAIgjIW2aASA2KvEqA0ACxgOABBTbkSkA4khIm2YAiI1KvMoAkIDxACABxXZkCoA4EtKmGQBioxKvMgAkYDwASECxHZkCII6EtGkGgNioxKsMAAkYDwASUGxHpgCIIyFtmgEgNirxKgNAAsYDgAQU25EpAOJISJtmAIiNSrzKAJCA8QAgAcV2ZAqAOBLSppnma7p/bMquK8MhofMQ/2OrC0ACR6yqqnMp5ZM+Zrmkwunje6x1AEjgyC0Wi95ZJDll+wgs22jmAMgI0vfMZn+mlKJkB/gFVACABBS7NUVrkevr61PbqRZNrabT6c7Yh8mMINXoJgHIiCHQWm9LknclhDhQSlE5/EZQAICMIPqyyTt5oihhHv0oT9R5URSnGDXGDRAAGVd/WGeuAABhHiC4N64CAGRc/WGduQIAhHmA4N64CgCQcfWHdeYKABDmAYJ74yoAQMbVH9aZKwBAmAcI7o2rwL9NuZ5QQgPItwAAAABJRU5ErkJggg==">
  78. </image>
  79. </slot>
  80. </view>
  81. <!-- 暂无数据 -->
  82. <view v-if="isEmpty && !loading && mode !== 'dateSelector'"
  83. class="lb-picker-empty">
  84. <slot name="empty">
  85. <text class="lb-picker-empty-text"
  86. :style="{ color: emptyColor }">{{ emptyText }}</text>
  87. </slot>
  88. </view>
  89. <!-- 单选 -->
  90. <selector-picker v-if="mode === 'selector' && !loading && !isEmpty"
  91. :ref="mode"
  92. :value="value"
  93. :list="list"
  94. :mode="mode"
  95. :props="pickerProps"
  96. :height="pickerContentHeight"
  97. :inline="inline"
  98. :column-style="columnStyle"
  99. :active-column-style="activeColumnStyle"
  100. :align="align"
  101. :press-enable="pressEnable"
  102. :press-time="pressTime"
  103. :formatter="formatter"
  104. @change="handleChange">
  105. </selector-picker>
  106. <!-- 多列联动 -->
  107. <multi-selector-picker v-if="mode === 'multiSelector' && !loading && !isEmpty"
  108. :ref="mode"
  109. :value="value"
  110. :list="list"
  111. :mode="mode"
  112. :level="level"
  113. :visible="visible"
  114. :props="pickerProps"
  115. :height="pickerContentHeight"
  116. :inline="inline"
  117. :column-style="columnStyle"
  118. :active-column-style="activeColumnStyle"
  119. :align="align"
  120. :press-enable="pressEnable"
  121. :press-time="pressTime"
  122. :formatter="formatter"
  123. @change="handleChange">
  124. </multi-selector-picker>
  125. <!-- 非联动选择 -->
  126. <unlinked-selector-picker v-if="mode === 'unlinkedSelector' && !loading && !isEmpty"
  127. :ref="mode"
  128. :value="value"
  129. :list="list"
  130. :mode="mode"
  131. :visible="visible"
  132. :props="pickerProps"
  133. :height="pickerContentHeight"
  134. :inline="inline"
  135. :column-style="columnStyle"
  136. :active-column-style="activeColumnStyle"
  137. :align="align"
  138. :press-enable="pressEnable"
  139. :press-time="pressTime"
  140. :formatter="formatter"
  141. @change="handleChange">
  142. </unlinked-selector-picker>
  143. <!-- 日期选择 -->
  144. <date-selector-picker v-if="mode === 'dateSelector' && !loading"
  145. :ref="mode"
  146. :value="value"
  147. :mode="mode"
  148. :visible="visible"
  149. :height="pickerContentHeight"
  150. :inline="inline"
  151. :column-style="columnStyle"
  152. :active-column-style="activeColumnStyle"
  153. :align="align"
  154. :formatter="formatter"
  155. :format="format"
  156. :display-format="displayFormat"
  157. :start-date="startDate"
  158. :end-date="endDate"
  159. :default-time-limit="defaultTimeLimit"
  160. :is-show-chinese="isShowChinese"
  161. :ch-config="pickerChConfig"
  162. :filter="filter"
  163. @change="handleChange">
  164. </date-selector-picker>
  165. </view>
  166. <!-- 选择器底部插槽 -->
  167. <slot name="picker-bottom"></slot>
  168. </view>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. const defaultMaskBgColor = 'rgba(0, 0, 0, 0)'
  174. const defaultProps = {
  175. label: 'label',
  176. value: 'value',
  177. children: 'children'
  178. }
  179. const defaultChConfig = {
  180. year: '年',
  181. month: '月',
  182. day: '日',
  183. hour: '时',
  184. minute: '分',
  185. second: '秒'
  186. }
  187. // #ifdef APP-NVUE
  188. const animation = weex.requireModule('animation')
  189. // #endif
  190. import { getColumns } from './utils'
  191. import SelectorPicker from './pickers/selector-picker'
  192. import MultiSelectorPicker from './pickers/multi-selector-picker'
  193. import UnlinkedSelectorPicker from './pickers/unlinked-selector-picker'
  194. import DateSelectorPicker from './pickers/date-selector-picker'
  195. export default {
  196. components: {
  197. SelectorPicker,
  198. MultiSelectorPicker,
  199. UnlinkedSelectorPicker,
  200. DateSelectorPicker
  201. },
  202. props: {
  203. value: [String, Number, Array],
  204. list: Array,
  205. mode: {
  206. type: String,
  207. default: 'selector'
  208. },
  209. level: {
  210. type: Number,
  211. default: 1
  212. },
  213. props: {
  214. type: Object
  215. },
  216. cancelText: {
  217. type: String,
  218. default: '取消'
  219. },
  220. cancelColor: {
  221. type: String,
  222. default: '#999'
  223. },
  224. confirmText: {
  225. type: String,
  226. default: '确定'
  227. },
  228. confirmColor: {
  229. type: String,
  230. default: '#007aff'
  231. },
  232. canHide: {
  233. type: Boolean,
  234. default: true
  235. },
  236. emptyColor: {
  237. type: String,
  238. default: '#999'
  239. },
  240. emptyText: {
  241. type: String,
  242. default: '暂无数据'
  243. },
  244. radius: String,
  245. columnNum: {
  246. type: Number,
  247. default: 5
  248. },
  249. loading: Boolean,
  250. closeOnClickMask: {
  251. type: Boolean,
  252. default: true
  253. },
  254. showMask: {
  255. type: Boolean,
  256. default: true
  257. },
  258. maskColor: {
  259. type: String,
  260. default: 'rgba(0, 0, 0, 0.4)'
  261. },
  262. dataset: Object,
  263. inline: Boolean,
  264. showHeader: {
  265. type: Boolean,
  266. default: true
  267. },
  268. animation: {
  269. type: Boolean,
  270. default: true
  271. },
  272. zIndex: {
  273. type: Number,
  274. default: 999
  275. },
  276. safeAreaInsetBottom: {
  277. type: Boolean,
  278. default: true
  279. },
  280. disabled: Boolean,
  281. columnStyle: Object,
  282. activeColumnStyle: Object,
  283. align: {
  284. type: String,
  285. default: 'center'
  286. },
  287. pressEnable: Boolean,
  288. pressTime: {
  289. type: Number,
  290. default: 500
  291. },
  292. formatter: Function,
  293. format: {
  294. type: String,
  295. default: 'YYYY-MM-DD'
  296. },
  297. displayFormat: {
  298. type: String,
  299. default: 'YYYY-MM-DD'
  300. },
  301. startDate: String,
  302. endDate: String,
  303. defaultTimeLimit: {
  304. type: Number,
  305. default: 20
  306. },
  307. isShowChinese: {
  308. type: Boolean,
  309. default: true
  310. },
  311. chConfig: Object,
  312. filter: Function
  313. },
  314. data () {
  315. return {
  316. visible: false,
  317. containerVisible: false,
  318. maskBgColor: defaultMaskBgColor,
  319. myValue: this.value,
  320. picker: {},
  321. pickerProps: Object.assign({}, defaultProps, this.props),
  322. pickerChConfig: Object.assign({}, defaultChConfig, this.chConfig)
  323. }
  324. },
  325. computed: {
  326. pickerContentHeight () {
  327. return 34 * this.columnNum + 'px'
  328. },
  329. isEmpty () {
  330. if (this.mode === 'dateSelector') return false
  331. if (!this.list && this.mode !== 'dateSelector') return true
  332. if (this.list && !this.list.length) return true
  333. return false
  334. }
  335. },
  336. methods: {
  337. show () {
  338. if (this.inline || this.disabled) return
  339. this.visible = true
  340. setTimeout(() => {
  341. this.maskBgColor = this.maskColor
  342. // #ifndef APP-NVUE
  343. this.containerVisible = true
  344. // #endif
  345. // #ifdef APP-NVUE
  346. this.wxAnimation(0)
  347. // #endif
  348. }, 20)
  349. },
  350. hide () {
  351. if (this.inline) return
  352. this.maskBgColor = defaultMaskBgColor
  353. // #ifndef APP-NVUE
  354. this.containerVisible = false
  355. // #endif
  356. // #ifdef APP-NVUE
  357. this.wxAnimation('100%')
  358. // #endif
  359. setTimeout(() => {
  360. this.visible = false
  361. }, 300)
  362. },
  363. handleCancel () {
  364. this.$emit('cancel', this.picker)
  365. if (this.canHide && !this.inline) {
  366. this.hide()
  367. }
  368. },
  369. handleConfirm () {
  370. if (this.isEmpty) {
  371. this.$emit('confirm', null)
  372. this.hide()
  373. } else {
  374. const picker = { ...this.picker }
  375. this.$refs[this.mode].isConfirmChange = true
  376. this.myValue = picker.value
  377. this.$emit('confirm', this.picker)
  378. if (this.canHide) this.hide()
  379. }
  380. },
  381. handleChange ({ value, valueArr, item, index, change }) {
  382. if (this.mode === 'dateSelector') {
  383. this.picker.valueArr = valueArr
  384. }
  385. this.picker.value = value
  386. this.picker.item = item
  387. this.picker.index = index
  388. this.picker.change = change
  389. this.picker.dataset = this.dataset || {}
  390. if (this.$refs[this.mode] && this.inline) {
  391. this.$refs[this.mode].isConfirmChange = true
  392. }
  393. this.$emit('change', this.picker)
  394. },
  395. handleMaskTap () {
  396. if (this.closeOnClickMask) {
  397. this.hide()
  398. }
  399. },
  400. moveHandle () {},
  401. // #ifdef APP-NVUE
  402. wxAnimation (num) {
  403. const $container = this.$refs.container
  404. animation.transition($container, {
  405. styles: {
  406. transform: `translateY(${num})`
  407. },
  408. duration: 300
  409. })
  410. },
  411. // #endif
  412. getColumnsInfo (value, type = 1) {
  413. let columnsInfo = getColumns(
  414. {
  415. value,
  416. list: this.list,
  417. mode: this.mode,
  418. props: this.pickerProps,
  419. level: this.level
  420. },
  421. type
  422. )
  423. if (columnsInfo) {
  424. if (this.mode === 'selector') {
  425. columnsInfo.index = columnsInfo.index[0]
  426. }
  427. } else {
  428. columnsInfo = {}
  429. }
  430. columnsInfo.dataset = this.dataset || {}
  431. return columnsInfo
  432. }
  433. },
  434. watch: {
  435. value (newVal) {
  436. this.myValue = newVal
  437. },
  438. myValue (newVal) {
  439. this.$emit('input', newVal)
  440. },
  441. visible (newVisible) {
  442. if (newVisible) {
  443. this.$emit('show')
  444. } else {
  445. this.$emit('hide')
  446. }
  447. },
  448. props (newProps) {
  449. this.pickerProps = Object.assign({}, defaultProps, newProps)
  450. },
  451. chConfig (newVal) {
  452. this.pickerChConfig = Object.assign({}, defaultChConfig, newVal)
  453. }
  454. }
  455. }
  456. </script>
  457. <style lang="scss" scoped>
  458. @import "./style/picker.scss";
  459. </style>