index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="page">
  3. <el-card shadow="nover">
  4. <el-form inline>
  5. <el-form-item label="选择产品" prop="productKey">
  6. <el-select v-model="params.productKey" filterable placeholder="请选择产品" @change="productChange">
  7. <el-option v-for="item in productList" :key="item.key" :label="item.name" :value="item.key">
  8. <span style="float: left">{{ item.name }}</span>
  9. <span style="float: right; font-size: 13px">{{ item.key }}</span>
  10. </el-option>
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label="选择设备" prop="deviceKey">
  14. <el-select v-model="params.deviceKey" filterable placeholder="请选择设备" @change="deviceChange">
  15. <el-option v-for="item in deviceList" :key="item.key" :label="item.name" :value="item.key">
  16. <span style="float: left">{{ item.name }}</span>
  17. <span style="float: right; font-size: 13px">{{ item.key }}</span>
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="选择属性" prop="deviceKey">
  22. <el-select v-model="params.deviceKey" filterable placeholder="请选择属性" @change="deviceChange">
  23. <el-option v-for="item in deviceList" :key="item.key" :label="item.name" :value="item.key">
  24. <span style="float: left">{{ item.name }}</span>
  25. <span style="float: right; font-size: 13px">{{ item.key }}</span>
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button type="primary" class="ml10" @click="getData">
  31. <el-icon>
  32. <ele-Search />
  33. </el-icon>
  34. 查询
  35. </el-button>
  36. </el-form-item>
  37. </el-form>
  38. </el-card>
  39. </div>
  40. </template>
  41. <script lang="ts" setup>
  42. import { ref, toRefs, reactive, onMounted, defineComponent } from 'vue';
  43. import { ElMessageBox, ElMessage } from 'element-plus';
  44. import api from '/@/api/device';
  45. const productList = ref<any[]>([])
  46. const deviceList = ref<any[]>([])
  47. const params = reactive({
  48. productKey: '',
  49. deviceKey: '',
  50. })
  51. api.product.getLists({ status: 1 }).then((res: any) => {
  52. productList.value = res.product || [];
  53. });
  54. function getData() {
  55. }
  56. function productChange(productKey: string) {
  57. params.deviceKey = ''
  58. deviceList.value = []
  59. api.device.allList({ productKey }).then((res: any) => {
  60. deviceList.value = res.device;
  61. });
  62. }
  63. function deviceChange() {
  64. }
  65. </script>