index.vue 11 KB

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