@fmdevui/fm-dev
Version:
Page level components developed based on Element Plus.
269 lines (264 loc) • 10.9 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var elementPlus = require('element-plus');
var smCryptoV2 = require('sm-crypto-v2');
require('../../../api/index.js');
var vueI18n = require('vue-i18n');
var index = require('../../../api/sys/index.js');
var request = require('../../../api/utils/request.js');
const _hoisted_1 = { class: "changePassword-container" };
const _hoisted_2 = { style: { "color": "#fff" } };
const _hoisted_3 = { style: { "color": "red", "padding": "10px 10px", "background": "#faecd8", "margin-bottom": "30px" } };
const _hoisted_4 = { class: "dialog-footer" };
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "changePassword",
setup(__props, { expose: __expose }) {
const { t } = vueI18n.useI18n();
const ruleFormRef = vue.ref();
const state = vue.reactive({
isShowDialog: false,
ruleForm: {},
passwordNew2: ""
});
const openDialog = () => {
state.isShowDialog = true;
ruleFormRef.value?.resetFields();
};
const submit = () => {
ruleFormRef.value?.validate(async (valid) => {
if (!valid) return;
var cpwd = { passwordOld: "", passwordNew: "" };
var publicKey = window.__env__.VITE_SM_PUBLIC_KEY;
if (publicKey == "") {
var res = await index.useSysApi().getSmPublicKey();
publicKey = window.__env__.VITE_SM_PUBLIC_KEY = res.data.result ?? "";
}
cpwd.passwordOld = smCryptoV2.sm2.doEncrypt(state.ruleForm.passwordOld, publicKey, 1);
cpwd.passwordNew = smCryptoV2.sm2.doEncrypt(state.ruleForm.passwordNew, publicKey, 1);
await index.useSysApi().changePwd(cpwd);
elementPlus.ElMessage.success(t("message.list.passwordChangedNeedRelogin"));
state.isShowDialog = false;
request.clearAccessTokens();
});
};
const validatePassword = (_rule, value, callback) => {
if (state.passwordNew2 != state.ruleForm.passwordNew) {
callback(new Error(t("message.list.passwordNotMatch")));
} else {
callback();
}
};
const logout = () => {
request.clearAccessTokens();
};
__expose({ openDialog });
return (_ctx, _cache) => {
const _component_ele_View = vue.resolveComponent("ele-View");
const _component_el_icon = vue.resolveComponent("el-icon");
const _component_ele_Bell = vue.resolveComponent("ele-Bell");
const _component_el_input = vue.resolveComponent("el-input");
const _component_el_form_item = vue.resolveComponent("el-form-item");
const _component_el_col = vue.resolveComponent("el-col");
const _component_el_row = vue.resolveComponent("el-row");
const _component_el_form = vue.resolveComponent("el-form");
const _component_el_button = vue.resolveComponent("el-button");
const _component_el_dialog = vue.resolveComponent("el-dialog");
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createVNode(_component_el_dialog, {
modelValue: state.isShowDialog,
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => state.isShowDialog = $event),
draggable: "",
"close-on-click-modal": false,
"close-on-press-escape": false,
width: "700px",
"show-close": false
}, {
header: vue.withCtx(() => [
vue.createElementVNode("div", _hoisted_2, [
vue.createVNode(_component_el_icon, {
size: "16",
style: { "margin-right": "3px", "display": "inline", "vertical-align": "middle" }
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_ele_View)
]),
_: 1
/* STABLE */
}),
vue.createElementVNode(
"span",
null,
vue.toDisplayString(vue.unref(t)("message.list.changePassword")),
1
/* TEXT */
)
])
]),
footer: vue.withCtx(() => [
vue.createElementVNode("span", _hoisted_4, [
vue.createVNode(_component_el_button, {
type: "danger",
plain: "",
onClick: logout
}, {
default: vue.withCtx(() => [
vue.createTextVNode(
vue.toDisplayString(vue.unref(t)("message.list.cancelButtonText")),
1
/* TEXT */
)
]),
_: 1
/* STABLE */
}),
vue.createVNode(_component_el_button, {
type: "primary",
icon: "ele-CircleCheckFilled",
onClick: submit
}, {
default: vue.withCtx(() => [
vue.createTextVNode(
vue.toDisplayString(vue.unref(t)("message.list.confirmButtonText")),
1
/* TEXT */
)
]),
_: 1
/* STABLE */
})
])
]),
default: vue.withCtx(() => [
vue.createElementVNode("div", _hoisted_3, [
vue.createVNode(_component_el_icon, { style: { "transform": "translateY(2px)" } }, {
default: vue.withCtx(() => [
vue.createVNode(_component_ele_Bell)
]),
_: 1
/* STABLE */
}),
vue.createElementVNode(
"span",
null,
vue.toDisplayString(vue.unref(t)("message.list.passwordPolicy")),
1
/* TEXT */
)
]),
vue.createVNode(_component_el_form, {
model: state.ruleForm,
ref_key: "ruleFormRef",
ref: ruleFormRef,
"label-width": "auto"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_row, { gutter: 10 }, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_col, {
xs: 24,
sm: 24,
md: 24,
lg: 24,
xl: 24,
class: "mb20"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_form_item, {
label: vue.unref(t)("message.list.currentPassword"),
prop: "passwordOld",
rules: [{ required: true, message: vue.unref(t)("message.list.currentPasswordRequired"), trigger: "blur" }]
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_input, {
modelValue: state.ruleForm.passwordOld,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.ruleForm.passwordOld = $event),
type: "password",
autocomplete: "off",
"show-password": ""
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}, 8, ["label", "rules"])
]),
_: 1
/* STABLE */
}),
vue.createVNode(_component_el_col, {
xs: 24,
sm: 24,
md: 24,
lg: 24,
xl: 24,
class: "mb20"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_form_item, {
label: vue.unref(t)("message.list.newPassword"),
prop: "passwordNew",
rules: [{ required: true, message: vue.unref(t)("message.list.newPasswordRequired"), trigger: "blur" }]
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_input, {
modelValue: state.ruleForm.passwordNew,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => state.ruleForm.passwordNew = $event),
type: "password",
autocomplete: "off",
"show-password": ""
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}, 8, ["label", "rules"])
]),
_: 1
/* STABLE */
}),
vue.createVNode(_component_el_col, {
xs: 24,
sm: 24,
md: 24,
lg: 24,
xl: 24,
class: "mb20"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_form_item, {
label: vue.unref(t)("message.list.confirmPassword"),
prop: "passwordNew2",
rules: [{ validator: validatePassword, required: true, trigger: "blur" }]
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_input, {
modelValue: state.passwordNew2,
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => state.passwordNew2 = $event),
type: "password",
autocomplete: "off",
"show-password": ""
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}, 8, ["label", "rules"])
]),
_: 1
/* STABLE */
})
]),
_: 1
/* STABLE */
})
]),
_: 1
/* STABLE */
}, 8, ["model"])
]),
_: 1
/* STABLE */
}, 8, ["modelValue"])
]);
};
}
});
exports.default = _sfc_main;