index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选start -->
  4. <div class="mb-20">所有台区</div>
  5. <div class="filter-container mb-20">
  6. <div>
  7. <div class="filter-item">
  8. 台区:
  9. <el-input
  10. v-model="input"
  11. placeholder="请输入内容"
  12. style="width: 240px"
  13. ></el-input>
  14. </div>
  15. <el-button type="primary" icon="el-icon-search" class="search-button"
  16. >搜索</el-button
  17. >
  18. <el-button icon="el-icon-plus" type="success" @click="addItem()"
  19. >新增</el-button
  20. >
  21. </div>
  22. </div>
  23. <!-- 筛选end -->
  24. <!-- 表格start -->
  25. <el-table
  26. :data="tableData"
  27. border
  28. stripe
  29. :header-cell-style="headClass"
  30. :cell-style="cellStyle"
  31. >
  32. <el-table-column fixed prop="stationName" label="台区名称" width="">
  33. </el-table-column>
  34. <el-table-column prop="stationCode" label="台区编号" width="">
  35. </el-table-column>
  36. <el-table-column prop="stationAddress" label="台区地址" width="">
  37. </el-table-column>
  38. <el-table-column prop="pointNum" label="点位数量" width="">
  39. <template #default-slot="scope">
  40. <router-link style="margin-right:15px;" :to="{ path:'siteList',query:{id:scope.row.stationName}}">
  41. {{ scope.row.pointNum }}
  42. </router-link>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="deviceNum" label="挂载设备数量" width="350">
  46. </el-table-column>
  47. <el-table-column fixed="right" label="操作" width="250">
  48. <template #default>
  49. <el-button
  50. type="text"
  51. size="small"
  52. @click.prevent="editRow(scope.row)"
  53. >编辑</el-button
  54. >
  55. <el-button
  56. @click="handleDelete(scope.$index, scope.row)"
  57. type="text"
  58. size="small"
  59. class="delete-text"
  60. >删除</el-button
  61. >
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <!-- 表格end -->
  66. <!--弹框组件开始-----------------------start-->
  67. <dialog-component
  68. v-if="showDialog"
  69. ref="dialogComponent"
  70. :dialog-title="dialogTitle"
  71. :item-info="tableItem"
  72. @closeDialog="closeDialog"
  73. ></dialog-component>
  74. <!--弹框组件开始-----------------------end-->
  75. </div>
  76. </template>
  77. <script>
  78. import DialogComponent from "./dialogComponent";
  79. // import { mapGetters } from "vuex";
  80. export default {
  81. // name: "Dashboard",
  82. // computed: {
  83. // ...mapGetters(["name"]),
  84. // },
  85. components: { DialogComponent },
  86. data() {
  87. return {
  88. showDialog: false,
  89. input: "请输入台区名称",
  90. tableData: [
  91. {
  92. stationName: "台区1",
  93. stationCode: "tq02",
  94. stationAddress: "青浦区徐泾镇",
  95. pointNum: "8",
  96. deviceNum: "10",
  97. },
  98. {
  99. stationName: "台区1",
  100. stationCode: "tq02",
  101. stationAddress: "青浦区徐泾镇",
  102. pointNum: "8",
  103. deviceNum: "10",
  104. },
  105. {
  106. stationName: "台区1",
  107. stationCode: "tq02",
  108. stationAddress: "青浦区徐泾镇",
  109. pointNum: "8",
  110. deviceNum: "10",
  111. },
  112. {
  113. stationName: "台区1",
  114. stationCode: "tq02",
  115. stationAddress: "青浦区徐泾镇",
  116. pointNum: "8",
  117. deviceNum: "10",
  118. },
  119. ],
  120. };
  121. },
  122. methods: {
  123. // 表头样式设置
  124. headClass() {
  125. return "background:#FAFAFA;";
  126. },
  127. //自定义列样式
  128. cellStyle({ row, column, rowIndex, columnIndex }) {
  129. if (columnIndex === 3) {
  130. return `color:#0284E8;`;
  131. } else {
  132. return "";
  133. }
  134. },
  135. // 添加操作
  136. addItem() {
  137. this.tableItem = {
  138. id: "",
  139. stationName: "",
  140. stationCode: "",
  141. stationAddress: "",
  142. siteList: [],
  143. done: "",
  144. guaZai: "",
  145. };
  146. this.dialogTitle = "新增";
  147. this.showDialog = true;
  148. this.$nextTick(() => {
  149. this.$refs["dialogComponent"].showDialog = true;
  150. });
  151. },
  152. // 编辑操作
  153. editRow(row) {
  154. console.log(row);
  155. this.tableItem = row;
  156. this.dialogTitle = "编辑";
  157. this.showDialog = true;
  158. this.$nextTick(() => {
  159. this.$refs["dialogComponent"].showDialog = true;
  160. });
  161. },
  162. // 关闭操作
  163. closeDialog(flag) {
  164. if (flag) {
  165. // 重新刷新表格内容
  166. this.fetchData();
  167. }
  168. this.showDialog = false;
  169. },
  170. // handleEdit(index, row) {
  171. // console.log(index, row);
  172. // },
  173. //删除操作
  174. handleDelete(index, row) {
  175. console.log(index, row);
  176. alert(index);
  177. },
  178. },
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. </style>