index.vue 5.5 KB

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