index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="table-container">
  3. <template v-if="showState === 1">
  4. <!-- <vab-query-form> -->
  5. <!-- <vab-query-form-left-panel> -->
  6. <el-form ref="form" :model="queryForm" :inline="true" @submit.native.prevent>
  7. <el-form-item label="统一编码"><el-input placeholder="请输入" v-model="form.code"></el-input></el-form-item>
  8. <el-form-item label="名称"><el-input placeholder="请输入" v-model="form.name"></el-input></el-form-item>
  9. <el-form-item label="类型">
  10. <el-select v-model="form.type" placeholder="请选择">
  11. <el-option
  12. v-for="item in typeOptions"
  13. :key="item.value"
  14. :label="item.label"
  15. :value="item.value">
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button icon="el-icon-search" type="primary" native-type="submit" @click="fetchData">查询</el-button>
  21. </el-form-item>
  22. <el-form-item style="float: right;">
  23. <el-button icon="el-icon-plus" type="primary" @click="handleAdd">添加</el-button>
  24. <el-button icon="el-icon-delete" type="danger" @click="handleDelete">删除</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <!-- </vab-query-form-left-panel> -->
  28. <!-- <vab-query-form-right-panel> -->
  29. <!-- <UploadExcel style="margin-left: 10px;" @getResult="getMyExcelData"></UploadExcel>
  30. <ExportExcel :exportList="exportExcel" partsName="公司"></ExportExcel> -->
  31. <!-- </vab-query-form-right-panel> -->
  32. <!-- </vab-query-form> -->
  33. <el-table ref="tableSort" v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText"
  34. :height="height" @selection-change="setSelectRows">
  35. <el-table-column show-overflow-tooltip type="selection" width="55"></el-table-column>
  36. <el-table-column show-overflow-tooltip label="id" prop="id" align="center" sortable></el-table-column>
  37. <el-table-column show-overflow-tooltip label="统一编码" prop="code" align="center" sortable></el-table-column>
  38. <el-table-column show-overflow-tooltip label="名称" prop="name" align="center" sortable></el-table-column>
  39. <el-table-column show-overflow-tooltip label="类型" prop="type" align="center" sortable></el-table-column>
  40. <el-table-column show-overflow-tooltip label="操作" width="260px">
  41. <template #default="{ row }">
  42. <el-button type="text" @click="handleEdit(row)">编辑</el-button>
  43. <el-button type="text" @click="handleDelete(row)">删除</el-button>
  44. <el-button type="text" @click="equipmentAllocation(row)">设备点表配置</el-button>
  45. <el-button type="text" @click="stationAllocation(row)">场站点表配置</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <el-pagination :background="background" :current-page="queryForm.pageNo" :layout="layout"
  50. :page-size="queryForm.pageSize" :total="total" @current-change="handleCurrentChange"
  51. @size-change="handleSizeChange"></el-pagination>
  52. <table-edit ref="edit" :options="options" @save-success="fetchData"></table-edit>
  53. </template>
  54. <EquipmentAllocation :showValue="showData" v-if="showState === 2" @cutState="cutState"/>
  55. <StationAllocation :showValue="showData" v-if="showState === 3" @cutState="cutState"/>
  56. </div>
  57. </template>
  58. <script>
  59. import EquipmentAllocation from './equipmentAllocation/index'
  60. import StationAllocation from './stationAllocation/index'
  61. // import ExportExcel from '@/components/ExportExcel/index'
  62. // import ExportExcel from '@/components/ExportExcel/index'
  63. import TableEdit from './components/TableEdit'
  64. import api from '@/api/pointConfiguration'
  65. export default {
  66. components: {
  67. // UploadExcel,
  68. // ExportExcel,
  69. TableEdit,
  70. EquipmentAllocation,
  71. StationAllocation
  72. },
  73. data() {
  74. return {
  75. showState: 1,
  76. showData: {},
  77. typeOptions: [
  78. {value: '风机计算', label:'风机计算'},
  79. {value: '场站计算', label:'场站计算'},
  80. {value: '风机基础点', label:'风机基础点'},
  81. ],
  82. form :{
  83. code: '',
  84. name: '',
  85. type: '',
  86. },
  87. //
  88. // fuzzyQuery: '',
  89. listLoading: true,
  90. list: [],
  91. options: [],
  92. exportExcel: [],
  93. elementLoadingText: '正在加载...',
  94. selectRows: '',
  95. layout: 'total, sizes, prev, pager, next, jumper',
  96. total: 0,
  97. background: true,
  98. exportList: [],
  99. queryForm: {
  100. pageNo: 1,
  101. pageSize: 20,
  102. },
  103. };
  104. },
  105. created() {
  106. this.fetchData()
  107. },
  108. computed: {
  109. height() {
  110. return this.$baseTableHeight() + 50
  111. },
  112. },
  113. methods: {
  114. cutState(data){
  115. this.showState = data
  116. },
  117. equipmentAllocation(data){
  118. this.showState = 2
  119. this.showData = data
  120. },
  121. stationAllocation(data){
  122. this.showState = 3
  123. this.showData = data
  124. },
  125. getMyExcelData(val) {
  126. val.forEach(item => {
  127. api.addCompanys(item).then(res => {
  128. if (res.code == 200) {
  129. this.$message({
  130. type: 'success',
  131. message: '添加成功!'
  132. });
  133. this.fetchData()
  134. }
  135. })
  136. })
  137. },
  138. fetchData() {
  139. this.listLoading = true
  140. api.standardpointList({
  141. id: '',
  142. code: this.form.code,
  143. name: this.form.name,
  144. type: this.form.type,
  145. pageNum: this.queryForm.pageNo,
  146. pageSize: this.queryForm.pageSize,
  147. }).then(res => {
  148. if (res.data) {
  149. this.listLoading = false
  150. this.total = res.data.total
  151. this.list = res.data.records
  152. let exportExcel = []
  153. res.data.records.forEach(item => {
  154. exportExcel.push({
  155. id: item.id,
  156. name: item.name,
  157. rid: item.rid,
  158. })
  159. })
  160. this.exportExcel = exportExcel
  161. }
  162. })
  163. },
  164. handleSizeChange(val) {
  165. this.queryForm.pageSize = val
  166. this.fetchData()
  167. },
  168. handleCurrentChange(val) {
  169. this.queryForm.pageNo = val
  170. this.fetchData()
  171. },
  172. handleAdd() {
  173. this.$refs['edit'].showEdit()
  174. },
  175. handleEdit(row) {
  176. this.$refs['edit'].showEdit(row)
  177. },
  178. handleDelete(row) {
  179. if (row.id || this.selectRows.length > 0) {
  180. this.$baseConfirm('你确定要删除吗', null, async () => {
  181. let ids = ''
  182. if (this.selectRows.length > 0) {
  183. ids = this.selectRows.map((item) => item.id).join()
  184. }
  185. api.deleteStandardpoint({
  186. id: row.id || ids
  187. }).then(res => {
  188. if (res.data) {
  189. this.$baseMessage('删除成功', 'success')
  190. this.fetchData()
  191. }
  192. })
  193. })
  194. } else {
  195. this.$baseMessage('未选中任何行', 'error')
  196. return false
  197. }
  198. },
  199. setSelectRows(val) {
  200. this.selectRows = val
  201. },
  202. },
  203. }
  204. </script>
  205. <style lang="less" scoped>
  206. a{
  207. float: right;
  208. }
  209. </style>