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.

196 lines
6.6 KiB

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