ycpoint.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div class="devicemenu">
  3. <el-space wrap :size="10">
  4. <el-input
  5. v-model="state.SearchVal"
  6. placeholder="筛选"
  7. style="width: 180px"
  8. size="mini"
  9. />
  10. <el-select
  11. size="mini"
  12. v-model="state.selectModel"
  13. style="width: 180px"
  14. placeholder="全部"
  15. >
  16. <el-option
  17. v-for="item in state.modelList"
  18. :key="item"
  19. :value="item"
  20. :label="item"
  21. ></el-option>
  22. </el-select>
  23. <el-select
  24. v-model="state.selectPoint"
  25. size="mini"
  26. style="width: 100px"
  27. placeholder="全部"
  28. >
  29. <el-option key="1" label="全部" value=""></el-option>
  30. <el-option key="2" label="遥测" value="AI"></el-option>
  31. <el-option key="3" label="遥调" value="MI"></el-option>
  32. <el-option key="4" label="计算" value="CI"></el-option>
  33. </el-select>
  34. <el-button class="buttons" size="mini" round @click="search"
  35. >查询</el-button
  36. >
  37. <el-button
  38. class="buttons"
  39. size="mini"
  40. round
  41. @click="handleEdit(state.addFormData)"
  42. :disabled="desc.code == ''"
  43. >新增</el-button
  44. >
  45. <el-upload
  46. class="upload-demo"
  47. :disabled="desc.code == ''"
  48. action="/sharding/device/input"
  49. :show-file-list="false"
  50. :on-success="handleSuccess"
  51. :on-progress="handleProgress"
  52. :on-error="handleError"
  53. >
  54. <el-button :disabled="desc.code == ''" class="buttons" size="mini" round
  55. >导入</el-button
  56. >
  57. </el-upload>
  58. <el-button
  59. class="buttons"
  60. size="mini"
  61. round
  62. @click="export2Excel"
  63. :disabled="desc.code == ''"
  64. >导出</el-button
  65. >
  66. </el-space>
  67. </div>
  68. <div class="ycpoint-table">
  69. <el-table
  70. :data="state.pointTableData"
  71. stripe
  72. style="width: 100%"
  73. height="calc(100% - 45px)"
  74. >
  75. <el-table-column type="index" width="50" />
  76. <el-table-column prop="metricCode" label="测点编码"></el-table-column>
  77. <el-table-column label="名称">
  78. <template #default="scope">
  79. <el-popover
  80. placement="right"
  81. popper-class="point-popover"
  82. :width="260"
  83. trigger="click"
  84. >
  85. <template #reference>
  86. <el-button type="text" style="color: #05bb4c" size="small">{{
  87. scope.row.name
  88. }}</el-button>
  89. </template>
  90. <el-table
  91. size="mini"
  92. :data="scope.row.deviceModelMetrics"
  93. max-height="400px"
  94. >
  95. <el-table-column
  96. property="devicemodel"
  97. label="机型"
  98. align="center"
  99. ></el-table-column>
  100. <el-table-column
  101. property="uniformcode"
  102. label="统一编码"
  103. align="center"
  104. ></el-table-column>
  105. <el-table-column
  106. property="multiplier"
  107. label="倍率"
  108. align="center"
  109. ></el-table-column>
  110. </el-table>
  111. </el-popover>
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="unitName" label="单位"></el-table-column>
  115. <el-table-column prop="categoryData" label="测点类型"></el-table-column>
  116. <el-table-column prop="categorysci" label="物理类型"></el-table-column>
  117. <el-table-column prop="categorysci" label="数据类型"></el-table-column>
  118. <el-table-column prop="description" label="描述"></el-table-column>
  119. <el-table-column label="操作" width="180" align="center">
  120. <template #default="scope">
  121. <el-button
  122. type="text"
  123. style="color: #05bb4c"
  124. @click="handleEdit(scope.row)"
  125. >编辑</el-button
  126. >
  127. <el-button
  128. type="text"
  129. style="color: red"
  130. @click="handleDelete(scope.row)"
  131. >删除</el-button
  132. >
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <div class="pagination">
  137. <el-pagination
  138. layout="total, sizes, prev, pager, next"
  139. :page-sizes="[19, 50, 100, 200, 500]"
  140. @size-change="
  141. (value) => {
  142. query.limit = value;
  143. query.page = 1;
  144. getPoint(desc);
  145. }
  146. "
  147. :current-page="query.page"
  148. :page-size="query.limit"
  149. :total="pageTotal"
  150. @current-change="handlePageChange"
  151. ></el-pagination>
  152. </div>
  153. </div>
  154. <!-- 传感点编辑弹出框 -->
  155. <el-dialog v-model="editVisible" width="40%">
  156. <el-form :model="editFormData" label-width="80px">
  157. <el-form-item label="编码">
  158. <el-input v-model="editFormData.metriccode"></el-input>
  159. </el-form-item>
  160. <el-row :gutter="24">
  161. <el-col :span="12">
  162. <el-form-item label="名称">
  163. <el-input v-model="editFormData.name"></el-input>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="12">
  167. <el-form-item label="英文名称">
  168. <el-input v-model="editFormData.enname"></el-input>
  169. </el-form-item>
  170. </el-col>
  171. </el-row>
  172. <el-row :gutter="24">
  173. <el-col :span="12">
  174. <el-form-item label="标准单位">
  175. <el-input v-model="editFormData.unitname"></el-input>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="12">
  179. <el-form-item label="单位名称">
  180. <el-input v-model="editFormData.unitnamecn"></el-input>
  181. </el-form-item>
  182. </el-col>
  183. </el-row>
  184. <el-form-item label="描述">
  185. <el-input
  186. v-model="editFormData.description"
  187. :rows="3"
  188. type="textarea"
  189. clearable
  190. ></el-input>
  191. </el-form-item>
  192. <el-row :gutter="24">
  193. <el-col :span="12">
  194. <el-form-item label="数据类型">
  195. <el-select v-model="editFormData.categorydata" placeholder="Select">
  196. <el-option
  197. v-for="item in state.categorydataoptions"
  198. :key="item"
  199. :label="item"
  200. :value="item"
  201. >
  202. </el-option>
  203. </el-select>
  204. </el-form-item>
  205. </el-col>
  206. <el-col :span="12">
  207. <el-form-item label="结构">
  208. <el-cascader
  209. v-model="editFormData.structurecode"
  210. :options="cascaderdata"
  211. :props="{ checkStrictly: true, emitPath: false }"
  212. clearable
  213. />
  214. </el-form-item>
  215. </el-col>
  216. </el-row>
  217. <el-row :gutter="24">
  218. <el-col :span="12">
  219. <el-form-item label="物理类型">
  220. <el-input v-model="editFormData.categorysci"></el-input>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="12">
  224. <el-form-item label="系统分类">
  225. <el-input v-model="editFormData.categorysys"></el-input>
  226. </el-form-item>
  227. </el-col>
  228. </el-row>
  229. <el-form-item label="适配机型" class="deviceModelClass">
  230. <el-select
  231. v-model="state.deviceModelSel"
  232. style="margin-right: 20px"
  233. placeholder="新增机型"
  234. size="mini"
  235. >
  236. <el-option
  237. v-for="item in state.deviceModel"
  238. :key="item.code"
  239. :label="item.code"
  240. :value="item.code"
  241. >
  242. </el-option>
  243. </el-select>
  244. <el-button
  245. v-show="state.deviceModelSel != ''"
  246. size="mini"
  247. class="buttons"
  248. round
  249. @click="deviceModelAdd()"
  250. >新增机型
  251. </el-button>
  252. <el-table
  253. :data="editFormData.deviceModelMetrics"
  254. style="width: 100%; margin-top: 10px"
  255. max-height="200px"
  256. >
  257. <el-table-column prop="devicemodel" label="机型" />
  258. <el-table-column label="倍率">
  259. <template #default="scope">
  260. <el-input v-model="scope.row.multiplier" size="mini" />
  261. </template>
  262. </el-table-column>
  263. <el-table-column label="统一编码">
  264. <template #default="scope">
  265. <el-input v-model="scope.row.uniformcode" size="mini" />
  266. </template>
  267. </el-table-column>
  268. </el-table>
  269. </el-form-item>
  270. </el-form>
  271. <template #footer>
  272. <span class="footerButton">
  273. <el-button
  274. size="mini"
  275. class="buttons"
  276. round
  277. @click="editVisible = false"
  278. >取 消</el-button
  279. >
  280. <el-button size="mini" class="buttons" round @click="saveEdit"
  281. >确 定</el-button
  282. >
  283. </span>
  284. </template>
  285. </el-dialog>
  286. </template>
  287. <script setup>
  288. import { ref, onMounted, inject, reactive, watch } from "vue";
  289. import { ElMessageBox, ElMessage } from "element-plus";
  290. import {
  291. point,
  292. metrics,
  293. delmetrics,
  294. device_list,
  295. getWtModel,
  296. } from "@/api/zhbj/index.js";
  297. import { outExportExcel } from "@/tools/excel/exportExcel.js"; //引入文件
  298. onMounted(() => {
  299. getPoint(desc.value);
  300. getDeviceModel();
  301. getequipmentmodel_list();
  302. });
  303. let editFormData = ref({});
  304. let editVisible = ref(false); //传感点
  305. let desc = inject("desc");
  306. let treeId = inject("treeId");
  307. let cascaderdata = inject("cascaderdata");
  308. watch(
  309. () => treeId,
  310. (newV, old) => {
  311. state.addFormData.structurecode = desc.value.code;
  312. getPoint(desc.value);
  313. },
  314. {
  315. deep: true,
  316. }
  317. );
  318. let state = reactive({
  319. pointTableData: "",
  320. SearchVal: "",
  321. selectPoint: "",
  322. selectModel: "",
  323. modelList: [],
  324. categorydataoptions: ["AI", "DI", "CI"],
  325. addFormData: {
  326. categorydata: "AI",
  327. categoryres1: null,
  328. categoryres2: null,
  329. categoryres3: null,
  330. categoryres4: null,
  331. categoryres5: null,
  332. categorysci: null,
  333. categorysys: null,
  334. description: null,
  335. deviceid: "windturbine",
  336. enname: null,
  337. id: null,
  338. metriccode: "",
  339. name: "",
  340. structurecode: "",
  341. unitname: null,
  342. unitnamecn: null,
  343. deviceModelMetrics: [],
  344. },
  345. });
  346. const query = reactive({
  347. page: 1,
  348. limit: 19,
  349. });
  350. let pageTotal = ref(0);
  351. const search = async () => {
  352. getPoint(desc.value);
  353. };
  354. // getPoint
  355. const getPoint = async (node, value) => {
  356. const res = await point(
  357. node.code,
  358. query.page,
  359. query.limit,
  360. state.selectPoint,
  361. state.SearchVal,
  362. "windturbine",
  363. state.selectModel
  364. );
  365. pageTotal.value = res.total;
  366. state.pointTableData = res.records?.sort((a, b) => {
  367. return a.id - b.id;
  368. });
  369. };
  370. // 机型
  371. const getequipmentmodel_list = async () => {
  372. const { data } = await getWtModel("");
  373. state.modelList = data || [];
  374. };
  375. // 测点 编辑
  376. const handleEdit = (row) => {
  377. if (!row.deviceModelMetrics) {
  378. row.deviceModelMetrics = [];
  379. }
  380. editFormData.value = row;
  381. editVisible.value = true;
  382. };
  383. //测点 add
  384. const postmetrics = async () => {
  385. const res = await metrics(editFormData.value);
  386. if (res.code == 200) {
  387. ElMessage.success(`操作成功!`);
  388. editVisible.value = false;
  389. } else {
  390. ElMessage.success(res.msg);
  391. }
  392. getPoint(desc.value);
  393. };
  394. // 保存编辑
  395. const saveEdit = async () => {
  396. postmetrics();
  397. };
  398. // 测点 删除
  399. const handleDelete = (row) => {
  400. // 二次确认删除
  401. ElMessageBox.confirm("确定要删除吗?", "提示", {
  402. type: "warning",
  403. })
  404. .then(async () => {
  405. const res = await delmetrics(row.id);
  406. if (res == 1) {
  407. ElMessage.success(`删除成功!`);
  408. } else {
  409. ElMessage.success("删除失败");
  410. }
  411. getPoint(desc.value);
  412. })
  413. .catch(() => {});
  414. };
  415. //deviceModelAdd 新增机型
  416. const deviceModelAdd = async () => {
  417. if (state.deviceModelSel == "") return;
  418. let obj = {
  419. deviceid: editFormData.value.deviceid,
  420. devicemodel: state.deviceModelSel,
  421. id: null,
  422. metriccode: editFormData.value.metriccode,
  423. multiplier: 0,
  424. uniformcode: "",
  425. };
  426. editFormData.value.deviceModelMetrics.push(obj);
  427. };
  428. //getDeviceModel
  429. const getDeviceModel = async () => {
  430. const res = await device_list();
  431. state.deviceModel = res;
  432. };
  433. // 分页导航
  434. const handlePageChange = (val) => {
  435. query.page = val;
  436. getPoint(desc.value);
  437. };
  438. // 批量导入
  439. const handleSuccess = (response, file, fileList) => {
  440. ElMessage.success("导入成功!");
  441. getPoint(desc.value);
  442. };
  443. const handleProgress = (response, file, fileList) => {};
  444. const handleError = (response, file, fileList) => {
  445. ElMessage.success("导入失败!");
  446. };
  447. // 批量导出
  448. const export2Excel = async () => {
  449. const tableData = await point(
  450. desc.value.code,
  451. 1,
  452. 99999999,
  453. state.selectPoint,
  454. state.SearchVal,
  455. "windturbine",
  456. state.selectModel
  457. );
  458. ElMessage.success(`导出成功!`);
  459. const tableHeader = [
  460. "上级结构编码",
  461. "测点编码",
  462. "名称",
  463. "英文名称",
  464. "单位",
  465. "测点类型",
  466. "物理类型",
  467. "描述",
  468. ];
  469. const tableKey = [
  470. "structurecode",
  471. "metriccode",
  472. "name",
  473. "enname",
  474. "unitname",
  475. "categorydata",
  476. "categorysci",
  477. "description",
  478. ];
  479. outExportExcel(tableHeader, tableKey, tableData.records, "测点导出excel");
  480. };
  481. </script>
  482. <style lang="less" scoped>
  483. .buttons {
  484. background-color: rgba(5, 187, 76, 0.2);
  485. border: 1px solid #3b6c53;
  486. color: #b3b3b3;
  487. font-size: 14px;
  488. &:hover {
  489. background-color: rgba(5, 187, 76, 0.5);
  490. color: #ffffff;
  491. }
  492. }
  493. .devicemenu {
  494. margin-bottom: 10px;
  495. }
  496. .ycpoint-table {
  497. height: calc(100% - 39px);
  498. }
  499. </style>
  500. <style lang="less">
  501. .point-popover {
  502. &.is-light {
  503. background: #081410;
  504. }
  505. .el-table {
  506. background: transparent;
  507. & th.el-table__cell {
  508. background: transparent;
  509. }
  510. & tr {
  511. background-color: transparent;
  512. }
  513. &::before {
  514. background-color: transparent;
  515. }
  516. }
  517. .el-popper__arrow::before {
  518. background: #081410 !important;
  519. border: 1px solid #081410 !important;
  520. }
  521. }
  522. </style>