QwUserSelect.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <el-drawer size="75%" title="选择个微账号" :visible.sync="shows" append-to-body destroy-on-close class="qw-user-select-drawer">
  3. <div class="drawer-container">
  4. <!-- 搜索表单 -->
  5. <el-card shadow="never" class="search-card">
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px" class="search-form">
  7. <el-row :gutter="16">
  8. <el-col :span="8">
  9. <el-form-item label="认领人" prop="companyUserNickName">
  10. <el-input v-model="queryParams.companyUserNickName" placeholder="请输入" clearable size="small" @keyup.enter.native="handleQuery"/>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="8">
  14. <el-form-item label="客户状态" prop="status">
  15. <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
  16. <el-option v-for="item in statusOptions" :key="'status'+item.dictValue" :label="item.dictLabel" :value="item.dictValue"/>
  17. </el-select>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="8">
  21. <el-form-item label="客户类型" prop="customerType">
  22. <el-select multiple v-model="ctsTypeArr" placeholder="请选择" clearable size="small">
  23. <el-option v-for="(item, index) in typeOptions" :key="`${item.dictValue}-${index}`" :label="item.dictLabel" :value="item.dictValue"/>
  24. </el-select>
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. <el-row :gutter="16">
  29. <el-col :span="8">
  30. <el-form-item label="创建时间" prop="createTime">
  31. <el-date-picker clearable size="small" v-model="dateRange" type="daterange" value-format="yyyy-MM-dd"
  32. start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;"></el-date-picker>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8">
  36. <el-form-item label="领取时间" prop="receiveTimeRange">
  37. <el-date-picker clearable size="small" v-model="receiveTimeRange" type="daterange" value-format="yyyy-MM-dd"
  38. start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;"></el-date-picker>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="8">
  42. <el-form-item label="客户来源" prop="source">
  43. <el-select multiple v-model="sourceArr" placeholder="请选择" clearable size="small">
  44. <el-option v-for="item in sourceOptions" :key="'source'+item.dictValue" :label="item.dictLabel" :value="item.dictValue"/>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-row :gutter="16">
  50. <el-col :span="8">
  51. <el-form-item label="客户标签" prop="tags">
  52. <el-select multiple v-model="tagIds" placeholder="请选择" clearable size="small">
  53. <el-option v-for="(item, index) in tagsOptions" :key="`${item.dictValue}-${index}`" :label="item.dictLabel" :value="item.dictLabel"/>
  54. </el-select>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="16" style="text-align: right;">
  58. <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
  59. <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
  60. </el-col>
  61. </el-row>
  62. </el-form>
  63. </el-card>
  64. <!-- 个微账号列表 -->
  65. <el-card shadow="never" class="table-card">
  66. <div slot="header" class="card-header">
  67. <span>个微账号列表</span>
  68. <el-tag v-if="selectedRows.length" type="success">已选择 {{ selectedRows.length }} 个账号</el-tag>
  69. </div>
  70. <el-table border v-loading="loading" :data="customerList" :row-key="getRowKeys" @selection-change="handleSelectionChange" size="small" ref="table" height="500">
  71. <el-table-column type="selection" width="55" align="center" :reserve-selection="true" />
  72. <el-table-column label="微信昵称" align="center" prop="wxNickName" min-width="120"/>
  73. <el-table-column label="微信号" align="center" prop="wxNo" min-width="150"/>
  74. <el-table-column label="手机号" align="center" prop="phone" width="120"/>
  75. <el-table-column label="员工" align="center" prop="companyUserName" width="100"/>
  76. </el-table>
  77. </el-card>
  78. <!-- 底部按钮 -->
  79. <div class="footer-actions">
  80. <el-button @click="shows = false">取 消</el-button>
  81. <el-button type="primary" @click="submitForm">确定选择</el-button>
  82. </div>
  83. </div>
  84. </el-drawer>
  85. </template>
  86. <script>
  87. import { getCompanyList } from "@/api/company/company";
  88. import {getCitys} from "@/api/store/city";
  89. import {companyUserList} from "@/api/company/companyVoiceRobotic";
  90. export default {
  91. name: "CustomerSelect",
  92. data() {
  93. return {
  94. rows: [], // 已选择的行数据
  95. selectedRows: [], // 已选择的行数据(别名)
  96. source:{
  97. title:"修改客户来源",
  98. open:false,
  99. },
  100. shows:false,
  101. deptOptions:[],
  102. receiveTimeRange:[],
  103. tagId:null,
  104. deptId:undefined,
  105. companyId:undefined,
  106. tagsOptions:[],
  107. ctsTypeArr:[],
  108. sourceArr:[],
  109. dateRange:[],
  110. cityIds:[],
  111. citys:[],
  112. tags:[],
  113. tagIds:[],
  114. inputVisible: false,
  115. inputValue: '',
  116. statusOptions:[],
  117. typeOptions:[],
  118. sourceOptions:[],
  119. sexOptions:[],
  120. pageSizes: [10, 20, 30, 50,100,500 ],
  121. show:{
  122. title:"客户详情",
  123. open:false,
  124. },
  125. companys:[],
  126. // 遮罩层
  127. loading: true,
  128. // 选中数组
  129. ids: [],
  130. names: [],
  131. userIds: [],
  132. // 非单个禁用
  133. single: true,
  134. // 非多个禁用
  135. multiple: true,
  136. // 显示搜索条件
  137. showSearch: true,
  138. // 总条数
  139. total: 0,
  140. // 客户表格数据
  141. customerList: [],
  142. // 弹出层标题
  143. title: "",
  144. // 是否显示弹出层
  145. open: false,
  146. // 查询参数
  147. queryParams: {
  148. customerCode: null,
  149. customerName: null,
  150. mobile: null,
  151. sex: null,
  152. weixin: null,
  153. userId: null,
  154. createUserId: null,
  155. receiveUserId: null,
  156. customerUserId: null,
  157. address: null,
  158. location: null,
  159. detailAddress: null,
  160. lng: null,
  161. lat: null,
  162. status: null,
  163. isReceive: null,
  164. deptId: null,
  165. isDel: null,
  166. customerType: null,
  167. receiveTime: null,
  168. poolTime: null,
  169. companyId: null,
  170. isLine: null,
  171. source: null,
  172. tags: null
  173. },
  174. // 表单参数
  175. form: {},
  176. // 表单校验
  177. rules: {
  178. // customerName: [
  179. // { required: true, message: "客户名称不能为空", trigger: "blur" }
  180. // ],
  181. mobile: [
  182. { required: true, message: "手机号不能为空", trigger: "blur" }
  183. ],
  184. // sex: [
  185. // { required: true, message: "性别不能为空", trigger: "blur" }
  186. // ],
  187. source: [
  188. { required: true, message: "客户来源不能为空", trigger: "blur" }
  189. ],
  190. }
  191. };
  192. },
  193. created() {
  194. this.getDicts("crm_customer_tag").then((response) => {
  195. this.tagsOptions = response.data;
  196. });
  197. this.getDicts("crm_customer_source").then((response) => {
  198. this.sourceOptions = response.data;
  199. });
  200. this.getDicts("common_sex").then((response) => {
  201. this.sexOptions = response.data;
  202. });
  203. this.getDicts("crm_customer_status").then((response) => {
  204. this.statusOptions = response.data;
  205. });
  206. this.getDicts("crm_customer_type").then((response) => {
  207. this.typeOptions = response.data;
  208. });
  209. getCompanyList().then(response => {
  210. this.companys = response.data;
  211. });
  212. this.getCitys();
  213. },
  214. methods: {
  215. setRows(rows){
  216. this.shows = true;
  217. this.rows = rows || [];
  218. this.selectedRows = rows || []; // 同步更新
  219. this.getList();
  220. },
  221. initSelect(){
  222. let row = this.rows;
  223. if(row && row.length > 0 && this.$refs.table){
  224. row.forEach(row => {
  225. this.$refs.table.toggleRowSelection(row, true);
  226. })
  227. }
  228. },
  229. getRowKeys(item){
  230. return item.id;
  231. },
  232. getCitys(){
  233. getCitys().then(res => {
  234. this.loading = false;
  235. this.citys=res.data;
  236. })
  237. },
  238. /** 查询客户列表 */
  239. getList() {
  240. this.loading = true;
  241. if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
  242. this.queryParams.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
  243. }
  244. else{
  245. this.queryParams.receiveTimeRange=null;
  246. }
  247. if(this.ctsTypeArr.length>0){
  248. this.queryParams.customerType=this.ctsTypeArr.toString();
  249. }
  250. else{
  251. this.queryParams.customerType=null
  252. }
  253. if(this.sourceArr.length>0){
  254. this.queryParams.source=this.sourceArr.toString();
  255. }
  256. else{
  257. this.queryParams.source=null
  258. }
  259. if(this.tagIds.length>0){
  260. this.queryParams.tags=this.tagIds.toString();
  261. }
  262. else{
  263. this.queryParams.tags=null
  264. }
  265. companyUserList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  266. if (this.$refs.table) {
  267. this.$refs.table.clearSelection();
  268. }
  269. this.customerList = response.data;
  270. this.loading = false;
  271. this.initSelect();
  272. });
  273. },
  274. // 取消按钮
  275. cancel() {
  276. this.open = false;
  277. this.reset();
  278. },
  279. /** 搜索按钮操作 */
  280. handleQuery() {
  281. this.getList();
  282. },
  283. /** 重置按钮操作 */
  284. resetQuery() {
  285. this.resetForm("queryForm");
  286. },
  287. // 多选框选中数据
  288. handleSelectionChange(selection) {
  289. this.rows = selection;
  290. this.selectedRows = selection; // 同步更新
  291. this.ids = selection.map(item => item.id)
  292. // this.names = selection.map(item => item.qwUserName)
  293. this.single = selection.length!==1
  294. this.multiple = !selection.length
  295. },
  296. currDeptChange(val){
  297. this.queryParams.deptId=val;
  298. this.getList();
  299. },
  300. submitForm(){
  301. this.$nextTick(() => {
  302. this.$emit("success", {ids: this.ids, names: this.names, rows: this.rows})
  303. this.shows = false;
  304. this.$refs.table.clearSelection();
  305. })
  306. },
  307. }
  308. };
  309. </script>
  310. <style scoped>
  311. .el-tag + .el-tag {
  312. margin-left: 10px;
  313. }
  314. .button-new-tag {
  315. margin-left: 10px;
  316. height: 32px;
  317. line-height: 30px;
  318. padding-top: 0;
  319. padding-bottom: 0;
  320. }
  321. .input-new-tag {
  322. width: 90px;
  323. margin-left: 10px;
  324. vertical-align: bottom;
  325. }
  326. .el-dialog__wrapper {
  327. z-index: 100000;
  328. }
  329. .app-container {
  330. padding: 0;
  331. }
  332. .dialog-footer {
  333. position: absolute;
  334. bottom: 0;
  335. right: 20px;
  336. background: #FFF;
  337. }
  338. .drawer-container {
  339. display: flex;
  340. flex-direction: column;
  341. height: 100%;
  342. padding: 0 16px;
  343. }
  344. .search-card {
  345. margin-bottom: 12px;
  346. }
  347. .search-card >>> .el-card__body {
  348. padding: 16px 16px 0;
  349. }
  350. .search-form >>> .el-form-item {
  351. margin-bottom: 16px;
  352. }
  353. .search-form >>> .el-form-item__content {
  354. width: calc(100% - 80px);
  355. }
  356. .search-form >>> .el-select,
  357. .search-form >>> .el-date-editor {
  358. width: 100%;
  359. }
  360. .table-card {
  361. flex: 1;
  362. overflow: hidden;
  363. margin-bottom: 12px;
  364. }
  365. .table-card >>> .el-card__body {
  366. padding: 12px 16px;
  367. }
  368. .card-header {
  369. display: flex;
  370. align-items: center;
  371. justify-content: space-between;
  372. }
  373. .footer-actions {
  374. display: flex;
  375. justify-content: flex-end;
  376. align-items: center;
  377. padding: 12px 0;
  378. border-top: 1px solid #EBEEF5;
  379. }
  380. .footer-actions .el-button + .el-button {
  381. margin-left: 10px;
  382. }
  383. </style>