transfer.vue 8.0 KB

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