transfer.vue 8.7 KB

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