salary
qsh 6 months ago
parent a557255b4a
commit 94943df4f9
  1. 2
      src/api/mall/product/brand.ts
  2. 7
      src/api/mall/product/category.ts
  3. 4
      src/api/mall/product/index.js
  4. 4
      src/api/mall/product/property.ts
  5. 92
      src/api/mall/product/spu.ts
  6. 25
      src/api/mall/purchase/index.js
  7. 2
      src/api/system/dict/dict.data.ts
  8. 26
      src/api/system/library/index.js
  9. 26
      src/api/system/library/resource.js
  10. 6
      src/components/SSTable/index.vue
  11. 14
      src/components/UploadFile/src/UploadFile.vue
  12. 5
      src/components/UploadFile/src/UploadImg.vue
  13. 2
      src/utils/formatTime.ts
  14. 62
      src/views/Basic/Library/Comp/DialogLibrary.vue
  15. 126
      src/views/Basic/Library/Comp/DialogResource.vue
  16. 44
      src/views/Basic/Library/Comp/ImagePreview.vue
  17. 188
      src/views/Basic/Library/index.vue
  18. 17
      src/views/MiniMall/MallSet/Comp/BrandSet.vue
  19. 14
      src/views/MiniMall/MallSet/Comp/CategorySet.vue
  20. 14
      src/views/MiniMall/MallSet/Comp/DialogCategory.vue
  21. 36
      src/views/MiniMall/MallSet/Comp/DialogSupplier.vue
  22. 67
      src/views/MiniMall/MallSet/Comp/SupplierSet.vue
  23. 24
      src/views/MiniMall/Product/Comp/ProductAttributesAddForm.vue
  24. 317
      src/views/MiniMall/Product/Comp/SkuList.vue
  25. 296
      src/views/MiniMall/Product/add.vue
  26. 51
      src/views/MiniMall/Product/index.vue
  27. 130
      src/views/MiniMall/Purchase/Comp/DialogAdd.vue
  28. 114
      src/views/MiniMall/Purchase/Comp/DialogAudit.vue
  29. 16
      src/views/MiniMall/Purchase/index.data.js
  30. 172
      src/views/MiniMall/Purchase/index.vue

@ -57,5 +57,5 @@ export const getBrandParam = (params: PageParam) => {
// 获得商品品牌精简信息列表
export const getSimpleBrandList = () => {
return request.get({ url: '/product/brand/list-all-simple' })
return request.get({ url: '/admin-api/crm/erp-product-brand/simple-list' })
}

@ -56,5 +56,10 @@ export const getCategory = (id: number) => {
// 获得商品分类列表
export const getCategoryList = (params: any) => {
return request.get({ url: '/admin-api/crm/erp-product-category/page', params })
return request.get({ url: '/admin-api/crm/erp-product-category/list', params })
}
// 获得商品分类列表
export const getCategorySimpleList = (params: any) => {
return request.get({ url: '/admin-api/crm/erp-product-category/simple-list', params })
}

@ -23,3 +23,7 @@ export const updateProduct = async (params) => {
export const deleteProduct = async (id) => {
return await request.delete({ url: '/admin-api/crm/erp-product/delete?id=' + id })
}
export const getSimpleProductList = async () => {
return await request.get({ url: '/admin-api/crm/erp-product/simple-list' })
}

@ -42,7 +42,7 @@ export interface PropertyValueDetailVO {
// 创建属性项
export const createProperty = (data: PropertyVO) => {
return request.post({ url: '/product/property/create', data })
return request.post({ url: '/admin-api/crm/erp-product-property/create', data })
}
// 更新属性项
@ -89,7 +89,7 @@ export const getPropertyValue = (id: number): Promise<PropertyValueVO> => {
// 创建属性值
export const createPropertyValue = (data: PropertyValueVO) => {
return request.post({ url: '/product/property/value/create', data })
return request.post({ url: '/admin-api/crm/erp-product-property-value/create', data })
}
// 更新属性值

@ -1,92 +0,0 @@
import request from '@/config/axios'
export interface Property {
propertyId?: number // 属性编号
propertyName?: string // 属性名称
valueId?: number // 属性值编号
valueName?: string // 属性值名称
}
// TODO puhui999:是不是直接叫 Sku 更简洁一点哈。type 待后面,总感觉有个类型?
export interface SkuType {
id?: number // 商品 SKU 编号
spuId?: number // SPU 编号
properties?: Property[] // 属性数组
price?: number // 商品价格
marketPrice?: number // 市场价
costPrice?: number // 成本价
barCode?: string // 商品条码
picUrl?: string // 图片地址
stock?: number // 库存
weight?: number // 商品重量,单位:kg 千克
volume?: number // 商品体积,单位:m^3 平米
subCommissionFirstPrice?: number // 一级分销的佣金
subCommissionSecondPrice?: number // 二级分销的佣金
salesCount?: number // 商品销量
}
// TODO puhui999:是不是直接叫 Spu 更简洁一点哈。type 待后面,总感觉有个类型?
export interface SpuType {
id?: number
name?: string // 商品名称
categoryId?: number | null // 商品分类
keyword?: string // 关键字
unit?: number | null // 单位
picUrl?: string // 商品封面图
sliderPicUrls?: string[] // 商品轮播图
introduction?: string // 商品简介
deliveryTemplateId?: number | null // 运费模版
brandId?: number | null // 商品品牌编号
specType?: boolean // 商品规格
subCommissionType?: boolean // 分销类型
skus: SkuType[] // sku数组
description?: string // 商品详情
sort?: string // 商品排序
giveIntegral?: number // 赠送积分
virtualSalesCount?: number // 虚拟销量
recommendHot?: boolean // 是否热卖
recommendBenefit?: boolean // 是否优惠
recommendBest?: boolean // 是否精品
recommendNew?: boolean // 是否新品
recommendGood?: boolean // 是否优品
}
// 获得 Spu 列表
export const getSpuPage = (params: PageParam) => {
return request.get({ url: '/product/spu/page', params })
}
// 获得 Spu 列表 tabsCount
export const getTabsCount = () => {
return request.get({ url: '/product/spu/get-count' })
}
// 创建商品 Spu
export const createSpu = (data: SpuType) => {
return request.post({ url: '/product/spu/create', data })
}
// 更新商品 Spu
export const updateSpu = (data: SpuType) => {
return request.put({ url: '/product/spu/update', data })
}
// 更新商品 Spu status
export const updateStatus = (data: { id: number; status: number }) => {
return request.put({ url: '/product/spu/update-status', data })
}
// 获得商品 Spu
export const getSpu = (id: number) => {
return request.get({ url: `/product/spu/get-detail?id=${id}` })
}
// 删除商品 Spu
export const deleteSpu = (id: number) => {
return request.delete({ url: `/product/spu/delete?id=${id}` })
}
// 导出商品 Spu Excel
export const exportSpu = async (params) => {
return await request.download({ url: '/product/spu/export', params })
}

@ -0,0 +1,25 @@
import request from '@/config/axios'
// 查询列表
export const getPurchasePage = async (params) => {
return await request.get({ url: '/admin-api/crm/erp-purchase/page', params })
}
// 新增
export const createPurchase = async (data) => {
return await request.post({ url: '/admin-api/crm/erp-purchase/create', data: data })
}
// 修改
export const updatePurchase = async (params) => {
return await request.put({ url: '/admin-api/crm/erp-purchase/update', data: params })
}
// 删除
export const deletePurchase = async (id) => {
return await request.delete({ url: '/admin-api/crm/erp-purchase/delete?id=' + id })
}
// 审核
export const auditPurchase = async (params) => {
return await request.get({ url: '/admin-api/crm/erp-purchase/audit', params })
}

@ -15,7 +15,7 @@ export type DictDataVO = {
// 查询字典数据(精简)列表
export const listSimpleDictData = () => {
return request.get({ url: '/admin-api/system/dict-data/simple-list' })
return request.get({ url: '/admin-api/crm/dict-data/simple-list' })
}
// 查询字典数据列表

@ -0,0 +1,26 @@
import request from '@/config/axios'
// 查询知识库列表
export const getLibraryPage = (params) => {
return request.get({ url: '/admin-api/crm/knowledge-lib/page', params })
}
// 查询知识库详情
export const getLibrary = (id) => {
return request.get({ url: '/admin-api/crm/knowledge-lib/get?id=' + id })
}
// 新增知识库
export const createLibrary = (data) => {
return request.post({ url: '/admin-api/crm/knowledge-lib/create', data })
}
// 修改知识库
export const updateLibrary = (data) => {
return request.put({ url: '/admin-api/crm/knowledge-lib/update', data })
}
// 删除知识库
export const deleteLibrary = (id) => {
return request.delete({ url: '/admin-api/crm/knowledge-lib/delete?id=' + id })
}

@ -0,0 +1,26 @@
import request from '@/config/axios'
// 查询资源列表
export const getResourcePage = (params) => {
return request.get({ url: '/admin-api/crm/knowledge-lib-info/page', params })
}
// 查询资源详情
export const getResource = (id) => {
return request.get({ url: '/admin-api/crm/knowledge-lib-info/get?id=' + id })
}
// 新增资源
export const createResource = (data) => {
return request.post({ url: '/admin-api/crm/knowledge-lib-info/create', data })
}
// 修改资源
export const updateResource = (data) => {
return request.put({ url: '/admin-api/crm/knowledge-lib-info/update', data })
}
// 删除资源
export const deleteResource = (id) => {
return request.delete({ url: '/admin-api/crm/knowledge-lib-info/delete?id=' + id })
}

@ -39,7 +39,7 @@
<!-- 分页 -->
<Pagination
v-model:limit="pageSize"
v-model:page="currentPage"
v-model:page="pageNo"
:total="tableObject.total"
@pagination="getList"
/>
@ -61,7 +61,7 @@ const emit = defineEmits(['update:tableObject', 'getList', 'getCheckedColumns'])
const route = useRoute()
const { id: userId } = useUserStore().user //ID
const currentPage = ref(props.tableObject?.currentPage || 1)
const pageNo = ref(props.tableObject?.pageNo || 1)
const pageSize = ref(props.tableObject?.pageSize || 20)
@ -74,7 +74,7 @@ const checkedColumns = ref([])
// ,使
function getList({ page, limit }) {
emit('update:tableObject', { ...props.tableObject, currentPage: page, pageSize: limit })
emit('update:tableObject', { ...props.tableObject, pageNo: page, pageSize: limit })
nextTick(() => {
emit('getList')
})

@ -34,20 +34,14 @@
</div>
</template>
<script setup lang="ts" name="UploadFile">
import { PropType } from 'vue'
import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { getAccessToken, getTenantId, getAppId } from '@/utils/auth'
import type { UploadInstance, UploadUserFile, UploadProps, UploadRawFile } from 'element-plus'
const message = useMessage() //
const emit = defineEmits(['update:modelValue'])
const props = defineProps({
modelValue: {
type: Array as PropType<UploadUserFile[]>,
required: true
},
modelValue: propTypes.oneOfType<string | string[]>([String, Array<String>]).isRequired,
title: propTypes.string.def('文件上传'),
updateUrl: propTypes.string.def(import.meta.env.VITE_UPLOAD_URL),
fileType: propTypes.array.def(['doc', 'xls', 'ppt', 'txt', 'pdf']), // , ['png', 'jpg', 'jpeg']
@ -66,8 +60,10 @@ const fileList = ref<UploadUserFile[]>(props.modelValue)
const uploadNumber = ref<number>(0)
const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
'tenant-id': getTenantId(),
'instance-id': getAppId()
})
//
const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
if (fileList.value.length >= props.limit) {

@ -55,7 +55,7 @@ import type { UploadProps } from 'element-plus'
import { generateUUID } from '@/utils'
import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { getAccessToken, getTenantId, getAppId } from '@/utils/auth'
type FileTypes =
| 'image/apng'
@ -96,7 +96,8 @@ const deleteImg = () => {
const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
'tenant-id': getTenantId(),
'instance-id': getAppId()
})
const editImg = () => {

@ -18,7 +18,7 @@ export function formatDate(date: Date, format?: string): string {
}
// 日期存在,则进行格式化
if (format === undefined) {
format = 'YYYY-MM-DD HH:mm:ss'
format = 'YYYY-MM-DD'
}
return dayjs(date).format(format)
}

@ -1,11 +1,11 @@
<template>
<Dialog :title="title" v-model="dialogVisible" width="800px">
<el-form :model="form" ref="addForm" :rules="rules" label-width="100px">
<el-form-item label="知识库名称" prop="name">
<el-input v-model="form.name" placeholder="请输入" />
<el-form v-loading="formLoading" :model="form" ref="formRef" :rules="rules" label-width="100px">
<el-form-item label="知识库名称" prop="libName">
<el-input v-model="form.libName" placeholder="请输入" />
</el-form-item>
<el-form-item label="资源类型" prop="type">
<el-radio-group v-model="form.type">
<el-form-item label="资源类型" prop="libType">
<el-radio-group v-model="form.libType">
<el-radio :label="1"> 文件 </el-radio>
<el-radio :label="2"> 纯图片 </el-radio>
<el-radio :label="3"> 自主编辑 </el-radio>
@ -18,49 +18,71 @@
<template #footer>
<span>
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleSave"> </el-button>
<el-button type="primary" :disabled="formLoading" @click="handleSave"> </el-button>
</span>
</template>
</Dialog>
</template>
<script setup>
import * as LibraryApi from '@/api/system/library'
const emit = defineEmits(['success'])
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const form = ref()
const rules = ref({
name: { required: true, message: '名称不可为空', trigger: 'blur' }
libName: { required: true, message: '名称不可为空', trigger: 'blur' }
})
const title = ref('')
const addForm = ref()
const formRef = ref()
const formLoading = ref(false)
const formType = ref('create')
const emit = defineEmits(['update'])
const open = (val) => {
const open = (type, val) => {
dialogVisible.value = true
formType.value = type
if (val) {
title.value = '修改知识库'
form.value = { ...val }
} else {
title.value = '新增知识库'
form.value = {
name: '',
type: 1,
remark: undefined
libName: '',
libType: 1,
remark: undefined,
isDefault: false
}
}
}
defineExpose({ open }) // open
function handleSave() {
addForm.value.validate((valid) => {
if (valid) {
emit('update', form.value)
dialogVisible.value = false
async function handleSave() {
//
if (!formRef.value) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
if (formType.value === 'create') {
await LibraryApi.createLibrary(form.value)
message.success(t('common.createSuccess'))
} else {
await LibraryApi.updateLibrary(form.value)
message.success(t('common.updateSuccess'))
}
})
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

@ -1,6 +1,6 @@
<template>
<Dialog :title="title" v-model="show" width="800px">
<el-form :model="form" ref="resourceForm" :rules="rules" label-width="60px">
<el-form v-loading="formLoading" :model="form" ref="formRef" :rules="rules" label-width="60px">
<el-row :gutter="20">
<el-col :span="12" :offset="0">
<el-form-item label="标题" prop="title">
@ -8,16 +8,19 @@
</el-form-item>
</el-col>
<el-col :span="12" :offset="0">
<el-form-item label="标签" prop="tipList">
<el-form-item label="标签" prop="tags">
<el-select
v-model="form.tipList"
v-model="form.tags"
multiple
filterable
collapse-tags
collapse-tags-tooltip
allow-create
default-first-option
:reserve-keyword="false"
placeholder="请选择标签或输入"
clearable
@change="tipChange"
style="width: 100%"
>
<el-option
@ -33,15 +36,10 @@
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<el-form-item label="内容" prop="content">
<UploadFile
v-if="form.type == 1"
v-model="form.sliderPicUrls"
:isShowTip="false"
:fileType="[]"
/>
<UploadImgs
v-else-if="form.type == 2"
v-model:modelValue="form.sliderPicUrls"
<UploadFile v-if="libType == 1" v-model="form.files" :limit="1" :isShowTip="false" />
<UploadImg
v-else-if="libType == 2"
v-model:modelValue="form.files"
width="100px"
height="100px"
/>
@ -60,41 +58,107 @@
<template #footer>
<span>
<el-button @click="show = false"> </el-button>
<el-button type="primary" @click="handleSave"> </el-button>
<el-button type="primary" :disabled="formLoading" @click="handleSave"> </el-button>
</span>
</template>
</Dialog>
</template>
<script setup>
<script setup name="DialogResource">
import * as ResourceApi from '@/api/system/library/resource'
import { getDictOptions } from '@/utils/dict'
import * as dictApi from '@/api/system/dict/dict.data'
const { t } = useI18n() //
const message = useMessage() //
const show = ref(false)
const title = ref('')
const formType = ref('create')
const libType = ref(1)
const form = ref({})
const rules = ref({})
const formLoading = ref(false)
const rules = ref({
title: { required: true, message: '标题不可为空', trigger: 'blur' }
})
const tipOptions = ref([{ label: '绿色', value: '绿色' }])
const tipOptions = ref([])
function open(type, val) {
function getOptions() {
tipOptions.value = getDictOptions('knowledge_tags')
}
async function open(type, info, id) {
show.value = true
if (val) {
title.value = '修改资源'
form.value = { ...val, type }
} else {
title.value = '新增资源'
form.value = {
type,
title: '',
tipList: [],
sliderPicUrls: [],
content: '',
remark: null
title.value = type == 'update' ? '修改资源' : '新增资源'
formType.value = type
libType.value = info.libType
resetForm(info.libId)
getOptions()
if (id) {
formLoading.value = true
try {
form.value = await ResourceApi.getResource(id)
} finally {
formLoading.value = false
}
}
}
function resetForm(libId) {
form.value = {
libId,
title: '',
tags: [],
files: '',
content: '',
remark: null,
isDefault: false
}
}
async function tipChange(val) {
const valStr = val.at(-1)
if (!tipOptions.value.some((it) => it.value == valStr)) {
await dictApi.createDictData({
label: valStr,
value: valStr,
sort: 1,
status: 0,
dictType: 'knowledge_tags'
})
tipOptions.value.push({ label: valStr, value: valStr })
}
}
defineExpose({ open }) // open
function handleSave() {
console.log('保存成功')
const formRef = ref()
/** 提交表单 */
const emit = defineEmits(['success']) // success
async function handleSave() {
//
if (!formRef.value) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
if (formType.value === 'create') {
await ResourceApi.createResource(form.value)
message.success(t('common.createSuccess'))
} else {
await ResourceApi.updateResource(form.value)
message.success(t('common.updateSuccess'))
}
show.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

@ -1,7 +1,6 @@
<template>
<teleport v-if="show" to="#app">
<div class="container">
<!-- <Icon class="ep:circle-close close-icon" /> -->
<el-icon class="close-icon" @click="show = false"><CircleClose /></el-icon>
<el-drawer
v-model="showDrawer"
@ -16,22 +15,30 @@
<template #header>
<span style="color: #fff">资源详情</span>
</template>
<el-form style="flex: 1" :model="info" label-width="80px" label-position="left">
<el-form-item label="标题:">
{{ info.title }}
</el-form-item>
<el-form-item label="文件名称:">
{{ info.fileName }}
</el-form-item>
<el-form-item label="标签:">
<el-tag class="mr-5px mb-5px" v-for="(item, index) in info.tipList" :key="index">{{
item
}}</el-tag>
</el-form-item>
<el-form-item label="备注:">
{{ info.remark }}
</el-form-item>
</el-form>
<div>
<div class="flex mb-18px">
<div class="w-80px text-light-50">标题</div>
<div class="flex-1 ml-10px text-light-50">{{ info.title }}</div>
</div>
<div class="flex mb-18px">
<div class="w-80px text-light-50">文件名称</div>
<div class="flex-1 ml-10px text-light-50 w-80px" style="word-wrap: break-word">{{
info.files
}}</div>
</div>
<div class="flex mb-18px">
<div class="w-80px text-light-50">标签</div>
<div class="flex-1 ml-10px w-80px">
<el-tag class="mr-5px" v-for="(item, index) in info.tags" :key="index">
{{ getDictLabel('knowledge_tags', item) }}
</el-tag>
</div>
</div>
<div class="flex mb-18px">
<div class="w-80px text-light-50">备注</div>
<div class="flex-1 ml-10px text-light-50">{{ info.remark }}</div>
</div>
</div>
<template #footer>
<div class="flex justify-between">
<el-button plain :disabled="imgIndex <= 0" @click="imgIndex--">上一张</el-button>
@ -42,13 +49,14 @@
</template>
</el-drawer>
<img :src="info.fileUrl" :alt="info.fileName" srcset="" class="width-fit img" />
<img :src="info.files" :alt="info.files" srcset="" class="width-fit img" />
<div class="img-idx">{{ imgIndex + 1 }} / {{ imgList.length }}</div>
</div>
</teleport>
</template>
<script setup>
import { getDictLabel } from '@/utils/dict'
import { ElIcon } from 'element-plus'
import { CircleClose } from '@element-plus/icons-vue'

@ -3,7 +3,9 @@
<el-card shadow="always" :body-style="{ padding: '10px' }">
<div class="flex justify-between items-center" style="width: 400px">
<div class="text-16px font-bold">知识库名称</div>
<el-button type="primary" style="padding: 0px" text @click="handleAdd">新增</el-button>
<el-button type="primary" style="padding: 0px" text @click="openForm('create', null)"
>新增</el-button
>
</div>
<div class="border-top-1px mt-10px pt-10px">
<div
@ -11,24 +13,27 @@
v-for="(item, index) in libraryList"
:key="index"
:class="{ actived: libraryIndex == index }"
@click="libraryIndex = index"
@click="handleClickLib(index)"
>
<div class="flex-1 text-14px">{{ item.name }}</div>
<div class="flex-1 text-14px">{{ item.libName }}</div>
<div class="ml-10px">
<el-button type="primary" style="padding: 0px" text @click="handleUpdate(item)"
>修改</el-button
>
<el-button type="primary" style="padding: 0px" text @click="openForm('update', item)">
修改
</el-button>
<el-button
type="primary"
class="ml-10px"
style="padding: 0px"
text
@click="handleRemove(index)"
>删除</el-button
@click="handleRemove(item.libId)"
>
删除
</el-button>
</div>
</div>
<Pagination
small
layout="total, prev, pager, next, jumper"
v-model:limit="pageSize"
v-model:page="currentPage"
:total="total"
@ -36,44 +41,55 @@
/>
</div>
</el-card>
<el-card class="ml-20px" style="flex: 1" shadow="always" :body-style="{ padding: '10px' }">
<el-card
v-if="libraryList.length"
class="ml-20px"
style="flex: 1"
shadow="always"
:body-style="{ padding: '10px' }"
>
<div class="flex justify-between items-center border-bottom-1px pb-10px mb-20px">
<div>{{ libraryList[libraryIndex].name }}资源详情</div>
<el-button type="primary" @click="handleAddResource">新增资源</el-button>
<div>{{ libraryList[libraryIndex].libName }}资源详情</div>
<el-button type="primary" @click="openResource('create', null)">新增资源</el-button>
</div>
<div v-if="libraryList[libraryIndex].type == 1">
<el-table :data="tableList" border>
<div v-if="libraryList[libraryIndex].libType == 1">
<el-table :data="tableList" border v-loading="loading">
<el-table-column type="index" width="50" />
<el-table-column prop="title" label="标题" width="200" />
<el-table-column label="标签" width="200px">
<template #default="{ row }">
<el-tag v-for="(item, index) in row.tipList" :key="index" class="mr-5px">{{
item
}}</el-tag>
<el-tag v-for="(item, index) in row.tags" :key="index" class="mr-5px">
{{ getDictLabel('knowledge_tags', item) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="fileName" label="附件">
<el-table-column prop="files" label="附件">
<template #default="{ row }">
<el-link type="primary" underline :href="row.fileUrl" target="_blank">{{
row.fileName
}}</el-link>
<el-link type="primary" underline :href="row.fileUrl" target="_blank">
{{ row.files }}
</el-link>
</template>
</el-table-column>
<el-table-column label="操作" width="120px">
<template #default="{ row, $index }">
<el-button type="primary" style="padding: 0" text @click="updateResource(row)"
>修改</el-button
>
<el-button type="danger" style="padding: 0" text @click="removeResource($index)"
>删除</el-button
<el-button
type="primary"
style="padding: 0"
text
@click="openResource('update', row.id)"
>
修改
</el-button>
<el-button type="danger" style="padding: 0" text @click="removeResource($index)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div v-else-if="libraryList[libraryIndex].type == 2" class="flex">
<div v-else-if="libraryList[libraryIndex].libType == 2" class="flex">
<div v-for="(item, index) in tableList" :key="index" class="mr-10px">
<el-image :src="item.fileUrl" @click="imagePreview(index)" class="w-150px h-150px" />
<el-image :src="item.files" @click="imagePreview(index)" class="w-150px h-150px" />
<div class="mt-5px text-center">{{ item.title }}</div>
</div>
</div>
@ -83,19 +99,24 @@
<el-table-column prop="title" label="标题" />
<el-table-column label="标签">
<template #default="{ row }">
<el-tag v-for="(item, index) in row.tipList" :key="index" class="mr-5px">{{
item
}}</el-tag>
<el-tag v-for="(item, index) in row.tags" :key="index" class="mr-5px">
{{ getDictLabel('knowledge_tags', item) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="120px">
<template #default="{ row, $index }">
<el-button type="primary" style="padding: 0" text @click="updateResource(row)"
>修改</el-button
>
<el-button type="danger" style="padding: 0" text @click="removeResource($index)"
>删除</el-button
<el-button
type="primary"
style="padding: 0"
text
@click="openResource('update', row.infoId)"
>
修改
</el-button>
<el-button type="danger" style="padding: 0" text @click="removeResource($index)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
@ -108,27 +129,31 @@
/>
</el-card>
</div>
<DialogLibrary ref="library" @update="afterSaveLibrary" />
<DialogResource ref="resourceDialog" />
<DialogLibrary ref="library" @success="getList" />
<DialogResource ref="resourceDialog" @success="getResourceList" />
<ImagePreview ref="imgPreview" />
</template>
<script setup>
<script setup name="Library">
import * as LibraryApi from '@/api/system/library/index'
import * as ResourceApi from '@/api/system/library/resource'
import DialogLibrary from './Comp/DialogLibrary.vue'
import DialogResource from './Comp/DialogResource.vue'
import ImagePreview from './Comp/ImagePreview.vue'
import { getDictLabel } from '@/utils/dict'
const { t } = useI18n() //
const message = useMessage() //
const libraryIndex = ref(0)
const libraryList = ref([
{ name: '成交案例', id: 1, type: 2 },
{ name: '公司资质材料', id: 2, type: 1 },
{ name: '会议纪要', id: 3, type: 3 }
])
const libraryList = ref([])
const pageSize = ref(20)
const currentPage = ref(1)
const total = ref(0)
const loading = ref(false)
const library = ref()
const resourceDialog = ref()
const imgPreview = ref()
@ -137,61 +162,70 @@ const resourcePageSize = ref(20)
const resourcePageNum = ref(1)
const resourceTotal = ref(0)
const tableList = ref([
{
fileUrl:
'https://img0.baidu.com/it/u=1033018635,7901815&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500',
fileName: '测试图片1'
},
{
tipList: ['优质材料', '无污染'],
fileUrl:
'https://img0.baidu.com/it/u=1610680713,975251961&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750',
fileName: '测试图片2'
}
])
function handleAdd() {
//
library.value.open(null)
}
const tableList = ref([])
function handleUpdate(item) {
library.value.open(item)
function openForm(type, item) {
library.value.open(type, item)
}
function handleRemove(index) {
libraryList.value.splice(index, 1)
async function handleRemove(id) {
try {
//
await message.delConfirm()
//
await LibraryApi.deleteLibrary(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
function afterSaveLibrary(val) {
libraryList.value.push(val)
async function getList() {
const data = await LibraryApi.getLibraryPage({
pageNo: currentPage.value,
pageSize: pageSize.value
})
libraryList.value = data.list
total.value = data.total
handleClickLib(0)
}
function getList() {
libraryList.value = []
function handleClickLib(index) {
libraryIndex.value = index
getResourceList()
}
function handleAddResource() {
resourceDialog.value.open(libraryList.value[libraryIndex.value].type, null)
}
function updateResource(row) {
resourceDialog.value.open(libraryList.value[libraryIndex.value].type, row)
function openResource(type, id) {
resourceDialog.value.open(type, libraryList.value[libraryIndex.value], id)
}
function removeResource(index) {
tableList.value.splice(index, 1)
}
function getResourceList() {
tableList.value = []
async function getResourceList() {
loading.value = true
try {
const data = await ResourceApi.getResourcePage({
libId: libraryList.value[libraryIndex.value].libId,
pageNo: resourcePageNum.value,
pageSize: resourcePageSize.value
})
tableList.value = data.list
resourceTotal.value = data.total
} finally {
loading.value = false
}
}
/** 商品图预览 */
function imagePreview(index) {
imgPreview.value.open(index, tableList.value)
}
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>

@ -32,8 +32,10 @@
/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="primary" text @click="openForm('update', scope.row.id)">修改</el-button>
<el-button type="danger" text @click="handleDelete(scope.row.id)">删除</el-button>
<el-button type="primary" text @click="openForm('update', scope.row.brandId)"
>修改</el-button
>
<el-button type="danger" text @click="handleDelete(scope.row.brandId)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -54,6 +56,9 @@ import { dateFormatter } from '@/utils/formatTime'
import * as ProductBrandApi from '@/api/mall/product/brand'
import DialogBrand from './DialogBrand.vue'
const message = useMessage() //
const { t } = useI18n() //
const searchForm = ref({
name: undefined,
pageNo: 1,
@ -102,8 +107,14 @@ async function handleDelete(id) {
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
} catch (err) {
console.log(err)
}
}
onMounted(() => {
handleQuery()
})
</script>
<style lang="scss" scoped></style>

@ -16,10 +16,10 @@
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" row-key="id" :tree-props="{ children: 'children' }">
<el-table-column prop="categoryName" label="分类名称" />
<el-table-column prop="orderNum" label="排序" width="100px" />
<el-table-column prop="name" label="分类名称" />
<el-table-column prop="sort" label="排序" width="100px" />
<el-table-column prop="remark" label="备注" />
<el-table-column label="状态" align="center" min-width="150" prop="status">
<el-table-column label="状态" min-width="150" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
@ -33,16 +33,16 @@
<el-table-column label="操作">
<template #default="scope">
<el-button type="primary" text @click="openForm('update', scope.row)">修改</el-button>
<el-button type="primary" text @click="openForm('createChildren', scope.row)"
>新增</el-button
>
<el-button type="primary" text @click="openForm('createChildren', scope.row)">
新增
</el-button>
<el-button type="danger" text @click="handleDelete(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
v-model:limit="searchForm.pageSize"
v-model:page="searchForm.pageNum"
v-model:page="searchForm.pageNo"
:total="total"
@pagination="handleQuery"
/>

@ -7,7 +7,7 @@
:rules="formRules"
label-width="80px"
>
<el-form-item v-if="formData.level > 1" label="上级分类">
<el-form-item v-if="formData.parentCategory" label="上级分类">
<el-input v-model="formData.parentCategory" disabled />
</el-form-item>
<el-form-item label="分类名称" prop="name">
@ -71,12 +71,14 @@ const open = async (type, info) => {
if (type == 'update') {
formData.value = await ProductCategoryApi.getCategory(info.id)
} else {
formData.value.level = info.level + 1
formData.value.parentCategory = info.name
formData.value.parentId = info.id
}
} finally {
formLoading.value = false
}
} else {
formData.value.parentId = 0
}
}
defineExpose({ open }) // open
@ -91,12 +93,12 @@ const submitForm = async () => {
//
formLoading.value = true
try {
if (formType.value === 'create') {
if (formType.value === 'update') {
await ProductCategoryApi.updateCategory(formData.value)
message.success(t('common.updateSuccess'))
} else {
await ProductCategoryApi.createCategory(formData.value)
message.success(t('common.createSuccess'))
} else {
await ProductCategoryApi.updateCategory(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//

@ -7,11 +7,11 @@
:rules="formRules"
label-width="80px"
>
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入供应商名称" />
<el-form-item label="名称" prop="label">
<el-input v-model="formData.label" placeholder="请输入供应商名称" />
</el-form-item>
<el-form-item label="排序" prop="orderNum">
<el-input v-model="formData.orderNum" placeholder="请输入排序" type="number" :min="0" />
<el-form-item label="排序" prop="sort">
<el-input v-model="formData.sort" placeholder="请输入排序" type="number" :min="0" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
@ -29,6 +29,7 @@
</Dialog>
</template>
<script name="DialogSupplier" setup>
import * as dictApi from '@/api/system/dict/dict.data'
const { t } = useI18n() //
const message = useMessage() //
@ -37,27 +38,26 @@ const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
name: '',
orderNum: 1,
label: '',
sort: 1,
remark: ''
})
const formRules = reactive({
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
label: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type, info) => {
const open = async (type, id) => {
dialogVisible.value = true
dialogTitle.value = type == 'update' ? '修改供应商' : '新增供应商'
formType.value = type
resetForm()
//
if (info.id) {
if (id) {
formLoading.value = true
try {
formData.value = { ...info }
// formData.value = await UserApi.getUser(id)
formData.value = await dictApi.getDictData(id)
} finally {
formLoading.value = false
}
@ -75,12 +75,14 @@ const submitForm = async () => {
//
formLoading.value = true
try {
// const data = formData.value as unknown as UserApi.UserVO
if (!formData.value.value) {
formData.value.value = formData.value.label
}
if (formType.value === 'create') {
// await UserApi.createUser(data)
await dictApi.createDictData(formData.value)
message.success(t('common.createSuccess'))
} else {
// await UserApi.updateUser(data)
await dictApi.updateDictData(formData.value)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
@ -94,8 +96,10 @@ const submitForm = async () => {
/** 重置表单 */
const resetForm = () => {
formData.value = {
name: '',
orderNum: 1,
label: '',
sort: 1,
status: 0,
dictType: 'erp_supplier',
remark: ''
}
formRef.value?.resetFields()

@ -16,23 +16,27 @@
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="tableList">
<el-table-column prop="name" label="供应商名称" />
<el-table-column prop="orderNum" label="排序" width="100px" />
<el-table-column prop="label" label="供应商名称" />
<el-table-column prop="sort" label="排序" width="100px" />
<el-table-column prop="remark" label="备注" />
<el-table-column label="创建时间" prop="createTime" width="180px" />
<el-table-column label="创建人" prop="createUser" width="150px" />
<el-table-column
label="创建时间"
prop="createTime"
width="180px"
:formatter="dateFormatter"
/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="primary" text @click="openForm('update', scope.row)">修改</el-button>
<el-button type="danger" text @click="handleDelete(scope.row)">删除</el-button>
<el-button type="primary" text @click="openForm('update', scope.row.id)">修改</el-button>
<el-button type="danger" text @click="handleDelete(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
v-model:limit="searchForm.pageSize"
v-model:page="searchForm.pageNum"
v-model:page="searchForm.pageNo"
:total="total"
@pagination="handleQuery"
@pagination="getList"
/>
<DialogSupplier ref="brandDialog" @success="handleQuery" />
@ -40,11 +44,18 @@
</template>
<script setup name="SupplierSet">
import { dateFormatter } from '@/utils/formatTime'
import DialogSupplier from './DialogSupplier.vue'
import * as dictApi from '@/api/system/dict/dict.data'
const { t } = useI18n() //
const message = useMessage() //
const searchForm = ref({
pageNum: 1,
pageSize: 20
label: '',
pageSize: 20,
pageNo: 1,
dictType: 'erp_supplier'
})
const total = ref(0)
@ -53,43 +64,49 @@ const tableList = ref([])
const loading = ref(false)
function handleQuery() {
searchForm.value.pageNum = 1
searchForm.value.pageNo = 1
getList()
}
function resetQuery() {
searchForm.value = {
name: '',
label: '',
pageSize: 20,
pageNum: 1
pageNo: 1,
dictType: 'erp_supplier'
}
getList()
}
function getList() {
tableList.value = [
{
id: 1,
name: '测试'
}
]
async function getList() {
loading.value = true
try {
const data = await dictApi.getDictDataPage(searchForm.value)
tableList.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
function openForm(type, info) {
brandDialog.value.open(type, info)
function openForm(type, id) {
brandDialog.value.open(type, id)
}
async function handleDelete(row) {
async function handleDelete(id) {
try {
console.log(row)
//
await message.delConfirm()
//
// await UserApi.deleteUser(row.id)
await dictApi.deleteDictData(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
onMounted(() => {
handleQuery()
})
</script>
<style lang="scss" scoped></style>

@ -6,6 +6,7 @@
:model="formData"
:rules="formRules"
label-width="80px"
@submit.prevent
>
<el-form-item label="属性名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" />
@ -33,7 +34,7 @@ const formRules = reactive({
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const attributeList = ref([]) //
const attributeList = ref<any>([]) //
const props = defineProps({
propertyList: {
type: Array,
@ -69,17 +70,13 @@ const submitForm = async () => {
formLoading.value = true
try {
const data = formData.value as PropertyApi.PropertyVO
//
const res = await PropertyApi.getPropertyListAndValue({ name: data.name })
if (res.length === 0) {
const propertyId = await PropertyApi.createProperty(data)
attributeList.value.push({ id: propertyId, ...formData.value, values: [] })
} else {
if (res[0].values === null) {
res[0].values = []
}
attributeList.value.push(res[0]) //
}
const propertyId = await PropertyApi.createProperty(data)
//
attributeList.value.push({
id: propertyId + '',
...formData.value,
values: []
})
message.success(t('common.createSuccess'))
dialogVisible.value = false
} finally {
@ -90,8 +87,7 @@ const submitForm = async () => {
/** 重置表单 */
const resetForm = () => {
formData.value = {
name: '',
remark: ''
name: ''
}
formRef.value?.resetFields()
}

@ -1,317 +0,0 @@
<template>
<el-table
:data="isBatch ? skuList : formData.skus"
border
class="tabNumWidth"
max-height="500"
size="small"
>
<el-table-column align="center" fixed="left" label="图片" min-width="100">
<template #default="{ row }">
<UploadImg v-model="row.picUrl" height="80px" width="100%" />
</template>
</el-table-column>
<template v-if="formData.specType && !isBatch">
<!-- 根据商品属性动态添加 -->
<el-table-column
v-for="(item, index) in tableHeaders"
:key="index"
:label="item.label"
align="center"
min-width="120"
>
<template #default="{ row }">
<!-- TODO puhui999展示成蓝色有点区分度哈 -->
{{ row.properties[index]?.valueName }}
</template>
</el-table-column>
</template>
<el-table-column align="center" label="商品条码" min-width="168">
<template #default="{ row }">
<el-input v-model="row.barCode" class="w-100%" />
</template>
</el-table-column>
<el-table-column align="center" label="销售价(元)" min-width="168">
<template #default="{ row }">
<el-input-number v-model="row.price" :min="0" :precision="2" :step="0.1" class="w-100%" />
</template>
</el-table-column>
<el-table-column align="center" label="市场价(元)" min-width="168">
<template #default="{ row }">
<el-input-number
v-model="row.marketPrice"
:min="0"
:precision="2"
:step="0.1"
class="w-100%"
/>
</template>
</el-table-column>
<el-table-column align="center" label="成本价(元)" min-width="168">
<template #default="{ row }">
<el-input-number
v-model="row.costPrice"
:min="0"
:precision="2"
:step="0.1"
class="w-100%"
/>
</template>
</el-table-column>
<el-table-column align="center" label="库存" min-width="168">
<template #default="{ row }">
<el-input-number v-model="row.stock" :min="0" class="w-100%" />
</template>
</el-table-column>
<el-table-column align="center" label="重量(kg)" min-width="168">
<template #default="{ row }">
<el-input-number v-model="row.weight" :min="0" :precision="2" :step="0.1" class="w-100%" />
</template>
</el-table-column>
<el-table-column align="center" label="体积(m^3)" min-width="168">
<template #default="{ row }">
<el-input-number v-model="row.volume" :min="0" :precision="2" :step="0.1" class="w-100%" />
</template>
</el-table-column>
<template v-if="formData.subCommissionType">
<el-table-column align="center" label="一级返佣(元)" min-width="168">
<template #default="{ row }">
<el-input-number
v-model="row.subCommissionFirstPrice"
:min="0"
:precision="2"
:step="0.1"
class="w-100%"
/>
</template>
</el-table-column>
<el-table-column align="center" label="二级返佣(元)" min-width="168">
<template #default="{ row }">
<el-input-number
v-model="row.subCommissionSecondPrice"
:min="0"
:precision="2"
:step="0.1"
class="w-100%"
/>
</template>
</el-table-column>
</template>
<el-table-column v-if="formData.specType" align="center" fixed="right" label="操作" width="80">
<template #default="{ row }">
<el-button v-if="isBatch" link size="small" type="primary" @click="batchAdd">
批量添加
</el-button>
<el-button v-else link size="small" type="primary" @click="deleteSku(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script lang="ts" name="SkuList" setup>
import { PropType } from 'vue'
import { copyValueToTarget } from '@/utils'
import { propTypes } from '@/utils/propTypes'
import { UploadImg } from '@/components/UploadFile'
import type { Property, SkuType, SpuType } from '@/api/mall/product/spu'
const props = defineProps({
propFormData: {
type: Object as PropType<SpuType>,
default: () => {}
},
propertyList: {
type: Array,
default: () => []
},
isBatch: propTypes.bool.def(false) //
})
const formData = ref<SpuType>() //
const skuList = ref<SkuType[]>([
{
price: 0, //
marketPrice: 0, //
costPrice: 0, //
barCode: '', //
picUrl: '', //
stock: 0, //
weight: 0, //
volume: 0, //
subCommissionFirstPrice: 0, //
subCommissionSecondPrice: 0 //
}
]) //
// TODO @puhui999 0.01
/** 批量添加 */
const batchAdd = () => {
formData.value.skus.forEach((item) => {
copyValueToTarget(item, skuList.value[0])
})
}
/** 删除 sku */
const deleteSku = (row) => {
const index = formData.value.skus.findIndex(
//
(sku) => JSON.stringify(sku.properties) === JSON.stringify(row.properties)
)
formData.value.skus.splice(index, 1)
}
const tableHeaders = ref<{ prop: string; label: string }[]>([]) //
/**
* 将传进来的值赋值给 skuList
*/
watch(
() => props.propFormData,
(data) => {
if (!data) return
formData.value = data
},
{
deep: true,
immediate: true
}
)
/** 生成表数据 */
const generateTableData = (propertyList: any[]) => {
//
const propertyValues = propertyList.map((item) =>
item.values.map((v) => ({
propertyId: item.id,
propertyName: item.name,
valueId: v.id,
valueName: v.name
}))
)
// TODO @puhui buildSkuListitem sku
const buildList = build(propertyValues)
// sku skus
if (!validateData(propertyList)) {
// sku
formData.value!.skus = []
}
for (const item of buildList) {
const row = {
properties: Array.isArray(item) ? item : [item], // property
price: 0,
marketPrice: 0,
costPrice: 0,
barCode: '',
picUrl: '',
stock: 0,
weight: 0,
volume: 0,
subCommissionFirstPrice: 0,
subCommissionSecondPrice: 0
}
// sku
const index = formData.value!.skus.findIndex(
(sku) => JSON.stringify(sku.properties) === JSON.stringify(row.properties)
)
if (index !== -1) {
continue
}
formData.value.skus.push(row)
}
}
/**
* 生成 skus 前置校验
*/
const validateData = (propertyList: any[]) => {
const skuPropertyIds = []
formData.value.skus.forEach((sku) =>
sku.properties
?.map((property) => property.propertyId)
.forEach((propertyId) => {
if (skuPropertyIds.indexOf(propertyId) === -1) {
skuPropertyIds.push(propertyId)
}
})
)
const propertyIds = propertyList.map((item) => item.id)
return skuPropertyIds.length === propertyIds.length
}
/** 构建所有排列组合 */
const build = (propertyValuesList: Property[][]) => {
if (propertyValuesList.length === 0) {
return []
} else if (propertyValuesList.length === 1) {
return propertyValuesList[0]
} else {
const result: Property[][] = []
const rest = build(propertyValuesList.slice(1))
for (let i = 0; i < propertyValuesList[0].length; i++) {
for (let j = 0; j < rest.length; j++) {
//
if (Array.isArray(rest[j])) {
result.push([propertyValuesList[0][i], ...rest[j]])
} else {
result.push([propertyValuesList[0][i], rest[j]])
}
}
}
return result
}
}
/** 监听属性列表,生成相关参数和表头 */
watch(
() => props.propertyList,
(propertyList) => {
//
if (!formData.value.specType) {
return
}
// 使
if (props.isBatch) {
skuList.value = [
{
price: 0,
marketPrice: 0,
costPrice: 0,
barCode: '',
picUrl: '',
stock: 0,
weight: 0,
volume: 0,
subCommissionFirstPrice: 0,
subCommissionSecondPrice: 0
}
]
}
//
if (JSON.stringify(propertyList) === '[]') {
return
}
//
tableHeaders.value = []
//
propertyList.forEach((item, index) => {
// nameindex
tableHeaders.value.push({ prop: `name${index}`, label: item.name })
})
// sku
if (validateData(propertyList)) {
return
}
//
if (propertyList.some((item) => item.values.length === 0)) {
return
}
// table sku
generateTableData(propertyList)
},
{
deep: true,
immediate: true
}
)
// sku
defineExpose({ generateTableData })
</script>

@ -1,5 +1,5 @@
<template>
<el-tabs v-model="tabName" type="border-card" tab-position="top">
<el-tabs v-model="tabName" type="border-card" tab-position="top" v-loading="formLoading">
<el-tab-pane label="商品信息" name="basic">
<el-form :model="form" ref="spuForm" :rules="rules" label-width="90px">
<el-row :gutter="20">
@ -11,9 +11,10 @@
<el-col :span="8" :offset="0">
<el-form-item label="分类" prop="productCategory">
<el-cascader
:options="opts.productCategory"
:options="opts.category"
v-model="form.productCategory"
placeholder="请选择分类"
:props="{ label: 'name', value: 'id' }"
filterable
show-all-levels
style="width: 100%"
@ -25,9 +26,9 @@
<el-select v-model="form.productBrand" placeholder="请选择品牌" filterable>
<el-option
v-for="item in opts.brand"
:key="item.value"
:label="item.label"
:value="item.value"
:key="item.brandId"
:label="item.name"
:value="item.brandId"
/>
</el-select>
</el-form-item>
@ -110,11 +111,16 @@
</template>
</el-table-column>
<el-table-column
v-for="col in form.productSpecList"
:prop="col.id"
v-for="(col, index) in form.productSpecList"
:key="col.id"
:label="col.name"
/>
>
<template #default="{ row }">
<span style="font-weight: bold; color: #40aaff">
{{ row.properties[index]?.valueName }}
</span>
</template>
</el-table-column>
<el-table-column prop="price" label="销售价">
<template #default="{ row }">
<el-input-number v-model="row.price" :min="0.01" :step="1" />
@ -130,22 +136,30 @@
</el-col>
</el-row>
</el-form>
<div class="mt-20px flex justify-center">
<el-button type="primary" @click="onSubmit">保存</el-button>
<el-button plain>重置</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="详细信息" name="detail">
<Editor v-model:modelValue="form.detailInfo" />
</el-tab-pane>
</el-tabs>
<div class="mt-20px flex justify-center">
<el-button type="primary" @click="onSubmit">保存</el-button>
<el-button plain>重置</el-button>
</div>
<ProductAttributesAddForm ref="attributesAddFormRef" :propertyList="form.productSpecList" />
</template>
<script setup>
import { cloneDeep } from 'lodash-es'
import * as PropertyApi from '@/api/mall/product/property'
import * as ProductApi from '@/api/mall/product/index'
import ProductAttributesAddForm from './Comp/ProductAttributesAddForm.vue'
import * as BrandApi from '@/api/mall/product/brand'
import * as CategoryApi from '@/api/mall/product/category'
import { handleTree } from '@/utils/tree'
const route = useRoute()
const message = useMessage() //
const { t } = useI18n() //
const tabName = ref('basic')
const form = ref({
@ -157,25 +171,32 @@ const form = ref({
carouselImages: [],
productSpecList: [],
skuList: [],
detailInfo: null
detailInfo: null,
status: 0
})
const rules = ref({})
const rules = {
productName: { required: true, message: '产品名称不可为空', trigger: 'blur' }
}
const attributesAddFormRef = ref() //
const opts = {
brand: [{ value: 1, label: '品牌1' }],
productCategory: [
{
id: 1,
label: '分类1',
children: [{ id: 2, label: '子分类1' }]
}
]
const opts = ref({
brand: [],
category: []
})
async function getOptions() {
BrandApi.getSimpleBrandList().then((data) => {
opts.value.brand = data || []
})
CategoryApi.getCategorySimpleList().then((data) => {
opts.value.category = handleTree(data || [])
})
}
/** 删除属性*/
function handleCloseProperty(index) {
form.value.productSpecList?.splice(index, 1)
getTableList()
}
const attributeIndex = ref(null)
@ -191,8 +212,7 @@ async function handleInputConfirm(index, propertyId) {
if (inputValue.value) {
//
try {
// const id = await PropertyApi.createPropertyValue({ propertyId, name: inputValue.value })
const id = propertyId || parseInt(Math.random() * 1000000)
const id = await PropertyApi.createPropertyValue({ propertyId, name: inputValue.value })
form.value.productSpecList[index].values.push({ id, name: inputValue.value })
message.success('添加成功')
} catch {
@ -201,31 +221,88 @@ async function handleInputConfirm(index, propertyId) {
}
attributeIndex.value = null
inputValue.value = ''
form.value.skuList = getTableList()
getTableList()
}
/** 删除属性值*/
function handleCloseValue(index, valueIndex) {
form.value.productSpecList[index].values?.splice(valueIndex, 1)
getTableList()
}
function getTableList() {
let list = []
form.value.productSpecList.map((item) => {
if (!list.length) {
item.values.map((it) => {
const obj = {}
obj[it.id] = it.name
list.push(obj)
})
} else {
item.values.map((it, index) => {
if (index < list.length) {
list[index][it.id] = it.name
const propertyList = [...form.value.productSpecList]
//
const propertyValues = propertyList.map((item) =>
item.values.map((v) => ({
propertyId: item.id,
propertyName: item.name,
valueId: v.id,
valueName: v.name
}))
)
const buildSkuList = build(propertyValues)
// sku skuList
if (!validateData(propertyList)) {
// sku
// form.value.skuList = []
}
form.value.skuList = []
for (const item of buildSkuList) {
const row = {
properties: Array.isArray(item) ? item : [item], // property
price: 0.01,
intro: '',
specsName: ''
}
// sku
const index = form.value.skuList.findIndex(
(sku) => JSON.stringify(sku.properties) === JSON.stringify(row.properties)
)
if (index !== -1) {
continue
}
form.value.skuList.push(row)
}
}
/**
* 生成 skuList 前置校验
*/
const validateData = (propertyList) => {
const skuPropertyIds = []
form.value.skuList.forEach((sku) =>
sku.properties.map((property) => {
if (skuPropertyIds.indexOf(property.propertyId) === -1) {
skuPropertyIds.push(property.propertyId)
}
})
)
const propertyIds = propertyList.map((item) => item.id)
return skuPropertyIds.length === propertyIds.length
}
/** 构建所有排列组合 */
const build = (propertyValuesList) => {
if (propertyValuesList.length === 0) {
return []
} else if (propertyValuesList.length === 1) {
return propertyValuesList[0]
} else {
const result = []
const rest = build(propertyValuesList.slice(1))
for (let i = 0; i < propertyValuesList[0].length; i++) {
for (let j = 0; j < rest.length; j++) {
//
if (Array.isArray(rest[j])) {
result.push([propertyValuesList[0][i], ...rest[j]])
} else {
const obj = {}
obj[it.id] = it.name
list.push(obj)
result.push([propertyValuesList[0][i], rest[j]])
}
})
}
}
})
return list
return result
}
}
const inputRef = ref([]) //Ref
@ -248,14 +325,103 @@ function handleAddSpec() {
attributesAddFormRef.value.open()
}
const spuForm = ref()
function onSubmit() {
message.success('保存成功!')
spuForm.value.validate(async (valid) => {
if (valid && validateSku()) {
// , server
const deepCopyFormData = cloneDeep(unref(form.value))
deepCopyFormData.productSpecList = deepCopyFormData.skuList
if (deepCopyFormData.productCategory && deepCopyFormData.productCategory.length) {
deepCopyFormData.productCategory = deepCopyFormData.productCategory.at(-1)
}
delete deepCopyFormData.skuList
//
const data = deepCopyFormData
const id = route.query.id
if (!id) {
await ProductApi.createProduct(data)
message.success(t('common.createSuccess'))
} else {
await ProductApi.updateProduct(data)
message.success(t('common.updateSuccess'))
}
}
})
}
//
const ruleConfig = [
{
name: 'specsName',
rule: (arg) => arg.length,
message: '规格名称不可为空 !!!'
},
{
name: 'price',
rule: (arg) => arg >= 0.01,
message: '商品销售价格必须大于等于 0.01 元!!!'
}
]
/**
* 保存时每个商品规格的表单要校验下例如说销售金额最低是 0.01 这种
*/
const validateSku = () => {
let warningInfo = '请检查商品各行相关属性配置,'
let validate = form.value.skuList.length > 0 //
if (!form.value.skuList.length) {
message.info('请添加商品规格!!!')
}
for (const sku of form.value.skuList) {
for (const rule of ruleConfig) {
const arg = getValue(sku, rule.name)
if (!rule.rule(arg)) {
validate = false //
warningInfo += rule.message
break
}
}
//
if (!validate) {
message.warning(warningInfo)
throw new Error(warningInfo)
}
}
return validate
}
const getValue = (obj, arg) => {
const keys = arg.split('.')
let value = obj
for (const key of keys) {
if (value && typeof value === 'object' && key in value) {
value = value[key]
} else {
value = undefined
break
}
}
return value
}
onMounted(() => {
const formLoading = ref(false)
/** 获得详情 */
const getDetail = async () => {
if (route.query?.id) {
form.value = {
productName: '商品名称哦~'
formLoading.value = true
try {
const res = await ProductApi.getProduct(route.query.id)
const propList = getPropertyList(res.productSpecList)
form.value = {
...res,
skuList: res.productSpecList,
productSpecList: propList
}
} finally {
formLoading.value = false
}
} else {
form.value = {
@ -267,9 +433,41 @@ onMounted(() => {
carouselImages: ['https://ss-cloud.ahduima.com/1001/1796426117251600384.png'],
productSpecList: [],
skuList: [],
detailInfo: null
detailInfo: null,
status: 0
}
}
}
/**
* 获得商品的规格列表 - 商品相关的公共函数
*
* @param spu
* @return PropertyAndValues 规格列表
*/
const getPropertyList = (list) => {
// skus propertyList
const properties = []
//
list.forEach((sku) => {
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
//
if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId, name: propertyName, values: [] })
}
//
const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values?.push({ id: valueId, name: valueName })
}
})
})
return properties
}
onMounted(async () => {
getOptions()
await getDetail()
})
</script>

@ -20,9 +20,9 @@
>
<el-option
v-for="item in opts.brand"
:key="item.value"
:label="item.label"
:value="item.value"
:key="item.brandId"
:label="item.name"
:value="item.brandId"
/>
</el-select>
</el-form-item>
@ -33,6 +33,7 @@
placeholder="请选择分类"
clearable
filterable
:props="{ label: 'name', value: 'id', checkStrictly: true }"
show-all-levels
@change="handleQuery"
/>
@ -40,7 +41,7 @@
<el-form-item>
<el-button @click="handleQuery" v-hasPermi="['mall:prod:search']"> 搜索 </el-button>
<el-button @click="resetQuery" v-hasPermi="['mall:prod:reset']"> 重置 </el-button>
<el-button plain type="primary" @click="openForm" v-hasPermi="['mall:prod:add']">
<el-button plain type="primary" @click="openForm(null)" v-hasPermi="['mall:prod:add']">
新增
</el-button>
</el-form-item>
@ -53,6 +54,16 @@
<div class="pl-100px pr-100px">
<el-table :data="row.productSpecList">
<el-table-column label="规格名称" prop="specsName" />
<el-table-column />
<el-table-column
v-for="(item, index) in row.properties"
:key="index"
:label="item.label"
>
<template #default="scope">
{{ scope.row.properties[index].valueName }}
</template>
</el-table-column>
<el-table-column label="售价" prop="price" />
<el-table-column label="简介" prop="intro" />
</el-table>
@ -105,6 +116,9 @@
import { dateFormatter } from '@/utils/formatTime'
import { createImageViewer } from '@/components/ImageViewer'
import * as ProductApi from '@/api/mall/product'
import * as BrandApi from '@/api/mall/product/brand'
import * as CategoryApi from '@/api/mall/product/category'
import { handleTree } from '@/utils/tree'
const { currentRoute, push } = useRouter()
const message = useMessage() //
@ -143,8 +157,18 @@ async function handleDelete(id) {
async function getList() {
loading.value = true
try {
const data = await ProductApi.getProductPage(queryParams.value)
tableList.value = data.list
const params = { ...queryParams.value }
if (params.productCategory && params.productCategory.length) {
params.productCategory = params.productCategory.at(-1)
}
const data = await ProductApi.getProductPage(params)
tableList.value = data.list.map((prod) => ({
...prod,
properties: prod.productSpecList[0].properties.map((item) => ({
propertyId: item.propertyId,
label: item.propertyName
}))
}))
total.value = data.total
} finally {
loading.value = false
@ -163,6 +187,15 @@ function handleQuery() {
getList()
}
async function getOptions() {
BrandApi.getSimpleBrandList().then((data) => {
opts.value.brand = data || []
})
CategoryApi.getCategorySimpleList().then((data) => {
opts.value.productCategory = handleTree(data || [])
})
}
/** 重置按钮操作 */
function resetQuery() {
queryParams.value = {
@ -182,7 +215,7 @@ function resetQuery() {
*/
function openForm(id) {
//
if (typeof id == 'number') {
if (id) {
push({
path: '/miniMall/productEdit',
query: { id }
@ -201,6 +234,10 @@ watch(
)
handleQuery()
onMounted(() => {
getOptions()
})
</script>
<style lang="scss" scoped>

@ -1,27 +1,27 @@
<template>
<Dialog title="发起采购" v-model="dialogVisible" width="800px">
<el-form :model="form" ref="addForm" :rules="rules" label-width="100px">
<el-form :model="form" ref="formRef" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :span="12" :offset="0">
<el-form-item label="产品" prop="product">
<el-select v-model="form.product" placeholder="请选择" filterable style="width: 100%">
<el-form-item label="产品" prop="productId">
<el-select v-model="form.productId" placeholder="请选择" filterable style="width: 100%">
<el-option
v-for="item in productOptions"
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in props.opts.product"
:key="item.productId"
:label="item.productName"
:value="item.productId"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" :offset="0">
<el-form-item label="规格" prop="specs">
<el-select v-model="form.specs" placeholder="请选择" filterable style="width: 100%">
<el-form-item label="规格" prop="specsId">
<el-select v-model="form.specsId" placeholder="请选择" filterable style="width: 100%">
<el-option
v-for="item in specsOptions"
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in specOptions"
:key="item.specsId"
:label="item.specsName"
:value="item.specsId"
/>
</el-select>
</el-form-item>
@ -30,34 +30,41 @@
<el-row :gutter="20">
<el-col :span="12" :offset="0">
<el-form-item label="供应商" prop="supplier">
<el-input v-model="form.supplier" placeholder="请输入" />
<el-select v-model="form.supplier" placeholder="选择供应商" filterable>
<el-option
v-for="item in opts.supplier"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" :offset="0">
<el-form-item label="采购数量" prop="purchaseCount">
<el-input-number
:min="1"
v-model="form.purchaseCount"
placeholder="请输入"
style="width: 100%"
/>
<el-form-item label="采购数量" prop="num">
<el-input-number :min="1" v-model="form.num" placeholder="请输入" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12" :offset="0">
<el-form-item label="采购单价" prop="price">
<el-form-item label="采购单价" prop="unitPrice">
<el-input-number
:min="0"
v-model="form.price"
v-model="form.unitPrice"
placeholder="请输入"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :span="12" :offset="0">
<el-form-item label="存放仓库" prop="warehouse">
<el-select v-model="form.warehouse" placeholder="请选择" filterable style="width: 100%">
<el-form-item label="存放仓库" prop="warehouseId">
<el-select
v-model="form.warehouseId"
placeholder="请选择"
filterable
style="width: 100%"
>
<el-option
v-for="item in warehouseOptions"
:key="item.value"
@ -86,13 +93,42 @@
</template>
<script setup>
import * as PurchaseApi from '@/api/mall/purchase'
const props = defineProps({
opts: {
type: Object,
default: () => {
return {
product: [],
spec: [],
supplier: []
}
}
}
})
const specOptions = computed(() => {
if (form.value.productId) {
return (
props.opts.product.find((it) => it.productId == form.value.productId)?.productSpecList || []
)
} else {
return []
}
})
const dialogVisible = ref(false) //
const form = ref()
const rules = ref({})
const form = ref({})
const rules = {
productId: { required: true, message: '产品不可为空', trigger: 'change' },
specsId: { required: true, message: '规格不可为空', trigger: 'change' },
supplier: { required: true, message: '供应商不可为空', trigger: 'change' },
warehouseId: { required: true, message: '仓库不可为空', trigger: 'change' },
num: { required: true, message: '采购数量不可为空', trigger: 'change,blur' },
unitPrice: { required: true, message: '采购单价不可为空', trigger: 'change,blur' }
}
const productOptions = ref([])
const specsOptions = ref([])
const warehouseOptions = ref([
{ label: '自营仓', value: 1 },
{ label: '供应商仓', value: 2 }
@ -100,19 +136,37 @@ const warehouseOptions = ref([
const open = (val) => {
dialogVisible.value = true
form.value = val || {
product: '',
specs: '',
supplier: '',
purchaseCount: 1,
warehouse: 1,
remark: ''
form.value = { ...val } || {
productId: undefined,
specsId: undefined,
supplier: undefined,
num: undefined,
unitPrice: undefined,
warehouseId: undefined,
remark: undefined
}
}
defineExpose({ open }) // open
function handleSave() {
console.log('保存')
const formRef = ref()
const formLoading = ref(false)
async function handleSave() {
//
if (!formRef.value) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
await PurchaseApi.createPurchase(form.value)
message.success(t('common.createSuccess'))
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

@ -1,11 +1,11 @@
<template>
<Dialog title="采购审核" v-model="dialogVisible" width="800px">
<Descriptions :data="form" :schema="schema" :columns="3" />
<el-form v-if="canEdit" :model="form" ref="auditForm" :rules="rules" label-width="80px">
<el-form v-if="canEdit" :model="form" ref="auditForm" label-width="80px">
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<el-form-item label="审核" prop="status">
<el-radio-group v-model="form.status">
<el-form-item label="审核" prop="isPass">
<el-radio-group v-model="form.isPass">
<el-radio :label="2">通过</el-radio>
<el-radio :label="3">驳回</el-radio>
</el-radio-group>
@ -29,74 +29,31 @@
</Dialog>
</template>
<script setup>
<script setup name="DialogAuditPurchase">
const dialogVisible = ref(false) //
const form = ref({})
const rules = ref({})
const canEdit = ref(true)
const schema = ref([
{
field: 'name',
label: '产品名称'
},
{
field: 'specsName',
label: '规格名称'
},
{
field: 'supplier',
label: '供应商'
},
{
field: 'purchaseCount',
label: '采购数量'
},
{
field: 'unitPrice',
label: '采购单价'
},
{
field: 'totalPrice',
label: '总金额'
},
{
field: 'warehouse',
label: '仓库'
},
{
field: 'warehouse',
label: '申请人'
},
{
field: '',
label: '申请时间'
},
{
field: 'remark',
label: '备注',
isEditor: true,
span: 3
}
])
const schema = ref([])
const open = (val, flag) => {
dialogVisible.value = true
form.value = { ...val, status: 2, remark: '<p style="color: red;">哈哈哈</p>' }
form.value = { ...val }
canEdit.value = flag
resetSchema()
if (!canEdit.value) {
const arr = [
{
field: 'status',
field: 'auditStatusName',
label: '采购状态'
},
{
field: 'auditUser',
field: 'checkUserName',
label: '审核人'
},
{
field: 'auditTime',
field: 'checkTime',
label: '审核时间'
},
{
@ -107,10 +64,61 @@ const open = (val, flag) => {
}
]
schema.value = [...schema.value, ...arr]
} else {
form.value.isPass = 2
form.value.auditRemark = ''
}
}
defineExpose({ open }) // open
const resetSchema = () => {
schema.value = [
{
field: 'productName',
label: '产品名称'
},
{
field: 'specsName',
label: '规格名称'
},
{
field: 'supplier',
label: '供应商'
},
{
field: 'num',
label: '采购数量'
},
{
field: 'unitPrice',
label: '采购单价'
},
{
field: 'totalPrice',
label: '总金额'
},
{
field: 'warehouseName',
label: '仓库'
},
{
field: 'applyUserName',
label: '申请人'
},
{
field: 'applyTime',
label: '申请时间',
dateFormat: 'YYYY-MM-DD'
},
{
field: 'remark',
label: '备注',
isEditor: true,
span: 3
}
]
}
function handleSave() {
console.log('保存')
}

@ -1,4 +1,3 @@
// import { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
const statusOptions = [
@ -7,11 +6,10 @@ const statusOptions = [
{ label: '已驳回', value: 3 }
]
// CrudSchema:https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive([
{
label: '产品名称',
field: 'name',
field: 'productName',
isSearch: true,
isTable: true
},
@ -29,7 +27,7 @@ const crudSchemas = reactive([
},
{
label: '采购数量',
field: 'purchaseCount',
field: 'num',
isSearch: false,
isTable: true
},
@ -47,7 +45,7 @@ const crudSchemas = reactive([
},
{
label: '仓库',
field: 'warehouse',
field: 'warehouseName',
isSearch: false,
isTable: true
},
@ -79,13 +77,13 @@ const crudSchemas = reactive([
},
{
label: '审核人',
field: 'auditUserName',
field: 'checkUserName',
isSearch: true,
isTable: true
},
{
label: '审核时间',
field: 'auditTime',
field: 'checkTime',
isSearch: true,
isTable: true,
formatter: dateFormatter,
@ -105,7 +103,7 @@ const crudSchemas = reactive([
},
{
label: '采购状态',
field: 'status',
field: 'auditStatus',
isSearch: true,
isTable: true,
search: {
@ -119,7 +117,7 @@ const crudSchemas = reactive([
}
},
table: {
field: 'statusName',
field: 'auditStatusName',
fixed: 'right'
}
},

@ -1,22 +1,76 @@
<template>
<div>
<!-- 搜索工作栏 -->
<Search :schema="allSchemas.searchSchema" labelWidth="0">
<template #actionMore>
<el-form inline :model="queryParams" class="-mb-15px" label-width="0">
<el-form-item>
<el-select
v-model="queryParams.productId"
placeholder="选择产品"
clearable
filterable
@change="changeProd"
>
<el-option
v-for="item in opts.product"
:key="item.productId"
:label="item.productName"
:value="item.productId"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="queryParams.specsId"
placeholder="选择规格"
clearable
filterable
:disabled="!queryParams.productId"
>
<el-option
v-for="item in opts.spec"
:key="item.specsId"
:label="item.specsName"
:value="item.specsId"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-select v-model="queryParams.supplier" placeholder="供应商" clearable filterable>
<el-option
v-for="item in opts.supplier"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-date-picker
v-model="queryParams.applyTime"
type="daterange"
range-separator="-"
start-placeholder="申请时间"
end-placeholder="申请时间"
/>
</el-form-item>
<el-form-item>
<el-date-picker
v-model="queryParams.checkTime"
type="daterange"
range-separator="-"
start-placeholder="审核时间"
end-placeholder="审核时间"
/>
</el-form-item>
<el-form-item>
<el-button @click="getList" v-hasPermi="['mall:purchase:search']"> 搜索 </el-button>
<el-button @click="resetQuery" v-hasPermi="['mall:purchase:reset']"> 重置 </el-button>
<el-button type="primary" @click="handleAdd" v-hasPermi="['mall:purchase:add']">
发起采购
</el-button>
</template>
</Search>
</el-form-item>
</el-form>
<!-- 列表 -->
<SSTable
class="mt-20px"
v-model:tableObject="tableObject"
:tableColumns="allSchemas.tableColumns"
@get-list="getTableList"
>
<el-table v-loading="loading" class="mt-20px" :data="tableList" border>
<el-table-column
v-for="item in allSchemas.tableColumns"
:key="item.table?.field || item.field"
@ -24,6 +78,7 @@
:label="item.label"
:fixed="item.fixed"
min-width="150px"
:formatter="item.formatter"
showOverflowTooltip
/>
<el-table-column label="操作" width="150px" fixed="right">
@ -56,53 +111,89 @@
</el-button>
</template>
</el-table-column>
</SSTable>
<DialogAdd ref="creatPurchase" />
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
<DialogAdd :opts="opts" ref="creatPurchase" />
<DialogAudit ref="auditPurchase" />
</div>
</template>
<script setup>
<script setup name="Purchase">
import * as ProductApi from '@/api/mall/product'
import { allSchemas } from './index.data.js'
import DialogAdd from './Comp/DialogAdd.vue'
import DialogAudit from './Comp/DialogAudit.vue'
import * as PurchaseApi from '@/api/mall/purchase'
import { getDictOptions } from '@/utils/dict'
const creatPurchase = ref()
const auditPurchase = ref()
const tableObject = ref({
tableList: [],
loading: false,
total: 1,
pageSize: 20,
currentPage: 1
const opts = ref({
product: [],
spec: [],
supplier: []
})
const tableList = ref([])
const loading = ref(false)
const total = ref(0)
const queryParams = ref({
productId: undefined,
specsId: undefined,
supplier: undefined,
applyTime: [],
checkTime: [],
pageNo: 1,
pageSize: 20
})
function getOptions() {
ProductApi.getSimpleProductList().then((data) => {
opts.value.product = data
})
opts.value.supplier = getDictOptions('erp_supplier')
}
function changeProd(val) {
if (val) {
opts.value.spec = opts.value.product.find((it) => it.productId == val).productSpecList
} else {
opts.value.spec = []
}
queryParams.value.specsId = undefined
}
function resetQuery() {
queryParams.value = {
productName: undefined,
productBrand: undefined,
productCategory: undefined,
productId: undefined,
specsId: undefined,
supplier: undefined,
applyTime: [],
checkTime: [],
pageNo: 1,
pageSize: 10
pageSize: 20
}
getList()
}
const getList = function () {
tableObject.value.tableList = [
{ name: '测试', status: 1, statusName: '审核中', supplier: '林氏木业', purchaseCount: 10 },
{ name: '测试2', status: 2, statusName: '已通过', supplier: '张氏木业', purchaseCount: 1 },
{ name: '测试3', status: 3, statusName: '已驳回', supplier: '周氏木业', purchaseCount: 5 }
]
}
function getTableList() {
tableObject.value.tableList = [
{ name: '测试', status: 1, statusName: '审核中', supplier: '林氏木业', purchaseCount: 10 },
{ name: '测试2', status: 2, statusName: '已通过', supplier: '张氏木业', purchaseCount: 1 },
{ name: '测试3', status: 3, statusName: '已驳回', supplier: '周氏木业', purchaseCount: 5 }
]
const getList = async function () {
loading.value = true
try {
const data = await PurchaseApi.getPurchasePage(queryParams.value)
tableList.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
function purchaseAgain(row) {
@ -119,6 +210,11 @@ function handleAdd() {
function handleDetail(row) {
auditPurchase.value.open({ ...row }, false)
}
onMounted(() => {
getOptions()
getList()
})
</script>
<style lang="scss" scoped></style>

Loading…
Cancel
Save