index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <el-select v-model="msgCatId" value-key="msgCatId" style="width: 100%" filterable placeholder="请选择消息类型">
  3. <el-option-group>
  4. <el-option
  5. v-for="item in msgCatList"
  6. :key="item.msgCatId"
  7. :label="item.msgCatTitle"
  8. :value="item.msgCatId"
  9. />
  10. </el-option-group>
  11. </el-select>
  12. </template>
  13. <script>
  14. import { getMsgCatByList } from '@/api/system/msgCatApi'
  15. export default {
  16. name: 'MsgCatSelector',
  17. components: { },
  18. props: {
  19. value: {
  20. type: Number,
  21. default: undefined
  22. }
  23. },
  24. data() {
  25. return {
  26. msgCatId: undefined,
  27. msgCatList: []
  28. }
  29. },
  30. watch: {
  31. value(val) {
  32. this.msgCatId = val
  33. },
  34. msgCatId(val) {
  35. this.$emit('input', val)
  36. }
  37. },
  38. created() {
  39. this.initMsgCatListData()
  40. },
  41. mounted() {},
  42. methods: {
  43. // Init Measure Type List
  44. initMsgCatListData() {
  45. getMsgCatByList().then((resp) => {
  46. const { code, data, msg } = resp
  47. if (code === 200) {
  48. this.msgCatList = data
  49. } else {
  50. this.$message.error(msg)
  51. }
  52. }).catch((error) => {
  53. console.log(error)
  54. })
  55. }
  56. }
  57. }
  58. </script>