Compare commits
	
		
			2 Commits
		
	
	
		
			85d88da9f9
			...
			3e7f25d00b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3e7f25d00b | |||
| a6344ce7f6 | 
| @ -39,6 +39,7 @@ export function getBrandInfo(id) { | ||||
|     method: "get", | ||||
|   }); | ||||
| } | ||||
| //品牌启用停用
 | ||||
| export function updateStatusBrand(data) { | ||||
|   return request({ | ||||
|     url: "brand/brandbase/updateStatus", | ||||
| @ -79,3 +80,54 @@ export function applicationrenewalApprove(data) { | ||||
|     data: data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 获取品牌使用管理列表
 | ||||
| export function brandUsingList(query) { | ||||
|   return request({ | ||||
|     url: "/brand/brandUsingSystem/page", | ||||
|     method: "get", | ||||
|     params: query, | ||||
|   }); | ||||
| } | ||||
| // 新增品牌使用
 | ||||
| export function addBrandUsing(data) { | ||||
|   return request({ | ||||
|     url: "/brand/brandUsingSystem/save", | ||||
|     method: "post", | ||||
|     data: data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 编辑品牌使用
 | ||||
| export function updateBrandUsing(data) { | ||||
|   return request({ | ||||
|     url: "/brand/brandUsingSystem/update", | ||||
|     method: "post", | ||||
|     data: data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 获取品牌使用管理详情(id)
 | ||||
| export function getBrandUsing(id) { | ||||
|   return request({ | ||||
|     url: `/brand/brandUsingSystem/detail/${id}`, | ||||
|     method: "get", | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| //  删除品牌使用管理
 | ||||
| export function deleteBrandUsing(id) { | ||||
|   return request({ | ||||
|     url: '/brand/brandUsingSystem/del?ids=' + id, | ||||
|     method: "delete", | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| //品牌使用管理启用停用
 | ||||
| export function updateStatusBrandUsing(data) { | ||||
|   return request({ | ||||
|     url: "/brand/brandUsingSystem/enable", | ||||
|     method: "post", | ||||
|     data: data, | ||||
|   }); | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| <template> | ||||
|     <div class="component-upload-image"> | ||||
|         <div class="upload-tip">图片比例1:1,建议尺寸为800 * 800px,支持png、jpg、gif等格式,大小 {{ fileSize }} MB以内</div> | ||||
|         <div class="upload-tip">图片比例1:1,建议尺寸为800 * 800px,支持{{fileType.join(",")}}等格式,大小 {{ fileSize }} MB以内</div> | ||||
|         <el-upload multiple :disabled="disabled" :action="uploadImgUrl" list-type="picture-card" | ||||
|             :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload" :data="data" :limit="limit" | ||||
|             :on-error="handleUploadError" :on-exceed="handleExceed" ref="imageUpload" :before-remove="handleDelete" | ||||
|  | ||||
| @ -423,18 +423,18 @@ export const constantRoutes = [ | ||||
|         }, | ||||
|         name: "renewal", | ||||
|       }, | ||||
|       // {
 | ||||
|       //   path: 'brand/management',
 | ||||
|       //   component: () => import('@/views/brand/management/index'),
 | ||||
|       //   hidden: false,
 | ||||
|       //   meta: {
 | ||||
|       //     title: "品牌使用管理",
 | ||||
|       //     icon: "",
 | ||||
|       //     noCache: false,
 | ||||
|       //     link: null,
 | ||||
|       //   },
 | ||||
|       //   name: "management",
 | ||||
|       // },
 | ||||
|       { | ||||
|         path: 'brand/management', | ||||
|         component: () => import('@/views/brand/management/index'), | ||||
|         hidden: false, | ||||
|         meta: { | ||||
|           title: "品牌使用管理", | ||||
|           icon: "", | ||||
|           noCache: false, | ||||
|           link: null, | ||||
|         }, | ||||
|         name: "management", | ||||
|       }, | ||||
|     ], | ||||
|   }, | ||||
|   { | ||||
|  | ||||
| @ -289,7 +289,18 @@ const handleSelectionChange = (selection) => { | ||||
| // 批量删除 | ||||
| const batchDelete = async () => { | ||||
|   // deleteGoods(selectedIds.value.join(",")); | ||||
|   deleteGoods(selectedIds.value); | ||||
|   ElMessageBox.confirm("确定要删除选中的数据吗?", "提示", { | ||||
|     confirmButtonText: "确定", | ||||
|     cancelButtonText: "取消", | ||||
|     type: "warning", | ||||
|   }) | ||||
|     .then(async () => { | ||||
|        deleteGoods(selectedIds.value); | ||||
|     }) | ||||
|     .catch(() => { | ||||
|       ElMessage.info("已取消删除"); | ||||
|     }) | ||||
|    | ||||
| }; | ||||
| const deleteGoods = async (param) => { | ||||
|   console.log("批量删除参数:", param); | ||||
|  | ||||
| @ -111,7 +111,8 @@ | ||||
|           <template #action="slotProps"> | ||||
|             <el-button v-if="slotProps.row.status == 0" text class="el-button-custom" @click="startStop(slotProps.row)">启用</el-button> | ||||
|             <el-button v-if="slotProps.row.status == 1" text class="el-button-custom" @click="startStop(slotProps.row)">停用</el-button> | ||||
|             <el-button text class="el-button-custom" @click="handleEdit(slotProps.row)">编辑</el-button> | ||||
|             <el-button text class="el-button-custom" @click="handleEdit(slotProps.row,'edit')">编辑</el-button> | ||||
|             <el-button text class="el-button-custom" @click="handleEdit(slotProps.row,'details')">查看</el-button> | ||||
|             <el-button text class="el-button-delete" @click="handleDelete(slotProps.row)">删除</el-button> | ||||
|           </template> | ||||
|         </tableComponent> | ||||
| @ -119,12 +120,32 @@ | ||||
|     </div> | ||||
|     <!-- 添加/编辑商品 --> | ||||
|     <el-dialog v-model="dialogFormVisible" :title="dialogTitle" width="500" :close-on-click-modal="false"> | ||||
|       <el-form :model="dialogForm" :label-width="'80'" :rules="dialogFormRules" ref="dialogRef"> | ||||
|         <el-form-item label="品牌名称" prop="title"> | ||||
|       <el-form :disabled="isDetails" :model="dialogForm" :label-width="'80'" :rules="dialogFormRules" ref="dialogRef"> | ||||
|         <el-form-item label="制度名称" prop="title"> | ||||
|           <el-input v-model="dialogForm.title" autocomplete="off" placeholder="请输入品牌名称" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="品牌图片" prop="imgPath"> | ||||
|           <myUploadImage v-model="dialogForm.imgPath" :limit="1" ></myUploadImage> | ||||
|         <el-form-item label="上传文件" prop="files"> | ||||
|           <!-- <myUploadFile v-model="dialogForm.files"></myUploadFile> --> | ||||
|            <el-upload | ||||
|             v-model:file-list="dialogForm.files" | ||||
|             :before-upload="handleBeforeUpload" | ||||
|             class="upload-demo" | ||||
|             :action="uploadFileUrl" | ||||
|             multiple | ||||
|             :on-preview="handlePreview" | ||||
|             :on-remove="handleRemove" | ||||
|             :before-remove="beforeRemove" | ||||
|             :limit="limit" | ||||
|             :on-exceed="handleExceed" | ||||
|             :headers="headers" | ||||
|           > | ||||
|             <el-button type="primary">上传文件</el-button> | ||||
|             <template #tip> | ||||
|               <div class="el-upload__tip"> | ||||
|                 只允许上传"doc", "docx", "pdf"文件且文件大小需小于 {{fileSize}}MB. | ||||
|               </div> | ||||
|             </template> | ||||
|           </el-upload> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|       <template #footer> | ||||
| @ -141,11 +162,19 @@ | ||||
| <script setup> | ||||
| import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue"; | ||||
| import tableComponent from "@/components/tableComponent.vue"; | ||||
| import myUploadImage from "@/components/myUploadImage.vue"; | ||||
| import Mock from "mockjs"; | ||||
| import {getBrandbaseList,addBrand,updateBrand,deleteBrand,getBrandInfo,updateStatusBrand} from "@/api/brand/index"; | ||||
| import {brandUsingList,addBrandUsing,updateBrandUsing,deleteBrandUsing,getBrandUsing,updateStatusBrandUsing} from "@/api/brand/index"; | ||||
| import { id } from "element-plus/es/locales.mjs"; | ||||
| import { ElMessage,ElMessageBox } from "element-plus"; | ||||
| import { getToken } from "@/utils/auth" | ||||
| 
 | ||||
| const action = "/uploadApis/upload"; // 上传文件接口地址 | ||||
| const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + action) // 上传文件服务器地址 | ||||
| const headers = ref({ Authorization: "Bearer " + getToken() }) | ||||
| 
 | ||||
| const fileSize = ref(10); // 文件大小限制,单位为MB | ||||
| const fileType = ref(["doc", "docx", "pdf"]); | ||||
| const limit = ref(5); // 文件上传数量限制 | ||||
| 
 | ||||
| const formInline = reactive({ | ||||
|   id: "", | ||||
| @ -161,6 +190,7 @@ const formInline = reactive({ | ||||
|   size: 10, | ||||
| }); | ||||
| 
 | ||||
| let isDetails = ref(true); | ||||
| let isADD = ref(true); | ||||
| const dialogFormVisible = ref(false); | ||||
| const dialogRef = ref(null); | ||||
| @ -168,13 +198,16 @@ const dialogTitle = ref("添加品牌"); | ||||
| let dialogForm = reactive({ | ||||
|     id: "", | ||||
|     title: "", | ||||
|     imgPath:"", | ||||
|     files:[], | ||||
| 
 | ||||
| }); | ||||
| const dialogFormRules = ref({ | ||||
|     title:  [ | ||||
|         { required: true, message: "请输入品牌名称", trigger: "blur" }, | ||||
|     ] | ||||
|     ], | ||||
|     files:  [ | ||||
|         { required: true, message: "请上传文件", trigger: "blur" }, | ||||
|     ], | ||||
| }); | ||||
| 
 | ||||
| const statusList = ref([ | ||||
| @ -208,7 +241,7 @@ const loadData = async () => { | ||||
|   try { | ||||
|     prams.startDate = formInline.startDate ? formInline.startDate + " 00:00:00" : ""; | ||||
|     prams.endDate = formInline.endDate ? formInline.endDate + " 23:59:59" : ""; | ||||
|     let response = await getBrandbaseList(prams); | ||||
|     let response = await brandUsingList(prams); | ||||
|     if (response.code == 200) { | ||||
|       tableData.value = response.data.records; | ||||
|       tableTotal.value = response.data.total; | ||||
| @ -243,7 +276,7 @@ let nowClickRow = ref({}); | ||||
| const columns = ref([ | ||||
|   { prop: "id", label: "ID" }, | ||||
|   { prop: "title", label: "制度名称" }, | ||||
| //   { prop: "code", label: "品牌编码", width: "120" }, | ||||
|   // { prop: "code", label: "品牌编码", width: "120" }, | ||||
|   { prop: "createTime", label: "提交时间" }, | ||||
| //   { prop: "applicationNum", label: "申请数量" }, | ||||
| //   { prop: "useNum", label: "使用数量" }, | ||||
| @ -257,6 +290,8 @@ const getHeaderClass = ({ column }) => { | ||||
| // 分页变化 | ||||
| const handlePaginationChange = ({ page, pageSize }) => { | ||||
|   console.log("分页变化:", page, pageSize); | ||||
|   formInline.current = page; | ||||
|   formInline.size = pageSize; | ||||
|   // 这里可以调用API获取新数据 | ||||
|   loadData(); | ||||
| }; | ||||
| @ -272,14 +307,25 @@ const handleSelectionChange = (selection) => { | ||||
| // 批量删除 | ||||
| const batchDelete = async () => { | ||||
|   // deleteGoods(selectedIds.value.join(",")); | ||||
|   deleteGoods(selectedIds.value); | ||||
|   ElMessageBox.confirm("确定要删除选中的数据吗?", "提示", { | ||||
|     confirmButtonText: "确定", | ||||
|     cancelButtonText: "取消", | ||||
|     type: "warning", | ||||
|   }) | ||||
|     .then(async () => { | ||||
|        deleteGoods(selectedIds.value); | ||||
|     }) | ||||
|     .catch(() => { | ||||
|       ElMessage.info("已取消删除"); | ||||
|     }) | ||||
|   | ||||
| }; | ||||
| const deleteGoods = async (param) => { | ||||
|   console.log("批量删除参数:", param); | ||||
|    | ||||
|   try { | ||||
|     tableLoading.value = true; | ||||
|     let res = await deleteBrand(param); | ||||
|     let res = await deleteBrandUsing(param); | ||||
|     tableLoading.value = false; | ||||
|     if (res.code == 200) { | ||||
|       ElMessage.success("删除成功"); | ||||
| @ -294,6 +340,7 @@ const deleteGoods = async (param) => { | ||||
| 
 | ||||
| //  添加商品 | ||||
| const handleAdd = () => { | ||||
|   isDetails.value = false; | ||||
| resetDlg(); | ||||
|   dialogTitle.value = "添加品牌"; | ||||
|     isADD.value = true; | ||||
| @ -302,10 +349,20 @@ resetDlg(); | ||||
| }; | ||||
| //提交保存 | ||||
| const onSaveCategory = async () => {  | ||||
|   console.log('dialogForm',dialogForm); | ||||
| 
 | ||||
|   //处理dialogForm.files | ||||
|   dialogForm.files.forEach((item, index) => { | ||||
|     item.fileName = item.name; | ||||
|     item.fileUrl = item.response.data.url; | ||||
|   }) | ||||
|   console.log('dialogForm.files',dialogForm.files); | ||||
|    | ||||
|    | ||||
|   dialogRef.value.validate(async (valid) => {  | ||||
|     if (valid) {  | ||||
|         if(isADD.value){ | ||||
|             let response = await addBrand(dialogForm); | ||||
|             let response = await addBrandUsing(dialogForm); | ||||
|             if (response.code === 200) { | ||||
|                 dialogFormVisible.value = false; | ||||
|                 ElMessage.success("新增成功!"); | ||||
| @ -315,7 +372,7 @@ const onSaveCategory = async () => { | ||||
|                 ElMessage.error(response.message); | ||||
|             } | ||||
|         }else{  | ||||
|             let response = await updateBrand(dialogForm); | ||||
|             let response = await updateBrandUsing(dialogForm); | ||||
|             if (response.code === 200) { | ||||
|                 dialogFormVisible.value = false; | ||||
|                 ElMessage.success("编辑成功!"); | ||||
| @ -333,7 +390,7 @@ const onSaveCategory = async () => { | ||||
| const startStop = async (row) => { | ||||
|   let status = row.status == 1 ? 0 : 1; | ||||
|   let params = { id: row.id, status: status }; | ||||
|   let response = await updateStatusBrand(params); | ||||
|   let response = await updateStatusBrandUsing(params); | ||||
|   if (response.code === 200) { | ||||
|     ElMessage.success("操作成功!"); | ||||
|     loadData(); | ||||
| @ -343,12 +400,24 @@ const startStop = async (row) => { | ||||
| }; | ||||
| 
 | ||||
| // 编辑操作 | ||||
| const handleEdit = async(row) => { | ||||
| const handleEdit = async(row,type) => { | ||||
|   if(type == 'details'){ | ||||
|     isDetails.value = true; | ||||
|   }else{ | ||||
|     isDetails.value = false; | ||||
|   } | ||||
|   resetDlg(); | ||||
|     isADD.value = false; | ||||
|   dialogFormVisible.value = true; | ||||
|   let response = await getBrandInfo(row.id); | ||||
|   let response = await getBrandUsing(row.id); | ||||
|   if (response.code === 200) { | ||||
|     let temList = response.data; | ||||
|     temList.files = temList.files.map((item) => { | ||||
|       return { | ||||
|         name: item.fileName, | ||||
|         url: item.fileUrl, | ||||
|       }; | ||||
|     }) | ||||
|     Object.assign(dialogForm, response.data); // 保持响应性 | ||||
|     dialogTitle.value = "编辑品牌"; | ||||
|   } else { | ||||
| @ -364,7 +433,7 @@ const handleDelete = async(row) => { | ||||
|     type: "warning", | ||||
|   }) | ||||
|     .then(async () => { | ||||
|       let response = await deleteBrand(row.id); | ||||
|       let response = await deleteBrandUsing(row.id); | ||||
|       if (response.code === 200) { | ||||
|         ElMessage.success("品牌删除成功!"); | ||||
|         loadData(); | ||||
| @ -387,12 +456,53 @@ const resetDlg= () => { | ||||
|   Object.assign(dialogForm, {  // 保持响应性,手动清空字段 | ||||
|     id: "", | ||||
|     title: "", | ||||
|     imgPath: "", | ||||
|     files: [], | ||||
|     code: "" | ||||
|   }); | ||||
|   dialogFormVisible.value = false; | ||||
| } | ||||
| 
 | ||||
| // 上传前校检格式和大小 | ||||
| const handleBeforeUpload = (file) => { | ||||
|   // 校检文件类型 | ||||
|   if (fileType.value.length) { | ||||
|     const fileName = file.name.split('.') | ||||
|     const fileExt = fileName[fileName.length - 1] | ||||
|     const isTypeOk = fileType.value.indexOf(fileExt) >= 0 | ||||
|     if (!isTypeOk) { | ||||
|       ElMessage.error(`文件格式不正确,请上传${fileType.value.join("/")}格式文件!`) | ||||
|       return false | ||||
|     } | ||||
|   } | ||||
|   // 校检文件名是否包含特殊字符 | ||||
|   if (file.name.includes(',')) { | ||||
|     proxy.$modal.msgError('文件名不正确,不能包含英文逗号!') | ||||
|     return false | ||||
|   } | ||||
|   // 校检文件大小 | ||||
|   if (fileSize.value) { | ||||
|     const isLt = file.size / 1024 / 1024 < fileSize.value | ||||
|     if (!isLt) { | ||||
|       ElMessage.error(`上传文件大小不能超过 ${fileSize.value} MB!`) | ||||
|       return false | ||||
|     } | ||||
|   } | ||||
|   return true | ||||
| } | ||||
| 
 | ||||
| // 文件个数超出 | ||||
| function handleExceed() { | ||||
|   // proxy.$modal.msgError(`上传文件数量不能超过 ${limit.value} 个!`) | ||||
|   ElMessage.error(`上传文件数量不能超过 ${limit.value} 个!`) | ||||
| } | ||||
| 
 | ||||
| //点击上传的文件 | ||||
| const handlePreview = (file) => { | ||||
|   // console.log(file.url); | ||||
|   if (!file.url) return; | ||||
|   window.open(file.url, '_blank'); | ||||
| } | ||||
| 
 | ||||
| const titleRef = ref(null); | ||||
| const searchBarRef = ref(null); | ||||
| const tableViewportHeight = ref(0); | ||||
| @ -442,4 +552,7 @@ onBeforeUnmount(() => { | ||||
|   justify-content: end; | ||||
|   padding: 14px 16px 0 0; | ||||
| } | ||||
| :deep(.el-upload-list--text){ | ||||
|   width: 375px !important; | ||||
| } | ||||
| </style> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user