|
|
@@ -0,0 +1,456 @@
|
|
|
+<template>
|
|
|
+ <div class="vip-edit-page">
|
|
|
+ <div class="page-inner">
|
|
|
+ <div class="card header-card">
|
|
|
+ <div class="edit-header">
|
|
|
+ <zy-button class="back-btn" type="primary" link @click="goBack">返回</zy-button>
|
|
|
+ <span class="edit-title">身份等级编辑</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="edit-content">
|
|
|
+ <div class="card basic-card">
|
|
|
+ <div class="card-title">基本信息</div>
|
|
|
+ <zy-form label-position="top" class="basic-form">
|
|
|
+ <zy-form-item label="身份等级名称:">
|
|
|
+ <zy-input v-model="form.levelName" placeholder="请输入等级名称" />
|
|
|
+ </zy-form-item>
|
|
|
+ <zy-form-item v-if="isCreate" label="身份等级编号:">
|
|
|
+ <zy-input v-model="form.levelCode" placeholder="请输入等级编号" />
|
|
|
+ </zy-form-item>
|
|
|
+ <zy-form-item label="身份等级图标:">
|
|
|
+ <zy-upload
|
|
|
+ :action="fileUpdateUrl"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :file-list="iconFileList"
|
|
|
+ :headers="fileUpdateHeaders"
|
|
|
+ :limit="5"
|
|
|
+ :on-exceed="handlePictureExceed"
|
|
|
+ :on-preview="handlePictureCardPreview"
|
|
|
+ :on-success="handleUploadSuccess"
|
|
|
+ class="avatar-uploader"
|
|
|
+ list-type="picture-card"
|
|
|
+ name="newsFile"
|
|
|
+ >
|
|
|
+ <zy-icon class="avatar-uploader-icon">
|
|
|
+ <el-icon-plus />
|
|
|
+ </zy-icon>
|
|
|
+ </zy-upload>
|
|
|
+ </zy-form-item>
|
|
|
+ <zy-form-item label="全流程主题:">
|
|
|
+ <zy-select v-model="form.theme">
|
|
|
+ <zy-option
|
|
|
+ v-for="item in themeOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </zy-select>
|
|
|
+ </zy-form-item>
|
|
|
+ <zy-form-item label="当前状态:">
|
|
|
+ <zy-select v-model="form.status">
|
|
|
+ <zy-option label="上架" value="1" />
|
|
|
+ <zy-option label="下架" value="0" />
|
|
|
+ </zy-select>
|
|
|
+ </zy-form-item>
|
|
|
+ </zy-form>
|
|
|
+ <zy-button type="primary" class="save-btn" @click="handleSave">保存信息</zy-button>
|
|
|
+ <zy-button
|
|
|
+ v-if="!isCreate"
|
|
|
+ class="delete-btn"
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="handleDelete"
|
|
|
+ >
|
|
|
+ 删除身份等级
|
|
|
+ </zy-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { computed, getCurrentInstance, onMounted, reactive, ref } from "vue";
|
|
|
+import { useRoute, useRouter } from "vue-router";
|
|
|
+
|
|
|
+const route = useRoute();
|
|
|
+const router = useRouter();
|
|
|
+
|
|
|
+const isCreate = computed(() => route.query.mode !== "edit");
|
|
|
+
|
|
|
+const form = reactive({
|
|
|
+ levelName: "", // 新建时为空,编辑时在 onMounted 里填充
|
|
|
+ levelCode: "",
|
|
|
+ iconTheme: "tag-vip",
|
|
|
+ levelIconLabel: "",
|
|
|
+ shelfText: "上架",
|
|
|
+ theme: "", // 真实值由主题字典返回
|
|
|
+ status: "1", // 1=上架, 0=下架
|
|
|
+});
|
|
|
+
|
|
|
+const goBack = () => {
|
|
|
+ router.back();
|
|
|
+};
|
|
|
+
|
|
|
+const toggleShelf = () => {
|
|
|
+ if (form.shelfText === "上架") {
|
|
|
+ form.shelfText = "下架";
|
|
|
+ form.status = "0";
|
|
|
+ } else {
|
|
|
+ form.shelfText = "上架";
|
|
|
+ form.status = "1";
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as any;
|
|
|
+
|
|
|
+// 上传相关状态
|
|
|
+const iconFileList = ref<any[]>([]);
|
|
|
+const viewPictureUrl = ref("");
|
|
|
+const viewPictureModal = ref(false);
|
|
|
+
|
|
|
+// 主题下拉数据
|
|
|
+const themeOptions = ref<{ label: string; value: string }[]>([]);
|
|
|
+
|
|
|
+// 从全局配置里取后端 baseURL
|
|
|
+const baseURL = (window as any).config?.baseURL || "";
|
|
|
+
|
|
|
+// 上传地址和头信息
|
|
|
+const fileUpdateUrl = computed(
|
|
|
+ () => `${baseURL}/upload/uploadFile.do?fileDir=identityLevel`
|
|
|
+);
|
|
|
+const fileUpdateHeaders = computed(() => ({
|
|
|
+ token: proxy.$toolEntry.cookie.get("token"),
|
|
|
+}));
|
|
|
+
|
|
|
+// 图片超出数量
|
|
|
+const handlePictureExceed = () => {
|
|
|
+ proxy.$message.error("图片超出上传个数限制");
|
|
|
+};
|
|
|
+
|
|
|
+// 预览
|
|
|
+const handlePictureCardPreview = (file: any) => {
|
|
|
+ viewPictureUrl.value = file.url;
|
|
|
+ viewPictureModal.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+// 上传前校验
|
|
|
+const beforeAvatarUpload = (file: any) => {
|
|
|
+ const isImage =
|
|
|
+ file.type === "image/jpeg" || file.type === "image/png";
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+
|
|
|
+ if (!isImage) {
|
|
|
+ proxy.$message.error("图片格式不正确!");
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ proxy.$message.error("图片大小不能超过 2MB!");
|
|
|
+ }
|
|
|
+ return isImage && isLt2M;
|
|
|
+};
|
|
|
+
|
|
|
+// 上传成功
|
|
|
+const handleUploadSuccess = (response: any, file: any) => {
|
|
|
+
|
|
|
+ if (response.RespCode !== 10000) {
|
|
|
+ proxy.$message.error(response.RespMessage || "上传失败");
|
|
|
+ } else {
|
|
|
+ // 把所有的反斜杠统一替换成正斜杠
|
|
|
+ const url = (response.url || "").replace(/\\+/g, "/");
|
|
|
+ file.url = url;
|
|
|
+
|
|
|
+ // 把图标地址存到表单里,保存时一并提交
|
|
|
+ form.levelIconLabel = url;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 保存(新建 / 修改)
|
|
|
+const handleSave = async () => {
|
|
|
+ if (!form.levelName) {
|
|
|
+ proxy.$message.warning("请输入身份等级名称");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isCreate.value && !form.levelCode) {
|
|
|
+ proxy.$message.warning("请输入身份等级编号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const payload: any = {
|
|
|
+ IdLevelName: form.levelName,
|
|
|
+ IdLevelCode: form.levelCode,
|
|
|
+ IdLevelIcon: form.levelIconLabel,
|
|
|
+ Theme: form.theme,
|
|
|
+ Status: Number(form.status), // 直接转换为数字:1=上架, 0=下架
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ let resWrap;
|
|
|
+ console.log(payload);
|
|
|
+
|
|
|
+ if (isCreate.value) {
|
|
|
+ // 新建
|
|
|
+ ({ res: resWrap } = await proxy.$interfaceEntry.vip.InsertPatientLevel(payload));
|
|
|
+ } else {
|
|
|
+ // 修改
|
|
|
+ ({ res: resWrap } = await proxy.$interfaceEntry.vip.UpdatePatientLevel(payload));
|
|
|
+ }
|
|
|
+ const data = resWrap?.data || {};
|
|
|
+ if (data.RespCode == 10000) {
|
|
|
+ proxy.$message.success(isCreate.value ? "新增成功" : "修改成功");
|
|
|
+ router.back();
|
|
|
+ } else {
|
|
|
+ proxy.$message.error(data.errorMsg || data.msg || "保存失败");
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ proxy.$message.error("保存失败");
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 删除身份等级
|
|
|
+const handleDelete = async () => {
|
|
|
+ if (!form.levelCode) {
|
|
|
+ proxy.$message.warning("无法获取身份等级编号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 确认删除
|
|
|
+ await proxy.$messageBox.confirm("确定要删除该身份等级吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+
|
|
|
+ // 用户确认后执行删除
|
|
|
+ const { res } = await proxy.$interfaceEntry.vip.DelPatientLevel({
|
|
|
+ IdLevelCode: form.levelCode,
|
|
|
+ });
|
|
|
+
|
|
|
+ const data = res?.data || {};
|
|
|
+ if (data.RespCode == 10000) {
|
|
|
+ proxy.$message.success("删除成功");
|
|
|
+ router.back();
|
|
|
+ } else {
|
|
|
+ proxy.$message.error(data.errorMsg || data.msg || "删除失败");
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ // 用户取消删除时,confirm 会 reject,这里不处理
|
|
|
+ // 如果是其他错误,提示删除失败
|
|
|
+ if (e && e !== "cancel" && typeof e !== "string") {
|
|
|
+ proxy.$message.error("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 查询主题字典
|
|
|
+const queryTheme = async () => {
|
|
|
+ try {
|
|
|
+ const { res } = await proxy.$interfaceEntry.vip.QueryDictList({
|
|
|
+ dictType: "VipColor",
|
|
|
+ });
|
|
|
+ const data = res.data || {};
|
|
|
+ const list =
|
|
|
+ data.Data ||
|
|
|
+ data.data ||
|
|
|
+ data.result ||
|
|
|
+ data.list ||
|
|
|
+ [];
|
|
|
+
|
|
|
+ if (Array.isArray(list) && list.length) {
|
|
|
+ themeOptions.value = list.map((item: any) => ({
|
|
|
+ label:
|
|
|
+ item.dictLabel,
|
|
|
+ value:
|
|
|
+ item.dictValue
|
|
|
+ }));
|
|
|
+ if (!form.theme) {
|
|
|
+ form.theme = themeOptions.value[0].value;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ themeOptions.value = [
|
|
|
+ { label: "金色", value: "gold" },
|
|
|
+ { label: "银色", value: "silver" },
|
|
|
+ { label: "蓝色", value: "blue" },
|
|
|
+ ];
|
|
|
+ if (!form.theme) {
|
|
|
+ form.theme = themeOptions.value[0].value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ themeOptions.value = [
|
|
|
+ { label: "金色", value: "gold" },
|
|
|
+ { label: "银色", value: "silver" },
|
|
|
+ { label: "蓝色", value: "blue" },
|
|
|
+ ];
|
|
|
+ if (!form.theme) {
|
|
|
+ form.theme = themeOptions.value[0].value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ // 如果是编辑,从路由参数里回填表单
|
|
|
+ if (!isCreate.value) {
|
|
|
+ form.levelName = (route.query.name as string) || "";
|
|
|
+ form.levelCode = (route.query.code as string) || "";
|
|
|
+ form.theme = (route.query.theme as string) || "";
|
|
|
+ form.status = (route.query.status as string) || "1"; // 1=上架, 0=下架
|
|
|
+ form.levelIconLabel = (route.query.icon as string) || "";
|
|
|
+ if (form.levelIconLabel) {
|
|
|
+ iconFileList.value = [
|
|
|
+ {
|
|
|
+ name: "icon",
|
|
|
+ url: form.levelIconLabel,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ queryTheme();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+.vip-edit-page {
|
|
|
+ min-height: 100%;
|
|
|
+ padding: 24px 0 32px;
|
|
|
+ background: #f5f7fb;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.page-inner {
|
|
|
+ width: 1600px;
|
|
|
+ margin: 0 auto;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.card {
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 8px;
|
|
|
+ box-shadow: 0 6px 24px rgba(44, 69, 105, 0.08);
|
|
|
+ padding: 20px 24px;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.header-card {
|
|
|
+ padding: 12px 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.edit-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.edit-title {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: var(--el-text-color-primary);
|
|
|
+}
|
|
|
+
|
|
|
+.edit-content {
|
|
|
+ display: flex;
|
|
|
+ gap: 16px;
|
|
|
+ flex: 1;
|
|
|
+ align-items: flex-start;
|
|
|
+}
|
|
|
+
|
|
|
+.basic-card {
|
|
|
+ width: 300px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.basic-form :deep(.el-form-item) {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.basic-form :deep(.el-form-item__label) {
|
|
|
+ line-height: 20px;
|
|
|
+ padding-bottom: 6px;
|
|
|
+ color: #606266;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
+
|
|
|
+.basic-form :deep(.el-form-item__content) {
|
|
|
+ flex: none;
|
|
|
+}
|
|
|
+
|
|
|
+.basic-form :deep(.el-input__wrapper),
|
|
|
+.basic-form :deep(.el-select) {
|
|
|
+ width: 260px;
|
|
|
+}
|
|
|
+
|
|
|
+.icon-field {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.status-link {
|
|
|
+ color: #409eff;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+
|
|
|
+.save-btn {
|
|
|
+ width: 100%;
|
|
|
+ background: var(--el-color-primary);
|
|
|
+ border-color: var(--el-color-primary);
|
|
|
+}
|
|
|
+
|
|
|
+.delete-btn {
|
|
|
+ align-self: center;
|
|
|
+ color: var(--el-color-primary);
|
|
|
+}
|
|
|
+
|
|
|
+.level-tag {
|
|
|
+ display: inline-block;
|
|
|
+ min-width: 48px;
|
|
|
+ text-align: center;
|
|
|
+ padding: 4px 12px;
|
|
|
+ border-radius: 6px;
|
|
|
+ color: #fff;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+.tag-vip {
|
|
|
+ background: #f69c45;
|
|
|
+}
|
|
|
+
|
|
|
+/* 图片上传样式:图片卡片+加号按钮 */
|
|
|
+.avatar-uploader :deep(.el-upload) {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ width: 86px;
|
|
|
+ height: 86px;
|
|
|
+ background-color: #fafafa;
|
|
|
+}
|
|
|
+
|
|
|
+.avatar-uploader :deep(.el-upload:hover) {
|
|
|
+ border-color: var(--el-color-primary);
|
|
|
+}
|
|
|
+
|
|
|
+.avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 86px;
|
|
|
+ height: 86px;
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+.avatar-uploader :deep(.el-upload-list__item) {
|
|
|
+ width: 86px;
|
|
|
+ height: 86px;
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|