|
@@ -2,7 +2,7 @@
|
|
|
* @Author:
|
|
|
* @Date: 2023-03-01 19:20:44
|
|
|
* @LastEditors: guicheng 1625811865@qq.com
|
|
|
- * @LastEditTime: 2024-06-20 16:08:20
|
|
|
+ * @LastEditTime: 2024-06-21 13:41:18
|
|
|
* @Description: kxs files
|
|
|
* @filePath:
|
|
|
-->
|
|
@@ -13,23 +13,14 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<script setup lang="ts">
|
|
|
-import { inject, ref } from "vue";
|
|
|
-import Uploadfile from "@/components/Uploadfile/index.vue";
|
|
|
-import UploadImg from "@/components/UploadImg/index.vue";
|
|
|
-import Editor from "@/components/Editor/index.vue";
|
|
|
-import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
|
-import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
-import Upload from "@iconify-icons/ri/upload-2-fill";
|
|
|
-import Close from "@iconify-icons/ri/close-fill";
|
|
|
-import { http } from "@/utils/http";
|
|
|
+import { inject, onMounted, reactive, ref, Uploadfile, UploadImg, Editor, useRenderIcon, ElMessage, ElMessageBox, Upload, Close, http, getGroupUrl, RegularVerification, verification } from "@/utils/importUsed"
|
|
|
+// 接口列表实例
|
|
|
+const UserUrl = ref(null)
|
|
|
// 获取当前板块接口列表
|
|
|
-import { getGroupUrl } from "@/utils/getUrl/getUrl";
|
|
|
-// 获取URLLIST
|
|
|
-async function getUerUrl() {
|
|
|
- const result = await getGroupUrl(["User"]);
|
|
|
- return result;
|
|
|
-}
|
|
|
-const UserUrl = getUerUrl();
|
|
|
+onMounted(async () => {
|
|
|
+ UserUrl.value = await getGroupUrl(["User"]);
|
|
|
+})
|
|
|
+// 组件传参对象
|
|
|
const props = defineProps<{
|
|
|
editVisible: {
|
|
|
type: Boolean;
|
|
@@ -61,54 +52,52 @@ const optionList = [
|
|
|
{ Id: "2", label: "实物" },
|
|
|
{ Id: "3", label: "虚拟商品" }
|
|
|
];
|
|
|
+// 表单实例
|
|
|
+const ruleFormRef = ref()
|
|
|
// 富文本实例
|
|
|
const childComp = ref();
|
|
|
// 选项卡参数(默认值为列表某项的id)
|
|
|
const activeId = ref("1");
|
|
|
// 提交函数
|
|
|
-const submit = async () => {
|
|
|
- // 富文本实例赋值
|
|
|
- UpdateForm.value.content = childComp.value.valueHtml;
|
|
|
- console.log(UpdateForm.value);
|
|
|
- const { status, info }: any = http.request(
|
|
|
- UserUrl.User.userSearch.method,
|
|
|
- UserUrl.User.userSearch.url,
|
|
|
- UpdateForm.value
|
|
|
- );
|
|
|
- if (status === "1") {
|
|
|
- ElMessage({
|
|
|
- message: "修改成功",
|
|
|
- type: "success"
|
|
|
- });
|
|
|
- // 清空表单项;
|
|
|
- UpdateForm.value.AdminName = "";
|
|
|
- UpdateForm.value.RealName = "";
|
|
|
- UpdateForm.value.RoleId = "";
|
|
|
- UpdateForm.value.PassWord = "";
|
|
|
- UpdateForm.value.content = "";
|
|
|
- UpdateForm.value.upLoadFile = "";
|
|
|
- UpdateForm.value.upLoadImg = "";
|
|
|
- } else {
|
|
|
- ElMessageBox.alert(info, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
- }
|
|
|
-};
|
|
|
-// 关闭弹窗回调函数
|
|
|
-const closeVisible = inject("closeEditVisible");
|
|
|
-const openVisible = async () => {
|
|
|
- // 将获取到的富文本字段数据重新赋值到富文本实例
|
|
|
- childComp.value.valueHtml = "<p>12312312</p>";
|
|
|
- //通过ID获取表格数据
|
|
|
- const { data, info }: any = http.Request({
|
|
|
- url: UserUrl.User.userSearch.method,
|
|
|
- method: UserUrl.User.userSearch.url,
|
|
|
- params: props.formData.id
|
|
|
- });
|
|
|
- UpdateForm.value = data;
|
|
|
- // 通过表格项获取数据
|
|
|
- UpdateForm.value = props.formData;
|
|
|
+const submit = async (formEl) => {
|
|
|
+ // 表单校验拦截
|
|
|
+ if (!formEl) return
|
|
|
+ await formEl.validate((valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ //表单校验成功回调
|
|
|
+ console.log('submit!')
|
|
|
+ // 富文本实例赋值
|
|
|
+ UpdateForm.value.content = childComp.value.valueHtml;
|
|
|
+ console.log(UpdateForm.value);
|
|
|
+ // 需动态生成接口
|
|
|
+ const { status, info }: any = http.request(
|
|
|
+ UserUrl.User.userSearch.method,
|
|
|
+ UserUrl.User.userSearch.url,
|
|
|
+ UpdateForm.value
|
|
|
+ );
|
|
|
+ if (status === "1") {
|
|
|
+ //业务成功回调
|
|
|
+ ElMessage({
|
|
|
+ message: "修改成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ // 关闭修改弹窗;
|
|
|
+ closeVisible();
|
|
|
+ } else {
|
|
|
+ //业务失败回调
|
|
|
+ ElMessageBox.alert(info, "提示", {
|
|
|
+ confirmButtonText: "关闭",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //表单校验失败回调
|
|
|
+ ElMessage({
|
|
|
+ message: "请输入完整信息",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
//上传文件回调
|
|
@@ -127,6 +116,56 @@ const UploadImgCallBack = (url) => {
|
|
|
});
|
|
|
UpdateForm.value.upLoadImg = url;
|
|
|
}
|
|
|
+// 表单校验规则
|
|
|
+const rules = reactive({
|
|
|
+ RealName: [
|
|
|
+ // 必传
|
|
|
+ { required: true, message: '请输入账户名称', trigger: 'blur' },
|
|
|
+ // 长度
|
|
|
+ { min: 3, max: 5, message: '长度为3-5', trigger: 'blur' },
|
|
|
+ // 时间类型必填
|
|
|
+ {
|
|
|
+ type: 'date',
|
|
|
+ required: true,
|
|
|
+ message: '请选择正确时间类型',
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ // 封装正则
|
|
|
+ {
|
|
|
+ validator: (rule: any, value: any, callback: any) => {
|
|
|
+ verification.verificationName(value, callback)
|
|
|
+ }, trigger: 'blur'
|
|
|
+ },
|
|
|
+ // 自定义正则
|
|
|
+ {
|
|
|
+ validator: (rule: any, value: any, callback: any) => {
|
|
|
+ // 自定义正则替换
|
|
|
+ const regular = /^((13[0-9])|(14(0|[5-7]|9))|(15([0-3]|[5-9]))|(16(2|[5-7]))|(17[0-8])|(18[0-9])|(19([0-3]|[5-9])))\d{8}$/;
|
|
|
+ RegularVerification(regular, value, callback)
|
|
|
+ }, trigger: 'blur'
|
|
|
+ },
|
|
|
+ ],
|
|
|
+})
|
|
|
+
|
|
|
+// 关闭弹窗回调函数
|
|
|
+const closeVisible: any = inject("closeEditVisible");
|
|
|
+
|
|
|
+// 调用修改弹窗函数
|
|
|
+const openVisible = async () => {
|
|
|
+ //通过ID获取表格数据(二选一)
|
|
|
+ const { data, info }: any = http.Request({
|
|
|
+ url: UserUrl.User.userSearch.method,
|
|
|
+ method: UserUrl.User.userSearch.url,
|
|
|
+ params: props.formData.id
|
|
|
+ });
|
|
|
+ UpdateForm.value = data;
|
|
|
+
|
|
|
+ // 通过表格项获取数据(二选一)
|
|
|
+ UpdateForm.value = props.formData;
|
|
|
+
|
|
|
+ // 将获取到的富文本字段数据重新赋值到富文本实例
|
|
|
+ childComp.value.valueHtml = "<p>12312312</p>";
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<template lang="pug">
|
|
@@ -135,7 +174,7 @@ const UploadImgCallBack = (url) => {
|
|
|
//- 有选项卡模板
|
|
|
el-tabs(v-model="activeId" class="demo-tabs" @tab-click="handleClick")
|
|
|
el-tab-pane(label="选项卡一" name="1")
|
|
|
- el-form(:model='UpdateForm' label-position="right" label-width="100px")
|
|
|
+ el-form(ref="ruleFormRef" :model='UpdateForm' label-position="right" label-width="100px" :rules="rules")
|
|
|
el-form-item(label='账户名称' prop="RealName")
|
|
|
el-input(v-model='UpdateForm.RealName' autocomplete='off' class="!w-[230px]"
|
|
|
placeholder="请输入账户名称")
|
|
@@ -152,7 +191,7 @@ const UploadImgCallBack = (url) => {
|
|
|
clearable,
|
|
|
class="!w-[230px]"
|
|
|
)
|
|
|
- el-option(:label="item.label", :value="item.Id" v-for="(item,index) in optionList")
|
|
|
+ el-option(:label="item.label", :value="item.Id" v-for="(item, index) in optionList")
|
|
|
el-form-item(label='上传图片' prop="UploadImg")
|
|
|
UploadImg(:cropper="true" :callBack="UploadImgCallBack" :imgList="UpdateForm.upLoadImg.split(',')")
|
|
|
el-form-item(label='上传文件' prop="Uploadfile")
|
|
@@ -178,7 +217,7 @@ const UploadImgCallBack = (url) => {
|
|
|
clearable,
|
|
|
class="!w-[230px]"
|
|
|
)
|
|
|
- el-option(:label="item.label", :value="item.Id" v-for="(item,index) in optionList")
|
|
|
+ el-option(:label="item.label", :value="item.Id" v-for="(item, index) in optionList")
|
|
|
//- 无选项卡模板
|
|
|
el-form(:model='UpdateForm' label-position="right" label-width="100px")
|
|
|
el-form-item(label='账户名称' prop="RealName")
|
|
@@ -194,17 +233,15 @@ const UploadImgCallBack = (url) => {
|
|
|
clearable,
|
|
|
class="!w-[230px]"
|
|
|
)
|
|
|
- el-option(:label="item.label", :value="item.Id" v-for="(item,index) in optionList")
|
|
|
+ el-option(:label="item.label", :value="item.Id" v-for="(item, index) in optionList")
|
|
|
el-button(
|
|
|
:icon="useRenderIcon(Close)",
|
|
|
- :loading="loading",
|
|
|
- @click="closeVisible()"
|
|
|
+ @click="closeVisible"
|
|
|
) 关闭
|
|
|
el-button(
|
|
|
type="primary",
|
|
|
:icon="useRenderIcon(Upload)",
|
|
|
- :loading="loading",
|
|
|
- @click="submit"
|
|
|
+ @click="submit(ruleFormRef)"
|
|
|
) 确认提交
|
|
|
</template>
|
|
|
|