ludc
2023-11-20 20ace44c6d012839687a59058b6000079bdae55d
Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
@@ -8,16 +8,27 @@
          <div>
            <div style="display: flex; flex-direction: column;">
              <div style="display: flex;">
                <el-button plain size="small" type="primary" @click="TreeAdd" v-if="permissionList.TreeAddStatus">添加</el-button>
                <el-button plain size="small" type="primary" @click="TreeEdit" v-if="permissionList.TreeEditStatus">修改</el-button>
                <el-button plain size="small" type="primary" @click="TreeDel" v-if="permissionList.TreeDelStatus">删除</el-button>
                <el-button plain size="small" type="primary" @click="flushed" v-if="permissionList.flushedStatus">刷新</el-button>
                <el-button v-if="permissionList.TreeAddStatus" plain size="small" type="primary" @click="TreeAdd">添加
                </el-button>
                <el-button v-if="permissionList.TreeEditStatus" plain size="small" type="primary" @click="TreeEdit">修改
                </el-button>
                <el-button v-if="permissionList.TreeDelStatus" plain size="small" type="primary" @click="TreeDel">删除
                </el-button>
                <el-button v-if="permissionList.flushedStatus" plain size="small" type="primary" @click="flushed">刷新
                </el-button>
              </div>
              <div style="display: flex; margin-top: 10px">
                <el-button plain size="small" type="primary" @click="Enable" v-if="permissionList.EnableStatus">启用</el-button>
                <el-button plain size="small" type="primary" @click="Deactivate" v-if="permissionList.DeactivateStatus">停用</el-button>
                <el-button plain size="small" type="primary" @click.native="ImportExcel" v-if="permissionList.ImportExcelStatus">导入</el-button>
                <el-button plain size="small" type="primary" @click="ExportExcel" v-if="permissionList.ExportExcelStatus">导出</el-button>
                <el-button v-if="permissionList.EnableStatus" plain size="small" type="primary" @click="Enable">启用
                </el-button>
                <el-button v-if="permissionList.DeactivateStatus" plain size="small" type="primary" @click="Deactivate">
                  停用
                </el-button>
                <el-button v-if="permissionList.ImportExcelStatus" plain size="small" type="primary"
                           @click.native="ImportExcel">导入
                </el-button>
                <el-button v-if="permissionList.ExportExcelStatus" plain size="small" type="primary"
                           @click="ExportExcel">导出
                </el-button>
              </div>
            </div>
            <div style="display: flex;justify-content: space-around;margin-top: 5px;margin-bottom: 5px">
@@ -66,10 +77,10 @@
              <el-form-item label="是否参与关键属性校验:" label-width="170px">
                <el-switch
                  v-model="TreeAddform.codeKeyAttrValue"
                  active-text="是"
                  inactive-text="否"
                  active-color="#13ce66"
                  active-text="是"
                  inactive-color="#ff4949"
                  inactive-text="否"
                  @change="switchChange">
                </el-switch>
              </el-form-item>
@@ -117,9 +128,11 @@
                  </template>
            <template slot="menuLeft">
              <el-button plain size="small" type="primary" @click="FindeHanler" v-if="permissionList.FindStatus">查询</el-button>
              <el-button plain size="small" type="primary" @click="TemRefresh" v-if="permissionList.TemRefreshStatus">刷新</el-button>
              <el-button plain size="small" type="primary" @click="CloneBtn" v-if="permissionList.CloneBtnStuatus">从其它模板克隆</el-button>
              <el-button v-if="permissionList.FindStatus" plain size="small" type="primary"
                         @click="FindeHanler">查询</el-button>
              <el-button v-if="permissionList.TemRefreshStatus" plain size="small" type="primary"
                         @click="TemRefresh">刷新</el-button>
              <el-button v-if="permissionList.CloneBtnStuatus" plain size="small" type="primary" @click="CloneBtn">从其它模板克隆</el-button>
              <!--              查询对话框-->
           <el-dialog :visible.sync="FindFormVisible" append-to-body title="高级查询">
              <div>
@@ -415,6 +428,7 @@
import {defaultReferDataGrid, referDataGrid} from '@/api/MasterData/master'
import func from "@/util/func";
import {mapGetters} from "vuex";
export default {
  name: "classifyTrees.vue",
  data() {
@@ -1100,7 +1114,10 @@
    },
    //分类树数据处理
    getAttr() {
      getAtrrList().then(res => {
      this.loading = true;
      return new Promise((resolve, reject) => {
        getAtrrList()
          .then(res => {
        this.Treedata = res.data;
        this.CloneTreedata = res.data;
        this.Treedata.forEach(() => {
@@ -1116,10 +1133,14 @@
          }
          return item;
        });
      }).catch(res => {
        this.$message.error(res)
            this.loading = false;
            resolve(); // 完成请求,调用resolve方法
      })
          .catch(error => {
            this.$message.error(error)
            reject(error); // 请求出错,调用reject方法
          });
      });
    },
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
@@ -1166,34 +1187,30 @@
      this.$refs.myForm.clearValidate();
    },
    //树节点添加事件
    TreeAddHandler() {
    async TreeAddHandler() {
      if ((!this.TreeAddform.id || !this.TreeAddform.name) || (this.TreeFlagCode && !this.TreeAddform.btmTypeName)) {
        this.$message.warning('请输入内容!');
      } else {
        return;
      }
      try {
        const data = this.TreeAddform;
        this.$set(data, "parentCodeClassifyOid", this.nodeClickList.oid);
        TreeSave(data)
          .then(() => {
            this.$message({
              type: "success",
              message: "添加成功!",
            });
        await TreeSave(data)
        this.$message.success("添加成功!");
            Object.keys(this.TreeAddform).forEach(key => {
              this.TreeAddform[key] = "";
        });
              this.TreeAddform.codeKeyAttrValue = true;
              this.TreeAddform.isParticipateCheck = 1;
            });
            this.getAttr();
            this.TreeAddFormVisible = false;
            //添加完成后右侧清空
            this.ProData = [];
            this.Formlist = [];
          })
          .catch((res) => {
      } catch (res) {
            this.$message({
              type: "warning",
              message: res,
            });
          });
      }
    },
@@ -1265,82 +1282,96 @@
      }
    },
    //树刷新
    flushed() {
      this.loading = true
      this.getAttr()
      setTimeout(() => {
        this.loading = false;
    async flushed() {
        await this.getAttr()
        this.$refs.tree.setCurrentKey(null);
        this.nodeClickList = {}
        this.TreeList = []
        this.TreeFlagCode = true;
      }, 600);
    },
    //启用和停用都先判断状态
    //启用
    Enable() {
    async Enable() {
      if (Object.keys(this.nodeClickList).length < 1) {
        this.$message.warning('请先从树上选择一条数据')
      } else {
        this.$message.warning('请先从树上选择一条数据');
        return;
      }
        if (this.FlagObj.lcStatus == "Enabled") {
          this.$message({
            type: 'warning',
            message: '当前分类不是停用状态'
          });
        } else {
          this.$confirm('是否将子分类一并启用?', '提示', {
        return;
      }
      this.loading = true;
      try {
        const confirmResult = await this.$confirm('是否将子分类一并启用?', '提示', {
            confirmButtonText: '是',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            TreeEnable(this.nodeClickList).then(() => {
        });
        if (confirmResult) {
          await TreeEnable(this.nodeClickList).then(res => {
              this.$message({
                type: 'success',
                message: '启用成功!'
              });
              this.getAttr()
            })
          }).catch(() => {
          await this.getAttr();
        } else {
            this.$message({
              type: 'info',
              message: '已取消启用'
            });
          });
        }
      } catch (error) {
        console.error(error);
      } finally {
        this.loading = false;
      }
    },
    async Deactivate() {
      if (Object.keys(this.nodeClickList).length < 1) {
        this.$message.warning('请先从树上选择一条数据');
        return;
      }
    },
    //停用
    Deactivate() {
      if (Object.keys(this.nodeClickList).length < 1) {
        this.$message.warning('请先从树上选择一条数据')
      } else {
        if (this.FlagObj.lcStatus === "Disabled") {
          this.$message({
            type: 'warning',
            message: '当前分类不是启用状态!'
          });
        } else {
          this.$confirm('是否停用当前分类,停用后,子分类也将不能被使用,是否继续?', '提示', {
        return;
      }
      this.loading = true;
      try {
        const confirmResult = await this.$confirm('是否停用当前分类,停用后,子分类也将不能被使用,是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            TreeDeactivate(this.nodeClickList).then(() => {
        });
        if (confirmResult) {
          await TreeDeactivate(this.nodeClickList).then(res => {
              this.$message({
                type: 'success',
                message: '停用成功!'
              });
              this.nodeClickList['flag'] = true;
              this.getAttr()
            })
          }).catch(() => {
          this.nodeClickList['flag'] = true;
          await this.getAttr();
        } else {
            this.$message({
              type: 'info',
              message: '已取消停用'
            });
          });
        }
      } catch (error) {
        console.error(error);
      } finally {
        this.loading = false;
      }
    },
    //树点击事件