he wei
2025-04-09 850af610b190eeabbd05eba3291fe359775676af
src/components/contextMenu.vue
@@ -44,15 +44,15 @@
      append-to-body
      width="30%"
    >
      <el-input v-model="stationName" placeholder="请输入..."></el-input>
      <el-input v-model="stationName" :placeholder="$t('form.inputMsg')"></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="stationNameOk">确 定</el-button>
        <el-button @click="dialogVisible = false">{{ $t('operate.cancel') }}</el-button>
        <el-button type="primary" @click="stationNameOk">{{ $t('operate.ok') }}</el-button>
      </span>
    </el-dialog>
    <!-- 文件属性 -->
    <el-dialog
      title="属性"
      :title="$t('Properties')"
      class="file-info"
      :visible.sync="fileInfoVisible"
      append-to-body
@@ -62,6 +62,7 @@
      width="800px"
    >
      <file-info
        v-if="fileInfoVisible"
        :info="fileData"
        @ok="editOk"
        @cancel="editCancel"
@@ -73,16 +74,22 @@
<script>
import FileInfo from "@/components/fileInfo";
import i18n from './i18n/contextMenu';
import { createI18nOption } from '@/assets/js/tools/i18n';
const i18nMixin = createI18nOption(i18n);
import {
  addStation,
  addFileInStation,
  updateStation,
  deleteStation,
  delFileFromStation,
  getXmlValue,
  getParamByFileId,
  updateFileParam,
} from "@/apis";
export default {
  name: "ContextMenu",
  mixins: [i18nMixin],
  model: {
    prop: "visible",
    event: "change",
@@ -110,26 +117,26 @@
    const menuList = [
      {
        id: 0,
        title: "打开文件",
        title: this.$t('OpenFile'),
        method: "openFile",
        disabled: false,
        visible: false,
      },
      {
        id: 1,
        title: "新建",
        title: this.$t('New'),
        disabled: false,
        visible: false,
        children: [
          {
            id: 11,
            title: "新建根文件",
            title: this.$t('NewRootFile'),
            method: "addRootStation",
            disabled: false,
          },
          {
            id: 12,
            title: "新建子文件",
            title: this.$t('NewSubFile'),
            method: "addSubStation",
            disabled: false,
          },
@@ -137,19 +144,19 @@
      },
      {
        id: 2,
        title: "添加",
        title: this.$t('New1'),
        disabled: false,
        visible: false,
        children: [
          {
            id: 13,
            title: "指定目录下所有文件",
            title: this.$t('Allfilesinthespecifieddirectory'),
            method: "selectDir",
            disabled: false,
          },
          {
            id: 14,
            title: "单一文件",
            title: this.$t('SingleFile'),
            method: "selectFile",
            disabled: false,
          },
@@ -157,14 +164,14 @@
      },
      {
        id: 3,
        title: "重命名",
        title: this.$t('Rename'),
        method: "rename",
        disabled: false,
        visible: false,
      },
      {
        id: 4,
        title: "删除",
        title: this.$t('Delete'),
        method: "deleteItem",
        disabled: false,
        visible: false,
@@ -175,14 +182,14 @@
      dialogTitle: "",
      dialogVisible: false,
      stationName: "",
      // 操作类型 'rename', 'add'
      type: "",
      fileInfoVisible: false,
      fileData: {},
      currFile: {
        name: "",
        url: "",
        fileId: undefined
        // url: "",
        stationId: 0,
        fileId: undefined,
      },
    };
  },
@@ -233,21 +240,19 @@
      });
    },
    openFile() {
      let { url, fileId } = this.contextData;
      const params = {
        filePath: url
      };
      getXmlValue(params).then((res) => {
      let { fileId, label, stationId } = this.contextData;
      getParamByFileId(fileId).then((res) => {
        const { code, data, data2 } = res.data;
        if (code && data) {
          // console.log(data2);
          this.fileData = data2.fileParam;
          this.currFile.name = data2.fileName;
          this.currFile.url = data2.fileUrl;
          this.fileData = data2;
          this.currFile.name = label;
          // this.currFile.url = url;
          this.currFile.stationId = stationId;
          this.currFile.fileId = fileId;
          this.fileInfoVisible = true;
        } else {
          this.$message.error("文件解析失败");
          this.$message.error(this.$t('FileParsingFailed'));
        }
      });
    },
@@ -277,20 +282,20 @@
      // console.log(this.menuList, this.disabledList, 9090);
    },
    addRootStation() {
      this.dialogTitle = "新建根文件名称";
      this.dialogTitle = this.$t('NewRootFileName');
      this.stationName = "";
      this.type = "add";
      this.dialogVisible = true;
    },
    addSubStation() {
      this.dialogTitle = "新建子文件名称";
      this.dialogTitle = this.$t('NewSubFileName');
      this.stationName = "";
      this.type = "add";
      this.dialogVisible = true;
    },
    stationNameOk() {
      if ("" == this.stationName.trim()) {
        this.$message.error("名称不能为空");
        this.$message.error(this.$t('Thenamecannotbeblank'));
        return false;
      }
      if (this.type == "add") {
@@ -320,10 +325,10 @@
        const { code, data } = res.data;
        if (code && data) {
          this.dialogVisible = false;
          this.$message.success("添加成功");
          this.$message.success(this.$t('AddSuccessfully'));
          this.reload();
        } else {
          this.$message.error("操作失败");
          this.$message.error(this.$t('OperationFailed'));
        }
      });
    },
@@ -334,12 +339,14 @@
      window.api.send("open-file-dialog", "ContextMenu");
    },
    addFileInStation(path) {
      let { label, parent } = this.contextData;
      let { label, parent, children } = this.contextData;
      let fileId = children[0] ? children[0].fileId : 0;
      parent = parent.map((v) => v);
      parent.push(label);
      const params = {
        FilePath: path,
        stationName: parent.join("-"),
        fileId
      };
      addFileInStation(params).then((res) => {
        const { code, data, data2 } = res.data;
@@ -353,17 +360,17 @@
    deleteItem() {
      let { label, parent, level } = this.contextData;
      if (level == 3) {
        this.$confirm("此操作将从站点移除该文件, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        this.$confirm(this.$t('Thefilewillberemovedfromthesitewhethertocontinue'), this.$t('Note'), {
          confirmButtonText: this.$t('operate.ok'),
          cancelButtonText: this.$t('operate.cancel'),
          type: "warning",
        }).then(() => {
          this.deleteFile();
        });
      } else {
        this.$confirm("此操作将删除该站点, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        this.$confirm(this.$t('Thesitewillbedeletedcontinuetheoperation'), this.$t('Note'), {
          confirmButtonText: this.$t('operate.ok'),
          cancelButtonText: this.$t('operate.cancel'),
          type: "warning",
        }).then(() => {
          this.deleteStation();
@@ -396,25 +403,25 @@
      });
    },
    deleteFile() {
      let { label, parent, url } = this.contextData;
      let { fileId, parent } = this.contextData;
      parent = parent.map((v) => v);
      let params = {
        stationName: parent.join("-"),
        FilePath: url,
        fileId,
      };
      delFileFromStation(params).then((res) => {
        const { code, data, data2 } = res.data;
        if (code && data) {
          this.$message.success("操作成功");
          this.$message.success(this.$t('OperationSuccessfully'));
          this.reload();
        } else {
          this.$message.error("操作失败");
          this.$message.error(this.$t('OperationFailed'));
        }
      });
    },
    // 重命名现只针对台站 (文件是否重命名需要确认需求)
    rename() {
      this.dialogTitle = "修改站点名称";
      this.dialogTitle = this.$t('ModifySiteName');
      this.stationName = this.contextData.label;
      this.type = "rename";
      this.dialogVisible = true;
@@ -444,10 +451,10 @@
        const { code, data } = res.data;
        if (code && data) {
          this.dialogVisible = false;
          this.$message.success("操作成功");
          this.$message.success(this.$t('OperationSuccessfully'));
          this.reload();
        } else {
          this.$message.error("操作失败");
          this.$message.error(this.$t('OperationFailed'));
        }
      });
    },
@@ -456,6 +463,14 @@
    },
    editOk(data) {
      this.fileInfoVisible = false;
      updateFileParam(this.currFile.stationId, data).then((res) => {
        const { code, data } = res.data;
        if (code && data) {
          this.$message.success(this.$t('ModifySuccessfully'));
        } else {
          this.$message.error(this.$t('ModifyFailed'));
        }
      });
      this.toRes();
    },
    editCancel(data) {
@@ -463,13 +478,14 @@
      this.toRes();
    },
    toRes() {
      const { name, url, fileId } = this.currFile;
      const { name, url, fileId, stationId } = this.currFile;
      // debugger;
      this.$router.push({
        path: "/result/" + name,
        query: {
          url,
          fileId
          stationId,
          fileId,
        },
      });
      this.$bus.$emit("checkScroll");