indexProject.vue 30 KB

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