From e977b8737d88aa1bd0286fe27bf4fd22cb2501d9 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期四, 18 七月 2024 17:34:42 +0800 Subject: [PATCH] 整合代码 --- Source/plt-web/plt-web-ui/src/components/actions/handlers.js | 5 Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js | 61 +++++++ Source/plt-web/plt-web-ui/src/util/func.js | 47 +++++ Source/plt-web/plt-web-ui/src/views/modeling/enumType/index.vue | 303 +++++++++++++++++++++++++++++++++++++ Source/plt-web/plt-web-ui/src/store/modules/user.js | 4 Source/plt-web/plt-web-ui/src/views/system/user/option.js | 2 Source/plt-web/plt-web-ui/src/api/modeling/enumType/api.js | 10 + Source/plt-web/plt-web-ui/src/page/index/top/index.vue | 16 + Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js | 0 9 files changed, 443 insertions(+), 5 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/api/modeling/enumType/api.js b/Source/plt-web/plt-web-ui/src/api/modeling/enumType/api.js new file mode 100644 index 0000000..2f055eb --- /dev/null +++ b/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 + }); +} diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js new file mode 100644 index 0000000..3c59f46 --- /dev/null +++ b/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); + } +} diff --git a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js index 78d4ede..e67f42a 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js +++ b/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('鏈壘鍒板搴攁ction锛岃閲嶆柊閰嶇疆鎸夐挳锛�'); } diff --git a/Source/plt-web/plt-web-ui/src/page/index/top/index.vue b/Source/plt-web/plt-web-ui/src/page/index/top/index.vue index 9969734..7225469 100644 --- a/Source/plt-web/plt-web-ui/src/page/index/top/index.vue +++ b/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; diff --git a/Source/plt-web/plt-web-ui/src/store/modules/user.js b/Source/plt-web/plt-web-ui/src/store/modules/user.js index 9aef2f5..99a59e2 100644 --- a/Source/plt-web/plt-web-ui/src/store/modules/user.js +++ b/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); diff --git a/Source/plt-web/plt-web-ui/src/util/func.js b/Source/plt-web/plt-web-ui/src/util/func.js index 2eb5052..32bf2bd 100644 --- a/Source/plt-web/plt-web-ui/src/util/func.js +++ b/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(); + } +} + + diff --git a/Source/plt-web/plt-web-ui/src/views/modeling/enumType/index.vue b/Source/plt-web/plt-web-ui/src/views/modeling/enumType/index.vue new file mode 100644 index 0000000..37c9cc9 --- /dev/null +++ b/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 鎴栬�呬笉鏄疘nteger绫诲瀷锛屽垯瑙嗕负鏃犳晥 + 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; + } + }) + + // 鍒ゆ柇鏄惁鏄痠nteger鏍煎紡 + 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; + } + } + }, + + // 鍙兘杈撳叆鑻辨枃姝e垯鏍¢獙 + 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> diff --git a/Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js b/Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/views/modeling/enumType/option.js diff --git a/Source/plt-web/plt-web-ui/src/views/system/user/option.js b/Source/plt-web/plt-web-ui/src/views/system/user/option.js index 7941331..a4dbce6 100644 --- a/Source/plt-web/plt-web-ui/src/views/system/user/option.js +++ b/Source/plt-web/plt-web-ui/src/views/system/user/option.js @@ -7,7 +7,7 @@ rules: [ { required: true, - message: '璇疯緭鍏ュ鍚�', + message: '璇疯緭鍏ヨ处鍙�', trigger: 'blur' } ] -- Gitblit v1.9.3