index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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" v-if="ifAlone==null">
  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="90px" prop="username">
  21. <el-input
  22. v-model="queryParams.username"
  23. placeholder="请输入我方联系人"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item label="供应商联系人" label-width="98px" prop="contactName">
  30. <el-input
  31. v-model="queryParams.contactName"
  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. v-if="!isDetail"
  43. type="primary"
  44. plain
  45. @click="openForm('create')"
  46. >
  47. <Icon icon="ep:plus" class="mr-5px" /> 新增
  48. </el-button>
  49. <el-button
  50. v-if="!isDetail"
  51. type="success"
  52. plain
  53. @click="handleExport"
  54. :loading="exportLoading"
  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="supplierId" >
  65. <template #default="scope">
  66. <span>{{ supplierList.find((item) => item.id === scope.row.supplierId)?.name }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="我方联系人姓名" align="center" prop="username" />
  70. <el-table-column label="供应商联系人姓名" align="center" prop="contactName" />
  71. <el-table-column label="联系原因" align="center" prop="reason" />
  72. <el-table-column label="交流内容" align="center" prop="content" />
  73. <el-table-column label="附件" align="center" prop="urls" />
  74. <el-table-column
  75. label="创建时间"
  76. align="center"
  77. prop="createTime"
  78. :formatter="dateFormatter"
  79. width="180px"
  80. />
  81. <el-table-column label="操作" v-if="!isDetail" align="center" min-width="120px">
  82. <template #default="scope">
  83. <el-button
  84. link
  85. type="primary"
  86. @click="openForm('update', scope.row.id)"
  87. >
  88. 编辑
  89. </el-button>
  90. <el-button
  91. link
  92. type="danger"
  93. @click="handleDelete(scope.row.id)"
  94. >
  95. 删除
  96. </el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <!-- 分页 -->
  101. <Pagination
  102. :total="total"
  103. v-model:page="queryParams.pageNo"
  104. v-model:limit="queryParams.pageSize"
  105. @pagination="getList"
  106. />
  107. </ContentWrap>
  108. <!-- 表单弹窗:添加/修改 -->
  109. <ConnectRecordForm ref="formRef" :supplierId="{ receivedParam }" :ifAlone="ifAlone" @success="getList" />
  110. <el-form v-if="ifAlone!= null">
  111. <el-form-item style="float: right">
  112. <el-button type="primary" @click="close">返回</el-button>
  113. </el-form-item>
  114. </el-form>
  115. </template>
  116. <script setup lang="ts">
  117. import { dateFormatter } from '@/utils/formatTime'
  118. import download from '@/utils/download'
  119. import { ConnectRecordApi, ConnectRecordVO } from '@/api/supplier/connect/index'
  120. import ConnectRecordForm from './ConnectRecordForm.vue'
  121. import {SupplierVO} from "@/api/supplier/base";
  122. import * as SupplierBaseApi from "@/api/supplier/base";
  123. import { propTypes } from '@/utils/propTypes'
  124. import {useTagsViewStore} from "@/store/modules/tagsView";
  125. const { delView } = useTagsViewStore() // 视图操作
  126. const { push, currentRoute } = useRouter() // 路由
  127. /** 供应商联系记录 列表 */
  128. defineOptions({ name: 'ConnectRecord' })
  129. const message = useMessage() // 消息弹窗
  130. const { t } = useI18n() // 国际化
  131. const props = defineProps({
  132. isDetail: propTypes.bool.def(false), // 是否作为详情组件
  133. ifAlone: {type:Boolean, default:()=>null},
  134. receivedParam: { type: undefined, default: () => null }
  135. })
  136. const loading = ref(true) // 列表的加载中
  137. const list = ref<ConnectRecordVO[]>([]) // 列表的数据
  138. const total = ref(0) // 列表的总页数
  139. const supplierList = ref([] as SupplierVO[])
  140. const queryParams = reactive({
  141. pageNo: 1,
  142. pageSize: 10,
  143. supplierId: undefined,
  144. userId: undefined,
  145. username: undefined,
  146. contactId: undefined,
  147. contactName: undefined,
  148. reason: undefined,
  149. content: undefined,
  150. urls: undefined,
  151. createTime: [],
  152. })
  153. const queryFormRef = ref() // 搜索的表单
  154. const exportLoading = ref(false) // 导出的加载中
  155. /** 查询列表 */
  156. const getList = async () => {
  157. supplierList.value = await SupplierBaseApi.Api.getAll()
  158. loading.value = true
  159. try {
  160. if (props.ifAlone!=null) {
  161. queryParams.supplierId = props.receivedParam === null?'0000000000':props.receivedParam
  162. }
  163. const data = await ConnectRecordApi.getConnectRecordPage(queryParams)
  164. list.value = data.list
  165. total.value = data.total
  166. queryParams.supplierId = undefined
  167. } finally {
  168. loading.value = false
  169. }
  170. }
  171. /** 搜索按钮操作 */
  172. const handleQuery = async () => {
  173. queryParams.pageNo = 1
  174. await getList()
  175. supplierList.value = await SupplierBaseApi.Api.getAll()
  176. }
  177. /** 重置按钮操作 */
  178. const resetQuery = () => {
  179. queryFormRef.value.resetFields()
  180. handleQuery()
  181. }
  182. /** 添加/修改操作 */
  183. const formRef = ref()
  184. const openForm = (type: string, id?: number) => {
  185. formRef.value.open(type, id)
  186. }
  187. /** 删除按钮操作 */
  188. const handleDelete = async (id: number) => {
  189. try {
  190. // 删除的二次确认
  191. await message.delConfirm()
  192. // 发起删除
  193. await ConnectRecordApi.deleteConnectRecord(id)
  194. message.success(t('common.delSuccess'))
  195. // 刷新列表
  196. await getList()
  197. } catch {}
  198. }
  199. /** 导出按钮操作 */
  200. const handleExport = async () => {
  201. try {
  202. // 导出的二次确认
  203. await message.exportConfirm()
  204. // 发起导出
  205. exportLoading.value = true
  206. const data = await ConnectRecordApi.exportConnectRecord(queryParams)
  207. download.excel(data, '供应商联系记录.xls')
  208. } catch {
  209. } finally {
  210. exportLoading.value = false
  211. }
  212. }
  213. /** 初始化 **/
  214. onMounted(async () => {
  215. await getList()
  216. supplierList.value = await SupplierBaseApi.Api.getAll()
  217. })
  218. const close = () => {
  219. delView(unref(currentRoute))
  220. push({ name: 'Suppliers',query: {
  221. date: new Date().getTime(),
  222. } })
  223. }
  224. </script>