index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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.uniformcode" clearable></el-input></el-form-item>
  8. <el-form-item label="名称"><el-input placeholder="请输入" v-model="form.name" clearable></el-input></el-form-item>
  9. <el-form-item label="类型">
  10. <el-select v-model="form.type" placeholder="请选择" clearable>
  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-button type="primary" @click="generate">生成</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <!-- </vab-query-form-left-panel> -->
  29. <!-- <vab-query-form-right-panel> -->
  30. <!-- <UploadExcel style="margin-left: 10px;" @getResult="getMyExcelData"></UploadExcel>
  31. <ExportExcel :exportList="exportExcel" 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="id" prop="id" align="center" sortable></el-table-column>
  38. <el-table-column show-overflow-tooltip label="类型" prop="type" align="center" sortable :formatter="dateFormat"></el-table-column>
  39. <el-table-column show-overflow-tooltip label="测点编码" prop="point" align="center" sortable></el-table-column>
  40. <el-table-column show-overflow-tooltip label="统一编码" prop="uniformcode" align="center" sortable></el-table-column>
  41. <el-table-column show-overflow-tooltip label="名称" prop="name" align="center" sortable></el-table-column>
  42. <el-table-column show-overflow-tooltip label="操作" width="240px">
  43. <template #default="{ row }">
  44. <el-button type="text" @click="handleEdit(row)">编辑</el-button>
  45. <el-button type="text" @click="handleDelete(row)">删除</el-button>
  46. <el-button type="text" @click="generate(row)">生成</el-button>
  47. <el-button type="text" @click="equipmentAllocation(row)" v-show="row.type === 'fjjs' || row.type === 'fjjc'">设备点表配置</el-button>
  48. <el-button type="text" @click="stationAllocation(row)" v-show="row.type === 'czjs'">场站点表配置</el-button>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <el-pagination :background="background" :current-page="queryForm.pageNo" :layout="layout"
  53. :page-size="queryForm.pageSize" :total="total" @current-change="handleCurrentChange"
  54. @size-change="handleSizeChange"></el-pagination>
  55. <table-edit ref="edit" :options="options" @save-success="fetchData"></table-edit>
  56. </template>
  57. <EquipmentAllocation :showValue="showData" v-if="showState === 2" @cutState="cutState"/>
  58. <StationAllocation :showValue="showData" v-if="showState === 3" @cutState="cutState"/>
  59. </div>
  60. </template>
  61. <script>
  62. import EquipmentAllocation from './equipmentAllocation/index'
  63. import StationAllocation from './stationAllocation/index'
  64. // import ExportExcel from '@/components/ExportExcel/index'
  65. // import ExportExcel from '@/components/ExportExcel/index'
  66. import TableEdit from './components/TableEdit'
  67. import api from '@/api/pointConfiguration'
  68. export default {
  69. components: {
  70. // UploadExcel,
  71. // ExportExcel,
  72. TableEdit,
  73. EquipmentAllocation,
  74. StationAllocation
  75. },
  76. data() {
  77. return {
  78. showState: 1,
  79. showData: {},
  80. typeOptions: [
  81. {value: 'fjjs', label:'风机计算'},
  82. {value: 'czjs', label:'场站计算'},
  83. {value: 'fjjc', label:'风机基础点'},
  84. ],
  85. form :{
  86. uniformcode: '',
  87. name: '',
  88. type: '',
  89. },
  90. //
  91. // fuzzyQuery: '',
  92. listLoading: true,
  93. list: [],
  94. options: [],
  95. exportExcel: [],
  96. elementLoadingText: '正在加载...',
  97. selectRows: '',
  98. layout: 'total, sizes, prev, pager, next, jumper',
  99. total: 0,
  100. background: true,
  101. exportList: [],
  102. queryForm: {
  103. pageNo: 1,
  104. pageSize: 20,
  105. },
  106. };
  107. },
  108. created() {
  109. this.fetchData()
  110. },
  111. computed: {
  112. height() {
  113. return this.$baseTableHeight() + 50
  114. },
  115. },
  116. methods: {
  117. dateFormat(row, column, cellValue, index) {
  118. for (const iterator of this.typeOptions) {
  119. if(row.type === iterator.value){
  120. return iterator.label
  121. }
  122. }
  123. },
  124. cutState(data){
  125. this.showState = data
  126. },
  127. equipmentAllocation(data){
  128. this.showState = 2
  129. this.showData = data
  130. },
  131. stationAllocation(data){
  132. this.showState = 3
  133. this.showData = data
  134. },
  135. getMyExcelData(val) {
  136. val.forEach(item => {
  137. api.addCompanys(item).then(res => {
  138. if (res.code == 200) {
  139. this.$message({
  140. type: 'success',
  141. message: '添加成功!'
  142. });
  143. this.fetchData()
  144. }
  145. })
  146. })
  147. },
  148. fetchData() {
  149. this.listLoading = true
  150. api.standardpointList({
  151. id: '',
  152. uniformcode: this.form.uniformcode,
  153. name: this.form.name,
  154. type: this.form.type,
  155. pageNum: this.queryForm.pageNo,
  156. pageSize: this.queryForm.pageSize,
  157. }).then(res => {
  158. if (res.data) {
  159. this.listLoading = false
  160. this.total = res.data.total
  161. this.list = res.data.records
  162. let exportExcel = []
  163. res.data.records.forEach(item => {
  164. exportExcel.push({
  165. id: item.id,
  166. name: item.name,
  167. rid: item.rid,
  168. })
  169. })
  170. this.exportExcel = exportExcel
  171. }
  172. })
  173. },
  174. handleSizeChange(val) {
  175. this.queryForm.pageSize = val
  176. this.fetchData()
  177. },
  178. handleCurrentChange(val) {
  179. this.queryForm.pageNo = val
  180. this.fetchData()
  181. },
  182. handleAdd() {
  183. this.$refs['edit'].showEdit()
  184. },
  185. handleEdit(row) {
  186. this.$refs['edit'].showEdit(row)
  187. },
  188. generate(row) {
  189. if (row.uniformcode || this.selectRows.length > 0) {
  190. this.$baseConfirm('你确定要生成吗', null, async () => {
  191. let uniformcodeArr = []
  192. if (this.selectRows.length > 0) {
  193. this.selectRows.forEach(element => {
  194. uniformcodeArr.push(element.uniformcode)
  195. });
  196. }
  197. api.generateAdd({points: [row.uniformcode] || uniformcodeArr}).then(res => {
  198. if (res.data) {
  199. this.$baseMessage('生成成功', 'success')
  200. this.fetchData()
  201. }
  202. })
  203. })
  204. } else {
  205. this.$baseMessage('未选中任何行', 'error')
  206. return false
  207. }
  208. },
  209. handleDelete(row) {
  210. if (row.id || this.selectRows.length > 0) {
  211. this.$baseConfirm('你确定要删除吗', null, async () => {
  212. let ids = ''
  213. if (this.selectRows.length > 0) {
  214. ids = this.selectRows.map((item) => item.id).join()
  215. }
  216. api.deleteStandardpoint({
  217. id: row.id || ids
  218. }).then(res => {
  219. if (res.data) {
  220. this.$baseMessage('删除成功', 'success')
  221. this.fetchData()
  222. }
  223. })
  224. })
  225. } else {
  226. this.$baseMessage('未选中任何行', 'error')
  227. return false
  228. }
  229. },
  230. setSelectRows(val) {
  231. this.selectRows = val
  232. },
  233. },
  234. }
  235. </script>
  236. <style lang="less" scoped>
  237. a{
  238. float: right;
  239. }
  240. </style>