|
@@ -2,7 +2,7 @@
|
|
* @Author:
|
|
* @Author:
|
|
* @Date: 2023-03-01 19:20:44
|
|
* @Date: 2023-03-01 19:20:44
|
|
* @LastEditors: guicheng 1625811865@qq.com
|
|
* @LastEditors: guicheng 1625811865@qq.com
|
|
- * @LastEditTime: 2024-06-20 15:58:15
|
|
|
|
|
|
+ * @LastEditTime: 2024-06-21 13:42:43
|
|
* @Description: kxs files
|
|
* @Description: kxs files
|
|
* @filePath:
|
|
* @filePath:
|
|
-->
|
|
-->
|
|
@@ -13,24 +13,14 @@ export default {
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
<script setup lang="ts">
|
|
<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<{
|
|
const props = defineProps<{
|
|
submit: Function;
|
|
submit: Function;
|
|
addVisible: {
|
|
addVisible: {
|
|
@@ -52,16 +42,18 @@ const UpdateForm = ref({
|
|
upLoadFile: "",
|
|
upLoadFile: "",
|
|
upLoadImg: "",
|
|
upLoadImg: "",
|
|
});
|
|
});
|
|
|
|
+// 表单实例
|
|
|
|
+const ruleFormRef = ref()
|
|
// 富文本实例
|
|
// 富文本实例
|
|
const childComp = ref();
|
|
const childComp = ref();
|
|
// 传参选项数据
|
|
// 传参选项数据
|
|
|
|
+// 选项卡参数(默认值为列表某项的id)
|
|
|
|
+const activeId = ref("1");
|
|
const optionList = [
|
|
const optionList = [
|
|
{ Id: "1", label: "推荐" },
|
|
{ Id: "1", label: "推荐" },
|
|
{ Id: "2", label: "实物" },
|
|
{ Id: "2", label: "实物" },
|
|
{ Id: "3", label: "虚拟商品" }
|
|
{ Id: "3", label: "虚拟商品" }
|
|
];
|
|
];
|
|
-// 选项卡参数(默认值为列表某项的id)
|
|
|
|
-const activeId = ref("1");
|
|
|
|
// 穿梭框数据
|
|
// 穿梭框数据
|
|
const transferdata = ref([
|
|
const transferdata = ref([
|
|
{ key: 1, label: "1", disabled: false },
|
|
{ key: 1, label: "1", disabled: false },
|
|
@@ -73,41 +65,46 @@ const transferdata = ref([
|
|
]);
|
|
]);
|
|
// 提交函数
|
|
// 提交函数
|
|
const submit = async () => {
|
|
const submit = async () => {
|
|
- // 富文本实例赋值
|
|
|
|
- UpdateForm.value.content = childComp.value.valueHtml;
|
|
|
|
- const { status, info }: any = http.Request({
|
|
|
|
- url: UserUrl.User.userSearch.method,
|
|
|
|
- method: UserUrl.User.userSearch.url,
|
|
|
|
- params: 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 closeFn: any = inject("closeAddVisible");
|
|
|
|
-// 关闭弹窗回调函数
|
|
|
|
-const closeVisible = () => {
|
|
|
|
- UpdateForm.value.AdminName = "";
|
|
|
|
- UpdateForm.value.RealName = "";
|
|
|
|
- UpdateForm.value.RoleId = "";
|
|
|
|
- UpdateForm.value.PassWord = "";
|
|
|
|
- closeFn();
|
|
|
|
|
|
+ // 表单校验拦截
|
|
|
|
+ if (!formEl) return
|
|
|
|
+ await formEl.validate((valid, fields) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ //表单校验成功回调
|
|
|
|
+ console.log('submit!')
|
|
|
|
+ // 富文本实例赋值
|
|
|
|
+ UpdateForm.value.content = childComp.value.valueHtml;
|
|
|
|
+
|
|
|
|
+ // 需动态生成接口
|
|
|
|
+ const { status, info }: any = http.Request({
|
|
|
|
+ url: UserUrl.User.userSearch.method,
|
|
|
|
+ method: UserUrl.User.userSearch.url,
|
|
|
|
+ params: UpdateForm.value
|
|
|
|
+ });
|
|
|
|
+ if (status === "1") {
|
|
|
|
+ //业务成功回调
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "新增成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ // 关闭新增弹窗;
|
|
|
|
+ closeVisible()
|
|
|
|
+ } else {
|
|
|
|
+ //业务失败回调
|
|
|
|
+ ElMessageBox.alert(info, "提示", {
|
|
|
|
+ confirmButtonText: "关闭",
|
|
|
|
+ type: "warning"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //表单校验失败回调
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "请输入完整信息",
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
};
|
|
};
|
|
|
|
+// 选项卡切换回调
|
|
const handleClick = () => {
|
|
const handleClick = () => {
|
|
console.log("切换选项卡");
|
|
console.log("切换选项卡");
|
|
};
|
|
};
|
|
@@ -128,6 +125,43 @@ const UploadImgCallBack = (url) => {
|
|
});
|
|
});
|
|
UpdateForm.value.upLoadImg = 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 closeFn: any = inject("closeAddVisible");
|
|
|
|
+const closeVisible = () => {
|
|
|
|
+ // 清空表单项;
|
|
|
|
+ ruleFormRef.value.resetFields();
|
|
|
|
+ closeFn();
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template lang="pug">
|
|
<template lang="pug">
|
|
@@ -136,7 +170,7 @@ const UploadImgCallBack = (url) => {
|
|
//- 有选项卡模板
|
|
//- 有选项卡模板
|
|
el-tabs(v-model="activeId" class="demo-tabs" @tab-click="handleClick")
|
|
el-tabs(v-model="activeId" class="demo-tabs" @tab-click="handleClick")
|
|
el-tab-pane(label="选项卡一" name="1")
|
|
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='账户名称1' prop="RealName")
|
|
el-form-item(label='账户名称1' prop="RealName")
|
|
el-input(v-model='UpdateForm.RealName' autocomplete='off' class="!w-[230px]"
|
|
el-input(v-model='UpdateForm.RealName' autocomplete='off' class="!w-[230px]"
|
|
placeholder="请输入账户名称")
|
|
placeholder="请输入账户名称")
|
|
@@ -153,7 +187,7 @@ const UploadImgCallBack = (url) => {
|
|
clearable,
|
|
clearable,
|
|
class="!w-[230px]"
|
|
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-tab-pane(label="选项卡二" name="2")
|
|
el-tab-pane(label="选项卡二" name="2")
|
|
el-form(:model='UpdateForm' label-position="right" label-width="100px")
|
|
el-form(:model='UpdateForm' label-position="right" label-width="100px")
|
|
el-form-item(label='账户名称2' prop="RealName")
|
|
el-form-item(label='账户名称2' prop="RealName")
|
|
@@ -172,7 +206,7 @@ const UploadImgCallBack = (url) => {
|
|
clearable,
|
|
clearable,
|
|
class="!w-[230px]"
|
|
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(:model='UpdateForm' label-position="right" label-width="100px")
|
|
el-form-item(label='账户名称' prop="RealName")
|
|
el-form-item(label='账户名称' prop="RealName")
|
|
@@ -191,7 +225,7 @@ const UploadImgCallBack = (url) => {
|
|
clearable,
|
|
clearable,
|
|
class="!w-[230px]"
|
|
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="PassWord")
|
|
el-form-item(label='取色器' prop="PassWord")
|
|
el-color-picker(v-model="UpdateForm.AdminName" show-alpha)
|
|
el-color-picker(v-model="UpdateForm.AdminName" show-alpha)
|
|
el-form-item(label='数字输入框' prop="PassWord")
|
|
el-form-item(label='数字输入框' prop="PassWord")
|
|
@@ -223,7 +257,7 @@ const UploadImgCallBack = (url) => {
|
|
el-button(
|
|
el-button(
|
|
type="primary",
|
|
type="primary",
|
|
:icon="useRenderIcon(Upload)",
|
|
:icon="useRenderIcon(Upload)",
|
|
- @click="submit"
|
|
|
|
|
|
+ @click="submit(ruleFormRef)"
|
|
) 确认提交
|
|
) 确认提交
|
|
</template>
|
|
</template>
|
|
|
|
|