Newer
Older
KaiFengPC / src / views / preassess / removalRate / index.vue
@鲁yixuan 鲁yixuan on 20 Aug 6 KB updata
  1. <template>
  2. <div class="removalRate">
  3. <div class="top">
  4. <el-form ref="ruleForm" inline :model="form">
  5. <el-form-item label="使用状态:" prop="status">
  6. <el-select v-model="form.status" placeholder="使用状态">
  7. <el-option label="全部" value="" />
  8. <el-option label="启用" value="1" />
  9. <el-option label="停用" value="0" />
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item label="时间:" prop="time">
  13. <el-date-picker
  14. v-model="form.time"
  15. type="daterange"
  16. range-separator="~"
  17. start-placeholder="开始时间"
  18. end-placeholder="结束时间"
  19. format="YYYY-MM-DD"
  20. value-format="YYYY-MM-DD"
  21. />
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="Search" @click="search"> 搜索</el-button>
  25. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row class="mb8">
  29. <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增</el-button>
  30. </el-row>
  31. </div>
  32. <el-table :data="tableData" v-loading="loading" :max-height="600">
  33. <el-table-column type="index" width="55" label="序号" />
  34. <el-table-column label="记录名称" prop="configName" show-overflow-tooltip width="200">
  35. <template #default="{ row }">
  36. <span style="color: #409eef">{{ row.configName }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="启用时间" prop="startDatetime" show-overflow-tooltip />
  40. <el-table-column label="停用时间" prop="endDatetime" show-overflow-tooltip />
  41. <el-table-column label="修改人" prop="updateNickName" show-overflow-tooltip />
  42. <el-table-column label="修改日期" prop="updateTime" show-overflow-tooltip />
  43. <el-table-column label="使用状态" prop="status" show-overflow-tooltip>
  44. <template #default="{ row }">
  45. <el-tag :type="statusMap.get(row.status).type" v-if="row.status">{{ statusMap.get(row.status).text }}</el-tag>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" show-overflow-tooltip width="300">
  49. <template #default="{ row }">
  50. <el-button type="primary" link @click="copy(row)">复制</el-button>
  51. <el-button type="primary" link @click="enable(row)" :disabled="row.status === '1'">启用</el-button>
  52. <el-button icon="View" type="primary" link @click="openDialog(row, 'view')">详情</el-button>
  53. <el-button type="warning" icon="Edit" link @click="openDialog(row, 'edit')">修改</el-button>
  54. <el-button type="danger" icon="Delete" link @click="del(row)">删除</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
  59. <el-dialog
  60. class="dialog"
  61. v-model="visible"
  62. :title="`${opts.text}建议污染去除率`"
  63. :close-on-click-modal="false"
  64. style="width: 80%; height: 600px"
  65. :before-close="close"
  66. >
  67. <tableDalgo v-if="visible" ref="tableDalgoRef" :id="row.id || ''" :status="row.status" :opts="opts.type" @close="close"></tableDalgo>
  68. </el-dialog>
  69. </div>
  70. </template>
  71.  
  72. <script setup>
  73. import tableDalgo from './tableDalgo.vue';
  74. import { reactive, ref, onMounted, computed } from 'vue';
  75. import { optTextMap, statusMap } from '@/utils/map';
  76. import {
  77. getFacilitiesPolluteRemoveConfigPage,
  78. facilitiesPolluteRemoveConfigDel,
  79. facilitiesPolluteRemoveConfigCopy,
  80. facilitiesPolluteRemoveConfigEnable,
  81. } from '@/api/preassess/removalRate.js';
  82. import { usePagination } from '@/hooks';
  83. const { proxy } = getCurrentInstance();
  84.  
  85. const form = reactive({
  86. status: '',
  87. time: [],
  88. });
  89. const params = computed(() => {
  90. const args = JSON.parse(JSON.stringify(form));
  91. const { time } = args;
  92. delete args.time;
  93. return {
  94. ...args,
  95. startDatetime: time[0] || '',
  96. endDatetime: time[1] || '',
  97. };
  98. });
  99. const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getFacilitiesPolluteRemoveConfigPage, params);
  100. const visible = ref(false);
  101. const row = ref({});
  102. const opts = reactive({
  103. type: '',
  104. text: '',
  105. });
  106.  
  107. const search = () => {
  108. pageNum.value = 1;
  109. getTableList();
  110. };
  111.  
  112. const resetQuery = () => {
  113. proxy.$refs.ruleForm.resetFields();
  114. search();
  115. };
  116.  
  117. const openDialog = (data, type) => {
  118. visible.value = true;
  119. opts.type = type;
  120. opts.text = optTextMap.get(type);
  121. row.value = data;
  122. };
  123.  
  124. const close = type => {
  125. visible.value = false;
  126. opts.type = '';
  127. opts.text = '';
  128. row.value = {};
  129. if (type === 'add') search();
  130. if (type && ['add', 'edit'].includes(type)) proxy.$modal.msgSuccess('操作成功!');
  131. };
  132.  
  133. const del = row => {
  134. proxy.$modal
  135. .confirm('是否确认删除?')
  136. .then(async () => {
  137. const res = await facilitiesPolluteRemoveConfigDel(row.id);
  138. if (res?.code !== 200) return;
  139. proxy.$modal.msgSuccess('操作成功!');
  140. getTableList();
  141. })
  142. .catch(() => {});
  143. };
  144.  
  145. const copy = row => {
  146. proxy.$modal
  147. .confirm('是否确认复制?')
  148. .then(async () => {
  149. const res = await facilitiesPolluteRemoveConfigCopy({ id: row.id });
  150. if (res?.code !== 200) return;
  151. proxy.$modal.msgSuccess('操作成功!');
  152. getTableList();
  153. })
  154. .catch(() => {});
  155. };
  156.  
  157. const enable = row => {
  158. proxy.$modal
  159. .confirm('是否确认启用?')
  160. .then(async () => {
  161. const res = await facilitiesPolluteRemoveConfigEnable(row.id);
  162. if (res?.code !== 200) return;
  163. proxy.$modal.msgSuccess('操作成功!');
  164. getTableList();
  165. })
  166. .catch(() => {});
  167. };
  168.  
  169. onMounted(() => {
  170. getTableList();
  171. });
  172. </script>
  173.  
  174. <style lang="scss" scoped>
  175. .removalRate {
  176. padding: 20px;
  177. height: 90vh;
  178. overflow-y: hidden;
  179. .top {
  180. margin-bottom: 15px;
  181. }
  182. }
  183.  
  184. :deep(.dialog) {
  185. .el-dialog__body {
  186. padding-bottom: 20px !important;
  187. }
  188. .el-dialog__footer {
  189. padding-top: 0 !important;
  190. }
  191.  
  192. .innerDialog {
  193. .el-dialog__body {
  194. padding-bottom: 0 !important;
  195. }
  196. }
  197. }
  198. </style>