index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="table_item">
  3. <s-table
  4. ref="tableRef"
  5. :columns="columns"
  6. :data="loadData"
  7. :alert="options.alert.show"
  8. :row-key="(record) => record.id"
  9. bordered
  10. @resizeColumn="handleResizeColumn"
  11. :row-selection="options.rowSelection"
  12. >
  13. <template #operator>
  14. <!-- 搜索区域 -->
  15. <div class="table-search">
  16. <div class="table-search-form">
  17. <a-row :gutter="10">
  18. <a-form
  19. ref="searchFormRef"
  20. name="advanced_search"
  21. layout="inline"
  22. :label-col="{ style: { width: '70px', justifyContent: 'end' } }"
  23. :model="searchFormState"
  24. class="ant-advanced-search-form"
  25. >
  26. <a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8"
  27. ><a-form-item label="真实姓名" name="name">
  28. <a-input v-model:value="searchFormState.name" placeholder="请输入真实姓名" /> </a-form-item
  29. ></a-col>
  30. <a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8"
  31. ><a-form-item label="微信昵称" name="nickName">
  32. <a-input v-model:value="searchFormState.nickName" placeholder="请输入微信昵称" /> </a-form-item
  33. ></a-col>
  34. </a-form>
  35. </a-row>
  36. </div>
  37. <div class="table-search-buttons">
  38. <a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
  39. <a-button class="xn-mg08" @click="reset">重置</a-button>
  40. </div>
  41. </div>
  42. <!-- 其他操作区域 -->
  43. <div class="table-head-btn">
  44. <div class="btn-left" style="display: flex">
  45. <!-- <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('alarmUserAdd')">
  46. <template #icon><plus-outlined /></template>新增
  47. </a-button> -->
  48. <xn-batch-button
  49. class="xn-mg08"
  50. v-if="hasPerm('alarmUserBatchDelete')"
  51. buttonName="批量删除"
  52. icon="DeleteOutlined"
  53. :selectedRowKeys="selectedRowKeys"
  54. @batchCallBack="deleteBatchAlarmUser"
  55. />
  56. </div>
  57. </div>
  58. </template>
  59. <template #bodyCell="{ column, record, index }">
  60. <template v-if="column.dataIndex === 'index'">{{ index + 1 }} </template>
  61. <template v-if="column.dataIndex === 'avatar'">
  62. <a-avatar v-if="record.avatar" :src="record.avatar" class="xn-wh25" />
  63. </template>
  64. <template v-if="column.dataIndex === 'action'">
  65. <a-space>
  66. <!-- <a @click="formRef.onOpen(record)" v-if="hasPerm('alarmUserEdit')">编辑</a>
  67. <a-divider type="vertical" v-if="hasPerm(['alarmUserEdit', 'alarmUserDelete'], 'and')" /> -->
  68. <a @click="perfectformRef.onOpen(record)">完善信息</a>
  69. <a-divider type="vertical" v-if="hasPerm(['alarmUserEdit', 'alarmUserDelete'], 'and')" />
  70. <a-popconfirm title="确定要删除吗?" @confirm="deleteAlarmUser(record)">
  71. <a-button type="link" danger size="small" v-if="hasPerm('alarmUserDelete')">删除</a-button>
  72. </a-popconfirm>
  73. </a-space>
  74. </template>
  75. </template>
  76. </s-table>
  77. <Form ref="formRef" @successful="tableRef.refresh()" />
  78. <perfectForm ref="perfectformRef" @successful="tableRef.refresh()" />
  79. </div>
  80. </template>
  81. <script setup name="alarmuser">
  82. import { cloneDeep } from 'lodash-es'
  83. import Form from './form.vue'
  84. import perfectForm from './perfectForm.vue'
  85. import alarmUserApi from '@/api/coldchain/alarmUserApi'
  86. const searchFormState = ref({})
  87. const searchFormRef = ref()
  88. const tableRef = ref()
  89. const formRef = ref()
  90. const perfectformRef = ref()
  91. const columns = [
  92. {
  93. title: '序号',
  94. dataIndex: 'index',
  95. align: 'center',
  96. width: 50
  97. },
  98. {
  99. title: '真实姓名',
  100. dataIndex: 'name',
  101. align: 'center',
  102. ellipsis: true,
  103. resizable: true
  104. },
  105. {
  106. title: '手机号码',
  107. dataIndex: 'phone',
  108. align: 'center',
  109. ellipsis: true,
  110. resizable: true
  111. },
  112. {
  113. title: '微信昵称',
  114. dataIndex: 'nickName',
  115. align: 'center',
  116. ellipsis: true,
  117. resizable: true
  118. },
  119. {
  120. title: '组织',
  121. dataIndex: 'createOrgName',
  122. align: 'center',
  123. ellipsis: true,
  124. resizable: true
  125. },
  126. {
  127. title: '是否关注',
  128. dataIndex: 'subscribed',
  129. align: 'center',
  130. ellipsis: true,
  131. resizable: true,
  132. customRender({ value }) {
  133. return value == '0' ? '否' : '是'
  134. }
  135. },
  136. {
  137. title: '用户头像',
  138. dataIndex: 'avatar',
  139. align: 'center',
  140. ellipsis: true,
  141. resizable: true
  142. },
  143. {
  144. title: '创建时间',
  145. dataIndex: 'createTime',
  146. align: 'center',
  147. ellipsis: true,
  148. resizable: true
  149. }
  150. ]
  151. // 操作栏通过权限判断是否显示
  152. if (hasPerm(['alarmUserEdit', 'alarmUserDelete'])) {
  153. columns.push({
  154. title: '操作',
  155. dataIndex: 'action',
  156. align: 'center',
  157. width: 250
  158. })
  159. }
  160. const selectedRowKeys = ref([])
  161. // 列表选择配置
  162. const options = {
  163. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  164. alert: {
  165. show: true,
  166. clear: () => {
  167. selectedRowKeys.value = ref([])
  168. }
  169. },
  170. rowSelection: {
  171. onChange: (selectedRowKey, selectedRows) => {
  172. selectedRowKeys.value = selectedRowKey
  173. }
  174. }
  175. }
  176. // 可伸缩列
  177. const handleResizeColumn = (w, col) => {
  178. col.width = w
  179. }
  180. const loadData = (parameter) => {
  181. const searchFormParam = cloneDeep(searchFormState.value)
  182. return alarmUserApi.alarmUserPage(Object.assign(parameter, searchFormParam)).then((data) => {
  183. return data
  184. })
  185. }
  186. // 重置
  187. const reset = () => {
  188. searchFormRef.value.resetFields()
  189. tableRef.value.refresh(true)
  190. }
  191. // 删除
  192. const deleteAlarmUser = (record) => {
  193. let params = [
  194. {
  195. id: record.id
  196. }
  197. ]
  198. alarmUserApi.alarmUserDelete(params).then(() => {
  199. tableRef.value.refresh(true)
  200. })
  201. }
  202. // 批量删除
  203. const deleteBatchAlarmUser = (params) => {
  204. alarmUserApi.alarmUserDelete(params).then(() => {
  205. tableRef.value.clearRefreshSelected()
  206. })
  207. }
  208. </script>
  209. <style lang="less" scoped>
  210. .table_item {
  211. padding: 15px 20px;
  212. background-color: #ffffff;
  213. :deep(.ant-table-pagination-right) {
  214. justify-content: center !important;
  215. }
  216. }
  217. </style>