indexProject.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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="success"
  143. icon="el-icon-upload"
  144. size="mini"
  145. @click="handleUpload"
  146. v-hasPermi="['his:user:importData']"
  147. >转移导入</el-button>
  148. </el-col>
  149. <el-col :span="1.5">
  150. <el-button
  151. type="warning"
  152. icon="el-icon-download"
  153. size="mini"
  154. @click="handleExport"
  155. v-hasPermi="['his:user:export']"
  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="['his: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. <el-button
  247. size="mini"
  248. type="text"
  249. icon="el-icon-refresh-left"
  250. @click="handleClearWatchRecord(scope.row)"
  251. v-hasPermi="['his:user:clearUserWatchRecord']"
  252. >清除看课记录</el-button>
  253. </template>
  254. </el-table-column>
  255. </el-table>
  256. <pagination
  257. v-show="total>0"
  258. :total="total"
  259. :page.sync="queryParams.pageNum"
  260. :limit.sync="queryParams.pageSize"
  261. @pagination="getList"
  262. />
  263. <!-- 添加或修改用户对话框 -->
  264. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  265. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  266. <el-form-item label="会员头像" prop="avatar">
  267. <el-popover
  268. placement="right"
  269. title=""
  270. trigger="hover"
  271. >
  272. <img slot="reference" :src="form.avatar" width="80">
  273. <img :src="form.avatar" style="max-width: 80px;">
  274. </el-popover>
  275. </el-form-item>
  276. <el-form-item label="会员昵称" prop="nickname">
  277. <el-input v-model="form.nickname" disabled placeholder="请输入用户昵称" />
  278. </el-form-item>
  279. <el-form-item label="手机号码" prop="phone">
  280. <el-input v-model="form.phone" disabled placeholder="请输入手机号码" />
  281. </el-form-item>
  282. <el-form-item label="最后一次登录ip" prop="lastIp">
  283. <el-input v-model="form.lastIp" disabled placeholder="请输入最后一次登录ip" />
  284. </el-form-item>
  285. <!-- <el-form-item label="用户余额" prop="nowMoney">
  286. <el-input v-model="form.nowMoney" disabled placeholder="请输入用户余额" />
  287. </el-form-item> -->
  288. <!-- <el-form-item label="积分" prop="integral">
  289. <el-input v-model="form.integral" disabled placeholder="请输入用户积分" />
  290. </el-form-item> -->
  291. <el-form-item label="进线日期" prop="registerDate">
  292. <el-date-picker clearable size="small"
  293. v-model="form.registerDate"
  294. type="date"
  295. value-format="yyyy-MM-dd"
  296. placeholder="选择进线日期">
  297. </el-date-picker>
  298. </el-form-item>
  299. <el-form-item label="推线编码" prop="registerCode">
  300. <el-input v-model="form.registerCode" placeholder="请输入推线编码" />
  301. </el-form-item>
  302. <el-form-item label="渠道来源" prop="source">
  303. <el-input v-model="form.source" placeholder="请输入渠道来源" />
  304. </el-form-item>
  305. <el-form-item label="会员等级" prop="level">
  306. <el-select style="width: 200px" v-model="form.level" placeholder="请选择会员等级" clearable size="small" >
  307. <el-option
  308. v-for="item in userLevelOptions"
  309. :key="item.dictValue"
  310. :label="item.dictLabel"
  311. :value="item.dictValue"
  312. />
  313. </el-select>
  314. </el-form-item>
  315. <el-form-item label="是否为推广员" prop="isPromoter">
  316. <el-select style="width: 200px" v-model="form.isPromoter" placeholder="请选择" clearable size="small" >
  317. <el-option
  318. v-for="item in userIsPromoterOptions"
  319. :key="item.dictValue"
  320. :label="item.dictLabel"
  321. :value="item.dictValue"
  322. />
  323. </el-select>
  324. </el-form-item>
  325. <el-form-item label="状态" prop="level">
  326. <el-radio-group v-model="form.status">
  327. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  328. </el-radio-group>
  329. </el-form-item>
  330. <el-form-item label="是否展示" prop="isShow">
  331. <el-radio-group v-model="form.isShow">
  332. <el-radio :label="item.dictValue" v-for="item in isShowOptions" >{{item.dictLabel}}</el-radio>
  333. </el-radio-group>
  334. </el-form-item>
  335. <el-form-item label="用户备注" prop="remark">
  336. <el-input v-model="form.remark" placeholder="请输入用户备注" />
  337. </el-form-item>
  338. </el-form>
  339. <div slot="footer" class="dialog-footer">
  340. <el-button type="primary" @click="submitForm">确 定</el-button>
  341. <el-button @click="cancel">取 消</el-button>
  342. </div>
  343. </el-dialog>
  344. <el-drawer size="75%" :title="show.title" :visible.sync="show.open">
  345. <userDetailsByNew ref="userDetailsByNew" />
  346. </el-drawer>
  347. <!-- 更换会员归属对话框 -->
  348. <el-dialog title="更换会员归属" :visible.sync="changeCompanyUserOpen" width="500px" append-to-body>
  349. <el-form ref="changeCompanyUserForm" :model="changeCompanyUserForm" :rules="changeCompanyUserRules" label-width="100px">
  350. <el-form-item label="选择公司" prop="companyId">
  351. <el-select v-model="changeCompanyUserForm.companyId" placeholder="请选择公司" filterable style="width: 100%" @change="handleCompanyChange">
  352. <el-option
  353. v-for="item in companyOptions"
  354. :key="item.companyId"
  355. :label="item.companyName"
  356. :value="item.companyId"
  357. />
  358. </el-select>
  359. </el-form-item>
  360. <el-form-item label="选择销售" prop="companyUserId">
  361. <el-select v-model="changeCompanyUserForm.companyUserId" placeholder="请选择销售" filterable style="width: 100%" @change="handleCompanyUserChange">
  362. <el-option
  363. v-for="item in companyUserOptions"
  364. :key="item.userId"
  365. :label="item.nickName + '_' + item.userName"
  366. :value="item.userId"
  367. />
  368. </el-select>
  369. </el-form-item>
  370. </el-form>
  371. <div slot="footer" class="dialog-footer">
  372. <el-button type="primary" @click="submitChangeCompanyUserForm">确 定</el-button>
  373. <el-button @click="cancelChangeCompanyUser">取 消</el-button>
  374. </div>
  375. </el-dialog>
  376. <el-dialog title="选择项目" :visible.sync="projectSelectForClearDialogVisible" width="400px">
  377. <el-form :model="clearWatchRecordParams" style="margin-top: 15px;">
  378. <el-form-item label="选择项目" :label-width="100">
  379. <el-select v-model="clearWatchRecordParams.projectId" placeholder="请选择项目" style="width: 100%">
  380. <el-option
  381. v-for="option in projectOptions"
  382. :key="option.dictValue"
  383. :label="option.dictLabel"
  384. :value="option.dictValue">
  385. </el-option>
  386. </el-select>
  387. </el-form-item>
  388. </el-form>
  389. <div slot="footer" class="dialog-footer">
  390. <el-button @click="projectSelectForClearDialogVisible = false">取 消</el-button>
  391. <el-button type="primary" @click="confirmClearWatchRecord">确 定</el-button>
  392. </div>
  393. </el-dialog>
  394. <!-- 转移导入 -->
  395. <el-dialog :title="transferUploadDialog.title"
  396. :visible.sync="transferUploadDialog.visible"
  397. :width="transferUploadDialog.width" append-to-body>
  398. <transferUpload ref="transferUpload" />
  399. </el-dialog>
  400. </div>
  401. </template>
  402. <script>
  403. import {listUserByProject, getUser, addUser, updateUser, exportUser, delUserCompanyUser,exportListProject,clearUserWatchRecord} from "@/api/his/user";
  404. import { getCompanyUserList, changeCompanyUser, getCompanyList } from '@/api/company/companyUser';
  405. import userDetailsByNew from '@/views/his/user/userDetails.vue'
  406. import transferUpload from './transferUpload.vue'
  407. export default {
  408. name: "User",
  409. components: { userDetailsByNew, transferUpload },
  410. data() {
  411. return {
  412. companyQueryOptions:[],
  413. companyQueryUserOptions:[],
  414. userIsPromoterOptions:[],
  415. userLevelOptions:[],
  416. statusOptions:[],
  417. isShowOptions:[],
  418. // 遮罩层
  419. loading: true,
  420. // 选中数组
  421. ids: [],
  422. // 非单个禁用
  423. single: true,
  424. // 非多个禁用
  425. multiple: true,
  426. // 显示搜索条件
  427. showSearch: true,
  428. // 总条数
  429. total: 0,
  430. show:{
  431. title:"会员详情",
  432. open:false,
  433. },
  434. clearWatchRecordDialog: {
  435. visible: false,
  436. title: '清除看课记录',
  437. userId: null
  438. },
  439. clearWatchRecordParams: {
  440. projectId: null
  441. },
  442. projectSelectForClearDialogVisible: false,
  443. // 用户表格数据
  444. userList: [],
  445. // 弹出层标题
  446. title: "",
  447. // 是否显示弹出层
  448. open: false,
  449. // 日期范围
  450. dateRange: [],
  451. // 查询参数
  452. queryParams: {
  453. pageNum: 1,
  454. pageSize: 10,
  455. username: null,
  456. password: null,
  457. realName: null,
  458. birthday: null,
  459. idCard: null,
  460. mark: null,
  461. nickname: null,
  462. avatar: null,
  463. phone: null,
  464. lastIp: null,
  465. nowMoney: null,
  466. brokeragePrice: null,
  467. integral: null,
  468. signNum: null,
  469. status: null,
  470. level: null,
  471. spreadUserId: null,
  472. spreadTime: null,
  473. userType: null,
  474. isPromoter: null,
  475. payCount: null,
  476. spreadCount: null,
  477. addres: null,
  478. wxProfile: null,
  479. isDel: null,
  480. startCreateTime: null,
  481. endCreateTime: null,
  482. companyId: null,
  483. companyUserNickName: null,
  484. userId: null
  485. },
  486. // 表单参数
  487. form: {},
  488. // 表单校验
  489. rules: {
  490. status: [
  491. { required: true, message: "状态不能为空", trigger: "blur" }
  492. ],
  493. level: [
  494. { required: true, message: "等级不能为空", trigger: "blur" }
  495. ],
  496. },
  497. // 更换会员归属对话框
  498. changeCompanyUserOpen: false,
  499. // 更换会员归属表单
  500. changeCompanyUserForm: {
  501. companyId: null,
  502. companyUserId: null,
  503. userIds: []
  504. },
  505. // 更换会员归属表单校验
  506. changeCompanyUserRules: {
  507. companyId: [
  508. { required: true, message: '请选择公司', trigger: 'change' }
  509. ],
  510. companyUserId: [
  511. { required: true, message: '请选择销售', trigger: 'change' }
  512. ]
  513. },
  514. // 销售选项
  515. companyUserOptions: [],
  516. companyOptions: [],
  517. projectOptions: [],
  518. selectedUser: [],
  519. // 转移导入
  520. transferUploadDialog: {
  521. visible: false,
  522. title: '转移导入',
  523. width: '1200px'
  524. }
  525. };
  526. },
  527. created() {
  528. this.getDicts("project_user_status").then((response) => {
  529. this.statusOptions = response.data;
  530. });
  531. this.getDicts("user_level").then((response) => {
  532. this.userLevelOptions = response.data;
  533. });
  534. this.getDicts("sys_company_or").then((response) => {
  535. this.isShowOptions = response.data;
  536. });
  537. this.getDicts("user_is_promoter").then((response) => {
  538. this.userIsPromoterOptions = response.data;
  539. });
  540. this.getDicts("sys_course_project").then(response => {
  541. this.projectOptions = response.data;
  542. });
  543. this.getList();
  544. getCompanyList().then(response => {
  545. if (response.code === 200) {
  546. this.companyQueryOptions = response.data;
  547. }});
  548. },
  549. methods: {
  550. handleQueryCompanyChange(companyId){
  551. // 清空已选择的销售
  552. this.queryCompanyUserId = null;
  553. // 根据公司ID获取对应的销售列表
  554. if (companyId) {
  555. getCompanyUserList({ companyId: companyId }).then(response => {
  556. if (response.code === 200) {
  557. this.companyQueryUserOptions = response.data;
  558. } else {
  559. this.$message.error(response.msg || '获取销售列表失败');
  560. this.companyQueryUserOptions = [];
  561. }
  562. }).catch(() => {
  563. this.$message.error('获取销售列表失败');
  564. this.companyQueryUserOptions = [];
  565. });
  566. } else {
  567. this.companyQueryUserOptions = [];
  568. }
  569. },
  570. handleClearWatchRecord(row) {
  571. this.clearWatchRecordParams.projectId = null; // 重置项目选择
  572. this.clearWatchRecordDialog.userId = row.userId;
  573. this.projectSelectForClearDialogVisible = true;
  574. },
  575. /** 确认清除看课记录方法 */
  576. confirmClearWatchRecord() {
  577. this.projectSelectForClearDialogVisible = false;
  578. // 调用后端API清除看课记录
  579. this.clearUserWatchRecord(this.clearWatchRecordDialog.userId, this.clearWatchRecordParams.projectId);
  580. },
  581. clearUserWatchRecord(userId, projectId) {
  582. // 将projectId转换为数值类型
  583. const numericProjectId = projectId ? Number(projectId) : null;
  584. clearUserWatchRecord({userId: userId, projectId: numericProjectId}).then(response => {
  585. if (response.code === 200) {
  586. this.msgSuccess("清除看课记录成功");
  587. this.getList(); // 刷新列表
  588. } else {
  589. this.$message.error(response.msg || "清除看课记录失败");
  590. }
  591. }).catch(error => {
  592. console.error('清除看课记录失败:', error);
  593. this.$message.error('清除看课记录失败,请稍后重试');
  594. });
  595. },
  596. /** 查询用户列表 */
  597. getList() {
  598. this.loading = true;
  599. listUserByProject(this.queryParams).then(response => {
  600. this.userList = response.rows;
  601. this.total = response.total;
  602. this.loading = false;
  603. });
  604. },
  605. // 取消按钮
  606. cancel() {
  607. this.open = false;
  608. this.reset();
  609. },
  610. // 表单重置
  611. reset() {
  612. this.form = {
  613. userId: null,
  614. username: null,
  615. password: null,
  616. realName: null,
  617. birthday: null,
  618. idCard: null,
  619. mark: null,
  620. nickname: null,
  621. avatar: null,
  622. phone: null,
  623. createTime: null,
  624. updateTime: null,
  625. lastIp: null,
  626. nowMoney: null,
  627. brokeragePrice: null,
  628. integral: null,
  629. signNum: null,
  630. status: 0,
  631. level: 0,
  632. spreadUserId: null,
  633. spreadTime: null,
  634. userType: null,
  635. isPromoter: null,
  636. payCount: null,
  637. spreadCount: null,
  638. addres: null,
  639. wxProfile: null,
  640. isDel: null,
  641. isShow: null
  642. };
  643. this.resetForm("form");
  644. },
  645. /** 搜索按钮操作 */
  646. handleQuery() {
  647. this.queryParams.pageNum = 1;
  648. this.getList();
  649. },
  650. /** 重置按钮操作 */
  651. resetQuery() {
  652. this.dateRange = [];
  653. this.resetForm("queryForm");
  654. this.queryParams.companyId = null;
  655. this.queryParams.companyUserNickName = null;
  656. this.companyQueryUserOptions = null;
  657. this.queryParams.startCreateTime = null
  658. this.queryParams.endCreateTime = null
  659. this.handleQuery();
  660. },
  661. /** 处理日期范围变化 */
  662. handleDateRangeChange(dates) {
  663. if (dates) {
  664. this.queryParams.startCreateTime = dates[0];
  665. this.queryParams.endCreateTime = dates[1];
  666. } else {
  667. this.queryParams.startCreateTime = null;
  668. this.queryParams.endCreateTime = null;
  669. }
  670. },
  671. // 多选框选中数据
  672. handleSelectionChange(selection) {
  673. this.ids = selection.map(item => item.userId)
  674. this.selectedUser = selection.map(item => {return {userId: item.userId, projectId: item.projectId}})
  675. this.single = selection.length!==1
  676. this.multiple = !selection.length
  677. },
  678. /** 新增按钮操作 */
  679. handleAdd() {
  680. this.reset();
  681. this.open = true;
  682. this.title = "添加用户";
  683. },
  684. /** 修改按钮操作 */
  685. handleUpdate(row) {
  686. this.reset();
  687. const userId = row.userId || this.ids
  688. getUser(userId).then(response => {
  689. this.form = response.data;
  690. if(response.data.status){
  691. this.form.status = response.data.status.toString();
  692. } else {
  693. this.form.status = null;
  694. }
  695. if(response.data.isShow){
  696. this.form.isShow = response.data.isShow.toString();
  697. }else {
  698. this.form.isShow = null;
  699. }
  700. if(response.data.level){
  701. this.form.level = response.data.level.toString();
  702. }else {
  703. this.form.level = null;
  704. }
  705. if(response.data.isPromoter){
  706. this.form.isPromoter = response.data.isPromoter.toString();
  707. }else {
  708. this.form.status = null;
  709. }
  710. this.open = true;
  711. this.title = "修改用户";
  712. });
  713. },
  714. /** 提交按钮 */
  715. submitForm() {
  716. this.$refs["form"].validate(valid => {
  717. if (valid) {
  718. if (this.form.userId != null) {
  719. updateUser(this.form).then(response => {
  720. if (response.code === 200) {
  721. this.msgSuccess("修改成功");
  722. this.open = false;
  723. this.getList();
  724. }
  725. });
  726. } else {
  727. addUser(this.form).then(response => {
  728. if (response.code === 200) {
  729. this.msgSuccess("新增成功");
  730. this.open = false;
  731. this.getList();
  732. }
  733. });
  734. }
  735. }
  736. });
  737. },
  738. /** 删除按钮操作 */
  739. handleDelete(row) {
  740. const userCompanyUserId = row.userCompanyUserId;
  741. this.$confirm('是否确认删除用户编号为"' + userCompanyUserId + '"的数据项?', "警告", {
  742. confirmButtonText: "确定",
  743. cancelButtonText: "取消",
  744. type: "warning"
  745. }).then(function() {
  746. return delUserCompanyUser(userCompanyUserId);
  747. }).then(() => {
  748. this.getList();
  749. this.msgSuccess("删除成功");
  750. }).catch(function() {});
  751. },
  752. /** 导出按钮操作 */
  753. handleExport() {
  754. const queryParams = this.queryParams;
  755. this.$confirm('是否确认导出当前用户数据项?', "警告", {
  756. confirmButtonText: "确定",
  757. cancelButtonText: "取消",
  758. type: "warning"
  759. }).then(function() {
  760. return exportListProject(queryParams);
  761. }).then(response => {
  762. console.log(response)
  763. this.download(response.msg);
  764. }).catch(function() {});
  765. },
  766. handleShow(row){
  767. var that=this;
  768. that.show.open=true;
  769. setTimeout(() => {
  770. that.$refs.userDetailsByNew.getDetails(row.userId);
  771. }, 200);
  772. },
  773. /** 更换会员归属按钮操作 */
  774. handleChangeCompanyUser() {
  775. // 获取公司下拉列表
  776. getCompanyList().then(response => {
  777. if (response.code === 200) {
  778. this.companyOptions = response.data;
  779. // 重置表单和销售列表
  780. this.resetCompanyUserForm();
  781. this.companyUserOptions = [];
  782. this.changeCompanyUserOpen = true;
  783. } else {
  784. this.$message.error(response.msg || '获取公司列表失败');
  785. }
  786. }).catch(() => {
  787. this.$message.error('获取公司列表失败');
  788. });
  789. },
  790. /** 销售选择变化 */
  791. handleCompanyUserChange(userId) {
  792. if (!this.changeCompanyUserForm.companyId) {
  793. this.$message.warning('请先选择公司');
  794. this.changeCompanyUserForm.companyUserId = null;
  795. return;
  796. }
  797. },
  798. /** 重置更换会员归属表单 */
  799. resetCompanyUserForm() {
  800. this.changeCompanyUserForm = {
  801. companyId: null,
  802. companyUserId: null,
  803. userIds: []
  804. };
  805. this.resetForm("changeCompanyUserForm");
  806. },
  807. handleCompanyChange(companyId) {
  808. // 清空已选择的销售
  809. this.changeCompanyUserForm.companyUserId = null;
  810. // 根据公司ID获取对应的销售列表
  811. if (companyId) {
  812. getCompanyUserList({ companyId: companyId }).then(response => {
  813. if (response.code === 200) {
  814. this.companyUserOptions = response.data;
  815. } else {
  816. this.$message.error(response.msg || '获取销售列表失败');
  817. this.companyUserOptions = [];
  818. }
  819. }).catch(() => {
  820. this.$message.error('获取销售列表失败');
  821. this.companyUserOptions = [];
  822. });
  823. } else {
  824. this.companyUserOptions = [];
  825. }
  826. },
  827. /** 取消更换会员归属 */
  828. cancelChangeCompanyUser() {
  829. this.changeCompanyUserOpen = false;
  830. this.resetCompanyUserForm();
  831. },
  832. /** 提交更换会员归属 */
  833. submitChangeCompanyUserForm() {
  834. this.$refs["changeCompanyUserForm"].validate(valid => {
  835. if (valid) {
  836. // 调用更换会员归属接口
  837. // 检查companyId是否已设置
  838. if (!this.changeCompanyUserForm.companyId) {
  839. this.$message.error('请选择公司');
  840. return;
  841. }
  842. changeCompanyUser(this.selectedUser, {
  843. companyUserId: this.changeCompanyUserForm.companyUserId,
  844. companyId: this.changeCompanyUserForm.companyId
  845. }).then(response => {
  846. if (response.code === 200) {
  847. this.msgSuccess("操作成功");
  848. this.changeCompanyUserOpen = false;
  849. this.getList();
  850. } else {
  851. this.$message.error(response.msg || '操作失败');
  852. }
  853. }).catch(() => {
  854. this.$message.error('操作失败');
  855. });
  856. }
  857. });
  858. },
  859. /** 获取项目对应名称 */
  860. getProjectLabel(projectId) {
  861. return this.projectOptions.find(item => parseInt(item.dictValue) === projectId)?.dictLabel;
  862. },
  863. // 上传导入
  864. handleUpload() {
  865. this.transferUploadDialog.visible = true
  866. }
  867. }
  868. };
  869. </script>