index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="main">
  3. <div class="search" v-if="!communitStatus">
  4. <dmp-newsearch :normal="normal" :query="mixins_query" @search="queryList">
  5. <template slot="companyOrgId">
  6. <select-tree
  7. class="new-select-tree"
  8. selectTreeTitle="请选择公司"
  9. placeholder="请选择公司"
  10. :options="companyArray"
  11. :props="defaultProps"
  12. v-model="mixins_query.companyOrgId"
  13. />
  14. </template>
  15. <div class="search-icon opt" slot="right-opt">
  16. <el-tooltip class="item" effect="light" placement="bottom" content="新增">
  17. <i class="iconfont" @click="addOrEdit('add')">&#xe641;</i>
  18. </el-tooltip>
  19. </div>
  20. </dmp-newsearch>
  21. </div>
  22. <zz-table
  23. v-if="!communitStatus"
  24. :cols="cols"
  25. :settings="{ showIndex: true, stripe: true }"
  26. :loading="mixins_onQuery"
  27. :data="mixins_list"
  28. :pageset="mixins_pageset"
  29. @page-change="pageChange"
  30. >
  31. <template slot-scope="scope" slot="opt" class="opt">
  32. <div class="opt">
  33. <el-tooltip effect="light" placement="bottom" content="编辑">
  34. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope.row)"></i>
  35. </el-tooltip>
  36. <el-tooltip effect="light" placement="bottom" content="删除">
  37. <i class="zoniot_font zoniot-icon-shanchu redText" @click="deleteOne(scope.row.id)"></i>
  38. </el-tooltip>
  39. </div>
  40. </template>
  41. </zz-table>
  42. <add-communit v-else :params="activeData" @clerOwnerStatus="clerOwnerStatus" :isAdd="isAdd"></add-communit>
  43. </div>
  44. </template>
  45. <script>
  46. import list from '@utils/list.js';
  47. import addCommunit from './pageJump/AddOrEdit.vue';
  48. export default {
  49. mixins: [list],
  50. components: { addCommunit },
  51. data() {
  52. return {
  53. cols: [
  54. {
  55. label: '社区名称',
  56. prop: 'communityName'
  57. },
  58. {
  59. label: '所属公司',
  60. prop: 'companyName'
  61. },
  62. {
  63. label: '所在地区',
  64. prop: 'mangerName'
  65. },
  66. {
  67. label: '详细地址',
  68. prop: 'address'
  69. },
  70. {
  71. label: '负责人',
  72. prop: 'contactPerson'
  73. },
  74. {
  75. label: '负责人电话',
  76. prop: 'phone'
  77. },
  78. {
  79. label: '操作',
  80. prop: 'opt',
  81. slot: 'opt'
  82. }
  83. ],
  84. normal: [
  85. {
  86. prop: 'communityName',
  87. placeholder: '社区名称'
  88. },
  89. {
  90. prop: 'companyOrgId',
  91. slot: 'companyOrgId'
  92. }
  93. ],
  94. activeData: {},
  95. isAdd: true,
  96. communitStatus: '',
  97. defaultProps: {
  98. value: 'id', // 唯一标识
  99. label: 'orgName', // 标签显示
  100. children: 'orgs' // 子级
  101. }
  102. };
  103. },
  104. computed: {
  105. companyArray() {
  106. return this.$store.getters['getCompanyArray'];
  107. }
  108. },
  109. methods: {
  110. queryList(type = 'search') {
  111. this.mixins_search(type);
  112. },
  113. clerOwnerStatus() {
  114. this.communitStatus = '';
  115. this.activeData = {};
  116. this.isAdd = true;
  117. this.mixins_search();
  118. },
  119. addOrEdit(todo, row) {
  120. if (todo == 'edit') {
  121. this.activeData = row;
  122. this.isAdd = false;
  123. }
  124. this.communitStatus = todo;
  125. },
  126. //单个删除
  127. deleteOne(ids) {
  128. this.$msgBox(`刪除社区`, '删除后将无法恢复,请问是否继续?')
  129. .then(() => {
  130. this.$http.get('/assets/community/delete', { id: ids }).then(({ status }) => {
  131. if (0 === status) {
  132. this.$message({
  133. type: 'success',
  134. message: '删除成功!'
  135. });
  136. this.mixins_search();
  137. } else {
  138. this.$message.error('删除失败!');
  139. }
  140. });
  141. })
  142. .catch(() => {});
  143. },
  144. getCompany(type) {
  145. this.$http.postForm('/sc-user-center/org/getOrgTree', { orgType: type }).then(({ status, data, msg }) => {
  146. if (status === 0 && data) {
  147. if (type == 'company') {
  148. this.$store.commit('setCompanyArray', data);
  149. } else if (type == 'department') {
  150. this.$store.commit('setDepartmentArray', data);
  151. }
  152. }
  153. });
  154. }
  155. },
  156. created() {
  157. if (this.$store.getters['getCompanyArray'].length === 0) {
  158. this.getCompany('company');
  159. }
  160. if (this.$store.getters['getDepartmentArray'].length === 0) {
  161. this.getCompany('department');
  162. }
  163. this.mixins_post = 'post';
  164. this.mixins_dataUrl = '/assets/community/page';
  165. this.mixins_search();
  166. }
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. </style>