index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <doc-alert title="【采购】采购订单、入库、退货" url="https://doc.iocoder.cn/erp/purchase/" />
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="名称" prop="name">
  13. <el-input
  14. v-model="queryParams.name"
  15. placeholder="请输入名称"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="手机号码" prop="mobile">
  22. <el-input
  23. v-model="queryParams.mobile"
  24. placeholder="请输入手机号码"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="联系电话" prop="telephone">
  31. <el-input
  32. v-model="queryParams.telephone"
  33. placeholder="请输入联系电话"
  34. clearable
  35. @keyup.enter="handleQuery"
  36. class="!w-240px"
  37. />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  41. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  42. <el-button
  43. type="primary"
  44. plain
  45. @click="openForm('create')"
  46. v-hasPermi="['erp:supplier:create']"
  47. >
  48. <Icon icon="ep:plus" class="mr-5px" /> 新增
  49. </el-button>
  50. <el-button
  51. type="success"
  52. plain
  53. @click="handleExport"
  54. :loading="exportLoading"
  55. v-hasPermi="['erp:supplier:export']"
  56. >
  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="name" />
  66. <el-table-column label="联系人" align="center" prop="contact" />
  67. <el-table-column label="手机号码" align="center" prop="mobile" />
  68. <el-table-column label="联系电话" align="center" prop="telephone" />
  69. <el-table-column label="电子邮箱" align="center" prop="email" />
  70. <el-table-column label="备注" align="center" prop="remark" />
  71. <el-table-column label="排序" align="center" prop="sort" />
  72. <el-table-column label="状态" align="center" prop="status">
  73. <template #default="scope">
  74. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作" align="center">
  78. <template #default="scope">
  79. <el-button
  80. link
  81. type="primary"
  82. @click="openForm('update', scope.row.id)"
  83. v-hasPermi="['erp:supplier:update']"
  84. >
  85. 编辑
  86. </el-button>
  87. <el-button
  88. link
  89. type="danger"
  90. @click="handleDelete(scope.row.id)"
  91. v-hasPermi="['erp:supplier:delete']"
  92. >
  93. 删除
  94. </el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <!-- 分页 -->
  99. <Pagination
  100. :total="total"
  101. v-model:page="queryParams.pageNo"
  102. v-model:limit="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. </ContentWrap>
  106. <!-- 表单弹窗:添加/修改 -->
  107. <SupplierForm ref="formRef" @success="getList" />
  108. </template>
  109. <script setup lang="ts">
  110. import { DICT_TYPE } from '@/utils/dict'
  111. import { dateFormatter } from '@/utils/formatTime'
  112. import download from '@/utils/download'
  113. import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
  114. import SupplierForm from './SupplierForm.vue'
  115. /** ERP 供应商 列表 */
  116. defineOptions({ name: 'ErpSupplier' })
  117. const message = useMessage() // 消息弹窗
  118. const { t } = useI18n() // 国际化
  119. const loading = ref(true) // 列表的加载中
  120. const list = ref<SupplierVO[]>([]) // 列表的数据
  121. const total = ref(0) // 列表的总页数
  122. const queryParams = reactive({
  123. pageNo: 1,
  124. pageSize: 10,
  125. name: undefined,
  126. mobile: undefined,
  127. telephone: undefined
  128. })
  129. const queryFormRef = ref() // 搜索的表单
  130. const exportLoading = ref(false) // 导出的加载中
  131. /** 查询列表 */
  132. const getList = async () => {
  133. loading.value = true
  134. try {
  135. const data = await SupplierApi.getSupplierPage(queryParams)
  136. list.value = data.list
  137. total.value = data.total
  138. } finally {
  139. loading.value = false
  140. }
  141. }
  142. /** 搜索按钮操作 */
  143. const handleQuery = () => {
  144. queryParams.pageNo = 1
  145. getList()
  146. }
  147. /** 重置按钮操作 */
  148. const resetQuery = () => {
  149. queryFormRef.value.resetFields()
  150. handleQuery()
  151. }
  152. /** 添加/修改操作 */
  153. const formRef = ref()
  154. const openForm = (type: string, id?: number) => {
  155. formRef.value.open(type, id)
  156. }
  157. /** 删除按钮操作 */
  158. const handleDelete = async (id: number) => {
  159. try {
  160. // 删除的二次确认
  161. await message.delConfirm()
  162. // 发起删除
  163. await SupplierApi.deleteSupplier(id)
  164. message.success(t('common.delSuccess'))
  165. // 刷新列表
  166. await getList()
  167. } catch {}
  168. }
  169. /** 导出按钮操作 */
  170. const handleExport = async () => {
  171. try {
  172. // 导出的二次确认
  173. await message.exportConfirm()
  174. // 发起导出
  175. exportLoading.value = true
  176. const data = await SupplierApi.exportSupplier(queryParams)
  177. download.excel(data, 'ERP 供应商.xls')
  178. } catch {
  179. } finally {
  180. exportLoading.value = false
  181. }
  182. }
  183. /** 初始化 **/
  184. onMounted(() => {
  185. getList()
  186. })
  187. </script>