deptSelect.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="desc">
  3. <uni-row>
  4. <uni-col :span="5">
  5. <view class="desc" style="font-size: 25rpx;">
  6. {{label}}
  7. </view>
  8. </uni-col>
  9. <uni-col :span="19">
  10. <view class="pickerView">
  11. <picker @change="deptBindPickerChange" :value="deptConfig.deptIndex" :range="deptConfig.deptDatas"
  12. range-key="deptName">
  13. <view class="pickerText"
  14. v-if="deptConfig.deptDatas && deptConfig.deptDatas.length>0 && deptConfig.deptIndex !== undefined">
  15. {{ deptConfig.deptDatas[deptConfig.deptIndex].deptName }}
  16. </view>
  17. <view class="pickerText" v-else>
  18. {{defaultDept}}
  19. </view>
  20. </picker>
  21. </view>
  22. </uni-col>
  23. </uni-row>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. name: 'hs-dept-select',
  29. props: {
  30. value: {
  31. Type: String,
  32. default: null
  33. },
  34. label: {
  35. Type: String,
  36. default: '岗位'
  37. },
  38. autofill: false
  39. },
  40. data() {
  41. return {
  42. defaultDept: '待 选 择',
  43. deptConfig: {
  44. deptDatas: uni.getStorageSync('deptData'),
  45. deptIndex: undefined
  46. },
  47. }
  48. },
  49. mounted() {
  50. if (this.autofill) {
  51. //翻译默认部门
  52. let department = uni.getStorageSync('files').department
  53. this.defaultDept = this.$dictTranslation(department, 'deptData', 'dept')
  54. this.$emit('input', department)
  55. }
  56. },
  57. methods: {
  58. deptBindPickerChange: function(e) {
  59. this.deptConfig.deptIndex = e.detail.value
  60. this.$emit('input', this.deptConfig.deptDatas[this.deptConfig.deptIndex].deptId)
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .desc {
  67. padding: 10rpx 15rpx 0 15rpx;
  68. color: #818181;
  69. font-size: 20rpx;
  70. }
  71. .pickerView {
  72. // align-items: flex-end;
  73. padding: 10rpx 20rpx;
  74. margin-right: 20rpx;
  75. border: 1rpx #eeeeee solid;
  76. }
  77. .pickerText {
  78. font-size: 26rpx;
  79. color: #b1b1b1;
  80. }
  81. </style>