anemometer copy.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <div class="global-variable">
  3. <div class="condition">
  4. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  5. <el-form-item label="测风塔名称:">
  6. <el-input
  7. v-model="formInline.anemometerName"
  8. placeholder="请输入测风塔名称"
  9. size="small"
  10. ></el-input>
  11. </el-form-item>
  12. <el-form-item label="选择日期:" size="small">
  13. <el-date-picker
  14. v-model="formInline.timeQuantum"
  15. type="daterange"
  16. range-separator="至"
  17. start-placeholder="开始日期"
  18. end-placeholder="结束日期"
  19. @change="onDateChange"
  20. >
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" @click="onSubmit" size="small"
  25. >查询</el-button
  26. >
  27. <el-button @click="reset" size="small">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <div class="list-page">
  32. <div class="newly">
  33. <el-button type="primary" @click="newnuedialog" size="small"
  34. >新增</el-button
  35. >
  36. </div>
  37. <el-table
  38. class="center-align-table"
  39. :data="tableData"
  40. border
  41. :cell-style="rowStyle"
  42. >
  43. <el-table-column
  44. align="center"
  45. fixed
  46. prop="anemometerName"
  47. label="测风塔名称"
  48. >
  49. <template slot-scope="scope">
  50. <el-button
  51. @click="particulars(scope.row)"
  52. type="text"
  53. size="small"
  54. >{{ scope.row.anemometerName }}</el-button
  55. >
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. prop="anemometerCode"
  60. align="center"
  61. label="测风塔编号"
  62. >
  63. </el-table-column>
  64. <el-table-column
  65. prop="longitude"
  66. align="center"
  67. label="经度"
  68. min-width="200"
  69. >
  70. </el-table-column>
  71. <el-table-column
  72. prop="latitude"
  73. align="center"
  74. label="纬度"
  75. min-width="200"
  76. >
  77. </el-table-column>
  78. <el-table-column
  79. prop="state"
  80. align="center"
  81. label="状态"
  82. min-width="100"
  83. >
  84. <template slot-scope="{ row }">
  85. {{ row.state == 1 ? "启用" : "停用" }}
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="createTime" align="center" label="创建时间">
  89. </el-table-column>
  90. <el-table-column
  91. prop="transition"
  92. align="center"
  93. fixed="right"
  94. label="操作"
  95. min-width="200"
  96. >
  97. <template slot-scope="scope">
  98. <el-button @click="compile(scope.row)" type="text" size="small"
  99. >编辑</el-button
  100. >
  101. <el-button
  102. v-if="scope.row.state == 0"
  103. @click="start(scope.row, 1)"
  104. type="text"
  105. size="small"
  106. >启用</el-button
  107. >
  108. <el-button
  109. v-else
  110. style="color: #666"
  111. @click="start(scope.row, 0)"
  112. type="text"
  113. size="small"
  114. >停用</el-button
  115. >
  116. <el-button
  117. style="color: #f00"
  118. @click="deleted(scope.row)"
  119. type="text"
  120. size="small"
  121. >删除</el-button
  122. >
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <div class="pagination-container">
  127. <el-pagination
  128. @current-change="handleCurrentChange"
  129. :current-page.sync="formInline.pageNum"
  130. layout="total, prev, pager, next"
  131. :page-size="formInline.pageSize"
  132. :total="formInline.totalSize"
  133. >
  134. </el-pagination>
  135. </div>
  136. </div>
  137. <!-- 弹出层 -->
  138. <!-- 新增 -->
  139. <el-dialog
  140. :title="title"
  141. :visible.sync="nuedialog"
  142. width="860px"
  143. @close="resetForm"
  144. >
  145. <div class="addition">
  146. <span @click="addition">
  147. <SvgIcons
  148. name="jia"
  149. class="jia"
  150. width="20px"
  151. height="22px"
  152. color="#222"
  153. ></SvgIcons>
  154. </span>
  155. <span @click="subtraction">
  156. <SvgIcons
  157. name="jian"
  158. class="jian"
  159. width="20px"
  160. height="22px"
  161. color="#222"
  162. ></SvgIcons>
  163. </span>
  164. </div>
  165. <div class="general">
  166. <div class="condition">
  167. <p>测风塔名称:</p>
  168. <el-input v-model="anemometerName"></el-input>
  169. </div>
  170. <div class="condition">
  171. <p>经度:</p>
  172. <el-input v-model="latitude"></el-input>
  173. </div>
  174. <div class="condition">
  175. <p>纬度:</p>
  176. <el-input v-model="longitude"></el-input>
  177. </div>
  178. <div
  179. v-for="(tower, index) in anemometerTowerHeightDtoList || [
  180. { anemometerHeight: '' },
  181. ]"
  182. :key="index"
  183. class="condition"
  184. >
  185. <p>测风塔高度{{ index + 1 }}:</p>
  186. <el-input
  187. v-model="tower.anemometerHeight"
  188. placeholder="请输入测风塔高度"
  189. ></el-input>
  190. </div>
  191. </div>
  192. <span slot="footer" class="dialog-footer">
  193. <el-button @click="nuedialog = false" size="small">取 消</el-button>
  194. <el-button type="primary" @click="newly" size="small">确 定</el-button>
  195. </span>
  196. </el-dialog>
  197. <!-- 测风塔详情 -->
  198. <el-dialog title="详情" :visible.sync="unusualdialog" width="400px">
  199. <p>测风塔名称:{{ hightower.anemometerName }}</p>
  200. <p>测风塔编号:{{ hightower.anemometerCode }}</p>
  201. <p>经度:{{ hightower.longitude }}</p>
  202. <p>维度:{{ hightower.latitude }}</p>
  203. <p>状态: {{ hightower.state === 1 ? "启用" : "停用" }}</p>
  204. <p v-for="(item, index) in cftList" :key="index">
  205. 测风塔高度:{{ item.anemometerHeight }}米
  206. </p>
  207. </el-dialog>
  208. </div>
  209. </template>
  210. <script>
  211. import {
  212. createAnemometerTower,
  213. delAnemometerTower,
  214. getAnemometerTower,
  215. getAnemometerTowerPage,
  216. updateAnemometerTower,
  217. updateAnemometerTowerState,
  218. } from "@/api/ledger.js";
  219. export default {
  220. data() {
  221. return {
  222. tableData: [],
  223. formInline: {
  224. anemometerName: "",
  225. timeQuantum: [],
  226. pageNum: 1,
  227. pageSize: 10,
  228. totalSize: 0,
  229. },
  230. startDate: "",
  231. endDate: "",
  232. // 新增测风塔信息
  233. anemometerName: "",
  234. latitude: "",
  235. longitude: "",
  236. anemometerTowerHeightDtoList: [
  237. {
  238. anemometerHeight: "",
  239. },
  240. ],
  241. errors: [],
  242. hightower: [],
  243. cftList: [],
  244. // 新增信息
  245. nuedialog: false,
  246. unusualdialog: false,
  247. title: "",
  248. isEdit: false,
  249. detail: {},
  250. };
  251. },
  252. created() {
  253. this.onSubmit();
  254. },
  255. methods: {
  256. rowStyle() {
  257. return "text-align:center";
  258. },
  259. onDateChange(date) {
  260. if (Array.isArray(date)) {
  261. this.startDate = this.$formatDate(date[0]);
  262. this.endDate = this.$formatDate(date[1]);
  263. if (this.endDate < this.startDate) {
  264. this.endDate = this.startDate;
  265. }
  266. } else {
  267. this.startDate = null;
  268. this.endDate = null;
  269. }
  270. },
  271. // 查询
  272. onSubmit() {
  273. let paramsData = {
  274. anemometerName: this.formInline.anemometerName || undefined,
  275. beginTime: this.startDate || undefined,
  276. endTime: this.endDate || undefined,
  277. pageNum: this.formInline.pageNum,
  278. pageSize: this.formInline.pageSize,
  279. };
  280. getAnemometerTowerPage(paramsData).then((res) => {
  281. this.tableData = res.data.list;
  282. this.formInline.totalSize = res.data.totalSize;
  283. });
  284. },
  285. // 重置
  286. reset() {
  287. this.formInline.anemometerName = "";
  288. this.formInline.timeQuantum = [];
  289. this.endDate = "";
  290. this.startDate = "";
  291. },
  292. // 重置
  293. resetForm() {
  294. this.anemometerName = "";
  295. this.latitude = "";
  296. this.longitude = "";
  297. this.anemometerTowerHeightDtoList = [
  298. {
  299. anemometerHeight: "",
  300. },
  301. ];
  302. },
  303. //打开新增
  304. newnuedialog() {
  305. this.nuedialog = true;
  306. this.title = "新增";
  307. },
  308. // 新增提交
  309. newly() {
  310. const isEmptyAnemometerHeight = this.anemometerTowerHeightDtoList.some(
  311. (tower) =>
  312. !tower.anemometerHeight || !tower.anemometerHeight.toString().trim()
  313. );
  314. if (isEmptyAnemometerHeight) {
  315. this.$message({
  316. message: "测风塔高度不能为空",
  317. type: "warning",
  318. });
  319. return;
  320. }
  321. // Other validation checks
  322. if (!this.anemometerName) {
  323. this.$message({
  324. message: "请填写测风塔名称",
  325. type: "warning",
  326. });
  327. return;
  328. }
  329. if (!this.latitude) {
  330. this.$message({
  331. message: "请填写纬度",
  332. type: "warning",
  333. });
  334. return;
  335. }
  336. if (!this.longitude) {
  337. this.$message({
  338. message: "请填写经度",
  339. type: "warning",
  340. });
  341. return;
  342. }
  343. let paramsData = {
  344. anemometerName: this.anemometerName,
  345. latitude: this.latitude,
  346. longitude: this.longitude,
  347. };
  348. if (!this.isEdit) {
  349. paramsData.anemometerTowerHeightDtoList =
  350. this.anemometerTowerHeightDtoList;
  351. createAnemometerTower(paramsData).then((res) => {
  352. this.nuedialog = false;
  353. this.$message.success("新增成功");
  354. this.onSubmit();
  355. });
  356. } else {
  357. paramsData.anemometerTowerHeightListDtos =
  358. this.anemometerTowerHeightDtoList;
  359. paramsData.anemometerCode = this.detail.anemometerCode;
  360. // delete objectval.parentCode
  361. updateAnemometerTower(paramsData).then((res) => {
  362. this.isEdit = false;
  363. this.nuedialog = false;
  364. this.onSubmit();
  365. this.$message.success("编辑成功");
  366. });
  367. }
  368. this.resetForm();
  369. },
  370. // 查看详情
  371. particulars(row) {
  372. getAnemometerTower({ anemometerCode: row.anemometerCode }).then((res) => {
  373. this.hightower = res.data;
  374. this.cftList = res.data.list;
  375. });
  376. this.unusualdialog = true;
  377. },
  378. // 启用/停用
  379. start(row, type) {
  380. let objectval = {
  381. anemometerCode: row.anemometerCode,
  382. state: type === 0 ? 0 : 1,
  383. };
  384. updateAnemometerTowerState(objectval).then((res) => {
  385. this.$message({
  386. message: "状态已更新成功",
  387. type: "success",
  388. });
  389. // this.$message(`${type === 1 ? '状态已更新成功' : '状态已更新成功'}`);
  390. row.state = type === 1 ? 0 : 1;
  391. this.onSubmit();
  392. });
  393. },
  394. // 删除
  395. deleted(row) {
  396. if (row.state == "1") {
  397. this.$message({
  398. type: "error",
  399. message: "该项处于启用状态,无法删除!",
  400. });
  401. return;
  402. }
  403. this.$confirm("此操作将永久删除该文件,是否继续?", "提示", {
  404. confirmButtonText: "确定",
  405. cancelButtonText: "取消",
  406. type: "warning",
  407. })
  408. .then(() => {
  409. delAnemometerTower({ anemometerCode: row.anemometerCode }).then(
  410. (res) => {
  411. this.onSubmit();
  412. // 执行删除操作
  413. this.$message({
  414. type: "success",
  415. message: "删除成功!",
  416. });
  417. }
  418. );
  419. })
  420. .catch(() => {
  421. // 取消删除
  422. this.$message({
  423. type: "info",
  424. message: "已取消删除",
  425. });
  426. });
  427. },
  428. // 编辑
  429. compile(row) {
  430. this.title = "编辑";
  431. this.isEdit = true;
  432. getAnemometerTower({ anemometerCode: row.anemometerCode }).then((res) => {
  433. this.hightower = res.data;
  434. this.cftList = res.data.list;
  435. const item = JSON.parse(JSON.stringify(res.data));
  436. this.detail = item;
  437. this.anemometerName = item.anemometerName;
  438. this.latitude = item.latitude;
  439. this.longitude = item.longitude;
  440. this.anemometerTowerHeightDtoList = this.cftList;
  441. this.nuedialog = true;
  442. });
  443. },
  444. //分页数据切换
  445. handleCurrentChange(val) {
  446. this.formInline.pageNum = val;
  447. this.onSubmit();
  448. },
  449. // 测风塔高度
  450. addition() {
  451. this.anemometerTowerHeightDtoList.push({ anemometerHeight: "" });
  452. },
  453. subtraction() {
  454. if (this.anemometerTowerHeightDtoList.length > 1) {
  455. // Ensure at least one input remains
  456. this.anemometerTowerHeightDtoList.pop();
  457. }
  458. },
  459. },
  460. };
  461. </script>
  462. <style lang="scss" scoped>
  463. .general {
  464. display: flex;
  465. flex-wrap: wrap;
  466. .condition {
  467. width: 50%;
  468. display: flex;
  469. p {
  470. width: 130px;
  471. text-align: right;
  472. line-height: 40px;
  473. }
  474. span {
  475. line-height: 40px;
  476. margin-right: 5px;
  477. padding-left: 20px;
  478. }
  479. .el-select {
  480. width: 100%;
  481. margin-bottom: 20px;
  482. }
  483. .el-input {
  484. margin-bottom: 20px;
  485. }
  486. }
  487. }
  488. .attachment {
  489. display: flex;
  490. padding-top: 10px;
  491. p {
  492. margin-right: 20px;
  493. color: #409eff;
  494. }
  495. }
  496. .addition {
  497. display: flex;
  498. justify-content: flex-end;
  499. margin-bottom: 10px;
  500. }
  501. .error {
  502. color: red;
  503. position: absolute;
  504. bottom: 85px;
  505. left: 91px;
  506. width: 213px !important;
  507. font-size: 12px;
  508. }
  509. .forinput {
  510. position: relative;
  511. }
  512. </style>