Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

group_main.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button
  6. size="small"
  7. icon="el-icon-circle-plus-outline"
  8. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  9. type="primary"
  10. @click="addGroupAction"
  11. >新增</el-button
  12. >
  13. </div>
  14. <div class="app-container" v-loading="loading">
  15. <el-row>
  16. <el-col :span="24">
  17. <el-table
  18. :data="groups"
  19. border
  20. :row-style="{ color: '#303133' }"
  21. :header-cell-style="{
  22. backgroundColor: 'rgb(245, 247, 250)',
  23. color: '#606266'
  24. }"
  25. >
  26. <el-table-column
  27. prop="name"
  28. label="分组名称"
  29. align="center"
  30. ></el-table-column>
  31. <el-table-column label="操作" align="center">
  32. <template slot-scope="scope">
  33. <el-tooltip
  34. class="item"
  35. effect="dark"
  36. content="编辑"
  37. placement="top"
  38. >
  39. <el-button
  40. :disabled="
  41. $store.getters.xt_user.subscibe.state == 3 ? true : false
  42. "
  43. type="primary"
  44. icon="el-icon-edit-outline"
  45. size="small"
  46. @click="modifyGroupAt(scope.row)"
  47. ></el-button>
  48. </el-tooltip>
  49. <el-tooltip
  50. class="item"
  51. effect="dark"
  52. content="删除"
  53. placement="top"
  54. >
  55. <el-button
  56. :disabled="
  57. $store.getters.xt_user.subscibe.state == 3 ? true : false
  58. "
  59. type="danger"
  60. icon="el-icon-delete"
  61. size="small"
  62. @click="deleteGroupAt(scope.row)"
  63. ></el-button>
  64. </el-tooltip>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. </el-col>
  69. </el-row>
  70. <el-dialog
  71. width="800px"
  72. :title="group_form.id == 0 ? '新增分组' : '修改分组'"
  73. :visible.sync="showEditGroup"
  74. >
  75. <el-form
  76. :model="group_form"
  77. ref="form_group"
  78. :label-width="formLabelWidth"
  79. >
  80. <el-form-item
  81. label="分组名称 : "
  82. prop="name"
  83. :rules="[
  84. { required: true, message: '请输入分组名', trigger: 'blur' }
  85. ]"
  86. >
  87. <el-input v-model="group_form.name" style="width: 220px"></el-input>
  88. </el-form-item>
  89. <!-- <el-form-item>
  90. <el-button @click="cancelModifyGroup">取 消</el-button>
  91. <el-button :disabled="$store.getters.xt_user.subscibe.state==3?true:false" type="primary" @click="editGroupSubmitAction">保 存</el-button>
  92. </el-form-item> -->
  93. </el-form>
  94. <div slot="footer" class="dialog-footer">
  95. <el-button @click="cancelModifyGroup">取 消</el-button>
  96. <el-button
  97. :disabled="
  98. $store.getters.xt_user.subscibe.state == 3 ? true : false
  99. "
  100. type="primary"
  101. @click="editGroupSubmitAction"
  102. >保 存</el-button
  103. >
  104. </div>
  105. </el-dialog>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. import {
  111. getGroups,
  112. createGroup,
  113. modifyGroup,
  114. disableGroup
  115. } from "@/api/device/device";
  116. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  117. export default {
  118. name: "DeviceGroupMain",
  119. data() {
  120. return {
  121. crumbs: [
  122. { path: false, name: "设备管理" },
  123. { path: "/device/groups", name: "分组管理" }
  124. ],
  125. loading: false,
  126. groups: [],
  127. group_form: {
  128. id: 0,
  129. name: ""
  130. },
  131. showEditGroup: false,
  132. formLabelWidth: "90px"
  133. };
  134. },
  135. components: {
  136. BreadCrumb
  137. },
  138. created() {
  139. this.loading = true;
  140. getGroups().then(rs => {
  141. this.loading = false;
  142. var resp = rs.data;
  143. if (resp.state === 1) {
  144. this.groups.push(...resp.data.groups);
  145. } else {
  146. this.$message.error(resp.msg);
  147. }
  148. });
  149. },
  150. methods: {
  151. addGroupAction() {
  152. this.showEditGroup = true;
  153. },
  154. modifyGroupAt(row) {
  155. this.group_form.id = row.id;
  156. this.group_form.name = row.name;
  157. this.showEditGroup = true;
  158. },
  159. cancelModifyGroup() {
  160. this.group_form.id = 0;
  161. this.group_form.name = "";
  162. this.$refs.form_group.clearValidate();
  163. this.showEditGroup = false;
  164. },
  165. editGroupSubmitAction() {
  166. this.$refs.form_group.validate(valid => {
  167. if (valid) {
  168. if (this.group_form.id === 0) {
  169. createGroup(this.group_form.name).then(rs => {
  170. var resp = rs.data;
  171. if (resp.state === 1) {
  172. var newGroup = resp.data.group;
  173. this.groups.push(newGroup);
  174. this.cancelModifyGroup();
  175. } else {
  176. this.$message.error("分组名称已存在!");
  177. }
  178. });
  179. } else {
  180. modifyGroup(this.group_form.id, this.group_form.name).then(rs => {
  181. var resp = rs.data;
  182. if (resp.state === 1) {
  183. for (let index = 0; index < this.groups.length; index++) {
  184. const group = this.groups[index];
  185. if (group.id == this.group_form.id) {
  186. group.name = this.group_form.name;
  187. break;
  188. }
  189. }
  190. this.cancelModifyGroup();
  191. } else {
  192. this.$message.error("分组名称已存在!");
  193. }
  194. });
  195. }
  196. } else {
  197. return false;
  198. }
  199. });
  200. },
  201. deleteGroupAt: function(row) {
  202. this.$confirm("删除后将无法恢复,确定继续删除吗", "提示", {
  203. confirmButtonText: "确定",
  204. cancelButtonText: "取消",
  205. type: "warning"
  206. }).then(() => {
  207. this.loading = true;
  208. disableGroup(row.id).then(rs => {
  209. this.loading = false;
  210. var resp = rs.data;
  211. if (resp.state == 1) {
  212. var index = this.groups.indexOf(row);
  213. if (index > -1) {
  214. this.groups.splice(index, 1);
  215. }
  216. } else {
  217. this.$message.error(resp.msg);
  218. }
  219. });
  220. });
  221. }
  222. }
  223. };
  224. </script>
  225. <style scoped>
  226. .el-row {
  227. margin-bottom: 20px;
  228. }
  229. </style>
  230. <style>
  231. .el-table td,
  232. .el-table th.is-leaf,
  233. .el-table--border,
  234. .el-table--group {
  235. border-color: #d0d3da;
  236. }
  237. .el-table--border::after,
  238. .el-table--group::after,
  239. .el-table::before {
  240. background-color: #d0d3da;
  241. }
  242. </style>