index.vue 1.3 KB

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