indexProject.vue 31 KB

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