portOfRegistry.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div v-loading="loading" :element-loading-background="elementLoadingBackground" style="width: 100%;">
  3. <el-select
  4. style="width: 90px;"
  5. v-model="paramOneVal"
  6. :placeholder="`请选择`"
  7. clearable
  8. filterable
  9. @change="handleChange"
  10. :title="$store.state.dictionary.cbglPersonDictionaryMap.get(paramOneVal)"
  11. >
  12. <el-option
  13. v-for="item in $store.state.dictionary.cbglPersonDictionary"
  14. :key="item.dictType"
  15. :label="item.dictName"
  16. :value="item.dictType"
  17. :title="item.dictName"
  18. />
  19. </el-select>
  20. <el-select
  21. style="width: calc(100% - 90px - 2px);margin-left: 2px;"
  22. v-model="paramTwoVal"
  23. :placeholder="`请选择${label}`"
  24. :disabled="!paramOneVal"
  25. clearable
  26. filterable
  27. @change="handleChange"
  28. :title="$store.state.dictionary.portOfRegistryTwoMap.get(paramTwoVal)"
  29. >
  30. <el-option
  31. v-for="item in $store.state.dictionary.portOfRegistryTwoList.filter(v => v.parent === paramOneVal)"
  32. :key="item.dictValue"
  33. :label="item.dictName"
  34. :value="item.dictValue"
  35. :title="item.dictName"
  36. />
  37. </el-select>
  38. </div>
  39. </template>
  40. <script lang="ts">
  41. import {
  42. defineComponent,
  43. computed,
  44. onMounted,
  45. ref,
  46. reactive,
  47. watch,
  48. getCurrentInstance,
  49. ComponentInternalInstance,
  50. toRefs,
  51. nextTick,
  52. inject
  53. } from 'vue'
  54. import {useStore} from 'vuex'
  55. import {useRouter, useRoute} from 'vue-router'
  56. export default defineComponent({
  57. name: '',
  58. components: {},
  59. props: {
  60. paramOne: {},
  61. paramTwo: {},
  62. label: {},
  63. },
  64. setup(props, { emit }) {
  65. const store = useStore();
  66. const router = useRouter();
  67. const route = useRoute();
  68. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  69. const state = reactive({
  70. paramOneVal: props.paramOne,
  71. paramTwoVal: props.paramTwo,
  72. loading: true,
  73. elementLoadingBackground: inject('element-loading-background', null)
  74. })
  75. watch(() => state.paramOneVal, (n) => {
  76. state.paramTwoVal = null
  77. emit('emitParam', state.paramOneVal, state.paramTwoVal)
  78. })
  79. watch(() => state.paramTwoVal, (n) => {
  80. emit('emitParam', state.paramOneVal, state.paramTwoVal)
  81. })
  82. watch(() => [props.paramOne, props.paramTwo], (n) => {
  83. state.paramOneVal = n[0]
  84. state.paramTwoVal = n[1]
  85. })
  86. const handleChange = (val: any) => {
  87. }
  88. onMounted(() => {
  89. store.dispatch('dictionary/LOAD_PORT_OF_REGISTRY').then(() => {
  90. state.loading = false
  91. })
  92. })
  93. return {
  94. ...toRefs(state),
  95. handleChange
  96. }
  97. },
  98. })
  99. </script>
  100. <style scoped lang="scss">
  101. </style>