VirtualTable.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <!-- 虚端子关系表 -->
  2. <template>
  3. <div class="bigBox">
  4. <div class="header">
  5. <div v-if="needFlashName">
  6. {{ needFlashName + " — " + needScdName + " — 虚端子关系表" }}
  7. </div>
  8. <div v-else>虚端子关系表</div>
  9. <span class="closeX" @click="closeX">×</span>
  10. </div>
  11. <div class="antherHeader">
  12. <el-form
  13. :model="queryParams"
  14. ref="queryRef"
  15. :inline="true"
  16. label-width="68px"
  17. >
  18. <el-form-item label="间隔" prop="area_id">
  19. <el-select
  20. ref="levelRef"
  21. v-model="queryParams.area_id"
  22. placeholder="请选择间隔"
  23. multiple
  24. collapse-tags
  25. @change="changeLevel"
  26. @visible-change="visibleChange"
  27. @remove-tag="removeTag"
  28. clearable
  29. >
  30. <el-option
  31. v-for="dict in areaData"
  32. :key="dict.area_id"
  33. :label="dict.area_name"
  34. :value="dict.area_id"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="装置名称">
  39. <el-input v-model="queryParams.ied_name" clearable @change="onSubmitIedName"></el-input>
  40. </el-form-item>
  41. <el-form-item>
  42. <!-- <el-button type="primary" @click="onSubmit">搜索</el-button>
  43. <el-button @click="reset">重置</el-button> -->
  44. <el-button @click="exportAll" class="daochu">导出全部</el-button>
  45. </el-form-item>
  46. </el-form>
  47. </div>
  48. <div class="table-data" v-loading="loading"
  49. element-loading-text="数据加载中">
  50. <el-table
  51. :data="tableList"
  52. stripe
  53. height="90%"
  54. ref="tables"
  55. style="width: 100%; overflow-y: auto"
  56. :cell-style="{ color: '#1A2447', border: 'none', height: '40px' }"
  57. :header-cell-style="{
  58. color: '#7484AB',
  59. borderBottom: '1px solid #A3ADE0',
  60. }"
  61. >
  62. <el-table-column width="80" label="序号">
  63. <template #default="scope">
  64. {{ scope.$index + 1 }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="ied_name" label="装置名称" />
  68. <el-table-column
  69. prop="attr_desc"
  70. label="装置描述"
  71. :show-overflow-tooltip="true"
  72. />
  73. <el-table-column prop="doi_addr" label="端子地址" />
  74. <el-table-column prop="doi_desc" label="端子描述" />
  75. <el-table-column prop="gooseorsv" label="信号类型" />
  76. <el-table-column prop="in_doi_addr" label="输入端子地址" />
  77. <el-table-column prop="in_doi_desc" label="输入端子描述" />
  78. <el-table-column prop="in_ied_name" label="输入装置名字" />
  79. <el-table-column prop="in_ied_desc" label="输入装置描述" />
  80. </el-table>
  81. </div>
  82. </div>
  83. </template>
  84. <script setup>
  85. import { ref, onMounted, watch, reactive, toRefs, nextTick } from "vue";
  86. import { utils, writeFile } from "xlsx";
  87. import { checkArea, fcdaList } from "@/api/iedNetwork";
  88. import { ElMessage, ElLoading } from "element-plus";
  89. import { useRoute } from "vue-router";
  90. const route = useRoute();
  91. const scdIdValue = route.query.id;
  92. const props = defineProps({});
  93. const data = reactive({
  94. queryParams: {
  95. scd_id: scdIdValue,
  96. },
  97. });
  98. const { queryParams } = toRefs(data);
  99. // 表单重置
  100. const reset = () => {
  101. queryParams.value = {
  102. scd_id: scdIdValue,
  103. area_id: [], //间隔
  104. ied_name: null, //装置名称
  105. };
  106. chooseInterval.value = null;
  107. getData();
  108. };
  109. const all = [{ area_name: "全部", id: "alls" }];
  110. const areaData = ref([]); //获取间隔
  111. const getArea = async () => {
  112. const areaRes = await checkArea({ scd_id: scdIdValue });
  113. if (!areaRes || !areaRes.data) return;
  114. areaData.value = [...all, ...areaRes.data]; //搜索处的间隔
  115. };
  116. const emit = defineEmits(["sclBack"]);
  117. let needScdName = ref(""); //需要的scd名称
  118. let needFlashName = ref(""); //需要的变电站名称
  119. let tableList = ref([]); //crc效验结果表格数据
  120. const loading = ref(true);
  121. const getData = async () => {
  122. tableList.value = [];
  123. // let loading = ElLoading.service({
  124. // lock: true,
  125. // text: "正在查询数据",
  126. // background: "rgba(0, 0, 0, 0.7)",
  127. // });
  128. const data = await fcdaList({
  129. scd_id: scdIdValue,
  130. area_ids: chooseInterval.value,
  131. ied_name: queryParams.value.ied_name,
  132. });
  133. if (!data || !data.data) return loading.value=false;
  134. data.data.forEach((item) => {
  135. if (item.doi_addr) tableList.value.push(item);
  136. });
  137. loading.value=false;
  138. };
  139. const chooseInterval = ref(null); //间隔下拉框选中的数据
  140. const changeLevel = (e) => {
  141. chooseInterval.value = e ? e.join() : null;
  142. console.log('first', chooseInterval.value)
  143. };
  144. const removeTag = (e)=>{
  145. onSubmit()
  146. }
  147. //间隔下拉框关闭时触发
  148. const visibleChange = (visible) => {
  149. if (visible == false) {
  150. queryParams.value.ied_name = null;
  151. onSubmit()
  152. }
  153. };
  154. const tables = ref(null);
  155. const onSubmitIedName = () =>{
  156. queryParams.value.area_id = [];
  157. chooseInterval.value = null;
  158. onSubmit()
  159. }
  160. const onSubmit = () => {
  161. getData();
  162. nextTick(() => {
  163. if (!tables.value) return;
  164. tables.value.setScrollTop(0);
  165. });
  166. };
  167. const closeX = () => {
  168. emit("sclBack", 2);
  169. };
  170. // 导出全部
  171. const exportAll = () => {
  172. const array = [
  173. [
  174. "装置名称",
  175. "装置描述",
  176. "端子地址",
  177. "端子描述",
  178. "信号类型",
  179. "输入端子地址",
  180. "输入端子描述",
  181. "输入装置名称",
  182. "输入装置描述",
  183. ],
  184. ];
  185. tableList.value.forEach((d) => {
  186. array.push([
  187. d.ied_name,
  188. d.attr_desc,
  189. d.doi_addr,
  190. d.doi_desc,
  191. d.gooseorsv,
  192. d.in_doi_addr,
  193. d.in_doi_desc,
  194. d.in_ied_name,
  195. d.in_ied_desc,
  196. ]);
  197. });
  198. const sheetName = "Sheet1";
  199. const workbook = {
  200. SheetNames: [sheetName],
  201. Sheets: {},
  202. };
  203. const sheet = utils.aoa_to_sheet(array);
  204. workbook.Sheets[sheetName] = sheet;
  205. // 设置列宽
  206. sheet["!cols"] = [
  207. { wch: 10 },
  208. { wch: 30 },
  209. { wch: 30 },
  210. { wch: 30 },
  211. { wch: 20 },
  212. { wch: 30 },
  213. { wch: 30 },
  214. { wch: 10 },
  215. { wch: 25 },
  216. ];
  217. writeFile(workbook, "虚端子关系.xlsx");
  218. };
  219. onMounted(() => {
  220. getArea();
  221. getData();
  222. const parentData = JSON.parse(route.query.parentData);
  223. needFlashName.value = parentData ? parentData.station_name : null;
  224. needScdName.value = parentData ? parentData.scd_name : null;
  225. });
  226. </script>
  227. <style scoped lang="scss">
  228. em {
  229. list-style: none;
  230. font-style: normal;
  231. }
  232. .bigBox {
  233. width: 97%;
  234. height: calc(100vh - 230px);
  235. margin-left: 32px;
  236. overflow: hidden;
  237. }
  238. .header {
  239. width: 100%;
  240. height: auto;
  241. text-align: center;
  242. }
  243. .antherHeader {
  244. width: 100%;
  245. height: auto;
  246. color: #1a2447;
  247. font-size: 16px;
  248. margin: 16px 0;
  249. }
  250. .header {
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. font-size: 16px;
  255. width: 100%;
  256. height: auto;
  257. padding: 12px 0 20px 0;
  258. border-bottom: 1px solid #a3ade0;
  259. color: #1a2447;
  260. }
  261. .closeX {
  262. font-size: 24px;
  263. color: #7484ab;
  264. cursor: pointer;
  265. }
  266. .table-data {
  267. height: 100%;
  268. margin-left: 16px;
  269. overflow-y: auto;
  270. }
  271. .daochu {
  272. border: 1px solid #255ce7;
  273. color: #255ce7;
  274. background: #f6f9ff;
  275. }
  276. :deep(.el-select .el-input) {
  277. width: 340px;
  278. }
  279. </style>