index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <el-button type="primary" size="small" icon="Plus" @click="handleAdd"
  6. v-hasPermi="['business:tenant:add']">新增</el-button>
  7. <el-button type="warning" size="small" icon="Edit" :disabled="single" @click="handleUpdate"
  8. v-hasPermi="['business:tenant:edit']">修改</el-button>
  9. <!-- <el-button type="danger" size="small" icon="Delete" :disabled="multiple" @click="handleDelete"
  10. v-hasPermi="['business:tenant:remove']">删除</el-button>
  11. <el-button type="warning" size="small" icon="Download" @click="handleExport"
  12. v-hasPermi="['business:tenant:export']">导出</el-button> -->
  13. </div>
  14. <!-- 搜索区 -->
  15. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  16. label-width="68px">
  17. <el-form-item label="公司名称:" prop="companyName">
  18. <el-input v-model="queryParams.companyName" placeholder="企业名称" clearable @keyup.enter="handleQuery" />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  22. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <!-- 列表区 -->
  26. <el-table v-loading="loading" :data="tenantList" size="small" border height="100%"
  27. @selection-change="handleSelectionChange">
  28. <el-table-column type="selection" width="55" align="center" />
  29. <el-table-column label="公司名称" align="center" prop="companyName" />
  30. <el-table-column label="系统简称" align="center" prop="accountName" width="180" />
  31. <el-table-column label="状态" align="center" prop="status" width="100">
  32. <template #default="scope">
  33. <el-tag size="small" :type="checkStatusType(scope.row.status)">{{
  34. checkStatus(scope.row.status)
  35. }}</el-tag>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
  39. <template #default="scope">
  40. <el-button link type="primary" size="small" @click="handleUpdate(scope.row)"
  41. v-hasPermi="['business:tenant:edit']">查看</el-button>
  42. <el-button link type="primary" size="small" @click="handleInit(scope.row, 2)"
  43. v-hasPermi="['business:tenant:edit']">初始化系统</el-button>
  44. <el-button link type="primary" size="small" @click="handleGetIn(scope.row)"
  45. v-hasPermi="['business:tenant:getIn']">进入系统</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <!-- 分页 -->
  50. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
  51. @pagination="getList" />
  52. <!-- 表单 -->
  53. <tenant-form ref="tenantRef" :get-list="getList"></tenant-form>
  54. <tenant-init ref="tenantInitRef" :get-list="getList"></tenant-init>
  55. </div>
  56. </template>
  57. <script setup name="Tenant">
  58. import { setTenant } from "@/utils/auth";
  59. import tenantForm from "./form.vue";
  60. import router from "@/router";
  61. import { isHttp } from "@/utils/validate";
  62. import tenantInit from "./init.vue";
  63. import { listTenant, delTenant } from "@/api/business/tenant";
  64. import usePermissionStore from "@/store/modules/permission";
  65. const { proxy } = getCurrentInstance();
  66. /** 字典数组区 */
  67. const { org_nature } = proxy.useDict("org_nature");
  68. /** 查询 对象 */
  69. const tenantList = ref([]);
  70. const loading = ref(true);
  71. const ids = ref([]);
  72. const single = ref(true);
  73. const multiple = ref(true);
  74. const total = ref(0);
  75. const tenantInitRef = ref(null);
  76. /** 查询对象 */
  77. const queryParams = ref({
  78. pageNum: 1,
  79. pageSize: 20,
  80. orderByColumn: "create_time",
  81. });
  82. /*********************** 方法区 ****************************/
  83. /** 查询【请填写功能名称】列表 */
  84. function getList() {
  85. loading.value = true;
  86. listTenant(queryParams.value).then((response) => {
  87. tenantList.value = response.rows;
  88. total.value = response.total;
  89. loading.value = false;
  90. });
  91. }
  92. /** 搜索按钮操作 */
  93. function handleQuery() {
  94. queryParams.value.pageNum = 1;
  95. getList();
  96. }
  97. /** 重置按钮操作 */
  98. function resetQuery() {
  99. proxy.resetForm("queryRef");
  100. handleQuery();
  101. }
  102. // 多选框选中数据
  103. function handleSelectionChange(selection) {
  104. ids.value = selection.map((item) => item.id);
  105. single.value = selection.length != 1;
  106. multiple.value = !selection.length;
  107. }
  108. /** 新增按钮操作 */
  109. function handleAdd() {
  110. proxy.$refs.tenantRef.open();
  111. }
  112. /** 修改按钮操作 */
  113. function handleUpdate(row) {
  114. const id = row.id || ids.value;
  115. proxy.$refs.tenantRef.open(id);
  116. }
  117. /** 删除按钮操作 */
  118. function handleDelete(row) {
  119. const _ids = row.id || ids.value;
  120. proxy.$modal
  121. .confirm("是否确认删除选中的数据项?")
  122. .then(function () {
  123. return delTenant(_ids);
  124. })
  125. .then(() => {
  126. getList();
  127. proxy.$modal.msgSuccess("删除成功!");
  128. })
  129. .catch(() => { });
  130. }
  131. /** 导出按钮操作 */
  132. function handleExport() {
  133. proxy.download(
  134. "business/tenant/export",
  135. {
  136. ...queryParams.value,
  137. },
  138. `tenant_${new Date().getTime()}.xlsx`
  139. );
  140. }
  141. function checkStatusType(status) {
  142. switch (status) {
  143. case 0:
  144. case 1:
  145. return "warning";
  146. case 2:
  147. return "success";
  148. case 4:
  149. return "danger";
  150. default:
  151. return "";
  152. }
  153. }
  154. function checkStatus(status) {
  155. switch (status) {
  156. case 0:
  157. case 1:
  158. return "待审核";
  159. case 2:
  160. return "使用中";
  161. case 4:
  162. return "已停用";
  163. default:
  164. return "";
  165. }
  166. }
  167. function handleInit(row) {
  168. const id = row.id || ids.value;
  169. proxy.$refs["tenantInitRef"].open(row.id);
  170. }
  171. function handleGetIn(row) {
  172. const tenantId = row.id;
  173. setTenant(tenantId);
  174. usePermissionStore()
  175. .generateRoutes()
  176. .then((accessRoutes) => {
  177. // router.reload({ path: '/index' })
  178. location.reload();
  179. });
  180. }
  181. getList();
  182. </script>