index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="供应商" prop="supplierId">
  12. <el-input
  13. v-model="queryParams.supplierId"
  14. placeholder="请输入供应商"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="证件类型" label-width="85px" prop="type">
  21. <el-select
  22. v-model="queryParams.type"
  23. placeholder="证件类型"
  24. clearable
  25. class="!w-240px"
  26. >
  27. <el-option
  28. v-for="dict in getIntDictOptions(DICT_TYPE.SUPPLIER_CERT)"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="证件名称" prop="name">
  36. <el-input
  37. v-model="queryParams.name"
  38. placeholder="请输入证件名称"
  39. clearable
  40. @keyup.enter="handleQuery"
  41. class="!w-240px"
  42. />
  43. </el-form-item>
  44. <!-- <el-form-item label="创建时间" prop="createTime">-->
  45. <!-- <el-date-picker-->
  46. <!-- v-model="queryParams.createTime"-->
  47. <!-- value-format="YYYY-MM-DD HH:mm:ss"-->
  48. <!-- type="daterange"-->
  49. <!-- start-placeholder="开始日期"-->
  50. <!-- end-placeholder="结束日期"-->
  51. <!-- :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
  52. <!-- class="!w-220px"-->
  53. <!-- />-->
  54. <!-- </el-form-item>-->
  55. <el-form-item>
  56. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  57. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  58. <el-button
  59. type="primary"
  60. plain
  61. @click="openForm('create')"
  62. >
  63. <Icon icon="ep:plus" class="mr-5px" /> 新增
  64. </el-button>
  65. <el-button
  66. type="success"
  67. plain
  68. @click="handleExport"
  69. :loading="exportLoading"
  70. >
  71. <Icon icon="ep:download" class="mr-5px" /> 导出
  72. </el-button>
  73. </el-form-item>
  74. </el-form>
  75. </ContentWrap>
  76. <!-- 列表 -->
  77. <ContentWrap>
  78. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  79. <!-- <el-table-column label="主键" align="center" prop="id" />-->
  80. <el-table-column label="供应商" align="center" prop="supplierId" >
  81. <template #default="scope">
  82. <span>{{ supplierList.find((item) => item.id === scope.row.supplierId)?.name }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="证件类型" align="center" prop="type" >
  86. <template #default="scope">
  87. <dict-tag :type="DICT_TYPE.SUPPLIER_CERT" :value="scope.row.type" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="证件名称" align="center" prop="name" />
  91. <el-table-column label="附件" align="center" prop="urls" />
  92. <el-table-column
  93. label="创建时间"
  94. align="center"
  95. prop="createTime"
  96. :formatter="dateFormatter"
  97. width="180px"
  98. />
  99. <el-table-column label="操作" align="center" min-width="120px">
  100. <template #default="scope">
  101. <el-button
  102. link
  103. type="primary"
  104. @click="openForm('update', scope.row.id)"
  105. >
  106. 编辑
  107. </el-button>
  108. <el-button
  109. link
  110. type="danger"
  111. @click="handleDelete(scope.row.id)"
  112. >
  113. 删除
  114. </el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <!-- 分页 -->
  119. <Pagination
  120. :total="total"
  121. v-model:page="queryParams.pageNo"
  122. v-model:limit="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. </ContentWrap>
  126. <!-- 表单弹窗:添加/修改 -->
  127. <CertificateForm ref="formRef" @success="getList" />
  128. </template>
  129. <script setup lang="ts">
  130. import { dateFormatter } from '@/utils/formatTime'
  131. import download from '@/utils/download'
  132. import { CertificateApi, CertificateVO } from '@/api/supplier/certificate'
  133. import CertificateForm from './CertificateForm.vue'
  134. import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
  135. import {SupplierVO} from "@/api/supplier/base";
  136. import * as SupplierBaseApi from "@/api/supplier/base";
  137. /** 供应商证件资质 列表 */
  138. defineOptions({ name: 'SupplierCertificate' })
  139. const supplierList = ref([] as SupplierVO[])
  140. const message = useMessage() // 消息弹窗
  141. const { t } = useI18n() // 国际化
  142. const loading = ref(true) // 列表的加载中
  143. const list = ref<CertificateVO[]>([]) // 列表的数据
  144. const total = ref(0) // 列表的总页数
  145. const queryParams = reactive({
  146. pageNo: 1,
  147. pageSize: 10,
  148. supplierId: undefined,
  149. supplierName: undefined,
  150. type: undefined,
  151. name: undefined,
  152. urls: undefined,
  153. createTime: [],
  154. })
  155. const queryFormRef = ref() // 搜索的表单
  156. const exportLoading = ref(false) // 导出的加载中
  157. /** 查询列表 */
  158. const getList = async () => {
  159. loading.value = true
  160. try {
  161. const data = await CertificateApi.getCertificatePage(queryParams)
  162. list.value = data.list
  163. total.value = data.total
  164. } finally {
  165. loading.value = false
  166. }
  167. }
  168. /** 搜索按钮操作 */
  169. const handleQuery = () => {
  170. queryParams.pageNo = 1
  171. getList()
  172. }
  173. /** 重置按钮操作 */
  174. const resetQuery = () => {
  175. queryFormRef.value.resetFields()
  176. handleQuery()
  177. }
  178. /** 添加/修改操作 */
  179. const formRef = ref()
  180. const openForm = (type: string, id?: number) => {
  181. formRef.value.open(type, id)
  182. }
  183. /** 删除按钮操作 */
  184. const handleDelete = async (id: number) => {
  185. try {
  186. // 删除的二次确认
  187. await message.delConfirm()
  188. // 发起删除
  189. await CertificateApi.deleteCertificate(id)
  190. message.success(t('common.delSuccess'))
  191. // 刷新列表
  192. await getList()
  193. } catch {}
  194. }
  195. /** 导出按钮操作 */
  196. const handleExport = async () => {
  197. try {
  198. // 导出的二次确认
  199. await message.exportConfirm()
  200. // 发起导出
  201. exportLoading.value = true
  202. const data = await CertificateApi.exportCertificate(queryParams)
  203. download.excel(data, '供应商证件资质.xls')
  204. } catch {
  205. } finally {
  206. exportLoading.value = false
  207. }
  208. }
  209. /** 初始化 **/
  210. onMounted(async () => {
  211. await getList()
  212. supplierList.value = await SupplierBaseApi.Api.getAll()
  213. })
  214. </script>