田源
2024-07-18 e977b8737d88aa1bd0286fe27bf4fd22cb2501d9
整合代码
已修改5个文件
已添加4个文件
448 ■■■■■ 文件已修改
Source/plt-web/plt-web-ui/src/api/modeling/enumType/api.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/handlers.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/page/index/top/index.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/store/modules/user.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/util/func.js 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/modeling/enumType/index.vue 303 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/system/user/option.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/api/modeling/enumType/api.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,10 @@
import request from '@/router/axios';
// åˆ—表查询
export function getEnumTypeList(params) {
  return request({
    url: "/api/webEnumController/getEnumTypeList",
    method: "get",
    params
  });
}
Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
/**
 * æŒ‰é’®å¤„理 ä¸šåŠ¡ç±»åž‹å®¡ç­¾
 */
import {paramLow,callPreEvent, callPostEvent} from '../BaseAction';
import {validatenull} from "@/util/validate";
import Vue from "vue";
import func from "@/util/func";
import {download} from "@/api/base/file";
export const doAction = (options,callback) => {
  console.log(options)
  options.sourceData = options.sourceData || {};
  options.dataStore = options.dataStore || [];
  if (!options.dataStore || options.dataStore.length < 1) {
    Vue.prototype.$message.error("请至少选择一条数据");
    return false;
  }
  callPreEvent(options, doBefore, function (options) {
    showStartWindow(options, function () {
      callPostEvent(options, doAfter, callback,type);
    });
  });
};
/**
 * æ˜¾ç¤ºæµç¨‹çš„窗口
 * @param options æŒ‰é’®çš„配置信息
 * @param callback å›žè°ƒ
 */
export const showStartWindow = (options,callback)=> {
  const paramVOS = options.paramVOS;
  // if (!paramVOS['form'] && !paramVOS['context']) {
  //   Vue.prototype.$message.error("按钮配置不正确");
  //   return false;
  // }
  // func.downloadFileByBlobHandler();
}
/**
 * å‰ç½®äº‹ä»¶
 * @param options æŒ‰é’®çš„配置信息
 * @param callback å›žè°ƒ
 */
export const doBefore = (options,callback)=> {
  console.log("执行增加前置事件")
  if(callback){
    callback(options);
  }
}
/**
 * åŽç½®äº‹ä»¶
 * @param options æŒ‰é’®çš„配置信息
 * @param callback å›žè°ƒ
 */
export const doAfter = (options,callback,actionType)=> {
  console.log('执行增加后置事件');
  if(callback){
    callback(actionType);
  }
}
Source/plt-web/plt-web-ui/src/components/actions/handlers.js
@@ -39,9 +39,12 @@
    downloadfile: () => {import("@/components/actions/base/downloadFileAction").then(module => {
      module.doAction(options,callback);
    })},
    uprevision: () => {import("@/components/actions/base/upRevisionAction").then(module => {
      module.doAction(options,callback);
    })}
  };
  if (handlers[type]) {
    handlers[type]()
    handlers[type]();
  } else {
    Vue.prototype.$message.error('未找到对应action,请重新配置按钮!');
  }
Source/plt-web/plt-web-ui/src/page/index/top/index.vue
@@ -132,6 +132,7 @@
import topNotice from './top-notice'
import topLang from "./top-lang";
import {changePassword} from "@/api/user"
import func from "@/util/func";
export default {
  components: {
@@ -300,9 +301,20 @@
    submitSwitch(form, done) {
      let userInfo = JSON.parse(localStorage.getItem('saber-userInfo'));
      let params = {userOid:userInfo.content.userOid,...form}
      let params = {
        userOid:userInfo.content.userOid,
        oldPassword:func.encryptData(form.oldPassword,'daliantan0v0vcip'),
        password:func.encryptData(form.password,'daliantan0v0vcip'),
        confirmPassword:func.encryptData(form.confirmPassword,'daliantan0v0vcip'),
      }
      changePassword(params).then(res =>{
        console.log(res);
        if(res.data.code === 200){
          this.$message.success(res.data.msg);
          this.passwordVisible = false;
        }
      }).catch(err => {
        console.log(err);
      })
      // this.$store.dispatch("refreshToken", form).then(() => {
      //   this.userBox = false;
Source/plt-web/plt-web-ui/src/store/modules/user.js
@@ -7,6 +7,7 @@
import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons} from '@/api/user'
import {getTopMenu, getRoutes} from '@/api/system/menu'
import md5 from 'js-md5'
import func from "@/util/func";
function addPath(ele, first) {
@@ -62,7 +63,8 @@
    //根据用户名登录
    LoginByUsername({commit}, userInfo) {
      return new Promise((resolve, reject) => {
        loginByUsername(userInfo.deptId, userInfo.roleId, userInfo.username,userInfo.password, userInfo.type, userInfo.key,).then(res => {
        let passwordDes = func.encryptData(userInfo.password,'daliantan0v0vcip')
        loginByUsername(userInfo.deptId, userInfo.roleId, userInfo.username,passwordDes, userInfo.type, userInfo.key,).then(res => {
          const data = res.data;
          if (data.code === 200) {
            // commit('SET_TOKEN', data.obj.sessionInfo.token);
Source/plt-web/plt-web-ui/src/util/func.js
@@ -1,6 +1,8 @@
/**
 * é€šç”¨å·¥å…·ç±»
 */
import CryptoJS from 'crypto-js'
export default class func {
  /**
   * ä¸ä¸ºç©º
@@ -184,5 +186,50 @@
      return item[attr] !== array[0][attr];
    });
  }
  /**
   * 3des加密
   * @param message
   * @param key
   * @returns {string}
   */
  encryptByDES(message, key) {
    const keyHex = CryptoJS.enc.Utf8.parse(key);
    const encrypted = CryptoJS.DES.encrypt(message, keyHex, {
      mode: CryptoJS.mode.ECB,
      padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}
  /**
   * HmacMD5加密
   * @param message
   * @param key
   * @returns {string}
   * @constructor
   */
  static HmacMD5(message, key) {
    const encrypted = CryptoJS.HmacMD5(message,key);
    return encrypted.toString();
  }
  /**
   * aes加密
   * @param data
   * @param secretKey
   * @returns {string}
   */
  static encryptData(data, secretKey) {
    const key = CryptoJS.enc.Utf8.parse(secretKey);
    const iv = CryptoJS.enc.Utf8.parse(secretKey.substr(0, 16)); // AES block size is 128 bits (16 bytes)
    const encrypted = CryptoJS.AES.encrypt(data, key, {
      iv: iv,
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
  }
}
Source/plt-web/plt-web-ui/src/views/modeling/enumType/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,303 @@
<template>
  <basic-container>
    <avue-crud
      ref="userCrud"
      :data="tableData"
      :option="option"
      :table-loading="tableLoading"
      @on-load="getTableList"
      @refresh-change="handleRefresh"
      @search-change="handleSearch"
      @search-reset="handleReset"
      @selection-change="selectChange"
      @row-click="rowClickHandler"
    >
      <template slot="menuLeft" slot-scope="scope">
        <el-button icon="el-icon-plus" size="small" type="primary" @click="rowSaveHandlerClick">创建</el-button>
      </template>
    </avue-crud>
    <el-dialog
      v-dialogDrag
      v-loading="dialogLoading"
      :visible.sync="dialogVisible"
      append-to-body="true"
      class="avue-dialog"
      title="新增"
      width="70%"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="名称:" prop="id">
              <el-input v-model="form.id"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标签:">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类型:">
              <el-select v-model="form.type" placeholder="请选择类型">
                <el-option label="String" value="String"></el-option>
                <el-option label="Integer" value="Integer"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="长度:">
              <el-input-number v-model="form.num" :max="999" :min="1" label="描述文字"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <avue-crud
              ref="dialogCrud"
              :data="dialogData"
              :option="dialogOption"
              @row-save="rowSaveDialogHandler"
              @row-update="rowUpdateDialogHandler"
              @row-del="rowDeleteDialogHandler"
            >
            </avue-crud>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="rowSaveHandler">ç¡® å®š</el-button>
        <el-button @click="dialogVisible = false">取 æ¶ˆ</el-button>
      </span>
    </el-dialog>
  </basic-container>
</template>
<script>
import basicOption from '@/util/basic-option'
import {getEnumTypeList} from "@/api/modeling/enumType/api";
export default {
  name: "index",
  data() {
    return {
      dialogData: [],
      dialogOption: {
        ...basicOption,
        refreshBtn: false,
        selection: false,
        column: [
          {
            label: '枚举项名',
            prop: 'name',
            sortable: true,
            rules: [
              {
                required: true,
                message: '请输入枚举项名',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '枚举值',
            prop: 'value',
            sortable: true,
            rules: [
              {
                required: true,
                message: '请输入枚举值',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '描述',
            prop: 'description',
            sortable: true,
          },
        ]
      },
      rules: {
        id: [
          {required: true, message: '请输入枚举项名', trigger: 'blur'},
          {validator: this.validateEnglishOnly, trigger: 'blur'}
        ],
      },
      form: {
        id: '',
        name: '',
        type: 'String',
        num: 50
      },
      dialogLoading: false,
      dialogVisible: false,
      tableData: [],
      option: {
        ...basicOption,
        calcHeight: -60,
        searchMenuSpan: 8,
        addBtn: false,
        editBtn: false,
        column: [
          {
            label: '枚举名称',
            prop: 'id',
            sortable: true,
          },
          {
            label: '标签',
            prop: 'name',
            sortable: true,
          },
          {
            label: '返回类型',
            prop: 'enumValueDataTypeText',
            sortable: true,
          }
        ]
      },
      tableLoading: false,
    }
  },
  methods: {
    //表格查询请求
    getTableList() {
      this.tableLoading = true;
      getEnumTypeList().then(res => {
        const data = res.data.data;
        this.tableData = data;
        this.tableLoading = false;
      }).catch(err => {
        this.$message.error(err)
      });
    },
    // è¡¨æ ¼å¤´éƒ¨åˆ·æ–°
    handleRefresh() {
      this.getTableList();
    },
    // æœç´¢
    handleSearch() {
    },
    // é‡ç½®æœç´¢æ¡ä»¶
    handleReset() {
    },
    // é€‰æ‹©æ¡†
    selectChange() {
    },
    // ç‚¹å‡»è¡Œ
    rowClickHandler() {
    },
    // æ–°å¢ž
    rowSaveHandlerClick() {
      this.dialogVisible = true;
      this.dialogData = [];
    },
    // ä¿®æ”¹
    rowUpdateHandler() {
    },
    // æžšä¸¾é¡¹æ–°å¢ž
    rowSaveDialogHandler(row, done, loading) {
      const status = this.dialogData.some(item => item.name === row.name);
      if (status) {
        this.$message.error('枚举项名称不能重复添加!')
        loading();
      } else {
        if (this.form.type === "Integer") {
          if (!/^\-?\d+$/.test(row.value)) {
            // å¦‚果原始字符串包含非数字字符,则视为无效
            this.$message.error('枚举值必须是Integer类型');
            return loading();
          }
          let numValue = parseInt(row.value);
          if (isNaN(numValue) || !Number.isInteger(numValue)) {
            // å¦‚æžœ numValue æ˜¯ NaN æˆ–者不是Integer类型,则视为无效
            this.$message.error('枚举值必须是Integer类型');
            return loading();
          }
        }
        if (row.value.length > this.form.num) {
          this.$message.error('枚举值超过最大长度!')
          return loading();
        }
        this.dialogData.push(row);
        done();
      }
    },
    // æžšä¸¾é¡¹ä¿®æ”¹
    rowUpdateDialogHandler(row, index, done, loading) {
      this.dialogData.splice(index, 1, row);
      done();
    },
    // æžšä¸¾é¡¹åˆ é™¤
    rowDeleteDialogHandler(row, index) {
      this.dialogData.splice(index, 1);
    },
    // æ–°å¢žä¿å­˜
    rowSaveHandler() {
      const lengthStatus = this.dialogData.some(item => item.value > this.form.num)
      if (lengthStatus) {
        this.$message.error('请检查枚举值是否超过最大长度!')
        return;
      }
      if(this.form.type === "Integer"){
        // åˆ¤æ–­æ˜¯å¦åŒ…含字符
        const integerStatus = this.dialogData.some(item => {
          if (!/^\-?\d+$/.test(item.value)) {
            return true;
          }
        })
        // åˆ¤æ–­æ˜¯å¦æ˜¯integer格式
        const integerNumStatus =  this.dialogData.some(item => {
          let numValue = parseInt(item.value);
          if (isNaN(numValue) || !Number.isInteger(numValue)) {
            return true;
          }
        })
        if(integerStatus || integerNumStatus){
          this.$message.error('枚举值必须是Integer类型');
          return;
        }
      }
    },
    // åªèƒ½è¾“入英文正则校验
    validateEnglishOnly(rule, value, callback) {
      if (!value) {
        return callback(new Error('请输入枚举项名'));
      }
      if (!/^[A-Za-z]+$/.test(value)) {
        return callback(new Error('只能输入英文字母'));
      }
      callback(); // éªŒè¯é€šè¿‡
    }
  }
}
</script>
<style scoped>
</style>
Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js
Source/plt-web/plt-web-ui/src/views/system/user/option.js
@@ -7,7 +7,7 @@
    rules: [
      {
        required: true,
        message: '请输入姓名',
        message: '请输入账号',
        trigger: 'blur'
      }
    ]