QwUserSelect.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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" @blur="trimInput('companyUserNickName')"/>
  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. trimInput(field) {
  216. if (typeof this.queryParams[field] === 'string') {
  217. this.queryParams[field] = this.queryParams[field].trim();
  218. }
  219. },
  220. setRows(rows){
  221. this.shows = true;
  222. this.rows = rows || [];
  223. this.selectedRows = rows || []; // 同步更新
  224. this.getList();
  225. },
  226. initSelect(){
  227. let row = this.rows;
  228. if(row && row.length > 0 && this.$refs.table){
  229. row.forEach(row => {
  230. this.$refs.table.toggleRowSelection(row, true);
  231. })
  232. }
  233. },
  234. getRowKeys(item){
  235. return item.id;
  236. },
  237. getCitys(){
  238. getCitys().then(res => {
  239. this.loading = false;
  240. this.citys=res.data;
  241. })
  242. },
  243. /** 查询客户列表 */
  244. getList() {
  245. this.loading = true;
  246. if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
  247. this.queryParams.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
  248. }
  249. else{
  250. this.queryParams.receiveTimeRange=null;
  251. }
  252. if(this.ctsTypeArr.length>0){
  253. this.queryParams.customerType=this.ctsTypeArr.toString();
  254. }
  255. else{
  256. this.queryParams.customerType=null
  257. }
  258. if(this.sourceArr.length>0){
  259. this.queryParams.source=this.sourceArr.toString();
  260. }
  261. else{
  262. this.queryParams.source=null
  263. }
  264. if(this.tagIds.length>0){
  265. this.queryParams.tags=this.tagIds.toString();
  266. }
  267. else{
  268. this.queryParams.tags=null
  269. }
  270. companyUserList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  271. if (this.$refs.table) {
  272. this.$refs.table.clearSelection();
  273. }
  274. this.customerList = response.data;
  275. this.loading = false;
  276. this.initSelect();
  277. });
  278. },
  279. // 取消按钮
  280. cancel() {
  281. this.open = false;
  282. this.reset();
  283. },
  284. /** 搜索按钮操作 */
  285. handleQuery() {
  286. this.getList();
  287. },
  288. /** 重置按钮操作 */
  289. resetQuery() {
  290. this.resetForm("queryForm");
  291. },
  292. // 多选框选中数据
  293. handleSelectionChange(selection) {
  294. this.rows = selection;
  295. this.selectedRows = selection; // 同步更新
  296. this.ids = selection.map(item => item.id)
  297. // this.names = selection.map(item => item.qwUserName)
  298. this.single = selection.length!==1
  299. this.multiple = !selection.length
  300. },
  301. currDeptChange(val){
  302. this.queryParams.deptId=val;
  303. this.getList();
  304. },
  305. submitForm(){
  306. this.$nextTick(() => {
  307. this.$emit("success", {ids: this.ids, names: this.names, rows: this.rows})
  308. this.shows = false;
  309. this.$refs.table.clearSelection();
  310. })
  311. },
  312. }
  313. };
  314. </script>
  315. <style scoped>
  316. .el-tag + .el-tag {
  317. margin-left: 10px;
  318. }
  319. .button-new-tag {
  320. margin-left: 10px;
  321. height: 32px;
  322. line-height: 30px;
  323. padding-top: 0;
  324. padding-bottom: 0;
  325. }
  326. .input-new-tag {
  327. width: 90px;
  328. margin-left: 10px;
  329. vertical-align: bottom;
  330. }
  331. .el-dialog__wrapper {
  332. z-index: 100000;
  333. }
  334. .app-container {
  335. padding: 0;
  336. }
  337. .dialog-footer {
  338. position: absolute;
  339. bottom: 0;
  340. right: 20px;
  341. background: #FFF;
  342. }
  343. .drawer-container {
  344. display: flex;
  345. flex-direction: column;
  346. height: 100%;
  347. padding: 0 16px;
  348. }
  349. .search-card {
  350. margin-bottom: 12px;
  351. }
  352. .search-card >>> .el-card__body {
  353. padding: 16px 16px 0;
  354. }
  355. .search-form >>> .el-form-item {
  356. margin-bottom: 16px;
  357. }
  358. .search-form >>> .el-form-item__content {
  359. width: calc(100% - 80px);
  360. }
  361. .search-form >>> .el-select,
  362. .search-form >>> .el-date-editor {
  363. width: 100%;
  364. }
  365. .table-card {
  366. flex: 1;
  367. overflow: hidden;
  368. margin-bottom: 12px;
  369. }
  370. .table-card >>> .el-card__body {
  371. padding: 12px 16px;
  372. }
  373. .card-header {
  374. display: flex;
  375. align-items: center;
  376. justify-content: space-between;
  377. }
  378. .footer-actions {
  379. display: flex;
  380. justify-content: flex-end;
  381. align-items: center;
  382. padding: 12px 0;
  383. border-top: 1px solid #EBEEF5;
  384. }
  385. .footer-actions .el-button + .el-button {
  386. margin-left: 10px;
  387. }
  388. </style>