index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <el-row class="el-row-container" v-loading="loading">
  3. <el-col :span="24" style="padding: 16px; height: 100%">
  4. <el-card style="height: 100%; overflow-y: auto">
  5. <el-col :span="24" class="elrow-main__col-top">
  6. <div style="display: flex">
  7. <select-tree
  8. v-model="form.goodsName"
  9. style="width: 250px"
  10. :treeData="treeData"
  11. :placeholder="'请输入产品名称/批次号'"
  12. @handlerClick="handlerClick"
  13. :checkVal="cusareaName"
  14. ></select-tree>
  15. <el-input
  16. v-model="assocName"
  17. style="width: 250px; margin: 0 16px"
  18. placeholder="请输入用户协会名称"
  19. clearable
  20. />
  21. <el-button type="primary" size="small" @click="handleSearch"
  22. >查询</el-button
  23. >
  24. </div>
  25. <div class="top-left">
  26. <el-button
  27. type="primary"
  28. size="small"
  29. @click="addAssociation"
  30. v-hasPermi="['wpr:society:add']"
  31. >新增协会</el-button
  32. >
  33. </div>
  34. </el-col>
  35. <el-col :span="24" class="elrow-main__col-bottom">
  36. <b-table
  37. ref="tableRef"
  38. :args="{ 'highlight-current-row': true }"
  39. :data="loadData"
  40. :columns="columns"
  41. isShowIndex
  42. >
  43. <template #operate="scope">
  44. <el-link
  45. size="small"
  46. :underline="false"
  47. type="primary"
  48. style="margin-right: 10px"
  49. @click="editRowHandler(scope.row)"
  50. v-hasPermi="['wpr:society:edit']"
  51. >修改</el-link
  52. >
  53. <el-link
  54. size="small"
  55. :underline="false"
  56. type="danger"
  57. style="margin-right: 10px"
  58. @click="deleteRowHandler(scope.row)"
  59. v-hasPermi="['wpr:society:delete']"
  60. >删除</el-link
  61. >
  62. </template>
  63. </b-table>
  64. </el-col>
  65. </el-card>
  66. </el-col>
  67. <association-manage
  68. :visible.sync="associationManageShow"
  69. :treeData="treeData"
  70. :userList="userList"
  71. @getList="handleSearch"
  72. :typeAssoc="typeAssoc"
  73. :editRow="editRow"
  74. />
  75. </el-row>
  76. </template>
  77. <script>
  78. import { getAssocList, deleteAssoc } from '@/api/assoc/index.js';
  79. import { listUser } from '@/api/system/user.js';
  80. import BTable from '@/components/Table/index.vue';
  81. import AssociationManage from './component/associationManage.vue';
  82. import SelectTree from '@/components/SelectTree';
  83. import { getTree } from '@/api/tree.js';
  84. import { Message } from 'element-ui';
  85. import { assign, omit } from 'lodash-es';
  86. export default {
  87. name: 'waterManage',
  88. components: { BTable, AssociationManage, SelectTree },
  89. data() {
  90. return {
  91. form: {
  92. productName: ''
  93. },
  94. userList: [],
  95. treeData: [],
  96. loading: false,
  97. cusareaName: '',
  98. associationManageShow: false,
  99. assocName: '',
  100. areaId: '',
  101. typeAssoc: 'add',
  102. editRow: {},
  103. columns: [
  104. {
  105. label: '用水协会名称',
  106. prop: 'assocName',
  107. customRender: '',
  108. align: 'center'
  109. },
  110. {
  111. label: '管理区域',
  112. prop: 'cusareaNames',
  113. customRender: '',
  114. align: 'center'
  115. },
  116. {
  117. label: '负责人',
  118. prop: 'assocManageName',
  119. customRender: '',
  120. align: 'center'
  121. },
  122. {
  123. label: '电话',
  124. prop: 'userMobile',
  125. customRender: '',
  126. align: 'center'
  127. },
  128. {
  129. label: '操作',
  130. customRender: 'operate',
  131. align: 'center'
  132. }
  133. ]
  134. };
  135. },
  136. mounted() {
  137. this.searchHandler();
  138. },
  139. methods: {
  140. async searchHandler() {
  141. const res = await listUser({
  142. pageSize: 99999
  143. });
  144. this.userList = res.data;
  145. },
  146. addAssociation() {
  147. this.typeAssoc = 'add';
  148. this.editRow = {};
  149. this.associationManageShow = true;
  150. },
  151. // 删除
  152. deleteRowHandler(row) {
  153. const { assocId: assocIds } = row;
  154. this.$modal.confirm(`是否确认删除`).then(() => {
  155. deleteAssoc({
  156. assocIds
  157. }).then(() => {
  158. Message({ message: '删除成功', type: 'success' });
  159. this.handlerChange();
  160. });
  161. });
  162. },
  163. async loadData(parameter) {
  164. if (!this.areaId) {
  165. const treeList = this.$store.state.tree.treeList;
  166. let res = [];
  167. if (treeList.code === '000000') {
  168. res = treeList;
  169. } else {
  170. res = await getTree();
  171. this.$store.dispatch('tree/setTree', res);
  172. }
  173. this.treeData = res?.data;
  174. this.cusareaName ||= this.treeData[0].cusareaName;
  175. this.areaId = this.treeData[0].cusareaId;
  176. }
  177. const params = {
  178. assocName: this.assocName,
  179. areaId: this.areaId
  180. };
  181. const payload = omit(assign({}, parameter, params), []);
  182. return getAssocList(payload);
  183. },
  184. handlerClick(value) {
  185. this.areaId = value?.cusareaId;
  186. },
  187. handleSearch() {
  188. this.$refs.tableRef.refresh(true);
  189. },
  190. handlerChange() {
  191. this.$refs.tableRef.refresh(false);
  192. },
  193. // 修改
  194. editRowHandler(row) {
  195. this.typeAssoc = 'edit';
  196. this.editRow = row;
  197. this.associationManageShow = true;
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .el-row-container {
  204. height: 100%;
  205. }
  206. .elrow-main__col-top {
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. margin-bottom: 15px;
  211. .top-left {
  212. height: 100%;
  213. display: flex;
  214. align-items: center;
  215. i {
  216. background-color: #40d5ec;
  217. height: 45%;
  218. width: 5px;
  219. margin-right: 5px;
  220. }
  221. }
  222. }
  223. </style>