indexProject.vue 34 KB

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