index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <el-row :gutter="10" class="mb8">
  5. <el-col :span="1.5">
  6. <el-button
  7. type="primary"
  8. plain
  9. icon="el-icon-plus"
  10. size="mini"
  11. @click="handleAdd"
  12. >新增
  13. </el-button>
  14. </el-col>
  15. </el-row>
  16. <el-table v-loading="loading" border
  17. :data="tableAllData.slice((page.currentPage-1)*page.pageSize,page.currentPage*page.pageSize)">
  18. <el-table-column type="index" label="序号" width="55" align="center"/>
  19. <el-table-column label="场站编号" align="center" prop="stationId"/>
  20. <el-table-column label="场站名称" align="center" prop="stationName"/>
  21. <el-table-column label="简称" align="center" prop="abbreviation"/>
  22. <el-table-column label="场站经度" align="center" prop="longitude"/>
  23. <el-table-column label="场站纬度" align="center" prop="latitude"/>
  24. <el-table-column label="场站类型" align="center" prop="stationType" :formatter="formatStatus" />
  25. <el-table-column label="关联设备" align="center" prop="equipment">
  26. <!-- <template slot-scope="scope">-->
  27. <!-- <span>{{ formatEquipment(scope.row.equipment) }}</span>-->
  28. <!-- </template>-->
  29. </el-table-column>
  30. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  31. <template slot-scope="scope">
  32. <el-button
  33. size="mini"
  34. type="text"
  35. icon="el-icon-edit"
  36. @click="handleUpdate(scope.row)"
  37. >修改
  38. </el-button>
  39. <el-button
  40. size="mini"
  41. type="text"
  42. icon="el-icon-delete"
  43. @click="handleDelete(scope.row)"
  44. >删除
  45. </el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <div class="block" style="float: right">
  50. <el-pagination
  51. @size-change="handleSizeChange"
  52. @current-change="handleCurrentChange"
  53. :current-page=page.currentPage
  54. :page-sizes="[10, 15, 30, 50]"
  55. :page-size=page.pageSize
  56. layout="total, sizes, prev, pager, next, jumper"
  57. :total=page.total>
  58. </el-pagination>
  59. </div>
  60. </el-card>
  61. <!-- 添加或修改测风塔信息对话框 -->
  62. <el-dialog :title="title" :visible.sync="open" width="50%" append-to-body>
  63. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  64. <el-row :gutter="20" class="mb8">
  65. <el-col :span="12">
  66. <el-form-item label="场站编号" prop="stationId">
  67. <el-input v-model="form.stationId" placeholder="请输入场站编号"/>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="12">
  71. <el-form-item label="场站名称" prop="stationName">
  72. <el-input v-model="form.stationName" placeholder="请输入场站名称"/>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. <el-row :gutter="20" class="mb8">
  77. <el-col :span="12">
  78. <el-form-item label="场站缩写" prop="abbreviation">
  79. <el-input v-model="form.abbreviation" placeholder="请输入场站缩写"/>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="12">
  83. <el-form-item label="经度" prop="longitude">
  84. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row :gutter="20" class="mb8">
  89. <el-col :span="12">
  90. <el-form-item label="纬度" prop="latitude">
  91. <el-input v-model="form.latitude" placeholder="请输入纬度"/>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="12">
  95. <el-form-item label="场站类型" prop="stationType">
  96. <el-select v-model="form.stationType" placeholder="请选择" style="width: 100%" clearable @change="typeChange">
  97. <el-option
  98. v-for="item in terrain"
  99. :key="item.value"
  100. :label="item.label"
  101. :value="item.value">
  102. </el-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <el-form-item label="关联设备" prop="equipment" v-if="eType === '风'">
  108. <el-select v-model="form.equipment" placeholder="请选择" style="width: 100%" multiple clearable>
  109. <el-option
  110. v-for="item in equipment"
  111. :key="item.value"
  112. :label="item.label"
  113. :value="item.value"
  114. :disabled="item.disabled">
  115. </el-option>
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item label="关联设备" prop="equipment" v-if="eType === '光'">
  119. <el-select v-model="form.equipment" placeholder="请选择" style="width: 100%" multiple clearable>
  120. <el-option
  121. v-for="item in gEquipment"
  122. :key="item.value"
  123. :label="item.label"
  124. :value="item.value"
  125. :disabled="item.disabled">
  126. </el-option>
  127. </el-select>
  128. </el-form-item>
  129. </el-form>
  130. <div slot="footer" class="dialog-footer">
  131. <el-button type="primary" @click="submitForm">确 定</el-button>
  132. <el-button @click="cancel">取 消</el-button>
  133. </div>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import {
  139. listElectricStation,
  140. addElectricStation,
  141. updateElectricStation,
  142. delElectricStation
  143. } from "@/api/biz/dataQuery/electricStation";
  144. import {listAllDisabled} from "@/api/biz/dataQuery/windTowerStatusInfo";
  145. import axios from "axios";
  146. export default {
  147. name: "WindTowerStatusInfo",
  148. data() {
  149. return {
  150. //
  151. dialogVisible: false,
  152. equipmentNoDisable: false,
  153. //文件上传
  154. fileList: [],
  155. // 遮罩层
  156. loading: false,
  157. // 选中数组
  158. ids: [],
  159. // 非单个禁用
  160. single: true,
  161. // 非多个禁用
  162. multiple: true,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. total: 0,
  167. // 测风塔信息表格数据
  168. windTowerStatusInfoList: [],
  169. tableAllData: [],
  170. // 弹出层标题
  171. title: "",
  172. // 是否显示弹出层
  173. open: false,
  174. eType: '风',
  175. // 查询参数
  176. queryParams: {
  177. pageNum: 1,
  178. pageSize: 10,
  179. name: null,
  180. modelNumber: null,
  181. equipmentNo: null,
  182. installationTime: null,
  183. manufacturer: null,
  184. longitude: null,
  185. latitude: null
  186. },
  187. // 表单参数
  188. form: {},
  189. // 表单校验
  190. rules: {
  191. stationId: [{required: true, message: '请输入场站编号', trigger: 'blur'}],
  192. stationName: [{required: true, message: '请输入场站名称', trigger: 'blur'}],
  193. abbreviation: [{required: true, message: '请输入场站名称缩写', trigger: 'blur'}],
  194. longitude: [
  195. {required: true, message: '请正确填写场站经度'},
  196. {pattern: /^\d+(\.\d{1,9})?$/, message: '只能输入正数数字或带小数点9位以内的数字'},
  197. {pattern: /^-?((0|1?[0-8]?[0-9]?)(([.][0-9]{1,10})?)|180(([.][0]{1,10})?))$/, message: '请输入正确的经度'}
  198. // {message: '输入过长', max: 10}
  199. ],
  200. latitude: [
  201. {required: true, message: '请正确填写场站纬度'},
  202. {pattern: /^\d+(\.\d{1,9})?$/, message: '只能输入正数数字或带小数点9位以内的数字'},
  203. {pattern: /^-?((0|[1-8]?[0-9]?)(([.][0-9]{1,10})?)|90(([.][0]{1,10})?))$/, message: '请输入正确的纬度'}
  204. // {message: '输入过长', max: 10}
  205. ],
  206. stationType: [
  207. {required: true, message: '请填写场站类型'}
  208. ]
  209. },
  210. modId: '',
  211. cftData: [],
  212. cftId: '',
  213. page: {
  214. total: 0, // 总页数
  215. currentPage: 1, // 当前页数
  216. pageSize: 10 // 每页显示多少条
  217. },
  218. terrain: [{label: "风力电站", value: "风"},
  219. {label: "光伏电站", value: "光"}],
  220. status: [
  221. {label: "运行中", value: "Y1"},
  222. {label: "未运行", value: "Y2"},
  223. ],
  224. equipment: [],// 风的关联设备
  225. gEquipment: [],// 光的关联设备
  226. heightOption: []
  227. };
  228. },
  229. created() {
  230. this.getList();
  231. },
  232. mounted() {
  233. this.getAllWindTowerInfo()
  234. },
  235. methods: {
  236. /*获取所有的测风塔*/
  237. getAllWindTowerInfo() {
  238. listAllDisabled().then(res => {
  239. this.equipment = res.data
  240. })
  241. },
  242. // formatEquipment(data) {
  243. // console.log(data)
  244. // if (data !== null) {
  245. // var a = data.split(",");
  246. // var b = "";
  247. // if (a.length !== 0) {
  248. // for (let i = 0; i < a.length; i++) {
  249. // for (let k = 0; k < this.equipment.length; k++) {
  250. // if (this.equipment[k].value === a[i]) {
  251. // b += this.equipment[k].label
  252. // if (i !== a.length - 1) {
  253. // b += ","
  254. // }
  255. // }
  256. // }
  257. // }
  258. // return b;
  259. // }
  260. // }
  261. // },
  262. /** 查询测风塔信息列表 */
  263. getList() {
  264. // this.loading = true;
  265. listElectricStation().then(res => {
  266. this.tableAllData = res.data
  267. this.page.total = res.data.length;
  268. this.loading = false;
  269. })
  270. },
  271. typeChange(){
  272. this.eType = this.form.stationType
  273. },
  274. // 取消按钮
  275. cancel() {
  276. this.open = false;
  277. this.reset();
  278. },
  279. // 表单重置
  280. reset() {
  281. this.form = {
  282. id: null,
  283. stationId: null,
  284. stationName: null,
  285. abbreviation: null,
  286. longitude: null,
  287. latitude: null,
  288. stationType: null,
  289. equipment: null
  290. };
  291. this.resetForm("form");
  292. },
  293. /** 搜索按钮操作 */
  294. handleQuery() {
  295. this.queryParams.pageNum = 1;
  296. this.getList();
  297. },
  298. /** 重置按钮操作 */
  299. resetQuery() {
  300. this.resetForm("queryForm");
  301. this.handleQuery();
  302. },
  303. // 多选框选中数据
  304. handleSelectionChange(selection) {
  305. this.ids = selection.map(item => item.id)
  306. this.single = selection.length !== 1
  307. this.multiple = !selection.length
  308. },
  309. /** 新增按钮操作 */
  310. handleAdd() {
  311. this.reset();
  312. this.modId = ''
  313. this.open = true;
  314. this.equipmentNoDisable = false
  315. this.title = "添加场站信息";
  316. },
  317. /** 修改按钮操作 */
  318. handleUpdate(row) {
  319. this.equipmentNoDisable = true
  320. this.reset();
  321. var a = null
  322. const id = row.id || this.ids
  323. this.modId = id
  324. if (row. equipment!== null) {
  325. a = row.equipment.split(",")
  326. a = a.length === 1 && a[0] === "" ? null : row.equipment.split(",")
  327. }
  328. this.form = {
  329. id: row.id,
  330. stationId: row.stationId,
  331. stationName: row.stationName,
  332. abbreviation: row.abbreviation,
  333. longitude: row.longitude,
  334. latitude: row.latitude,
  335. stationType: row.stationType,
  336. equipment: a
  337. };
  338. this.eType = this.form.stationType
  339. this.open = true;
  340. },
  341. /** 提交按钮 */
  342. submitForm() {
  343. // this.form.heights = this.form.heights.toString()
  344. this.$refs["form"].validate(valid => {
  345. if (this.form.equipment !== null) {
  346. this.form.equipment = this.form.equipment.toString()
  347. }
  348. if (valid) {
  349. if (this.form.id != null) {
  350. updateElectricStation(this.form).then(response => {
  351. this.$modal.msgSuccess("修改成功");
  352. this.open = false;
  353. this.getList();
  354. });
  355. } else {
  356. addElectricStation(this.form).then(response => {
  357. this.$modal.msgSuccess("新增成功");
  358. this.open = false;
  359. this.getList();
  360. });
  361. }
  362. }
  363. });
  364. },
  365. /** 删除按钮操作 */
  366. handleDelete(row) {
  367. this.$modal.confirm('是否确认场站名称为"' + row.stationName + '"信息及所有数据?').then(function () {
  368. return delElectricStation(row);
  369. }).then(() => {
  370. this.getList();
  371. this.$modal.msgSuccess("删除成功");
  372. }).catch(() => {
  373. });
  374. },
  375. /*pageSize改变*/
  376. handleSizeChange(val) {
  377. this.page.pageSize = val
  378. this.page.currentPage = 1
  379. },
  380. /*currentPage改变*/
  381. handleCurrentChange(val) {
  382. this.page.currentPage = val
  383. },
  384. formatStatus(row){
  385. let option = this.terrain.find(w=>w.value === row.stationType)
  386. return option !==undefined?option.label:row.stationType
  387. },
  388. // formatType(row){
  389. // let option = this.status.find(w=>w.value === row.stationStatus)
  390. // return option !==undefined?option.label:row.stationStatus
  391. // },
  392. }
  393. };
  394. </script>
  395. <style scoped>
  396. .uploadDiv {
  397. display: flex;
  398. justify-content: flex-start;
  399. }
  400. .uploadText {
  401. font-size: 18px;
  402. padding: .5%;
  403. }
  404. .upload-demo {
  405. padding: .5%;
  406. }
  407. </style>