管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-05-27 0af4ecb9b2047b8ba6d00e891050cf2d68b829a6
src/views/datamanage/catalogueManage.vue
@@ -2,7 +2,7 @@
  <div class="subpage_Box">
    <My-bread :list="[
          `${$t('dataManage.dataManage')}`,
          `${$t('dataManage.catalogueManage')}`,
          `${$t('dataManage.projectManagement')}`,
        ]"></My-bread>
    <el-divider />
    <div class="mainBox">
@@ -45,6 +45,25 @@
                :inline="true"
                class="demo-form-inline"
              >
                <el-form-item>
                  <el-button
                    v-show="directoryFlag"
                    icon="el-icon-download"
                    type="info"
                    size="small"
                    @click="setDirectoryDownload"
                  >{{ $t("shuJuGuanLi.butten.directoryDownload") }}</el-button>
                </el-form-item>
                <el-form-item>
                  <el-button
                    icon="el-icon-download"
                    type="info"
                    size="small"
                    @click="setTemplateDownload"
                  >{{ $t("shuJuGuanLi.butten.templateDownload") }}</el-button>
                </el-form-item>
                <el-form-item>
                  <el-upload
                    action
@@ -126,27 +145,27 @@
        >
          <el-form-item
            prop="name"
            :label="$t('dataManage.dataUpObj.directoryName')"
            :label="$t('dataManage.dataUpObj.name')"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="itemdetail.name"
              size="small"
              style=" max-width: 420px"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueName')"
              clearable
            />
            <!--            style="max-width: 400px"-->
          </el-form-item>
          <el-form-item
            :label="$t('dataManage.dataUpObj.catalogDescription')"
            :label="$t('dataManage.dataUpObj.explain')"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="itemdetail.descr"
              type="textarea"
              style=" max-width: 420px"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueexplain')"
              clearable
            />
          </el-form-item>
@@ -154,13 +173,27 @@
            :label="$t('dataManage.dataUpObj.inspectionItems')"
            :label-width="formLabelWidth"
          >
            <el-input
            <el-select
              style="width: 420px"
              v-model="itemdetail.checks"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueexamine')"
              multiple
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <!-- <el-input
              type="textarea"
              style=" max-width: 420px"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
              clearable
            />
            /> -->
            <!--            resize="none"-->
            <!--            style="height: 100%; overflow: auto; max-width: 400px"-->
          </el-form-item>
@@ -172,7 +205,7 @@
              v-model="itemdetail.exts"
              type="textarea"
              style=" max-width: 420px"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuesuffix')"
              clearable
            />
          </el-form-item>
@@ -196,7 +229,6 @@
              disabled
              type="textarea"
              style=" max-width: 420px"
              :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
              autosize
            />
          </el-form-item>
@@ -272,22 +304,24 @@
        :rules="rules"
      >
        <el-form-item
          :label="$t('dataManage.dataUpObj.directoryName')"
          :label="$t('dataManage.dataUpObj.name')"
          prop="name"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="ruleForm.name"
            autocomplete="off"
            :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueName')"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('dataManage.dataUpObj.catalogDescription')"
          :label="$t('dataManage.dataUpObj.explain')"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="ruleForm.descr"
            autocomplete="off"
            :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueexplain')"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -299,18 +333,34 @@
            type="textarea"
            resize="none"
            style="height: 100%; overflow: auto"
            :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuesuffix')"
          />
        </el-form-item>
        <el-form-item
          :label="$t('dataManage.dataUpObj.inspectionItems')"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="ruleForm.checks"
          <!-- <el-input
            type="textarea"
            resize="none"
            style="height: 100%; overflow: auto"
          />
          /> -->
          <el-select
            v-model="ruleForm.checks"
            multiple
            style="width:100%;"
            :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueexamine')"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('dataManage.dataUpObj.code')"
@@ -325,12 +375,13 @@
          />
        </el-form-item>
        <el-form-item
          :label="$t('dataManage.dataUpObj.catalogRemarks')"
          :label="$t('dataManage.dataUpObj.Remarks')"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="ruleForm.bak"
            autocomplete="off"
            :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueRemarks')"
          ></el-input>
        </el-form-item>
      </el-form>
@@ -348,6 +399,11 @@
        >{{ $t("common.preservation") }}</el-button>
      </div>
    </el-dialog>
    <iframe
      id="Iframe1"
      src=""
      style="display: none; border: 0; padding: 0; height: 0; width: 0"
    ></iframe>
  </div>
</template>
@@ -364,6 +420,8 @@
import * as XSLX from "xlsx";
import MyBread from "../../components/MyBread.vue";
import clone from "@turf/clone";
import $ from 'jquery'
import { getToken } from '../../utils/auth';
export default {
  name: "catalogueManage",
  components: {
@@ -378,6 +436,8 @@
      }
    };
    return {
      directoryData: null,
      directoryFlag: false,
      menuStatus: {
        delete: false,
        insert: false,
@@ -392,7 +452,9 @@
      dirList: [], //el树数据
      old_dirDat: [], //el树数据(拖动前)
      newData: [], //拖动后原始数据
      itemdetail: {},
      itemdetail: {
        checks: [],
      },
      itemaName: null,
      backUpData: "",
      formLabelWidth: "150px",
@@ -406,6 +468,7 @@
        name: "",
        descr: "",
        bak: "",
        checks: []
      },
      rules: {
        name: [{ required: true, validator: validName, trigger: "blur" }],
@@ -415,9 +478,64 @@
      fileList: [],
      file: null,
      tableData: [],
      options: [
        {
          value: 'checkMain',
          label: '总质检'
        }, {
          value: 'checkOsgb',
          label: 'OSGB检查'
        }, {
          value: 'checkXls',
          label: '表格数据检查'
        }, {
          value: 'checkLaz',
          label: '点云检查'
        }, {
          value: 'checkDem',
          label: '高程检查'
        }, {
          value: 'checkAttrs',
          label: '属性检查'
        }, {
          value: 'checkTopology',
          label: '拓扑检查'
        }, {
          value: 'checkDecorate',
          label: '图面整饰检查'
        }, {
          value: 'checkOrigin',
          label: '原点检查'
        }, {
          value: 'checkDom',
          label: '栅格检查'
        }, {
          value: 'checkMath',
          label: '数学基础检查'
        }, {
          value: 'checkMeta',
          label: '元数据检查'
        }, {
          value: 'checkLogical',
          label: '逻辑一致性检查'
        }, {
          value: 'checkSingleIntegrity',
          label: '单项成果完整性检查'
        }
      ],
    };
  },
  methods: {
    setTemplateDownload() {
      var url = window.location.href;
      var testurl = window.location.origin + "/";
      if (url.indexOf("web") != -1) {
        testurl = testurl + "/web/";
      }
      testurl += dirTemplateFile
      $("#Iframe1").attr("src", testurl).click()
    },
    handleChange(file, fileList) {
      this.file = file;
      if (fileList.length > 0) {
@@ -451,25 +569,59 @@
            { defval: null }
          ); // 默认第一行下为空也能解析出第一四行
          var data = [...outdata];
          const arr = [];
          data.map((v) => {
            const obj = {};
            obj.name = v.name;
            obj.pname = v.pname;
            obj.descr = v.explain;
            obj.checks = v.checks;
            obj.bak = v.bak;
            obj.exts = v.exts;
            obj.orderNum = null;
            obj.pid = null;
            arr.push(obj);
          });
          that.tableData = arr;
          that.setInsertData(that.tableData);
          that.setLeToFc(data);
        };
      }
    },
    setLeToFc(res) {
      var arr = [];
      for (var i in res) {
        var value = this.getNameAndPname(res[i], res, i)
        arr.push({
          name: value[0],
          pname: value[1],
          descr: res[i].explain,
          checks: res[i].checks,
          bak: res[i].bak,
          exts: res[i].exts,
          orderNum: null,
          pid: null,
          tid: parseInt(value[2]) + 1,
          sid: parseInt(value[3]) + 1
        })
      }
      this.tableData = arr;
      this.setInsertData(this.tableData);
    },
    getNameAndPname(res, result, flag) {
      var chLevel = null;
      var faLevel = null;
      for (var i = 1; i < 8; i++) {
        var lel = 'L' + i;
        if (res[lel] != null) {
          chLevel = i
        }
      }
      if (chLevel == 1) {
        return [res['L' + chLevel], null, flag, -1]
      } else {
        faLevel = chLevel - 1;
        for (var i = flag; i >= 0; i--) {
          var val = result[i]
          if (val['L' + faLevel]) {
            return [res['L' + chLevel], val['L' + faLevel], flag, i]
            break;
          }
        }
      }
    },
    setInsertData(res) {
      var list = this.excelData(res);
      if (list.length != 0) {
@@ -477,7 +629,7 @@
          return this.$message.error("上传数据错误,第一条数据不为空");
        }
        this.getAllNodeId(list);
        this.getAllNodeId(res);
      }
    },
    async getAllNodeId(res) {
@@ -488,8 +640,9 @@
          val.orderNum = this.dirList[this.dirList.length - 1].orderNum + 1;
          val.pid = 0;
        } else {
          this.tableData.filter((child) => {
            if (child.name == val.pname) {
            if (child.tid == val.sid) {
              val.pid = child.id;
              val.orderNum = i + 1;
            }
@@ -499,29 +652,31 @@
        const data = await insertDir(val);
        if (data.code != 200) {
        }
        this.tableData.filter((child) => {
          if (child.name == val.name && child.pname == val.pname) {
          if (child.name == val.name && child.tid == val.tid) {
            child.id = data.result;
          }
        });
        this.itemaName = data.result;
        this.getDirTree();
        if (res[i].children) {
          this.getAllNodeId(res[i].children);
        }
        // if (res[i].children) {
        //   this.getAllNodeId(res[i].children);
        // }
      }
    },
    excelData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.name == child.pname); // 对比ID,分别上下级菜单,并返回数据
        let branchArr = cloneData.filter((child) => father.tid == child.sid); // 对比ID,分别上下级菜单,并返回数据
        branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
        // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
        // 由此循环多次后,就能形成相应的树形数据结构
        return father.pname == null; // 返回一级菜单
        return father.sid == 0; // 返回一级菜单
      });
    },
    readFile(file) {
@@ -545,6 +700,7 @@
      queryDirTree().then((res) => {
        // console.log(res);
        if (res.code == 200) {
          this.oriData = res.result;
          this.newData = res.result;
          this.dirList = this.treeData(res.result);
@@ -566,7 +722,7 @@
      });
    },
    handleClose() {
      this.$confirm("确认关闭?")
      this.$confirm("关闭后无法保存,是否关闭?")
        .then((_) => {
          this.resetForm();
        })
@@ -597,19 +753,22 @@
          if (currentId != 0) {
            const tempChildrenNodex1 = pchildNodes[currentId - 1];
            const tempChildrenNodex2 = pchildNodes[currentId];
            tempChildrenNodex2.orderNum =
              pchildNodes[currentId - 1].data.orderNum;
            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
            // tempChildrenNodex2.orderNum =
            //   pchildNodes[currentId - 1].data.orderNum;
            // tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
            var arr = [];
            this.oriData.filter((res) => {
              if (res.id == tempChildrenNodex2.data.id) {
                res.orderNum = tempChildrenNodex2.orderNum;
                // res.orderNum = tempChildrenNodex2.orderNum;
                arr.push(res);
              } else if (res.id == tempChildrenNodex1.data.id) {
                res.orderNum = tempChildrenNodex1.orderNum;
                // res.orderNum = tempChildrenNodex1.orderNum;
                arr.push(res);
              }
            });
            const orderNum = arr[1].orderNum
            arr[1].orderNum = arr[0].orderNum
            arr[0].orderNum = orderNum
            this.newData = arr;
            this.sendChange();
          } else {
@@ -623,19 +782,22 @@
          if (currentId < pchildNodes.length - 1) {
            const tempChildrenNodex1 = pchildNodes[currentId + 1];
            const tempChildrenNodex2 = pchildNodes[currentId];
            tempChildrenNodex2.orderNum =
              pchildNodes[currentId + 1].data.orderNum;
            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
            // tempChildrenNodex2.orderNum =
            //   pchildNodes[currentId + 1].data.orderNum;
            // tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
            var arr = [];
            this.oriData.filter((res) => {
              if (res.id == tempChildrenNodex2.data.id) {
                res.orderNum = tempChildrenNodex2.orderNum;
                // res.orderNum = tempChildrenNodex2.orderNum;
                arr.push(res);
              } else if (res.id == tempChildrenNodex1.data.id) {
                res.orderNum = tempChildrenNodex1.orderNum;
                // res.orderNum = tempChildrenNodex1.orderNum;
                arr.push(res);
              }
            });
            const orderNum = arr[1].orderNum
            arr[1].orderNum = arr[0].orderNum
            arr[0].orderNum = orderNum
            this.newData = arr;
            this.sendChange();
          } else {
@@ -712,7 +874,15 @@
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.fullscreenLoading = true;
            insertDir(this.ruleForm)
            var val = this.ruleForm;
            if (this.ruleForm.checks) {
              val.checks = this.ruleForm.checks.toString()
            } else {
              val.checks = ''
            }
            insertDir(val)
              .then((res) => {
                setTimeout(() => {
                  this.fullscreenLoading = false;
@@ -859,8 +1029,7 @@
            }
            item.orderNum = i + 1;
          });
          // console.log(nodeData);
          //更新原始整体数据
          let arr = [];
          this.oriData.forEach((e) => {
            nodeData.forEach((item) => {
@@ -883,26 +1052,58 @@
            this.getDirTree();
            return;
          } else {
            this.$message.error("修改失败,请重试!");
            this.$message.error("移动失败,请重试!");
          }
        })
        .catch(() => {
          this.$message.error("修改失败,请重试!");
          this.$message.error("移动失败,请重试!");
        });
    },
    setDirectoryDownload() {
      var url = BASE_URL + '/dir/downloadDir?token=' + getToken() + '&id=' + this.directoryData.id
      console.log(url)
      $("#Iframe1").attr("src", url).click()
    },
    handleNodeClick(data, node) {
      // console.log(data);
      if (data.pid == 0) {
        this.directoryData = data;
        this.directoryFlag = true;
      } else {
        this.directoryFlag = false;
      }
      this.newNode = node;
      this.backUpData = JSON.stringify(data);
      this.itemdetail = JSON.parse(JSON.stringify(data));
      var val = JSON.parse(JSON.stringify(data));
      this.itemdetail = val;
      var checks = [];
      if (val.checks) {
        if (val.checks.indexOf(',') > -1) {
          var value = val.checks.split(',');
          for (var i in value) {
            checks.push(value[i])
          }
        } else {
          checks.push(val.checks)
        }
        this.itemdetail.checks = checks;
      } else {
        this.itemdetail.checks = []
      }
    },
    updCata(formName) {
      this.$nextTick(() => {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.fullscreenLoading = true;
            updateDirTree(this.itemdetail)
            var val = this.itemdetail
            var value = this.itemdetail.checks.toString()
            val.checks = value;
            updateDirTree(val)
              .then((res) => {
                setTimeout(() => {
                  this.fullscreenLoading = false;
@@ -928,6 +1129,21 @@
      // this.$refs[formName].resetFields();
      if (this.backUpData != "") {
        this.itemdetail = JSON.parse(this.backUpData);
        var val = JSON.parse(this.backUpData);
        var checks = [];
        if (val.checks) {
          if (val.checks.indexOf(',') > -1) {
            var value = val.checks.split(',');
            for (var i in value) {
              checks.push(value[i])
            }
          } else {
            checks.push(val.checks)
          }
          this.itemdetail.checks = checks;
        } else {
          this.itemdetail.checks = []
        }
      }
    },
    showPermsMenu(res) {