index.vue 5.8 KB

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