index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="auxiliary-citizen-container layout-pd">
  3. <el-card shadow="never">
  4. <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent>
  5. <el-form-item label="市民联系方式" prop="PhoneNumber">
  6. <el-input
  7. v-model="state.queryParams.PhoneNumber"
  8. placeholder="请输入市民联系方式"
  9. clearable
  10. @keyup.enter="handleQuery"
  11. class="keyword-input"
  12. />
  13. </el-form-item>
  14. <el-form-item label="市民标签" prop="Label">
  15. <el-input v-model="state.queryParams.Label" placeholder="请输入市民标签" clearable @keyup.enter="handleQuery" class="keyword-input" />
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  19. <el-button @click="resetQuery(ruleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
  20. </el-form-item>
  21. </el-form>
  22. </el-card>
  23. <el-card shadow="never">
  24. <!-- <div class="mb20">
  25. <el-button type="primary" @click="onLexiconDelete" v-waves v-auth="'auxiliary:citizen:delete'" :disabled="!multipleSelection.length">
  26. <SvgIcon name="ele-Delete" class="mr5" />删除
  27. </el-button>
  28. </div>-->
  29. <!-- 表格 -->
  30. <ProTable
  31. ref="proTableRef"
  32. :columns="columns"
  33. :data="state.tableData"
  34. @updateTable="queryList"
  35. :loading="state.loading"
  36. :total="state.total"
  37. v-model:page-index="state.queryParams.PageIndex"
  38. v-model:page-size="state.queryParams.PageSize"
  39. >
  40. <!-- 表格操作 -->
  41. <template #operation="{ row }">
  42. <el-button link type="primary" @click="onTagsRecord(row)" v-auth="'auxiliary:citizen:tag'" title="查看市民标签记录"> 标签记录 </el-button>
  43. <el-button link type="primary" @click="onTagsEdit(row)" v-auth="'auxiliary:citizen:edit'" title="编辑市民画像"> 编辑 </el-button>
  44. </template>
  45. </ProTable>
  46. </el-card>
  47. <!-- 标签记录 -->
  48. <tags-record ref="tagsRecordRef" />
  49. <!-- 编辑市民画像 -->
  50. <tags-edit ref="TagsEditRef" @updateList="queryList" />
  51. </div>
  52. </template>
  53. <script lang="tsx" setup name="auxiliaryCitizen">
  54. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  55. import { ElButton, ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  56. import { formatDate } from '@/utils/formatTime';
  57. import { citizenDelete, citizenList } from '@/api/auxiliary/citizen';
  58. // 引入组件
  59. const TagsRecord = defineAsyncComponent(() => import('@/views/auxiliary/citizen/components/Tags-record.vue')); // 标签记录
  60. const TagsEdit = defineAsyncComponent(() => import('@/views/auxiliary/citizen/components/Tags-edit.vue')); // 标签编辑
  61. const proTableRef = ref<RefType>(); // 表格ref
  62. // 表格配置项
  63. const columns = ref<any[]>([
  64. { prop: 'phoneNumber', label: '市民联系方式', width: 200 },
  65. { prop: 'label', label: '市民标签', width: 300 },
  66. { prop: 'creatorName', label: '创建人' },
  67. {
  68. prop: 'creationTime',
  69. label: '创建时间',
  70. width: 170,
  71. render: (scope) => {
  72. return <span>{formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  73. },
  74. },
  75. { prop: 'lastModificationName', label: '更新人' },
  76. {
  77. prop: 'lastModificationTime',
  78. label: '更新时间',
  79. width: 170,
  80. render: (scope) => {
  81. return <span>{formatDate(scope.row.lastModificationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  82. },
  83. },
  84. { prop: 'operation', label: '操作', fixed: 'right', width: 140, align: 'center' },
  85. ]);
  86. // 定义变量内容
  87. const state = reactive({
  88. loading: false, // 加载状态
  89. queryParams: {
  90. // 查询参数
  91. PageIndex: 1,
  92. PageSize: 10,
  93. PhoneNumber: null,
  94. Label: null,
  95. },
  96. total: 0, // 总条数
  97. tableData: [], // 表格数据
  98. });
  99. const ruleFormRef = ref<RefType>(null); // 表单ref
  100. /** 搜索按钮操作 */
  101. const handleQuery = () => {
  102. state.queryParams.PageIndex = 1;
  103. queryList();
  104. };
  105. // 获取列表
  106. const queryList = () => {
  107. state.loading = true;
  108. citizenList(state.queryParams)
  109. .then((res) => {
  110. state.loading = false;
  111. state.tableData = res.result.items ?? [];
  112. state.total = res.result.total ?? 0;
  113. })
  114. .finally(() => {
  115. state.loading = false;
  116. });
  117. };
  118. // 重置表单
  119. const resetQuery = (formEl: FormInstance | undefined) => {
  120. if (!formEl) return;
  121. formEl.resetFields();
  122. queryList();
  123. };
  124. // 标签记录
  125. const tagsRecordRef = ref<RefType>();
  126. const onTagsRecord = (row: any) => {
  127. tagsRecordRef.value.openDialog(row);
  128. };
  129. // 编辑标签
  130. const TagsEditRef = ref<RefType>();
  131. const onTagsEdit = (row: any) => {
  132. TagsEditRef.value.openDialog(row);
  133. };
  134. // 页面加载时
  135. onMounted(() => {
  136. queryList();
  137. });
  138. </script>