indexProject.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="会员ID" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入会员ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="会员昵称(模糊)" prop="nickname" label-width="130px">
  14. <el-input
  15. v-model="queryParams.nickname"
  16. placeholder="请输入会员昵称(模糊搜索)"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="会员昵称(精确)" prop="nicknameExact" label-width="130px">
  23. <el-input
  24. v-model="queryParams.nicknameExact"
  25. placeholder="请输入会员昵称(精确搜索)"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="手机号码" prop="phone">
  32. <el-input
  33. v-model="queryParams.phone"
  34. placeholder="请输入手机号码"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="绑定时间" prop="createTimeRange">
  41. <el-date-picker clearable size="small" style="width: 340px"
  42. v-model="dateRange"
  43. type="daterange"
  44. value-format="yyyy-MM-dd"
  45. range-separator="至"
  46. start-placeholder="开始日期"
  47. end-placeholder="结束日期"
  48. @change="handleDateRangeChange">
  49. </el-date-picker>
  50. </el-form-item>
  51. <el-form-item label="所属公司" prop="companyName">
  52. <el-select
  53. v-model="queryParams.companyId"
  54. placeholder="请选择所属公司"
  55. clearable
  56. filterable
  57. size="small"
  58. @change="handleQueryCompanyChange"
  59. >
  60. <el-option
  61. v-for="item in companyQueryOptions"
  62. :key="item.companyId"
  63. :label="item.companyName"
  64. :value="item.companyId">
  65. </el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="所属销售" prop="companyUserNickName">
  69. <el-select
  70. v-model="queryParams.companyUserIds"
  71. multiple
  72. collapse-tags
  73. placeholder="请选择所属销售"
  74. clearable
  75. filterable
  76. size="small"
  77. >
  78. <el-option
  79. v-for="item in companyQueryUserOptions"
  80. :key="item.userId"
  81. :label="item.nickName"
  82. :value="item.userId">
  83. </el-option>
  84. </el-select>
  85. </el-form-item>
  86. <!-- <el-form-item label="推线编码" prop="registerCode">-->
  87. <!-- <el-input-->
  88. <!-- v-model="queryParams.registerCode"-->
  89. <!-- placeholder="请输入推线编码"-->
  90. <!-- clearable-->
  91. <!-- size="small"-->
  92. <!-- @keyup.enter.native="handleQuery"-->
  93. <!-- />-->
  94. <!-- </el-form-item>-->
  95. <el-form-item label="状态" prop="status">
  96. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small" >
  97. <el-option
  98. v-for="item in statusOptions"
  99. :key="item.dictValue"
  100. :label="item.dictLabel"
  101. :value="item.dictValue"
  102. />
  103. </el-select>
  104. </el-form-item>
  105. <!-- <el-form-item label="会员等级" prop="status">-->
  106. <!-- <el-select v-model="queryParams.level" placeholder="请选择会员等级" clearable size="small" >-->
  107. <!-- <el-option-->
  108. <!-- v-for="item in userLevelOptions"-->
  109. <!-- :key="item.dictValue"-->
  110. <!-- :label="item.dictLabel"-->
  111. <!-- :value="item.dictValue"-->
  112. <!-- />-->
  113. <!-- </el-select>-->
  114. <!-- </el-form-item>-->
  115. <!-- <el-form-item label="推广员" prop="isPromoter">-->
  116. <!-- <el-select v-model="queryParams.isPromoter" placeholder="请选择" clearable size="small" >-->
  117. <!-- <el-option-->
  118. <!-- v-for="item in userIsPromoterOptions"-->
  119. <!-- :key="item.dictValue"-->
  120. <!-- :label="item.dictLabel"-->
  121. <!-- :value="item.dictValue"-->
  122. <!-- />-->
  123. <!-- </el-select>-->
  124. <!-- </el-form-item>-->
  125. <el-form-item label="项目" prop="projectId">
  126. <el-select v-model="queryParams.projectId" placeholder="请选择项目" clearable size="small" >
  127. <el-option
  128. v-for="item in projectOptions"
  129. :key="item.dictValue"
  130. :label="item.dictLabel"
  131. :value="item.dictValue"
  132. />
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item>
  136. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  137. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  138. </el-form-item>
  139. </el-form>
  140. <el-row :gutter="10" class="mb8">
  141. <el-col :span="1.5">
  142. <el-button
  143. type="primary"
  144. icon="el-icon-user"
  145. size="mini"
  146. @click="handleChangeCompanyUser"
  147. :disabled="multiple"
  148. v-hasPermi="['company:companyUser:change']"
  149. >更换会员归属</el-button>
  150. </el-col>
  151. <el-col :span="1.5">
  152. <el-button
  153. type="warning"
  154. icon="el-icon-download"
  155. size="mini"
  156. @click="handleExport"
  157. v-hasPermi="['store:user:export']"
  158. >导出</el-button>
  159. </el-col>
  160. <el-col :span="1.5">
  161. <el-button
  162. type="_blank"
  163. icon="el-icon-brush"
  164. size="mini"
  165. @click="handleUnbind"
  166. v-hasPermi="['his:user:unbind']"
  167. >解绑会员</el-button>
  168. </el-col>
  169. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  170. </el-row>
  171. <el-table height="500" border v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  172. <el-table-column type="selection" width="55" align="center" />
  173. <el-table-column label="ID" align="center" prop="userId" />
  174. <el-table-column label="项目" align="center" prop="projectId">
  175. <template slot-scope="scope">
  176. <el-tag v-if="scope.row.projectId !== null">{{ getProjectLabel(scope.row.projectId,scope.row) }}</el-tag>
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="会员昵称" align="center" prop="nickname" />
  180. <el-table-column label="会员头像" align="center" width="80">
  181. <template slot-scope="scope">
  182. <el-popover
  183. placement="right"
  184. title=""
  185. trigger="hover"
  186. >
  187. <img slot="reference" :src="scope.row.avatar" width="50" >
  188. <img :src="scope.row.avatar" style="max-width: 120px;">
  189. </el-popover>
  190. </template>
  191. </el-table-column>
  192. <el-table-column label="手机号码" align="center" prop="phone" />
  193. <el-table-column label="用户余额" align="center" prop="nowMoney" />
  194. <!-- <el-table-column label="推广佣金" align="center" prop="brokeragePrice" />-->
  195. <el-table-column label="积分" align="center" prop="integral" />
  196. <el-table-column label="绑定时间" align="center" prop="bindTime" width="100" />
  197. <!-- <el-table-column label="累计消费金额" align="center" prop="totalAmount" />-->
  198. <!-- <el-table-column label="上次消费时间" align="center" prop="lastBuyTime" />-->
  199. <!-- <el-table-column label="上次消费金额(元)" align="center" prop="number" />-->
  200. <!-- <el-table-column label="会员等级" align="center" prop="level" >-->
  201. <!-- <template slot-scope="scope">-->
  202. <!-- <el-tag prop="status" v-for="(item, index) in userLevelOptions" v-if="scope.row.level==item.dictValue">{{item.dictLabel}}</el-tag>-->
  203. <!-- </template>-->
  204. <!-- </el-table-column>-->
  205. <!-- <el-table-column label="是否允许下单" align="center" prop="isShow" >-->
  206. <!-- <template slot-scope="scope">-->
  207. <!-- <el-tag prop="isShow" v-for="(item, index) in isShowOptions" v-if="scope.row.isShow==item.dictValue">{{item.dictLabel}}</el-tag>-->
  208. <!-- </template>-->
  209. <!-- </el-table-column>-->
  210. <!-- <el-table-column label="推广员" align="center" prop="isPromoter" >-->
  211. <!-- <template slot-scope="scope">-->
  212. <!-- <el-tag prop="status" v-for="(item, index) in userIsPromoterOptions" v-if="scope.row.isPromoter==item.dictValue">{{item.dictLabel}}</el-tag>-->
  213. <!-- </template>-->
  214. <!-- </el-table-column>-->
  215. <el-table-column label="状态" align="center" prop="status" >
  216. <template slot-scope="scope">
  217. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  218. </template>
  219. </el-table-column>
  220. <el-table-column label="所属公司" align="center" prop="companyName" />
  221. <el-table-column label="所属销售" align="center" prop="companyUserNickName" />
  222. <!-- <el-table-column label="创建时间" align="center" prop="createTime" />-->
  223. <!-- <el-table-column label="累计佣金" align="center" prop="registerDate" />-->
  224. <!-- <el-table-column label="可提现佣金" align="center" prop="registerCode" />-->
  225. <!-- <el-table-column label="冻结佣金" align="center" prop="source" />-->
  226. <!-- <el-table-column label="已提现佣金" align="center" prop="remark" />-->
  227. <el-table-column label="看课数量" align="center" prop="watchCourseCount" />
  228. <!-- 去掉营期数,这个数据获取的不准,准确获取影响速度 xgb -->
  229. <!-- <el-table-column label="参与营期数" align="center" prop="partCourseCount" />-->
  230. <el-table-column label="最后看课时间" align="center" prop="lastWatchDate" width="160">
  231. <template slot-scope="scope">
  232. <span>{{ parseTime(scope.row.lastWatchDate) }}</span>
  233. </template>
  234. </el-table-column>
  235. <el-table-column label="操作" align="center" width="150px" class-name="small-padding fixed-width">
  236. <template slot-scope="scope">
  237. <!-- <el-button-->
  238. <!-- size="mini"-->
  239. <!-- type="text"-->
  240. <!-- icon="el-icon-edit"-->
  241. <!-- @click="handleUpdate(scope.row)"-->
  242. <!-- v-hasPermi="['store:user:edit']"-->
  243. <!-- >修改</el-button>-->
  244. <el-button
  245. size="mini"
  246. type="text"
  247. @click="handleShow(scope.row)"
  248. v-hasPermi="['store:user:query']"
  249. >查看</el-button>
  250. <el-button
  251. size="mini"
  252. type="text"
  253. icon="el-icon-delete"
  254. @click="handleDelete(scope.row)"
  255. v-hasPermi="['his:userCompanyUser:remove']"
  256. >删除</el-button>
  257. </template>
  258. </el-table-column>
  259. </el-table>
  260. <pagination
  261. v-show="total>0"
  262. :total="total"
  263. :page.sync="queryParams.pageNum"
  264. :limit.sync="queryParams.pageSize"
  265. @pagination="getList"
  266. />
  267. <!-- 添加或修改用户对话框 -->
  268. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  269. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  270. <el-form-item label="会员头像" prop="avatar">
  271. <el-popover
  272. placement="right"
  273. title=""
  274. trigger="hover"
  275. >
  276. <img slot="reference" :src="form.avatar" width="80">
  277. <img :src="form.avatar" style="max-width: 80px;">
  278. </el-popover>
  279. </el-form-item>
  280. <el-form-item label="会员昵称" prop="nickname">
  281. <el-input v-model="form.nickname" disabled placeholder="请输入用户昵称" />
  282. </el-form-item>
  283. <el-form-item label="手机号码" prop="phone">
  284. <el-input v-model="form.phone" disabled placeholder="请输入手机号码" />
  285. </el-form-item>
  286. <el-form-item label="最后一次登录ip" prop="lastIp">
  287. <el-input v-model="form.lastIp" disabled placeholder="请输入最后一次登录ip" />
  288. </el-form-item>
  289. <!-- <el-form-item label="用户余额" prop="nowMoney">
  290. <el-input v-model="form.nowMoney" disabled placeholder="请输入用户余额" />
  291. </el-form-item> -->
  292. <!-- <el-form-item label="积分" prop="integral">
  293. <el-input v-model="form.integral" disabled placeholder="请输入用户积分" />
  294. </el-form-item> -->
  295. <el-form-item label="进线日期" prop="registerDate">
  296. <el-date-picker clearable size="small"
  297. v-model="form.registerDate"
  298. type="date"
  299. value-format="yyyy-MM-dd"
  300. placeholder="选择进线日期">
  301. </el-date-picker>
  302. </el-form-item>
  303. <el-form-item label="推线编码" prop="registerCode">
  304. <el-input v-model="form.registerCode" placeholder="请输入推线编码" />
  305. </el-form-item>
  306. <el-form-item label="渠道来源" prop="source">
  307. <el-input v-model="form.source" placeholder="请输入渠道来源" />
  308. </el-form-item>
  309. <el-form-item label="会员等级" prop="level">
  310. <el-select style="width: 200px" v-model="form.level" placeholder="请选择会员等级" clearable size="small" >
  311. <el-option
  312. v-for="item in userLevelOptions"
  313. :key="item.dictValue"
  314. :label="item.dictLabel"
  315. :value="item.dictValue"
  316. />
  317. </el-select>
  318. </el-form-item>
  319. <el-form-item label="是否为推广员" prop="isPromoter">
  320. <el-select style="width: 200px" v-model="form.isPromoter" placeholder="请选择" clearable size="small" >
  321. <el-option
  322. v-for="item in userIsPromoterOptions"
  323. :key="item.dictValue"
  324. :label="item.dictLabel"
  325. :value="item.dictValue"
  326. />
  327. </el-select>
  328. </el-form-item>
  329. <el-form-item label="状态" prop="level">
  330. <el-radio-group v-model="form.status">
  331. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  332. </el-radio-group>
  333. </el-form-item>
  334. <el-form-item label="是否展示" prop="isShow">
  335. <el-radio-group v-model="form.isShow">
  336. <el-radio :label="item.dictValue" v-for="item in isShowOptions" >{{item.dictLabel}}</el-radio>
  337. </el-radio-group>
  338. </el-form-item>
  339. <el-form-item label="用户备注" prop="remark">
  340. <el-input v-model="form.remark" placeholder="请输入用户备注" />
  341. </el-form-item>
  342. </el-form>
  343. <div slot="footer" class="dialog-footer">
  344. <el-button type="primary" @click="submitForm">确 定</el-button>
  345. <el-button @click="cancel">取 消</el-button>
  346. </div>
  347. </el-dialog>
  348. <el-drawer size="75%" :title="show.title" :visible.sync="show.open">
  349. <userDetailsByNew ref="userDetailsByNew" />
  350. </el-drawer>
  351. <!-- 更换会员归属对话框 -->
  352. <el-dialog title="更换会员归属" :visible.sync="changeCompanyUserOpen" width="500px" append-to-body>
  353. <el-form ref="changeCompanyUserForm" :model="changeCompanyUserForm" :rules="changeCompanyUserRules" label-width="100px">
  354. <el-form-item label="选择公司" prop="companyId">
  355. <el-select v-model="changeCompanyUserForm.companyId" placeholder="请选择公司" filterable style="width: 100%" @change="handleCompanyChange">
  356. <el-option
  357. v-for="item in companyOptions"
  358. :key="item.companyId"
  359. :label="item.companyName"
  360. :value="item.companyId"
  361. />
  362. </el-select>
  363. </el-form-item>
  364. <el-form-item label="选择销售" prop="companyUserId">
  365. <el-select v-model="changeCompanyUserForm.companyUserId" placeholder="请选择销售" filterable style="width: 100%" @change="handleCompanyUserChange">
  366. <el-option
  367. v-for="item in companyUserOptions"
  368. :key="item.userId"
  369. :label="item.nickName + '_' + item.userName"
  370. :value="item.userId"
  371. />
  372. </el-select>
  373. </el-form-item>
  374. </el-form>
  375. <div slot="footer" class="dialog-footer">
  376. <el-button type="primary" @click="submitChangeCompanyUserForm">确 定</el-button>
  377. <el-button @click="cancelChangeCompanyUser">取 消</el-button>
  378. </div>
  379. </el-dialog>
  380. </div>
  381. </template>
  382. <script>
  383. import {listUserByProject, getUser, addUser, updateUser, exportUser, delUserCompanyUser,exportListProject, batchUnbindUser} from "@/api/his/user";
  384. import { getCompanyUserList, changeCompanyUser, getCompanyList } from '@/api/company/companyUser';
  385. import userDetailsByNew from '@/views/his/user/userDetails.vue'
  386. export default {
  387. name: "User",
  388. components: { userDetailsByNew },
  389. data() {
  390. return {
  391. companyQueryOptions:[],
  392. companyQueryUserOptions:[],
  393. userIsPromoterOptions:[],
  394. userLevelOptions:[],
  395. statusOptions:[],
  396. isShowOptions:[],
  397. // 遮罩层
  398. loading: true,
  399. // 选中数组
  400. ids: [],
  401. // 非单个禁用
  402. single: true,
  403. // 非多个禁用
  404. multiple: true,
  405. // 显示搜索条件
  406. showSearch: true,
  407. // 总条数
  408. total: 0,
  409. show:{
  410. title:"会员详情",
  411. open:false,
  412. },
  413. // 用户表格数据
  414. userList: [],
  415. // 弹出层标题
  416. title: "",
  417. // 是否显示弹出层
  418. open: false,
  419. // 日期范围
  420. dateRange: [],
  421. // 查询参数
  422. queryParams: {
  423. pageNum: 1,
  424. pageSize: 10,
  425. username: null,
  426. password: null,
  427. realName: null,
  428. birthday: null,
  429. idCard: null,
  430. mark: null,
  431. nickname: null,
  432. nicknameExact: null,
  433. avatar: null,
  434. phone: null,
  435. lastIp: null,
  436. nowMoney: null,
  437. brokeragePrice: null,
  438. integral: null,
  439. signNum: null,
  440. status: null,
  441. level: null,
  442. spreadUserId: null,
  443. spreadTime: null,
  444. userType: null,
  445. isPromoter: null,
  446. payCount: null,
  447. spreadCount: null,
  448. addres: null,
  449. wxProfile: null,
  450. isDel: null,
  451. startCreateTime: null,
  452. endCreateTime: null,
  453. companyId: null,
  454. companyUserNickName: null,
  455. userId: null,
  456. companyUserIds: [], //销售id 多选数组
  457. companyUserIdMulti: null, //销售id 用于传到后端
  458. },
  459. // 表单参数
  460. form: {},
  461. // 表单校验
  462. rules: {
  463. status: [
  464. { required: true, message: "状态不能为空", trigger: "blur" }
  465. ],
  466. level: [
  467. { required: true, message: "等级不能为空", trigger: "blur" }
  468. ],
  469. },
  470. // 更换会员归属对话框
  471. changeCompanyUserOpen: false,
  472. // 更换会员归属表单
  473. changeCompanyUserForm: {
  474. companyId: null,
  475. companyUserId: null,
  476. userIds: []
  477. },
  478. // 更换会员归属表单校验
  479. changeCompanyUserRules: {
  480. companyId: [
  481. { required: true, message: '请选择公司', trigger: 'change' }
  482. ],
  483. companyUserId: [
  484. { required: true, message: '请选择销售', trigger: 'change' }
  485. ]
  486. },
  487. // 销售选项
  488. companyUserOptions: [],
  489. companyOptions: [],
  490. projectOptions: [],
  491. selectedUser: []
  492. };
  493. },
  494. created() {
  495. this.getDicts("project_user_status").then((response) => {
  496. this.statusOptions = response.data;
  497. });
  498. this.getDicts("user_level").then((response) => {
  499. this.userLevelOptions = response.data;
  500. });
  501. this.getDicts("sys_company_or").then((response) => {
  502. this.isShowOptions = response.data;
  503. });
  504. this.getDicts("user_is_promoter").then((response) => {
  505. this.userIsPromoterOptions = response.data;
  506. });
  507. this.getDicts("sys_course_project").then(response => {
  508. this.projectOptions = response.data;
  509. });
  510. this.getList();
  511. getCompanyList().then(response => {
  512. if (response.code === 200) {
  513. this.companyQueryOptions = response.data;
  514. }});
  515. },
  516. methods: {
  517. handleQueryCompanyChange(companyId){
  518. // 清空已选择的销售
  519. this.queryCompanyUserId = null;
  520. // 根据公司ID获取对应的销售列表
  521. if (companyId) {
  522. getCompanyUserList({ companyId: companyId }).then(response => {
  523. if (response.code === 200) {
  524. this.companyQueryUserOptions = response.data;
  525. } else {
  526. this.$message.error(response.msg || '获取销售列表失败');
  527. this.companyQueryUserOptions = [];
  528. }
  529. }).catch(() => {
  530. this.$message.error('获取销售列表失败');
  531. this.companyQueryUserOptions = [];
  532. });
  533. } else {
  534. this.companyQueryUserOptions = [];
  535. }
  536. },
  537. /** 查询用户列表 */
  538. async getList() {
  539. this.loading = true;
  540. this.queryParams.companyUserIdMulti =this.queryParams.companyUserIds.join(",");
  541. listUserByProject(this.queryParams).then(response => {
  542. this.userList = response.rows;
  543. this.total = response.total;
  544. this.loading = false;
  545. });
  546. },
  547. // 取消按钮
  548. cancel() {
  549. this.open = false;
  550. this.reset();
  551. },
  552. // 表单重置
  553. reset() {
  554. this.form = {
  555. userId: null,
  556. username: null,
  557. password: null,
  558. realName: null,
  559. birthday: null,
  560. idCard: null,
  561. mark: null,
  562. nickname: null,
  563. avatar: null,
  564. phone: null,
  565. createTime: null,
  566. updateTime: null,
  567. lastIp: null,
  568. nowMoney: null,
  569. brokeragePrice: null,
  570. integral: null,
  571. signNum: null,
  572. status: 0,
  573. level: 0,
  574. spreadUserId: null,
  575. spreadTime: null,
  576. userType: null,
  577. isPromoter: null,
  578. payCount: null,
  579. spreadCount: null,
  580. addres: null,
  581. wxProfile: null,
  582. isDel: null,
  583. isShow: null
  584. };
  585. this.resetForm("form");
  586. },
  587. /** 搜索按钮操作 */
  588. handleQuery() {
  589. this.queryParams.pageNum = 1;
  590. this.getList();
  591. },
  592. /** 重置按钮操作 */
  593. resetQuery() {
  594. this.dateRange = [];
  595. this.resetForm("queryForm");
  596. this.queryParams.companyId = null;
  597. this.queryParams.companyUserNickName = null;
  598. this.companyQueryUserOptions = null;
  599. this.queryParams.startCreateTime = null
  600. this.queryParams.endCreateTime = null
  601. this.handleQuery();
  602. },
  603. /** 处理日期范围变化 */
  604. handleDateRangeChange(dates) {
  605. if (dates) {
  606. this.queryParams.startCreateTime = dates[0];
  607. this.queryParams.endCreateTime = dates[1];
  608. } else {
  609. this.queryParams.startCreateTime = null;
  610. this.queryParams.endCreateTime = null;
  611. }
  612. },
  613. // 多选框选中数据
  614. handleSelectionChange(selection) {
  615. this.ids = selection.map(item => item.userId)
  616. this.selectedUser = selection.map(item => {return {userId: item.userId, projectId: item.projectId}})
  617. this.single = selection.length!==1
  618. this.multiple = !selection.length
  619. },
  620. /** 新增按钮操作 */
  621. handleAdd() {
  622. this.reset();
  623. this.open = true;
  624. this.title = "添加用户";
  625. },
  626. /** 修改按钮操作 */
  627. handleUpdate(row) {
  628. this.reset();
  629. const userId = row.userId || this.ids
  630. getUser(userId).then(response => {
  631. this.form = response.data;
  632. if(response.data.status){
  633. this.form.status = response.data.status.toString();
  634. } else {
  635. this.form.status = null;
  636. }
  637. if(response.data.isShow){
  638. this.form.isShow = response.data.isShow.toString();
  639. }else {
  640. this.form.isShow = null;
  641. }
  642. if(response.data.level){
  643. this.form.level = response.data.level.toString();
  644. }else {
  645. this.form.level = null;
  646. }
  647. if(response.data.isPromoter){
  648. this.form.isPromoter = response.data.isPromoter.toString();
  649. }else {
  650. this.form.status = null;
  651. }
  652. this.open = true;
  653. this.title = "修改用户";
  654. });
  655. },
  656. /** 提交按钮 */
  657. submitForm() {
  658. this.$refs["form"].validate(valid => {
  659. if (valid) {
  660. if (this.form.userId != null) {
  661. updateUser(this.form).then(response => {
  662. if (response.code === 200) {
  663. this.msgSuccess("修改成功");
  664. this.open = false;
  665. this.getList();
  666. }
  667. });
  668. } else {
  669. addUser(this.form).then(response => {
  670. if (response.code === 200) {
  671. this.msgSuccess("新增成功");
  672. this.open = false;
  673. this.getList();
  674. }
  675. });
  676. }
  677. }
  678. });
  679. },
  680. /** 删除按钮操作 */
  681. handleDelete(row) {
  682. const companyUserId = row.companyUserId;
  683. this.$confirm('是否确认删除用户编号为"' + companyUserId + '"的数据项?', "警告", {
  684. confirmButtonText: "确定",
  685. cancelButtonText: "取消",
  686. type: "warning"
  687. }).then(function() {
  688. return delUserCompanyUser(companyUserId);
  689. }).then(() => {
  690. this.getList();
  691. this.msgSuccess("删除成功");
  692. }).catch(function() {});
  693. },
  694. /** 导出按钮操作 */
  695. handleExport() {
  696. const queryParams = this.queryParams;
  697. this.$confirm('是否确认导出当前用户数据项?', "警告", {
  698. confirmButtonText: "确定",
  699. cancelButtonText: "取消",
  700. type: "warning"
  701. }).then(function() {
  702. return exportListProject(queryParams);
  703. }).then(response => {
  704. console.log(response)
  705. this.download(response.msg);
  706. }).catch(function() {});
  707. },
  708. // 解绑会员
  709. async handleUnbind() {
  710. // 解绑前先主动搜索一下
  711. this.queryParams.pageNum = 1;
  712. await this.getList();
  713. // 检查是否有勾选列表行
  714. if (this.selectedUser.length > 0) {
  715. // 有勾选行,获取选中的userId列表
  716. const userIds = this.selectedUser.map(item => item.userId);
  717. this.$confirm('确定要解绑当前选中的' + this.selectedUser.length + '个会员吗?', "警告", {
  718. confirmButtonText: "确定",
  719. cancelButtonText: "取消",
  720. type: "warning"
  721. }).then(() => {
  722. console.log('解绑选中会员,用户ID:', userIds);
  723. return batchUnbindUser(userIds);
  724. }).then(() => {
  725. this.msgSuccess("解绑成功");
  726. this.getList();
  727. }).catch(function () {
  728. this.$message.error('解绑失败');
  729. });
  730. } else {
  731. // 没有勾选行,提示用户是否解绑当前筛选条件下的所有会员
  732. this.$confirm('没有勾选列表项,将解绑当前筛选条件下的所有会员,请确认是否操作?', "警告", {
  733. confirmButtonText: "确定",
  734. cancelButtonText: "取消",
  735. type: "warning"
  736. }).then(() => {
  737. const userIds = this.userList.map(item => item.userId);
  738. return batchUnbindUser(userIds);
  739. }).then(() => {
  740. this.msgSuccess("解绑成功");
  741. this.getList();
  742. }).catch(function () {
  743. this.$message.error('解绑失败');
  744. });
  745. }
  746. },
  747. handleShow(row){
  748. var that=this;
  749. that.show.open=true;
  750. setTimeout(() => {
  751. that.$refs.userDetailsByNew.getDetails(row.userId);
  752. }, 200);
  753. },
  754. /** 更换会员归属按钮操作 */
  755. handleChangeCompanyUser() {
  756. // 获取公司下拉列表
  757. getCompanyList().then(response => {
  758. if (response.code === 200) {
  759. this.companyOptions = response.data;
  760. // 重置表单和销售列表
  761. this.resetCompanyUserForm();
  762. this.companyUserOptions = [];
  763. this.changeCompanyUserOpen = true;
  764. } else {
  765. this.$message.error(response.msg || '获取公司列表失败');
  766. }
  767. }).catch(() => {
  768. this.$message.error('获取公司列表失败');
  769. });
  770. },
  771. /** 销售选择变化 */
  772. handleCompanyUserChange(userId) {
  773. if (!this.changeCompanyUserForm.companyId) {
  774. this.$message.warning('请先选择公司');
  775. this.changeCompanyUserForm.companyUserId = null;
  776. return;
  777. }
  778. },
  779. /** 重置更换会员归属表单 */
  780. resetCompanyUserForm() {
  781. this.changeCompanyUserForm = {
  782. companyId: null,
  783. companyUserId: null,
  784. userIds: []
  785. };
  786. this.resetForm("changeCompanyUserForm");
  787. },
  788. handleCompanyChange(companyId) {
  789. // 清空已选择的销售
  790. this.changeCompanyUserForm.companyUserId = null;
  791. // 根据公司ID获取对应的销售列表
  792. if (companyId) {
  793. getCompanyUserList({ companyId: companyId }).then(response => {
  794. if (response.code === 200) {
  795. this.companyUserOptions = response.data;
  796. } else {
  797. this.$message.error(response.msg || '获取销售列表失败');
  798. this.companyUserOptions = [];
  799. }
  800. }).catch(() => {
  801. this.$message.error('获取销售列表失败');
  802. this.companyUserOptions = [];
  803. });
  804. } else {
  805. this.companyUserOptions = [];
  806. }
  807. },
  808. /** 取消更换会员归属 */
  809. cancelChangeCompanyUser() {
  810. this.changeCompanyUserOpen = false;
  811. this.resetCompanyUserForm();
  812. },
  813. /** 提交更换会员归属 */
  814. submitChangeCompanyUserForm() {
  815. this.$refs["changeCompanyUserForm"].validate(valid => {
  816. if (valid) {
  817. // 调用更换会员归属接口
  818. // 检查companyId是否已设置
  819. if (!this.changeCompanyUserForm.companyId) {
  820. this.$message.error('请选择公司');
  821. return;
  822. }
  823. changeCompanyUser(this.selectedUser, {
  824. companyUserId: this.changeCompanyUserForm.companyUserId,
  825. companyId: this.changeCompanyUserForm.companyId
  826. }).then(response => {
  827. if (response.code === 200) {
  828. this.msgSuccess("操作成功");
  829. this.changeCompanyUserOpen = false;
  830. this.getList();
  831. } else {
  832. this.$message.error(response.msg || '操作失败');
  833. }
  834. }).catch(() => {
  835. this.$message.error('操作失败');
  836. });
  837. }
  838. });
  839. },
  840. /** 获取项目对应名称 */
  841. getProjectLabel(projectId) {
  842. return this.projectOptions.find(item => parseInt(item.dictValue) === projectId)?.dictLabel;
  843. },
  844. }
  845. };
  846. </script>