From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/crm/product/index.vue | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 230 insertions(+), 0 deletions(-)
diff --git a/src/views/crm/product/index.vue b/src/views/crm/product/index.vue
new file mode 100644
index 0000000..5d656df
--- /dev/null
+++ b/src/views/crm/product/index.vue
@@ -0,0 +1,230 @@
+<template>
+ <doc-alert title="銆愪骇鍝併�戜骇鍝佺鐞嗐�佷骇鍝佸垎绫�" url="https://doc.iocoder.cn/crm/product/" />
+
+ <ContentWrap>
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <el-form
+ class="-mb-15px"
+ :model="queryParams"
+ ref="queryFormRef"
+ :inline="true"
+ label-width="68px"
+ >
+ <el-form-item label="浜у搧鍚嶇О" prop="name">
+ <el-input
+ v-model="queryParams.name"
+ placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+ clearable
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item label="鐘舵��" prop="status">
+ <el-select v-model="queryParams.status" placeholder="璇烽�夋嫨鐘舵��" clearable class="!w-240px">
+ <el-option
+ v-for="dict in getIntDictOptions(DICT_TYPE.CRM_PRODUCT_STATUS)"
+ :key="dict.value"
+ :label="dict.label"
+ :value="dict.value"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item>
+ <el-button @click="handleQuery"> <Icon icon="ep:search" class="mr-5px" /> 鎼滅储 </el-button>
+ <el-button @click="resetQuery"> <Icon icon="ep:refresh" class="mr-5px" /> 閲嶇疆 </el-button>
+ <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:product:create']">
+ <Icon icon="ep:plus" class="mr-5px" /> 鏂板
+ </el-button>
+ <el-button
+ type="success"
+ plain
+ @click="handleExport"
+ :loading="exportLoading"
+ v-hasPermi="['crm:product:export']"
+ >
+ <Icon icon="ep:download" class="mr-5px" />
+ 瀵煎嚭
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </ContentWrap>
+
+ <!-- 鍒楄〃 -->
+ <ContentWrap>
+ <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
+ <el-table-column label="浜у搧鍚嶇О" align="center" prop="name" width="160">
+ <template #default="scope">
+ <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
+ {{ scope.row.name }}
+ </el-link>
+ </template>
+ </el-table-column>
+ <el-table-column label="浜у搧绫诲瀷" align="center" prop="categoryName" width="160" />
+ <el-table-column label="浜у搧鍗曚綅" align="center" prop="unit">
+ <template #default="scope">
+ <dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="scope.row.unit" />
+ </template>
+ </el-table-column>
+ <el-table-column label="浜у搧缂栫爜" align="center" prop="no" />
+ <el-table-column
+ label="浠锋牸锛堝厓锛�"
+ align="center"
+ prop="price"
+ :formatter="erpPriceTableColumnFormatter"
+ width="100"
+ />
+ <el-table-column label="浜у搧鎻忚堪" align="center" prop="description" width="150" />
+ <el-table-column label="涓婃灦鐘舵��" align="center" prop="status" width="120">
+ <template #default="scope">
+ <dict-tag :type="DICT_TYPE.CRM_PRODUCT_STATUS" :value="scope.row.status" />
+ </template>
+ </el-table-column>
+ <el-table-column label="璐熻矗浜�" align="center" prop="ownerUserName" width="120" />
+ <el-table-column
+ label="鏇存柊鏃堕棿"
+ align="center"
+ prop="updateTime"
+ :formatter="dateFormatter"
+ width="180px"
+ />
+ <el-table-column label="鍒涘缓浜�" align="center" prop="creatorName" width="120" />
+ <el-table-column
+ label="鍒涘缓鏃堕棿"
+ align="center"
+ prop="createTime"
+ :formatter="dateFormatter"
+ width="180px"
+ />
+ <el-table-column label="鎿嶄綔" align="center" fixed="right" width="160">
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ @click="openForm('update', scope.row.id)"
+ v-hasPermi="['crm:product:update']"
+ >
+ 缂栬緫
+ </el-button>
+ <el-button
+ link
+ type="danger"
+ @click="handleDelete(scope.row.id)"
+ v-hasPermi="['crm:product:delete']"
+ >
+ 鍒犻櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ :total="total"
+ v-model:page="queryParams.pageNo"
+ v-model:limit="queryParams.pageSize"
+ @pagination="getList"
+ />
+ </ContentWrap>
+
+ <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+ <ProductForm ref="formRef" @success="getList" />
+</template>
+
+<script setup lang="ts">
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { dateFormatter } from '@/utils/formatTime'
+import download from '@/utils/download'
+import * as ProductApi from '@/api/crm/product'
+import ProductForm from './ProductForm.vue'
+import { erpPriceTableColumnFormatter } from '@/utils'
+
+defineOptions({ name: 'CrmProduct' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10,
+ name: undefined,
+ status: undefined
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const exportLoading = ref(false) // 瀵煎嚭鐨勫姞杞戒腑
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ const data = await ProductApi.getProductPage(queryParams)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.pageNo = 1
+ getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+ queryFormRef.value.resetFields()
+ handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ formRef.value.open(type, id)
+}
+
+/** 鎵撳紑璇︽儏 */
+const { currentRoute, push } = useRouter()
+const openDetail = (id: number) => {
+ push({ name: 'CrmProductDetail', params: { id } })
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id: number) => {
+ try {
+ // 鍒犻櫎鐨勪簩娆$‘璁�
+ await message.delConfirm()
+ // 鍙戣捣鍒犻櫎
+ await ProductApi.deleteProduct(id)
+ message.success(t('common.delSuccess'))
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+/** 瀵煎嚭鎸夐挳鎿嶄綔 */
+const handleExport = async () => {
+ try {
+ // 瀵煎嚭鐨勪簩娆$‘璁�
+ await message.exportConfirm()
+ // 鍙戣捣瀵煎嚭
+ exportLoading.value = true
+ const data = await ProductApi.exportProduct(queryParams)
+ download.excel(data, '浜у搧.xls')
+ } catch {
+ } finally {
+ exportLoading.value = false
+ }
+}
+
+/** 婵�娲绘椂 */
+onActivated(() => {
+ getList()
+})
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+ getList()
+})
+</script>
--
Gitblit v1.8.0