lipenghui 5 ヶ月 前
コミット
beb598a2c0

+ 43 - 0
src/api/supplier/certificate/index.ts

@@ -0,0 +1,43 @@
+import request from '@/config/axios'
+
+// 供应商证件资质 VO
+export interface CertificateVO {
+  id: number // 主键
+  supplierId: number // 供应商id
+  type: string // 证件类型 字典表
+  name: string // 证件名称
+  urls: string // 附件 多个附件逗号分隔
+}
+
+// 供应商证件资质 API
+export const CertificateApi = {
+  // 查询供应商证件资质分页
+  getCertificatePage: async (params: any) => {
+    return await request.get({ url: `/supplier/certificate/page`, params })
+  },
+
+  // 查询供应商证件资质详情
+  getCertificate: async (id: number) => {
+    return await request.get({ url: `/supplier/certificate/get?id=` + id })
+  },
+
+  // 新增供应商证件资质
+  createCertificate: async (data: CertificateVO) => {
+    return await request.post({ url: `/supplier/certificate/create`, data })
+  },
+
+  // 修改供应商证件资质
+  updateCertificate: async (data: CertificateVO) => {
+    return await request.put({ url: `/supplier/certificate/update`, data })
+  },
+
+  // 删除供应商证件资质
+  deleteCertificate: async (id: number) => {
+    return await request.delete({ url: `/supplier/certificate/delete?id=` + id })
+  },
+
+  // 导出供应商证件资质 Excel
+  exportCertificate: async (params) => {
+    return await request.download({ url: `/supplier/certificate/export-excel`, params })
+  },
+}

+ 1 - 0
src/utils/dict.ts

@@ -118,6 +118,7 @@ export enum DICT_TYPE {
   SUPPLIER_NATURE = "supplier_nature",
   SUPPLIER_STATUS = "supplier_status",
   SUPPLIER_SIZE = "supplier_size",
+  SUPPLIER_CERT = "supplier_certificate",
   // ========== SYSTEM 模块 ==========
   SYSTEM_USER_SEX = 'system_user_sex',
   SYSTEM_MENU_TYPE = 'system_menu_type',

+ 5 - 5
src/views/supplier/base/form/index.vue

@@ -1,7 +1,7 @@
 <template>
   <ContentWrap v-loading="formLoading">
     <el-tabs v-model="activeName">
-      <el-tab-pane label="基础设置" name="info">
+      <el-tab-pane label="基础信息" name="info">
         <InfoForm
           ref="infoRef"
           v-model:activeName="activeName"
@@ -9,7 +9,7 @@
           :propFormData="formData"
         />
       </el-tab-pane>
-      <el-tab-pane label="价格库存" name="sku">
+      <el-tab-pane label="证件信息" name="sku">
         <SkuForm
           ref="skuRef"
           v-model:activeName="activeName"
@@ -17,7 +17,7 @@
           :propFormData="formData"
         />
       </el-tab-pane>
-      <el-tab-pane label="物流设置" name="delivery">
+      <el-tab-pane label="联系人" name="delivery">
         <DeliveryForm
           ref="deliveryRef"
           v-model:activeName="activeName"
@@ -25,7 +25,7 @@
           :propFormData="formData"
         />
       </el-tab-pane>
-      <el-tab-pane label="商品详情" name="description">
+      <el-tab-pane label="核心产品" name="description">
         <DescriptionForm
           ref="descriptionRef"
           v-model:activeName="activeName"
@@ -33,7 +33,7 @@
           :propFormData="formData"
         />
       </el-tab-pane>
-      <el-tab-pane label="其它设置" name="other">
+      <el-tab-pane label="联系记录" name="other">
         <OtherForm
           ref="otherRef"
           v-model:activeName="activeName"

+ 133 - 0
src/views/supplier/certificate/CertificateForm.vue

@@ -0,0 +1,133 @@
+<template>
+  <Dialog :title="dialogTitle" v-model="dialogVisible">
+    <el-form
+      ref="formRef"
+      :model="formData"
+      :rules="formRules"
+      label-width="100px"
+      v-loading="formLoading"
+    >
+      <el-form-item label="供应商" prop="supplierId">
+        <el-select v-model="formData.supplierId" filterable placeholder="请选择">
+          <el-option
+            v-for="dict in supplierList"
+            :key="dict.id"
+            :label="dict.name"
+            :value="dict.id"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="证件类型" prop="type">
+        <el-select v-model="formData.type" placeholder="请选择">
+          <el-option
+            v-for="dict in getIntDictOptions(DICT_TYPE.SUPPLIER_CERT)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="证件名称" prop="name">
+        <el-input v-model="formData.name" placeholder="请输入证件名称" />
+      </el-form-item>
+      <el-form-item label="附件" prop="urls">
+        <UploadFile :is-show-tip="false" v-model="formData.urls"/>
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
+      <el-button @click="dialogVisible = false">取 消</el-button>
+    </template>
+  </Dialog>
+</template>
+<script setup lang="ts">
+import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
+import { CertificateApi, CertificateVO } from '@/api/supplier/certificate'
+import {SupplierVO} from "@/api/supplier/base";
+import * as SupplierBaseApi from "@/api/supplier/base";
+import {FormRules} from "element-plus";
+
+/** 供应商证件资质 表单 */
+defineOptions({ name: 'CertificateForm' })
+
+const { t } = useI18n() // 国际化
+const message = useMessage() // 消息弹窗
+const supplierList = ref([] as SupplierVO[])
+const dialogVisible = ref(false) // 弹窗的是否展示
+const dialogTitle = ref('') // 弹窗的标题
+const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
+const formType = ref('') // 表单的类型:create - 新增;update - 修改
+const formData = ref({
+  id: undefined,
+  supplierId: undefined,
+  supplierName: undefined,
+  type: undefined,
+  name: undefined,
+  urls: undefined,
+})
+const formRules = reactive<FormRules>({
+  supplierId: [{ required: true, message: '供应商不能为空', trigger: 'blur' }],
+  type: [{ required: true, message: '证件类型不能为空', trigger: 'blur' }],
+  name: [{ required: true, message: '证件名称不能为空', trigger: 'blur' }],
+})
+const formRef = ref() // 表单 Ref
+
+/** 打开弹窗 */
+const open = async (type: string, id?: number) => {
+  dialogVisible.value = true
+  dialogTitle.value = t('action.' + type)
+  formType.value = type
+  resetForm()
+  // 修改时,设置数据
+  if (id) {
+    formLoading.value = true
+    try {
+      formData.value = await CertificateApi.getCertificate(id)
+    } finally {
+      formLoading.value = false
+    }
+  }
+  supplierList.value = await SupplierBaseApi.Api.getAll()
+}
+defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+
+/** 提交表单 */
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
+const submitForm = async () => {
+  // 校验表单
+  await formRef.value.validate()
+  // 提交请求
+  formLoading.value = true
+  try {
+    const data = formData.value as unknown as CertificateVO
+    // const supplier = data.supplierId
+    // data.supplierId = supplier.id
+    // data.supplierName = supplier.name
+    data.urls = data.urls.join(",")
+    if (formType.value === 'create') {
+      await CertificateApi.createCertificate(data)
+      message.success(t('common.createSuccess'))
+    } else {
+      await CertificateApi.updateCertificate(data)
+      message.success(t('common.updateSuccess'))
+    }
+    dialogVisible.value = false
+    // 发送操作成功的事件
+    emit('success')
+  } finally {
+    formLoading.value = false
+  }
+}
+
+/** 重置表单 */
+const resetForm = () => {
+  formData.value = {
+    id: undefined,
+    supplierId: undefined,
+    type: undefined,
+    name: undefined,
+    urls: undefined,
+  }
+  formRef.value?.resetFields()
+}
+</script>

+ 225 - 0
src/views/supplier/certificate/index.vue

@@ -0,0 +1,225 @@
+<template>
+  <ContentWrap>
+    <!-- 搜索工作栏 -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="供应商" prop="supplierId">
+        <el-input
+          v-model="queryParams.supplierId"
+          placeholder="请输入供应商"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="证件类型" label-width="85px"  prop="type">
+        <el-select
+          v-model="queryParams.type"
+          placeholder="证件类型"
+          clearable
+          class="!w-240px"
+        >
+          <el-option
+            v-for="dict in getIntDictOptions(DICT_TYPE.SUPPLIER_CERT)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <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="createTime">-->
+<!--        <el-date-picker-->
+<!--          v-model="queryParams.createTime"-->
+<!--          value-format="YYYY-MM-DD HH:mm:ss"-->
+<!--          type="daterange"-->
+<!--          start-placeholder="开始日期"-->
+<!--          end-placeholder="结束日期"-->
+<!--          :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
+<!--          class="!w-220px"-->
+<!--        />-->
+<!--      </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"
+          plain
+          @click="openForm('create')"
+        >
+          <Icon icon="ep:plus" class="mr-5px" /> 新增
+        </el-button>
+        <el-button
+          type="success"
+          plain
+          @click="handleExport"
+          :loading="exportLoading"
+        >
+          <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="id" />-->
+      <el-table-column label="供应商" align="center" prop="supplierId" >
+        <template #default="scope">
+          <span>{{ supplierList.find((item) => item.id === scope.row.supplierId)?.name }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="证件类型" align="center" prop="type" >
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.SUPPLIER_CERT" :value="scope.row.type" />
+        </template>
+      </el-table-column>
+      <el-table-column label="证件名称" align="center" prop="name" />
+      <el-table-column label="附件" align="center" prop="urls" />
+      <el-table-column
+        label="创建时间"
+        align="center"
+        prop="createTime"
+        :formatter="dateFormatter"
+        width="180px"
+      />
+      <el-table-column label="操作" align="center" min-width="120px">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            @click="openForm('update', scope.row.id)"
+          >
+            编辑
+          </el-button>
+          <el-button
+            link
+            type="danger"
+            @click="handleDelete(scope.row.id)"
+          >
+            删除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 表单弹窗:添加/修改 -->
+  <CertificateForm ref="formRef" @success="getList" />
+</template>
+
+<script setup lang="ts">
+import { dateFormatter } from '@/utils/formatTime'
+import download from '@/utils/download'
+import { CertificateApi, CertificateVO } from '@/api/supplier/certificate'
+import CertificateForm from './CertificateForm.vue'
+import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
+import {SupplierVO} from "@/api/supplier/base";
+import * as SupplierBaseApi from "@/api/supplier/base";
+/** 供应商证件资质 列表 */
+defineOptions({ name: 'SupplierCertificate' })
+const supplierList = ref([] as SupplierVO[])
+const message = useMessage() // 消息弹窗
+const { t } = useI18n() // 国际化
+
+const loading = ref(true) // 列表的加载中
+const list = ref<CertificateVO[]>([]) // 列表的数据
+const total = ref(0) // 列表的总页数
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  supplierId: undefined,
+  supplierName: undefined,
+  type: undefined,
+  name: undefined,
+  urls: undefined,
+  createTime: [],
+})
+const queryFormRef = ref() // 搜索的表单
+const exportLoading = ref(false) // 导出的加载中
+
+/** 查询列表 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await CertificateApi.getCertificatePage(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 handleDelete = async (id: number) => {
+  try {
+    // 删除的二次确认
+    await message.delConfirm()
+    // 发起删除
+    await CertificateApi.deleteCertificate(id)
+    message.success(t('common.delSuccess'))
+    // 刷新列表
+    await getList()
+  } catch {}
+}
+
+/** 导出按钮操作 */
+const handleExport = async () => {
+  try {
+    // 导出的二次确认
+    await message.exportConfirm()
+    // 发起导出
+    exportLoading.value = true
+    const data = await CertificateApi.exportCertificate(queryParams)
+    download.excel(data, '供应商证件资质.xls')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
+/** 初始化 **/
+onMounted(async () => {
+  await getList()
+  supplierList.value = await SupplierBaseApi.Api.getAll()
+})
+</script>