index.vue 7.3 KB

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