he wei
2024-01-15 d592480beb70716a59b6ec5a00c73e92ff6ea986
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
@@ -74,6 +74,10 @@
<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,
@@ -85,6 +89,7 @@
} from "@/apis";
export default {
  name: "ContextMenu",
  mixins: [i18nMixin],
  model: {
    prop: "visible",
    event: "change",
@@ -112,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,
          },
@@ -139,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,
          },
@@ -159,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,
@@ -177,7 +182,6 @@
      dialogTitle: "",
      dialogVisible: false,
      stationName: "",
      // 操作类型 'rename', 'add'
      type: "",
      fileInfoVisible: false,
      fileData: {},
@@ -248,7 +252,7 @@
          this.currFile.fileId = fileId;
          this.fileInfoVisible = true;
        } else {
          this.$message.error("文件解析失败");
          this.$message.error(this.$t('FileParsingFailed'));
        }
      });
    },
@@ -278,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") {
@@ -321,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'));
        }
      });
    },
@@ -356,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();
@@ -408,16 +412,16 @@
      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;
@@ -447,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'));
        }
      });
    },
@@ -462,9 +466,9 @@
      updateFileParam(this.currFile.stationId, data).then((res) => {
        const { code, data } = res.data;
        if (code && data) {
          this.$message.success('修改成功');
          this.$message.success(this.$t('ModifySuccessfully'));
        } else {
          this.$message.error('修改失败');
          this.$message.error(this.$t('ModifyFailed'));
        }
      });
      this.toRes();