riku
2023-10-31 1f96f089eb3546c682313d29513be04ac72e2de5
src/views/overlay-grid/components/OptionGridRecord.vue
@@ -2,13 +2,13 @@
  <el-select
    v-model="selectedOptions"
    placeholder="网格化记录"
    style="max-width: 150px"
    style="width: 150px"
  >
    <el-option
      v-for="s in options"
      :key="s.value"
      :label="s.label"
      :value="s"
      :key="s.gsId"
      :label="s.gsName"
      :value="s.gsId"
    />
  </el-select>
</template>
@@ -16,17 +16,14 @@
<script>
// 网格化方案记录选项
import gridRecordApi from '@/api/gridRecordApi';
import gridSchemeApi from '@/api/grid/gridSchemeApi';
export default {
  props: {
    // 是否在首选项处添加“全部”选项
    // allOption: {
    //   type: Boolean,
    //   default: true,
    // },
    // 刷新下拉列表
    refresh: Boolean,
    // 返回结果
    value: Object,
    value: Number
  },
  data() {
    return {
@@ -35,18 +32,29 @@
    };
  },
  watch: {
    selectedOptions: {
      handler(val) {
        this.$emit('update:value', val);
      },
      deep: true,
    // selectedOptions: {
    //   handler(val) {
    //     this.$emit('update:value', val);
    //   },
    //   deep: true
    // },
    selectedOptions(nVal) {
      this.$emit('update:value', nVal);
    },
    refresh() {
      this.getOptions(true);
    }
  },
  methods: {
    getOptions() {
      gridRecordApi.getGridRecords().then((res) => {
        this.options = res;
        this.selectedOptions = res[0];
    getOptions(newScheme) {
      gridSchemeApi.fetchAllSchemes().then((res) => {
        if (res.length > 0) {
          this.options = res;
          this.selectedOptions = newScheme
            ? res[res.length - 1].gsId
            : res[0].gsId;
          // this.selectedOptions = res[0].gsId;
        }
      });
    }
  },