index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="table-container">
  3. <vab-query-form>
  4. <div class="title">
  5. <div class="left">
  6. <div class="left-item">
  7. <div style="width: 70px;">名称:</div>
  8. <el-input v-model="fuzzyQuery_name" placeholder="请输入" clearable />
  9. </div>
  10. <el-button icon="el-icon-search" type="primary" native-type="submit" @click="handleQuery">
  11. 查询
  12. </el-button>
  13. </div>
  14. <div class="right">
  15. <el-button icon="el-icon-plus" type="primary" @click="handleAdd">
  16. 添加
  17. </el-button>
  18. <el-button icon="el-icon-delete" type="danger" @click="handleDelete">
  19. 删除
  20. </el-button>
  21. <UploadExcel style="margin-left: 10px;" @getResult="getMyExcelData"></UploadExcel>
  22. <ExportExcel :exportList="exportExcel" :useType="'export'" partsName="设备型号"></ExportExcel>
  23. <ExportExcel :exportList="templateExcel" :useType="'template'" partsName="设备型号模板"></ExportExcel>
  24. </div>
  25. </div>
  26. <el-table header-cell-class-name="table_header_style" border ref="tableSort" v-loading="listLoading" :data="list"
  27. :element-loading-text="elementLoadingText" :height="height" @selection-change="setSelectRows">
  28. <el-table-column show-overflow-tooltip type="selection" align="center" width="40"></el-table-column>
  29. <el-table-column show-overflow-tooltip label="编号" prop="id" align="center" sortable></el-table-column>
  30. <el-table-column show-overflow-tooltip label="编码" prop="nemCode" align="center" sortable></el-table-column>
  31. <el-table-column show-overflow-tooltip label="名称" prop="name" align="center" sortable></el-table-column>
  32. <el-table-column show-overflow-tooltip label="描述" prop="description" align="center" sortable></el-table-column>
  33. <el-table-column show-overflow-tooltip label="容量" prop="powerProduction" align="center" sortable>
  34. </el-table-column>
  35. <el-table-column :formatter="windturbineManufacturerIdFormatter" show-overflow-tooltip label="厂商名称" prop="windturbineManufacturerId" align="center" sortable>
  36. </el-table-column>
  37. <el-table-column show-overflow-tooltip label="图片" prop="photo" align="center" sortable>
  38. </el-table-column>
  39. <el-table-column width="180" show-overflow-tooltip label="传输总发电量单位" prop="unit" align="center" sortable></el-table-column>
  40. <el-table-column show-overflow-tooltip label="切入风速" prop="cutinwindSpeed" align="center" sortable>
  41. </el-table-column>
  42. <el-table-column show-overflow-tooltip label="额定风速" prop="ratedwindSpeed" align="center" sortable>
  43. </el-table-column>
  44. <el-table-column show-overflow-tooltip label="切出风速" prop="cutoutwindSpeed" align="center" sortable>
  45. </el-table-column>
  46. <el-table-column width="150" show-overflow-tooltip label="叶片切入面积" prop="sweptArea" align="center" sortable>
  47. </el-table-column>
  48. <el-table-column show-overflow-tooltip label="设备类别" prop="equipmentCategory" :formatter="equipmentCategoryFormatter" align="center" sortable>
  49. </el-table-column>
  50. <el-table-column show-overflow-tooltip label="操作" width="100px" fixed="right">
  51. <template #default="{ row }">
  52. <el-button type="text" @click="handleEdit(row)">编辑</el-button>
  53. <el-button type="text" @click="handleDelete(row)">删除</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-pagination :background="background" :current-page="queryForm.pageNo" :layout="layout"
  58. :page-size="queryForm.pageSize" :total="total" @current-change="handleCurrentChange"
  59. @size-change="handleSizeChange"></el-pagination>
  60. <table-edit ref="edit" :options="options" :stationList="stationList" @save-success="fetchData"></table-edit>
  61. </vab-query-form>
  62. </div>
  63. </template>
  64. <script>
  65. import UploadExcel from '@/components/UploadExcel/index'
  66. import ExportExcel from '@/components/ExportExcel/index'
  67. import api from '@/api/station'
  68. import apis from '@/api/realtimeDatabaseConfiguration'
  69. import TableEdit from './components/TableEdit'
  70. export default {
  71. components: {
  72. UploadExcel,
  73. ExportExcel,
  74. TableEdit,
  75. },
  76. data() {
  77. return {
  78. windturbineManufacturerIdOptions: [],
  79. // 0:风机;1:集中;2:组串
  80. equipmentCategoryOptions: [
  81. {id: 0, name: "风机"},
  82. {id: 1, name: "集中"},
  83. {id: 2, name: "组串"},
  84. ],
  85. fuzzyQuery_name: '',
  86. listLoading: true,
  87. list: [],
  88. options: [],
  89. exportExcel: [],
  90. templateExcel: [],
  91. elementLoadingText: '正在加载...',
  92. selectRows: '',
  93. layout: 'total, sizes, prev, pager, next, jumper',
  94. total: 0,
  95. background: true,
  96. exportList: [],
  97. queryForm: {
  98. pageNo: 1,
  99. pageSize: 20,
  100. },
  101. stationList: [],
  102. selectValue: ''
  103. };
  104. },
  105. computed: {
  106. height() {
  107. return this.$baseTableHeight() + 50
  108. },
  109. },
  110. created() {
  111. this.sttreeMantreels()
  112. this.fetchData()
  113. },
  114. methods: {
  115. windturbineManufacturerIdFormatter(row){
  116. for (const key of this.windturbineManufacturerIdOptions) {
  117. if (key.id == row.windturbineManufacturerId) {
  118. return key.name
  119. }
  120. }
  121. },
  122. sttreeMantreels(){
  123. apis.sttreeMantreels(1).then(res => {
  124. if(res.data){
  125. res.data.forEach( item=> {
  126. this.windturbineManufacturerIdOptions.push(item)
  127. });
  128. }
  129. })
  130. },
  131. equipmentCategoryFormatter(row, column, cellValue, index){
  132. let val = this.equipmentCategoryOptions.filter(item=>{
  133. return item.id == row.equipmentCategory
  134. });
  135. return val[0] ? val[0].name : ""
  136. },
  137. handleQuery() {
  138. this.queryForm.pageNo = 1
  139. this.fetchData()
  140. },
  141. getMyExcelData(val) {
  142. val.forEach(item => {
  143. api.addEquipmentmodel(item).then(res => {
  144. if (res.code == 200) {
  145. this.$message({
  146. type: 'success',
  147. message: '添加成功!'
  148. });
  149. this.fetchData()
  150. }
  151. })
  152. })
  153. },
  154. getStation() {
  155. api.windpowerstationList({
  156. id: '',
  157. name: '',
  158. companyid: '',
  159. pageNum: 1,
  160. pageSize: 1000,
  161. }).then(res => {
  162. if (res.data) {
  163. this.listLoading = false
  164. this.stationList = res.data.records
  165. }
  166. })
  167. },
  168. fetchData() {
  169. api.equipmentmodel({
  170. name: this.fuzzyQuery_name,
  171. pageNum: this.queryForm.pageNo,
  172. pageSize: this.queryForm.pageSize,
  173. }).then(res => {
  174. if (res.data) {
  175. this.listLoading = false
  176. this.total = res.data.total
  177. this.list = res.data.records
  178. this.templateExcel = [
  179. {
  180. id: "",
  181. nemCode: "",
  182. name: "",
  183. description: "",
  184. powerProduction: "",
  185. windturbineManufacturerId: "",
  186. photo: "",
  187. unit: "",
  188. cutinwindSpeed: "",
  189. ratedwindSpeed: "",
  190. cutoutwindSpeed: "",
  191. sweptArea: "",
  192. equipmentCategory: "",
  193. }
  194. ]
  195. // 导出
  196. let exportExcel = []
  197. res.data.records.forEach(item => {
  198. exportExcel.push({
  199. id: item.id,
  200. nemCode: item.nemCode,
  201. name: item.name,
  202. description: item.description,
  203. powerProduction: item.powerProduction,
  204. windturbineManufacturerId: item.windturbineManufacturerId,
  205. photo: item.photo,
  206. unit: item.unit,
  207. cutinwindSpeed: item.cutinwindSpeed,
  208. ratedwindSpeed: item.ratedwindSpeed,
  209. cutoutwindSpeed: item.cutoutwindSpeed,
  210. sweptArea: item.sweptArea,
  211. equipmentCategory: item.equipmentCategory,
  212. })
  213. })
  214. this.exportExcel = exportExcel
  215. }
  216. })
  217. },
  218. handleSizeChange(val) {
  219. this.queryForm.pageSize = val
  220. this.fetchData()
  221. },
  222. handleCurrentChange(val) {
  223. this.queryForm.pageNo = val
  224. this.fetchData()
  225. },
  226. handleAdd() {
  227. this.$refs['edit'].showEdit()
  228. },
  229. handleEdit(row) {
  230. this.$refs['edit'].showEdit(row)
  231. },
  232. handleDelete(row) {
  233. if (row.id || this.selectRows.length > 0) {
  234. this.$baseConfirm('你确定要删除吗', null, async () => {
  235. let ids = ''
  236. if (this.selectRows.length > 0) {
  237. ids = this.selectRows.map((item) => item.id).join()
  238. }
  239. api.deleteEquipmentmodel({
  240. id: row.id || ids
  241. }).then(res => {
  242. if (res.data) {
  243. this.$baseMessage('删除成功', 'success')
  244. this.fetchData()
  245. }
  246. })
  247. })
  248. } else {
  249. this.$baseMessage('未选中任何行', 'error')
  250. return false
  251. }
  252. },
  253. setSelectRows(val) {
  254. this.selectRows = val
  255. },
  256. },
  257. }
  258. </script>
  259. <style lang="less" scoped>
  260. .title {
  261. display: flex;
  262. flex-direction: row;
  263. align-items: center;
  264. justify-content: space-between;
  265. margin-bottom: 20px;
  266. }
  267. .left {
  268. display: flex;
  269. flex-direction: row;
  270. align-items: center;
  271. .left-item {
  272. display: flex;
  273. flex-direction: row;
  274. align-items: center;
  275. margin-right: 10px;
  276. }
  277. }
  278. </style>