index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <el-tabs type="card" v-model="activeTab" style="height: 100%" @tab-click="handleClick">
  3. <el-tab-pane v-for="tab in tabs" :key="tab.key" :label="tab.label" :name="tab.key">
  4. <div class="sensitive-words flex">
  5. <TreeSelect class="mr20" ref="treeSelectdRef" @treeCheck="getTreeCheck"></TreeSelect>
  6. <div class="table-box">
  7. <pageSearch
  8. ref="searchTableRef"
  9. :searchConfig="activeTab === 'industry' ? searchConfig : searchNonIndustryConfig"
  10. />
  11. <pageContent
  12. ref="tableListRef"
  13. :total="total"
  14. :contentConfig="activeTab === 'industry' ? contentConfig : contentNonIndustryConfig"
  15. :pageList="tableData"
  16. >
  17. <template #button>
  18. <el-button type="primary" @click="onImport()">导入</el-button>
  19. <el-button type="primary" @click="onImport()">下载模版</el-button>
  20. <el-button type="primary" @click="onAdd()">新增</el-button>
  21. <el-button type="primary" @click="onExport()">导出</el-button>
  22. </template>
  23. <template #operate="scope">
  24. <el-button type="primary" link @click="handleEdit(scope.row.rentalCompanyId)"> 编辑 </el-button>
  25. <el-button type="primary" link @click="handleCheck(scope.row.rentalCompanyId)">
  26. 查看
  27. </el-button>
  28. <el-button type="primary" link @click="onDelete(scope.row.rentalCompanyId)"> 删除 </el-button>
  29. </template>
  30. </pageContent>
  31. </div>
  32. </div>
  33. </el-tab-pane>
  34. </el-tabs>
  35. <pageDetail :modalConfig="activeTab === 'industry' ? detailConfig : detailNonIndustryConfig" ref="modalRef">
  36. </pageDetail>
  37. </template>
  38. <script setup lang="ts">
  39. import contentConfig from './config/content.config';
  40. import contentNonIndustryConfig from './config/content.nonIndustry.config';
  41. import pageContent from '@/components/components/pageContent.vue';
  42. import searchConfig from './config/search.config';
  43. import searchNonIndustryConfig from './config/search.nonIndustry.config';
  44. import pageSearch from '@/components/components/pageSearch.vue';
  45. import detailConfig from './config/detail.config';
  46. import detailNonIndustryConfig from './config/detail.nonIndustry.config';
  47. import pageDetail from './components/detail.vue';
  48. import useSystemStore from '@/store/main';
  49. import TreeSelect from './components/treeSelect.vue';
  50. import { type TabsPaneContext } from 'element-plus';
  51. // 使用pinia数据
  52. const systemStore = useSystemStore();
  53. const { pageDetailInfo } = storeToRefs(systemStore);
  54. const total = ref(0);
  55. const pageSize = ref([10, 20, 30]);
  56. const tableData = ref([]);
  57. const tableListRef = ref<InstanceType<typeof pageContent>>();
  58. const tabs = reactive([
  59. {
  60. key: 'industry',
  61. label: '行业内联络员',
  62. total: 0,
  63. tableData: [],
  64. loading: false,
  65. showDetail: true,
  66. },
  67. {
  68. key: 'nonIndustry',
  69. label: '行业外联络员',
  70. total: 0,
  71. tableData: [],
  72. loading: false,
  73. showDetail: true,
  74. },
  75. ]);
  76. const activeTab = ref('industry');
  77. // 操作弹框
  78. import usePageModal from '@/components/components/hooks/usePageDetails';
  79. const { modalRef, handleNewDataClick, handleEditDataClick, handleCheckDataClick, handlePageDetail } =
  80. usePageModal();
  81. const getTreeCheck = async data => {
  82. // console.log(await tableListRef.value);
  83. // console.log(data);
  84. if (tableListRef.value) {
  85. if (activeTab.value == 'industry') {
  86. searchConfig.pageListParams.deptIds = data.join();
  87. } else {
  88. searchNonIndustryConfig.pageListParams.deptIds = data.join();
  89. }
  90. await tableListRef.value[0].fetchPageListData({ deptIds: data.join() });
  91. }
  92. };
  93. const treeSelectdRef = ref<InstanceType<typeof TreeSelect>>();
  94. const searchTableRef = ref<InstanceType<typeof pageSearch>>();
  95. const handleClick = async (tab: TabsPaneContext) => {
  96. console.log(tab.props.name);
  97. setTimeout(() => {
  98. if (treeSelectdRef.value) {
  99. treeSelectdRef.value[0].handleReset(false);
  100. }
  101. if (searchTableRef.value) {
  102. searchTableRef.value[0].handleResetClick();
  103. }
  104. }, 500);
  105. };
  106. const handleEdit = async (id: string) => {
  107. await handlePageDetail(id);
  108. await handleEditDataClick();
  109. };
  110. const handleCheck = async (id: string) => {
  111. await handlePageDetail(id);
  112. await handleCheckDataClick();
  113. };
  114. // 新增按钮
  115. const onAdd = () => {
  116. handleNewDataClick();
  117. };
  118. const onImport = () => {
  119. const link = document.createElement('a');
  120. link.href = `/assets/address-book.xlsx`;
  121. link.download = '违法信息通报通讯录人员导入模板.xlsx'; // 指定下载后的文件名
  122. link.style.display = 'none';
  123. document.body.appendChild(link);
  124. link.click();
  125. document.body.removeChild(link);
  126. };
  127. const onExport = () => {};
  128. // 删除按钮
  129. function onDelete(value: any) {
  130. ElMessageBox.confirm('确定删除该条违法信息通报通讯录吗?', '删除提示', {
  131. confirmButtonText: '确定',
  132. cancelButtonText: '取消',
  133. type: 'warning',
  134. })
  135. .then(() => {
  136. systemStore.deletePageDataAction(contentConfig.pageName, value);
  137. })
  138. .catch(() => {
  139. ElMessage({
  140. type: 'info',
  141. message: '取消删除',
  142. });
  143. });
  144. }
  145. // 筛选-状态赋值
  146. async function searchItem() {
  147. searchConfig.formItems.forEach(item => {
  148. if (item.prop === 'status') {
  149. // item.options = searchList.value;
  150. }
  151. });
  152. }
  153. searchItem();
  154. </script>
  155. <style scoped lang="scss">
  156. .sensitive-words {
  157. margin: 20px;
  158. height: calc(100vh - 20vh);
  159. }
  160. .status {
  161. cursor: pointer;
  162. position: relative;
  163. .status-tip {
  164. position: absolute;
  165. top: 2px;
  166. left: 60px;
  167. }
  168. }
  169. .dialog-tip {
  170. text-align: center;
  171. }
  172. .table-box {
  173. width: 75%;
  174. display: flex;
  175. flex-direction: column;
  176. }
  177. :deep .el-tabs__item.is-active {
  178. color: #fff;
  179. background-color: #409eff;
  180. }
  181. </style>