You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <div>
  3. <el-row v-loading="elRowLoading">
  4. <el-col :span="6" style=" overflow-x:auto; height:400px;">
  5. <span style="font-weight:bold;">请选择机构与部门</span>
  6. <dept-tree show-root default-expand-all :expand-on-click-node="false" @node-click="handleLeftDeptNodeClick"
  7. @branch-row-click="branchRowClick"></dept-tree>
  8. </el-col>
  9. <el-col :span="15">
  10. <el-col :span="5" style="margin-left:70px;"><el-input v-model="filterBusinessName" placeholder="模糊查询"></el-input></el-col>
  11. <el-col :span="8"><el-button type="danger" @click="selectshopLocationBySysDeptIdMethodLike">模糊搜索</el-button>
  12. <el-button type="primary" @click="checkSureMethod" v-if="isSupportCheck">确定</el-button>
  13. </el-col>
  14. <el-table ref="multipleTable" :data="shopLocationTable" style="width: 100%;margin-left:70px;" @selection-change="handleSelectionChange">
  15. <el-table-column type="selection" width="55" v-if="isSupportCheck">
  16. </el-table-column>
  17. <el-table-column prop="shopId" label="商户编号" width="180" align="center">
  18. </el-table-column>
  19. <el-table-column prop="id" label="门店编号" width="180" align="center">
  20. </el-table-column>
  21. <el-table-column prop="businessName" label="门店名称" align="center">
  22. </el-table-column>
  23. <el-table-column label="操作" align="center" v-if="!isSupportCheck">
  24. <template slot-scope="scope">
  25. <el-button type="primary" @click="sureMethod(scope.row,scope.$index)">确定</el-button>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. <el-pagination style="float:right" layout="total, sizes, prev, pager, next,jumper" @current-change="handleCurrentChange" @size-change="handleSizeChange"
  30. :page-sizes="[10,20, 50, 100, 500]" :current-page.sync="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total"></el-pagination>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </template>
  35. <script>
  36. import util from '@/common/js/util'; //全局公共库
  37. import Sticky from '@/components/Sticky' // 粘性header组件
  38. import DeptTree from './DeptTree.vue';
  39. import {
  40. selectshopLocationBySysDeptIdApi
  41. } from './shopLocation';
  42. import {
  43. mapGetters
  44. } from 'vuex'
  45. export default {
  46. computed: {
  47. ...mapGetters([
  48. 'userInfo'
  49. ])
  50. },
  51. props: ['isSupportCheck'],
  52. watch: {},
  53. data() {
  54. return {
  55. multipleSelection: [],
  56. filterBusinessName:'',//搜索名字过滤
  57. currentSelectDeptObject:{},//当前选择的部门对象
  58. elRowLoading: false,
  59. shopLocationTable: [],
  60. pageInfo: { //分页数据
  61. total: 0, //服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算。 计算出有多少条记录
  62. pageSize: 10, //每页数据 每页现实的数据的大小
  63. count: false, //是否需要重新计算总记录数
  64. pageNum: 1, //当前页码、从1开始计算
  65. orderFields: [], //排序列 如 ['sex','student_id'],必须为数据库字段
  66. orderDirs: [] //升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']
  67. }
  68. }
  69. }, //end data
  70. methods: {
  71. selectshopLocationBySysDeptIdMethodLike(){
  72. if(this.currentSelectDeptObject.branchId==null||this.currentSelectDeptObject.branchId==''){
  73. this.$message({showClose: true,
  74. message: "请选择机构和部门",
  75. type: "error"
  76. });
  77. return
  78. }
  79. this.selectshopLocationBySysDeptIdMethod();
  80. },
  81. handleCurrentChange(pageNum) { //分页组件的修改当前页数
  82. this.pageInfo.pageNum = pageNum;
  83. this.selectshopLocationBySysDeptIdMethod();
  84. },
  85. handleSizeChange(pageSize) { //分页组建的修改每页显示的大小
  86. this.pageInfo.pageSize = pageSize;
  87. this.selectshopLocationBySysDeptIdMethod();
  88. },
  89. //点击创建商户对话框左边的树触发的事件
  90. handleLeftDeptNodeClick(data, node, comp) {
  91. if (!data.isBranch) { //选择的不是机构节点
  92. let branchId = data.branchId;
  93. let deptid = data.deptid;
  94. this.pageInfo.count=true;
  95. this.currentSelectDeptObject=data;
  96. this.selectshopLocationBySysDeptIdMethod();
  97. }
  98. },
  99. //点击切换机构按钮的时候触发的事件
  100. branchRowClick: function(row, event, column) {
  101. },
  102. selectshopLocationBySysDeptIdMethod() {
  103. let that = this;
  104. let params = {
  105. "branchId": this.currentSelectDeptObject.branchId,
  106. "deptid": this.currentSelectDeptObject.deptid,
  107. "pageSize":this.pageInfo.pageSize,
  108. "pageNum":this.pageInfo.pageNum,
  109. "count":this.pageInfo.count
  110. };
  111. if(this.filterBusinessName!=null && this.filterBusinessName!=''){//店名模糊搜索
  112. params.filterBusinessName='%'+this.filterBusinessName+'%'
  113. }
  114. if (this.pageInfo.orderFields != null && this.pageInfo.orderFields.length > 0) { //获取排序的字段的内容 以及排序的方式 按时间倒叙排序
  115. let orderBys = [];
  116. for (var i = 0; i < this.pageInfo.orderFields.length; i++) {
  117. orderBys.push(this.pageInfo.orderFields[i] + " " + this.pageInfo.orderDirs[i])
  118. }
  119. params.orderBy = orderBys.join(",") //多个排序字段直接进行拼接的处理
  120. };
  121. this.elRowLoading = true;
  122. selectshopLocationBySysDeptIdApi(params).then(res => {
  123. this.elRowLoading = false;
  124. let tips = res.data.tips;
  125. if (tips.isOk) {
  126. this.pageInfo.total=res.data.total;
  127. this.pageInfo.count=false;
  128. that.shopLocationTable = res.data.data;
  129. }
  130. // this.$message({showClose: true,
  131. // message: tips.msg,
  132. // type: tips.isOk ? 'success' : 'error'
  133. // });
  134. }).catch(() => {
  135. this.elRowLoading = false
  136. });
  137. },
  138. handleSelectionChange(val) {
  139. this.multipleSelection = val;
  140. },
  141. sureMethod(row,index){
  142. this.$emit('sure',row);
  143. },
  144. checkSureMethod(){
  145. if(this.multipleSelection.length<1){
  146. this.$message({showClose: true,
  147. message: "必须选择某个门店",
  148. type: "error"
  149. });
  150. return;
  151. }
  152. this.$emit('checkSureMethod',this.multipleSelection);
  153. },
  154. clearSelectionMethod(){
  155. this.$refs.multipleTable.clearSelection();
  156. }
  157. }, //end methods
  158. components: {
  159. 'dept-tree': DeptTree,
  160. 'sticky': Sticky
  161. //在下面添加其它组件
  162. },
  163. mounted() {
  164. }
  165. }
  166. </script>
  167. <style scoped>
  168. </style>