田源
2025-03-05 f6b61a485501f326debe52d77ea65d87fb34b37f
Source/UBCS-WEB/src/views/integration/groupMapAttrXML.vue
@@ -1,37 +1,112 @@
<template>
  <el-container>
    <div class="editor-total">
      <div id="editor" v-html="xmlContent"></div>
      <button @click="saveXml">保 存</button>
    </div>
  </el-container>
  <basic-container>
    <avue-crud :data="tableData"
               :option="option"
               @on-load="onLoad"
               @row-save="rowSave"
               @row-update="rowUpdate">
      <template slot="groupMapAttrContent" slot-scope="scope">
        <avue-text-ellipsis :height="50" :text="scope.row.groupMapAttrContent">
          <small slot="more">...</small>
        </avue-text-ellipsis>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import { getGroupMapXML } from "@/api/integration/groupMapAttrXML.js";
import {getGroupMapXML, addGroupMapXML, updateGroupMapXML} from "@/api/integration/groupMapAttrXML.js";
export default {
  data() {
    return {
      xmlContent: "", // 从后端获取的XML内容
      tableData: [],
      option: {
        height: 'auto',
        border: true,
        index: true,
        viewBtn: true,
        delBtn: false,
        columnBtn: false,
        refreshBtn: false,
        highlightCurrentRow: true,
        dialogClickModal: true,
        column: [
          {
            label: "文件名称",
            prop: "groupMapAttrName",
          },
          {
            label: "文件保存路径",
            prop: "attrMapPath",
            display: false,
            labelWidth: 120,
          },
          {
            type: "textarea",
            label: "文件内容",
            prop: "groupMapAttrContent",
            slot: true,
            minRows: 15,
            span: 24
          },
          {
            label: '映射文件状态',
            prop: "isEnable",
            dicData: [{key: true, value: '启用'}, {key: false, value: '未启用'}],
            html: true,
            align: 'center',
            width: 125,
            display: false,
            formatter: function (row) {
              return row.isEnable ? '<i class="el-icon-check" style="color: #32cd32;font-size: 20px;font-weight: 800"></i>' : '<i class="el-icon-close" style="color: #ff0000;font-size: 20px;font-weight: 800"></i>'
            }
          }
        ]
      }
    };
  },
  mounted() {
  },
  created() {
    this.onLoad();
  },
  methods: {
    onLoad() {
      let xmlName = "PDM";
      getGroupMapXML({ xmlName: xmlName }).then((res) => {
        this.xmlContent = res.data.data;
        console.log(res.data.data);
      getGroupMapXML().then((res) => {
        this.tableData = res.data.data;
      });
    },
    rowSave(row, done) {
      row.groupMapAttrName = row.groupMapAttrName + '.xml';
      addGroupMapXML(row).then(res => {
        this.$message({
          type: "success",
          message: res.data.msg
        });
        done(row)
        this.onLoad()
      })
    },
    rowUpdate(row, index, done) {
      // updateXMLName 修改文件名
      // groupMapAttrName 原文件名
  },
      row.updateXMLName = row.groupMapAttrName.includes('.xml') ? row.groupMapAttrName : row.groupMapAttrName + '.xml';
      row.groupMapAttrName = this.tableData[index].groupMapAttrName;
      updateGroupMapXML(row).then(res => {
        this.$message({
          type: "success",
          message: res.data.msg
        });
        done();
        this.onLoad();
      });
    }
  }
};
</script>
<style>