transfer.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索区域 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="销售" prop="salesName">
  6. <el-select v-model="queryParams.companyUserId" remote placeholder="请选择" filterable clearable style="width: 100%;" @keyup.enter.native="handleQuery">
  7. <el-option
  8. v-for="dict in companyUserList"
  9. :key="`${dict.nickName} - ${dict.userName}`"
  10. :label="`${dict.nickName} - ${dict.userName}`"
  11. :value="dict.userId">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="会员ID" prop="userId">
  16. <el-input
  17. style="width: 200px"
  18. v-model="queryParams.userId"
  19. placeholder="请输入会员ID"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item label="会员昵称" prop="nickname">
  26. <el-input
  27. style="width: 200px"
  28. v-model="queryParams.nickname"
  29. placeholder="请输入会员昵称"
  30. clearable
  31. size="small"
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item label="手机号码" prop="phone">
  36. <el-input
  37. style="width: 220px"
  38. v-model="queryParams.phone"
  39. placeholder="请输入手机号码"
  40. clearable
  41. size="small"
  42. @keyup.enter.native="handleQuery"
  43. />
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  47. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  48. </el-form-item>
  49. </el-form>
  50. <!-- 操作按钮区域 -->
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. type="warning"
  55. icon="el-icon-d-arrow-right"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleTransfer"
  59. v-hasPermi="['company:user:transfer']"
  60. >转移</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <!-- 表格数据 -->
  65. <el-table height="500" border v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
  66. <el-table-column type="selection" width="55" align="center" />
  67. <el-table-column label="客户ID" align="center" prop="userId" />
  68. <el-table-column label="项目" align="center" prop="projectId">
  69. <template slot-scope="scope">
  70. <el-tag v-if="scope.row.projectId !== null">{{ getProjectLabel(scope.row.projectId) }}</el-tag>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="会员ID" align="center" prop="userId" />
  74. <el-table-column label="昵称" align="center" prop="nickname" />
  75. <el-table-column label="所属销售" align="center" prop="companyUserNickName" />
  76. <el-table-column label="手机号码" align="center" prop="phone" />
  77. <el-table-column label="状态" align="center" prop="statusText" >
  78. <template slot-scope="scope">
  79. <el-tag :type="scope.row.statusText === '正常' ? 'success' : 'danger'">{{ scope.row.statusText }}</el-tag>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.createTime }}</span>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <!-- 分页 -->
  89. <pagination
  90. v-show="total>0"
  91. :total="total"
  92. :page.sync="queryParams.pageNum"
  93. :limit.sync="queryParams.pageSize"
  94. @pagination="getList"
  95. />
  96. <!-- 客户转移对话框 (可选,更复杂的转移逻辑可能需要) -->
  97. <el-dialog title="客户转移" :visible.sync="openTransferDialog" width="500px" append-to-body>
  98. <el-form ref="transferForm" :model="transferForm" label-width="100px" :rules="cusTransfer">
  99. <el-alert
  100. title="会自动通过审核"
  101. type="warning">
  102. </el-alert>
  103. <el-form-item label="转移至销售" prop="targetUserId">
  104. <el-select v-model="transferForm.targetUserId" remote placeholder="请选择" filterable clearable>
  105. <el-option
  106. v-for="dict in companyUserList"
  107. :key="`${dict.nickName} - ${dict.userName}`"
  108. :label="`${dict.nickName} - ${dict.userName}`"
  109. :value="dict.userId">
  110. </el-option>
  111. </el-select>
  112. </el-form-item>
  113. <el-form-item label="转移原因" prop="content">
  114. <el-input type="textarea" v-model="transferForm.content" placeholder="转移原因"></el-input>
  115. </el-form-item>
  116. <p>确定要转移选中的 <strong>{{ ids.length }}</strong> 个客户吗?</p>
  117. </el-form>
  118. <div slot="footer" class="dialog-footer">
  119. <el-button type="danger" @click="submitTransfer">提交申请</el-button>
  120. <el-button @click="cancelTransfer">取 消</el-button>
  121. </div>
  122. </el-dialog>
  123. </div>
  124. </template>
  125. <script>
  126. import { listUser, transferUser} from "@/api/users/user";
  127. import {parseTime} from "../../../utils/common";
  128. import {getUserList} from "@/api/company/companyUser"; // 假设API文件路径
  129. export default {
  130. name: "CustomerTransfer",
  131. data() {
  132. return {
  133. loading: true,
  134. ids: [],
  135. single: true,
  136. multiple: true,
  137. showSearch: true,
  138. openTransferDialog: false,
  139. total: 0,
  140. customerList: [],
  141. companyUserList: [],
  142. transferForm: {
  143. targetUserId: null,
  144. content: null
  145. },
  146. cusTransfer: {
  147. targetUserId: [{required: true, message: '请选择转移至销售', trigger: 'change'}],
  148. content: [{required: true, message: '请选择转移至销售', trigger: 'change'}]
  149. },
  150. queryParams: {
  151. pageNum: 1,
  152. pageSize: 10,
  153. salesName: null,
  154. phoneNumber: null,
  155. },
  156. projectOptions: [],
  157. selectedUser: [],
  158. };
  159. },
  160. created() {
  161. this.getDicts("sys_course_project").then(response => {
  162. this.projectOptions = response.data;
  163. });
  164. getUserList().then(res=>{
  165. if(res.code === 200) {
  166. this.companyUserList = res.data
  167. }
  168. });
  169. this.getList();
  170. },
  171. methods: {
  172. parseTime,
  173. /** 查询客户列表 */
  174. getList() {
  175. this.loading = true;
  176. listUser(this.queryParams).then(response => {
  177. this.customerList = response.rows;
  178. this.total = response.total;
  179. this.loading = false;
  180. }).catch(() => {
  181. this.loading = false;
  182. });
  183. },
  184. cancelTransfer() {
  185. this.openTransferDialog = false;
  186. this.resetTransferForm();
  187. },
  188. resetTransferForm() {
  189. this.transferForm = {
  190. targetUserId: null,
  191. content: null
  192. };
  193. this.resetForm("transferForm"); // 假设 transferForm 是 el-form 的 ref
  194. },
  195. /** 搜索按钮操作 */
  196. handleQuery() {
  197. this.queryParams.pageNum = 1;
  198. this.getList();
  199. },
  200. /** 重置按钮操作 */
  201. resetQuery() {
  202. this.resetForm("queryForm");
  203. this.handleQuery();
  204. },
  205. // 多选框选中数据
  206. handleSelectionChange(selection) {
  207. this.ids = selection.map(item => item.userId)
  208. this.selectedUser = selection.map(item => {return {userId: item.userId, projectId: item.projectId}})
  209. this.single = selection.length !== 1;
  210. this.multiple = !selection.length;
  211. },
  212. /** 转移按钮操作 */
  213. handleTransfer(row) {
  214. const userIds = row.userId ? [row.userId] : this.ids;
  215. if (userIds.length === 0) {
  216. this.$message.warning("请至少选择一个客户进行转移");
  217. return;
  218. }
  219. this.resetTransferForm();
  220. this.openTransferDialog = true;
  221. },
  222. /** 提交转移按钮 (如果使用对话框) */
  223. submitTransfer() {
  224. this.$refs["transferForm"].validate(valid => {
  225. if (valid) {
  226. transferUser({
  227. userIds: this.selectedUser,
  228. targetCompanyUserId: this.transferForm.targetUserId,
  229. content: this.transferForm.content
  230. }).then(response => {
  231. if (response.code === 200) {
  232. this.msgSuccess(response.msg);
  233. this.openTransferDialog = false;
  234. this.getList();
  235. } else {
  236. this.msgError(response.msg || "转移失败");
  237. }
  238. }).catch(() => {
  239. this.msgError("转移请求失败");
  240. });
  241. }
  242. });
  243. },
  244. /** 导出按钮操作 */
  245. handleExport() {
  246. const queryParams = this.queryParams;
  247. this.$confirm('是否确认导出所有符合条件的客户数据项?', "警告", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning"
  251. }).then(() => {
  252. // 调用 exportCustomer API
  253. return exportCustomer(queryParams);
  254. }).then(response => {
  255. // 处理下载
  256. this.download(response.msg); // RuoYi 提供的下载方法
  257. }).catch(function() {});
  258. },
  259. /** 获取项目对应名称 */
  260. getProjectLabel(projectId) {
  261. return this.projectOptions.find(item => parseInt(item.dictValue) === projectId)?.dictLabel;
  262. },
  263. }
  264. };
  265. </script>
  266. <style scoped>
  267. /* 可以添加一些自定义样式 */
  268. .mb8 {
  269. margin-bottom: 8px;
  270. }
  271. </style>