无人机管理后台前端(已迁走)
rain
2025-05-13 c5fbc8bd6b529cd54a2689bbec3ff6cb3e99aa49
机场areacode绑定
1 files modified
84 ■■■■ changed files
src/views/device/airport.vue 84 ●●●● patch | view | raw | blame | history
src/views/device/airport.vue
@@ -134,6 +134,10 @@
          >远程调试
        </el-button>
      </template>
      <!-- 添加行政区划显示模板 -->
      <template #area_code="{ row }">
        <span>{{ row.area_name }}</span>
      </template>
    </avue-crud>
    <el-dialog title="固件升级" append-to-body v-model="firmwareBox" width="455px">
@@ -457,34 +461,56 @@
            props: {
              label: 'title',
              value: 'value',
              emitPath: false,
              checkStrictly: true,
              multiple: false,
              expandTrigger: 'hover',
            },
            dataType: 'string',
            rules: [
              {
                required: true,
                message: '请选择所在省份',
                trigger: 'blur',
                message: '请选择行政区划',
                trigger: 'change',
              },
            ],
            change: ({ value }) => {
              if (!value) {
                this.form.area_code = null;
              } else {
                if (typeof value === 'string' && value.includes(',')) {
                  const codes = value.split(',');
                  this.form.area_code = codes[codes.length - 1];
                } else {
                  this.form.area_code = value;
                }
              }
            },
            lazy: true,
            lazyLoad(node, resolve) {
              let level = node.level;
              let list = [];
              let callback = () => {
                resolve(
                  (list || []).map(ele => {
                    return Object.assign(ele, {
                      leaf: !ele.hasChildren,
                    });
                  })
                  (list || []).map(ele => ({
                    ...ele,
                    value: ele.value,
                    leaf: level >= 2,
                  }))
                );
              };
              if (level == 0) {
              if (level === 0) {
                getLazyTree('000000000000').then(res => {
                  list = res.data.data;
                  callback();
                });
              } else if (level > 0 && level < 5) {
              } else if (level === 1) {
                getLazyTree(node.value).then(res => {
                  list = res.data.data;
                  callback();
                });
              } else if (level === 2) {
                getLazyTree(node.value).then(res => {
                  list = res.data.data;
                  callback();
@@ -939,6 +965,15 @@
      this.ossSetBox = false;
    },
    rowSave(row, done, loading) {
      let areaCode = row.area_code;
      if (Array.isArray(areaCode)) {
        areaCode = areaCode[areaCode.length - 1];
      } else if (typeof areaCode === 'string' && areaCode.includes(',')) {
        const codes = areaCode.split(',');
        areaCode = codes[codes.length - 1];
      }
      row.area_code = areaCode || null;
      add(row).then(
        () => {
          this.onLoad(this.page);
@@ -955,7 +990,12 @@
      );
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
      const submitData = {
        ...row,
        area_code: row.area_code.split(',').pop(),
      };
      update(submitData).then(
        () => {
          this.onLoad(this.page);
          this.$message({
@@ -1026,10 +1066,32 @@
          this.$refs.crud.toggleSelection();
        });
    },
    getFullAreaCode(areaCode) {
      if (!areaCode) return '';
      const code = areaCode.toString();
      if (code.includes(',')) return code;
      if (code.endsWith('0000000000')) {
        return code;
      } else if (code.endsWith('00000000') && !code.endsWith('0000000000')) {
        const provinceCode = code.substring(0, 2) + '0000000000';
        return `${provinceCode},${code}`;
      } else {
        const provinceCode = code.substring(0, 2) + '0000000000';
        const cityCode = code.substring(0, 4) + '00000000';
        return `${provinceCode},${cityCode},${code}`;
      }
    },
    beforeOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
          const data = res.data.data;
          this.form = {
            ...data,
            area_code: this.getFullAreaCode(data.area_code),
          };
        });
      }
      done();