index.vue 11 KB

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