index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="table-container">
  3. <vab-query-form>
  4. <vab-query-form-left-panel>
  5. <el-form ref="form" :model="queryForm" :inline="true" @submit.native.prevent>
  6. <el-form-item label="公司名称">
  7. <el-input v-model="fuzzyQuery" placeholder="请输入" clearable />
  8. <!-- <el-cascader
  9. v-model="fuzzyQuery"
  10. :options="options"
  11. style="width: 240px"
  12. :props="{ checkStrictly: true, label: 'name', value: 'id' , children:'children1' }"
  13. clearable /> -->
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button icon="el-icon-search" type="primary" native-type="submit" @click="handleQuery">
  17. 查询
  18. </el-button>
  19. </el-form-item>
  20. </el-form>
  21. </vab-query-form-left-panel>
  22. <vab-query-form-right-panel>
  23. <el-button icon="el-icon-plus" type="primary" @click="handleAdd">
  24. 添加
  25. </el-button>
  26. <el-button icon="el-icon-delete" type="danger" @click="handleDelete">
  27. 删除
  28. </el-button>
  29. <UploadExcel style="margin-left: 10px;" @getResult="getMyExcelData"></UploadExcel>
  30. <ExportExcel :exportList="exportExcel" :useType="'export'" partsName="公司"></ExportExcel>
  31. <ExportExcel :exportList="templateExcel" :useType="'template'" partsName="公司模板"></ExportExcel>
  32. </vab-query-form-right-panel>
  33. </vab-query-form>
  34. <el-table ref="tableSort" v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText"
  35. :height="height" @selection-change="setSelectRows">
  36. <el-table-column show-overflow-tooltip type="selection" width="55"></el-table-column>
  37. <el-table-column show-overflow-tooltip label="编码" prop="id" align="center" sortable fixed="left"></el-table-column>
  38. <el-table-column width="120" show-overflow-tooltip label="公司名称" prop="name" align="center" sortable fixed="left"></el-table-column>
  39. <el-table-column width="120" show-overflow-tooltip label="别名" prop="aname" align="center" sortable></el-table-column>
  40. <el-table-column width="130" show-overflow-tooltip label="风电装机容量" prop="windcapacity" align="center" sortable></el-table-column>
  41. <el-table-column width="130" show-overflow-tooltip label="风电容量单位" prop="windcapacityunit" align="center" sortable></el-table-column>
  42. <el-table-column width="130" show-overflow-tooltip label="风电装机数量" prop="windquantity" align="center" sortable></el-table-column>
  43. <el-table-column width="150" show-overflow-tooltip label="风电场站数量" prop="windnumber" align="center" sortable></el-table-column>
  44. <el-table-column width="150" show-overflow-tooltip label="接入风电场站数" prop="jrwindnumber" align="center" sortable></el-table-column>
  45. <el-table-column width="150" show-overflow-tooltip label="光伏场站数量" prop="number" align="center" sortable></el-table-column>
  46. <el-table-column width="130" show-overflow-tooltip label="光伏装机容量" prop="capacity" align="center" sortable></el-table-column>
  47. <el-table-column width="130" show-overflow-tooltip label="光伏容量单位" prop="capacityunit" align="center" sortable></el-table-column>
  48. <el-table-column width="170" show-overflow-tooltip label="光伏装机数量集中" prop="quantityjz" align="center" sortable></el-table-column>
  49. <el-table-column width="170" show-overflow-tooltip label="光伏装机数量组串" prop="quantityzc" align="center" sortable></el-table-column>
  50. <el-table-column width="150" show-overflow-tooltip label="接入光伏场站数" prop="jrnumber" align="center" sortable></el-table-column>
  51. <el-table-column width="170" show-overflow-tooltip label="接入风电装机容量2" prop="jrwindcapacity" align="center" sortable></el-table-column>
  52. <el-table-column width="170" show-overflow-tooltip label="接入风电容量单位2" prop="jrwindcapacityunit" align="center" sortable></el-table-column>
  53. <el-table-column width="170" show-overflow-tooltip label="接入风电装机数量2" prop="jrwindquantity" align="center" sortable></el-table-column>
  54. <el-table-column width="170" show-overflow-tooltip label="接入光伏装机容量2" prop="jrcapacity" align="center" sortable></el-table-column>
  55. <el-table-column width="170" show-overflow-tooltip label="接入光伏容量单位2" prop="jrcapacityunit" align="center" sortable></el-table-column>
  56. <el-table-column width="190" show-overflow-tooltip label="接入光伏装机数量集中" prop="jrquantityjz" align="center" sortable></el-table-column>
  57. <el-table-column width="190" show-overflow-tooltip label="接入光伏装机数量组串" prop="jrquantityzc" align="center" sortable></el-table-column>
  58. <el-table-column show-overflow-tooltip label="操作" width="100px" fixed="right">
  59. <template #default="{ row }">
  60. <el-button type="text" @click="handleEdit(row)">编辑</el-button>
  61. <el-button type="text" @click="handleDelete(row)">删除</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <el-pagination :background="background" :current-page="queryForm.pageNo" :layout="layout"
  66. :page-size="queryForm.pageSize" :total="total" @current-change="handleCurrentChange"
  67. @size-change="handleSizeChange"></el-pagination>
  68. <table-edit ref="edit" :options="options" @save-success="fetchData"></table-edit>
  69. </div>
  70. </template>
  71. <script>
  72. import UploadExcel from '@/components/UploadExcel/index'
  73. import ExportExcel from '@/components/ExportExcel/index'
  74. import TableEdit from './components/TableEdit'
  75. import api from '@/api/station'
  76. export default {
  77. components: {
  78. UploadExcel,
  79. ExportExcel,
  80. TableEdit,
  81. },
  82. data() {
  83. return {
  84. fuzzyQuery: '',
  85. listLoading: true,
  86. list: [],
  87. options: [],
  88. exportExcel: [],
  89. templateExcel: [],
  90. elementLoadingText: '正在加载...',
  91. selectRows: '',
  92. layout: 'total, sizes, prev, pager, next, jumper',
  93. total: 0,
  94. background: true,
  95. exportList: [],
  96. queryForm: {
  97. pageNo: 1,
  98. pageSize: 20,
  99. },
  100. };
  101. },
  102. created() {
  103. this.fetchData()
  104. // this.getTree()
  105. },
  106. computed: {
  107. height() {
  108. return this.$baseTableHeight() + 50
  109. },
  110. },
  111. methods: {
  112. handleQuery() {
  113. this.queryForm.pageNo = 1
  114. this.fetchData()
  115. },
  116. getTree() {
  117. api.newtreeTreels({tag: 0}).then(res => {
  118. if (res.data) {
  119. this.options = res.data
  120. }
  121. })
  122. },
  123. getMyExcelData(val) {
  124. val.forEach(item => {
  125. api.addCompanys(item).then(res => {
  126. if (res.code == 200) {
  127. this.$message({
  128. type: 'success',
  129. message: '添加成功!'
  130. });
  131. this.fetchData()
  132. }
  133. })
  134. })
  135. },
  136. fetchData() {
  137. this.listLoading = true
  138. api.companys({
  139. id: '',
  140. name: this.fuzzyQuery,
  141. pageNum: this.queryForm.pageNo,
  142. pageSize: this.queryForm.pageSize,
  143. }).then(res => {
  144. if (res.data) {
  145. this.listLoading = false
  146. this.total = res.data.total
  147. this.list = res.data.records
  148. this.templateExcel = [
  149. {
  150. id: "",
  151. name: "",
  152. aname: "",
  153. windcapacity: "",
  154. windcapacityunit: "",
  155. windquantity: "",
  156. windnumber: "",
  157. jrwindnumber: "",
  158. number: "",
  159. capacity: "",
  160. capacityunit: "",
  161. quantityjz: "",
  162. quantityzc: "",
  163. jrnumber: "",
  164. jrwindcapacity: "",
  165. jrwindcapacityunit: "",
  166. jrwindquantity: "",
  167. jrcapacity: "",
  168. jrcapacityunit: "",
  169. jrquantityjz: "",
  170. jrquantityzc: ""
  171. }
  172. ]
  173. let exportExcel = []
  174. res.data.records.forEach(item => {
  175. exportExcel.push({
  176. id: item.id,
  177. name: item.name,
  178. aname: item.aname,
  179. windcapacity: item.windcapacity,
  180. windcapacityunit: item.windcapacityunit,
  181. windquantity: item.windquantity,
  182. windnumber: item.windnumber,
  183. jrwindnumber: item.jrwindnumber,
  184. number: item.number,
  185. capacity: item.capacity,
  186. capacityunit: item.capacityunit,
  187. quantityjz: item.quantityjz,
  188. quantityzc: item.quantityzc,
  189. jrnumber: item.jrnumber,
  190. jrwindcapacity: item.jrwindcapacity,
  191. jrwindcapacityunit: item.jrwindcapacityunit,
  192. jrwindquantity: item.jrwindquantity,
  193. jrcapacity: item.jrcapacity,
  194. jrcapacityunit: item.jrcapacityunit,
  195. jrquantityjz: item.jrquantityjz,
  196. jrquantityzc: item.jrquantityzc
  197. })
  198. })
  199. this.exportExcel = exportExcel
  200. }
  201. })
  202. },
  203. handleSizeChange(val) {
  204. this.queryForm.pageSize = val
  205. this.fetchData()
  206. },
  207. handleCurrentChange(val) {
  208. this.queryForm.pageNo = val
  209. this.fetchData()
  210. },
  211. handleAdd() {
  212. this.$refs['edit'].showEdit()
  213. },
  214. handleEdit(row) {
  215. this.$refs['edit'].showEdit(row)
  216. },
  217. handleDelete(row) {
  218. if (row.id || this.selectRows.length > 0) {
  219. this.$baseConfirm('你确定要删除吗', null, async () => {
  220. let ids = ''
  221. if (this.selectRows.length > 0) {
  222. ids = this.selectRows.map((item) => item.id).join()
  223. }
  224. api.deleteCompanys({
  225. id: row.id || ids
  226. }).then(res => {
  227. if (res.data) {
  228. this.$baseMessage('删除成功', 'success')
  229. this.fetchData()
  230. }
  231. })
  232. })
  233. } else {
  234. this.$baseMessage('未选中任何行', 'error')
  235. return false
  236. }
  237. },
  238. setSelectRows(val) {
  239. this.selectRows = val
  240. },
  241. },
  242. }
  243. </script>
  244. <style lang="less" scoped>
  245. </style>