selecDept.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <!-- 授权用户 -->
  3. <el-dialog
  4. title="选择用户"
  5. :visible.sync="visible"
  6. width="800px"
  7. top="5vh"
  8. append-to-body
  9. >
  10. <el-form
  11. v-show="!isSolo"
  12. :model="queryParams"
  13. ref="queryForm"
  14. size="small"
  15. :inline="true"
  16. >
  17. <el-form-item label="用户名称" prop="userName">
  18. <el-input
  19. v-model.trim="queryParams.userName"
  20. placeholder="请输入用户名称"
  21. clearable
  22. style="width: 240px"
  23. @keyup.enter.native="handleQuery"
  24. />
  25. </el-form-item>
  26. <el-form-item label="手机号码" prop="phonenumber">
  27. <el-input
  28. v-model.trim="queryParams.phonenumber"
  29. placeholder="请输入手机号码"
  30. clearable
  31. style="width: 240px"
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button
  37. type="primary"
  38. icon="el-icon-search"
  39. size="mini"
  40. @click="handleQuery"
  41. >搜索</el-button
  42. >
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  44. >重置</el-button
  45. >
  46. </el-form-item>
  47. </el-form>
  48. <el-row>
  49. <el-table
  50. @row-click="clickRow"
  51. ref="table"
  52. :data="userList"
  53. @selection-change="handleSelectionChange"
  54. height="260px"
  55. >
  56. <el-table-column type="selection" width="55"></el-table-column>
  57. <el-table-column
  58. label="用户名称"
  59. prop="userName"
  60. :show-overflow-tooltip="true"
  61. />
  62. <el-table-column
  63. label="用户昵称"
  64. prop="nickName"
  65. :show-overflow-tooltip="true"
  66. />
  67. <el-table-column
  68. label="部门"
  69. prop="deptId"
  70. :show-overflow-tooltip="true"
  71. />
  72. <el-table-column
  73. label="邮箱"
  74. prop="email"
  75. :show-overflow-tooltip="true"
  76. />
  77. <el-table-column
  78. label="手机"
  79. prop="phonenumber"
  80. :show-overflow-tooltip="true"
  81. />
  82. <el-table-column label="状态" align="center" prop="status">
  83. <template slot-scope="scope">
  84. <dict-tag
  85. :options="dict.type.sys_normal_disable"
  86. :value="scope.row.status"
  87. />
  88. </template>
  89. </el-table-column>
  90. <el-table-column
  91. label="创建时间"
  92. align="center"
  93. prop="createTime"
  94. width="180"
  95. >
  96. <template slot-scope="scope">
  97. <span>{{ parseTime(scope.row.createTime) }}</span>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <pagination
  102. v-show="total > 0"
  103. :total="total"
  104. :page.sync="queryParams.pageNum"
  105. :limit.sync="queryParams.pageSize"
  106. @pagination="getList"
  107. />
  108. </el-row>
  109. <div slot="footer" class="dialog-footer">
  110. <el-button type="primary" @click="handleSelectUser">确 定</el-button>
  111. <el-button @click="visible = false">取 消</el-button>
  112. </div>
  113. </el-dialog>
  114. </template>
  115. <script>
  116. import { listUserNew } from "@/api/system/user";
  117. import { number } from "echarts";
  118. export default {
  119. dicts: ["sys_normal_disable"],
  120. props: {
  121. deptId: {
  122. type: String,
  123. default: "",
  124. },
  125. isSolo: {
  126. type: Boolean,
  127. default: true,
  128. },
  129. // 回显数据传值
  130. // selectValues: {
  131. // type: Number | String | Array,
  132. // default: null,
  133. // required: false,
  134. // },
  135. },
  136. data() {
  137. return {
  138. type: 1,
  139. // 遮罩层
  140. visible: false,
  141. // 选中数组值
  142. ids: [],
  143. // 总条数
  144. total: 0,
  145. // 未授权用户数据
  146. userList: [],
  147. // 查询参数
  148. queryParams: {
  149. pageNum: 1,
  150. pageSize: 10,
  151. status: "0",
  152. userName: "",
  153. phonenumber: "",
  154. deptId: "",
  155. orderByColumn: "createTime",
  156. isAsc: "desc",
  157. },
  158. };
  159. },
  160. methods: {
  161. // 显示弹框
  162. show(type, promoterId) {
  163. this.queryParams.deptId = this.deptId;
  164. if (type) {
  165. this.type = type;
  166. }
  167. this.getList(promoterId);
  168. this.visible = true;
  169. },
  170. clickRow(row) {
  171. this.$refs.table.toggleRowSelection(row);
  172. },
  173. // 多选框选中数据
  174. handleSelectionChange(selection) {
  175. if (this.type == 1) {
  176. if (selection.length > 1) {
  177. this.$modal.msg("只能选择一个跟进人");
  178. this.$refs.table.clearSelection();
  179. return;
  180. }
  181. if (this.ids.length == 0) {
  182. this.ids = selection;
  183. } else {
  184. this.$modal.msg("只能选择一个跟进人");
  185. this.ids = [];
  186. // table与table的ref绑定的一样
  187. this.$refs.table.clearSelection();
  188. }
  189. } else {
  190. this.ids = selection;
  191. }
  192. },
  193. // 查询表数据
  194. getList(promoterId) {
  195. listUserNew(this.queryParams).then((res) => {
  196. this.userList = res.rows;
  197. this.total = res.total;
  198. if (promoterId) {
  199. promoterId = parseInt(promoterId);
  200. this.$nextTick(() => {
  201. this.$refs.table.toggleRowSelection(
  202. this.userList.find((item) => {
  203. if (promoterId == item.userId) {
  204. return item;
  205. }
  206. }),
  207. true
  208. );
  209. });
  210. }
  211. });
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.resetForm("queryForm");
  221. this.queryParams.orderByColumn = "createTime";
  222. this.queryParams.isAsc = "desc";
  223. this.handleQuery();
  224. },
  225. /** 选择用户操作 */
  226. handleSelectUser() {
  227. const deptId = this.queryParams.deptId;
  228. if (this.type === 2) {
  229. this.$emit("getDeptMoreUserInfo", this.ids);
  230. } else {
  231. this.$emit("getDeptUserInfo", this.ids);
  232. }
  233. this.visible = false;
  234. },
  235. },
  236. };
  237. </script>