riku
2024-08-23 1788c96aea9247cc36ef8b82734997f1a6a92fb4
src/components/search/OptionDevice.vue
@@ -8,7 +8,7 @@
      class="w-120"
    >
      <el-option
        v-for="(s, i) in deviceList"
        v-for="(s, i) in deviceOptions"
        :key="i"
        :label="s.label"
        :value="s.value"
@@ -18,6 +18,8 @@
</template>
<script>
import { deviceList } from '@/constant/device-type';
export default {
  props: {
    type: String,
@@ -28,20 +30,12 @@
    return {};
  },
  computed: {
    deviceList() {
      const t = this.type ? this.type : '0a';
      return [1, 2, 3].map((v) => {
        const label = `${this.getDeviceType(t)}设备${v}号`;
        const value = `${t}000000000${v}`;
        return {
          label: label,
          value: value
        };
      });
    deviceOptions() {
      return deviceList(this.type);
    }
  },
  watch: {
    deviceList(nV, oV) {
    deviceOptions(nV, oV) {
      if (nV != oV) {
        this.handleChange(nV[0].value);
      }
@@ -50,22 +44,10 @@
  methods: {
    handleChange(value) {
      this.$emit('update:modelValue', value);
    },
    getDeviceType(t) {
      switch (t) {
        case '0a':
          return '车载';
        case '0b':
          return '无人机';
        case '0c':
          return '无人船';
        default:
          return '车载';
      }
    }
  },
  mounted() {
    this.handleChange(this.deviceList[0].value);
    this.handleChange(this.deviceOptions[0].value);
  }
};
</script>