You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2571 line
77 KiB

  1. <template>
  2. <div class="user">
  3. <div style="background: #ffff; padding: 10px">
  4. <div class="tabcenbox" v-if="systemFlag" style="cursor: pointer;">
  5. <div
  6. :class="choseFlag ? 'ch1' : 'ch2'"
  7. style="border-right: 1px solid #ccc;"
  8. @click="choseFlag = true"
  9. >
  10. 注册用户
  11. </div>
  12. <div :class="!choseFlag ? 'ch1' : 'ch2'" @click="choseFlag = false">
  13. 组织用户
  14. </div>
  15. </div>
  16. <!-- 当他为注册用户的时候 -->
  17. <div class="top" style="margin-left: 10px" v-if="choseFlag">
  18. <el-form
  19. :inline="true"
  20. :model="searchMsg"
  21. class="demo-form-inline"
  22. ref="searchMsg"
  23. >
  24. <el-form-item label="身份" prop="flag">
  25. <el-input
  26. v-if="searchMsg.flag == 1"
  27. v-model="searchMsg.username"
  28. clearable
  29. placeholder="请输入"
  30. maxlength="15"
  31. >
  32. <el-select
  33. v-model="searchMsg.flag"
  34. slot="prepend"
  35. class="input-with-select"
  36. style="width: 140px"
  37. placeholder="请选择"
  38. @change="flagchange"
  39. >
  40. <el-option label="登陆手机" value="1"></el-option>
  41. <el-option label="用户名" value="2"></el-option>
  42. </el-select>
  43. </el-input>
  44. <el-input
  45. v-else
  46. v-model="searchMsg.name"
  47. clearable
  48. placeholder="请输入"
  49. maxlength="15"
  50. >
  51. <el-select
  52. v-model="searchMsg.flag"
  53. slot="prepend"
  54. class="input-with-select"
  55. style="width: 140px"
  56. placeholder="请选择"
  57. @change="flagchange"
  58. >
  59. <el-option label="登陆手机" value="1"></el-option>
  60. <el-option label="用户名" value="2"></el-option>
  61. </el-select>
  62. </el-input>
  63. </el-form-item>
  64. <!-- <el-form-item label="所属组织" prop="orgName">
  65. <el-input
  66. v-model="searchMsg.orgName"
  67. clearable
  68. placeholder="请输入所属组织名称"
  69. ></el-input>
  70. </el-form-item> -->
  71. <el-form-item>
  72. <el-button type="primary" @click="search">筛选</el-button>
  73. <el-button type="primary" @click="reset">清空筛选条件</el-button>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. <!-- 当他为组织用户的时候 -->
  78. <div class="top" style="margin-left: 10px" v-else>
  79. <el-form
  80. :inline="true"
  81. :model="searchMsg1"
  82. class="demo-form-inline"
  83. ref="searchMsg1"
  84. >
  85. <el-form-item label="身份" prop="flag">
  86. <el-input
  87. v-if="searchMsg1.flag == 1"
  88. v-model="searchMsg1.username"
  89. clearable
  90. placeholder="请输入"
  91. maxlength="15"
  92. >
  93. <el-select
  94. v-model="searchMsg1.flag"
  95. slot="prepend"
  96. class="input-with-select"
  97. style="width: 140px"
  98. placeholder="请选择"
  99. @change="flagchange1"
  100. >
  101. <el-option label="登陆账号" value="1"></el-option>
  102. <el-option label="用户名" value="2"></el-option>
  103. </el-select>
  104. </el-input>
  105. <el-input
  106. v-else
  107. v-model="searchMsg1.name"
  108. clearable
  109. placeholder="请输入"
  110. maxlength="15"
  111. >
  112. <el-select
  113. v-model="searchMsg1.flag"
  114. slot="prepend"
  115. class="input-with-select"
  116. style="width: 140px"
  117. placeholder="请选择"
  118. @change="flagchange1"
  119. >
  120. <el-option label="登陆账号" value="1"></el-option>
  121. <el-option label="用户名" value="2"></el-option>
  122. </el-select>
  123. </el-input>
  124. </el-form-item>
  125. <el-form-item label="组织类型" v-if="losorgType==2" prop="queryOrgType">
  126. <el-select
  127. v-model="searchMsg1.queryOrgType"
  128. @change="queryOrgTypeChange"
  129. clearable
  130. placeholder="请选择"
  131. >
  132. <!-- <el-option label="平台用户" value="0"></el-option> -->
  133. <!-- <el-option label="代理商用户" value="1"></el-option> -->
  134. <el-option label="公司用户" value="2"></el-option>
  135. <el-option label="楼盘用户" value="3"></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item label="用户身份" prop="userRoleType">
  139. <el-select
  140. v-model="searchMsg1.userRoleType"
  141. filterable
  142. clearable
  143. placeholder="请选择"
  144. >
  145. <!-- <el-option label="项目总" value="2"></el-option>
  146. <el-option label="客服" value="3"></el-option>
  147. <el-option label="策划" value="4"></el-option>
  148. <el-option label="经理" value="5"></el-option>
  149. <el-option label="置业顾问" value="6"></el-option> -->
  150. <el-option
  151. v-for="item in userRoleList"
  152. :key="item.dictValue"
  153. :label="item.dictName"
  154. :value="item.dictValue"
  155. >
  156. </el-option>
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="状态" prop="lockFlag">
  160. <el-select
  161. v-model="searchMsg1.lockFlag"
  162. clearable
  163. placeholder="请选择"
  164. >
  165. <el-option label="启用" value="0"></el-option>
  166. <el-option label="禁用" value="1"></el-option>
  167. </el-select>
  168. </el-form-item>
  169. <el-form-item>
  170. <el-button type="primary" @click="search1">筛选</el-button>
  171. <el-button type="primary" @click="reset1">清空筛选条件</el-button>
  172. </el-form-item>
  173. </el-form>
  174. </div>
  175. <div style="margin: 0 0 10px 10px" v-if="sys_user_add">
  176. <!-- <el-button type="primary" :disabled='checkRole.length==0' @click="delIds">批量删除</el-button> -->
  177. <el-button type="primary" @click="addRole">添加</el-button>
  178. </div>
  179. </div>
  180. <!-- 表格 -->
  181. <div class="con" style="margin-left: 10px">
  182. <el-table
  183. :data="tableData"
  184. v-if="choseFlag"
  185. border
  186. @selection-change="handleSelectionChange"
  187. style="width: 100%"
  188. :header-cell-style="{ textAlign: 'center' }"
  189. :cell-style="{ textAlign: 'center' }"
  190. >
  191. <el-table-column type="selection" width="55"> </el-table-column>
  192. <el-table-column prop="name" label="用户名"> </el-table-column>
  193. <el-table-column label="登录手机" prop="username"> </el-table-column>
  194. <el-table-column label="性别">
  195. <template slot-scope="{ row }">
  196. {{ row.sex == 0 ? "男" : "女" }}
  197. </template>
  198. </el-table-column>
  199. <!-- <el-table-column prop="orgName" label="所属组织"> </el-table-column> -->
  200. <el-table-column prop="createTime" label="注册时间"> </el-table-column>
  201. <el-table-column prop="address" label="操作">
  202. <template slot-scope="scope">
  203. <el-button
  204. v-if="resetPassword"
  205. @click="resetPwd(scope.row)"
  206. type="text"
  207. size="small"
  208. >密码重置</el-button
  209. >
  210. <el-button
  211. v-if="sys_user_edit"
  212. @click="editRole(scope.row, false)"
  213. type="text"
  214. size="small"
  215. >编辑</el-button
  216. >
  217. <!-- <el-tooltip
  218. style="font-size: 18px"
  219. effect="dark"
  220. content="密码重置"
  221. placement="top-start"
  222. >
  223. <i
  224. class="el-icon-unlock"
  225. style="color: #ff892a"
  226. @click="resetPwd(scope.row)"
  227. ></i>
  228. </el-tooltip>
  229. <el-tooltip
  230. style="font-size: 18px"
  231. effect="dark"
  232. content="查看"
  233. placement="top-start"
  234. >
  235. <i
  236. class="el-icon-zoom-in"
  237. style="color: #008ef2"
  238. @click="editRole(scope.row, true)"
  239. ></i>
  240. </el-tooltip>
  241. <el-tooltip
  242. style="font-size: 18px"
  243. effect="dark"
  244. content="编辑"
  245. placement="top-start"
  246. >
  247. <i
  248. class="el-icon-edit"
  249. style="color: red"
  250. @click="editRole(scope.row, false)"
  251. ></i>
  252. </el-tooltip>
  253. <el-tooltip
  254. style="font-size: 18px"
  255. effect="dark"
  256. content="删除"
  257. placement="top-start"
  258. >
  259. <i
  260. class="el-icon-close"
  261. style="color: #428bca"
  262. @click="deletes(scope.row)"
  263. ></i>
  264. </el-tooltip>
  265. <el-tooltip
  266. style="font-size: 18px"
  267. effect="dark"
  268. content="修改客户信息状态"
  269. placement="top-start"
  270. >
  271. <i
  272. class="el-icon-view"
  273. style="color: #428bca"
  274. @click="editStatus(scope.row)"
  275. ></i>
  276. </el-tooltip> -->
  277. </template>
  278. </el-table-column>
  279. </el-table>
  280. <el-table
  281. :data="tableData1"
  282. v-else
  283. border
  284. @selection-change="handleSelectionChange"
  285. style="width: 100%"
  286. :header-cell-style="{ textAlign: 'center' }"
  287. :cell-style="{ textAlign: 'center' }"
  288. >
  289. <el-table-column type="selection" width="55"> </el-table-column>
  290. <el-table-column prop="name" label="用户名"> </el-table-column>
  291. <el-table-column label="登录手机" prop="username"> </el-table-column>
  292. <el-table-column prop="orgName" label="所属组织"> </el-table-column>
  293. <!-- <el-table-column prop="orgType" label="组织类型">
  294. <template slot-scope="scope">
  295. {{
  296. scope.row.orgType == 0
  297. ? "系统用户"
  298. : scope.row.orgType == 1
  299. ? "代理商用户"
  300. : scope.row.orgType == 2
  301. ? "公司用户"
  302. : scope.row.orgType == 3?'楼盘用户'
  303. : ""
  304. }}
  305. </template>
  306. </el-table-column> -->
  307. <el-table-column prop="orgTypeName" label="组织类型"> </el-table-column>
  308. <el-table-column prop="roleName" label="组织角色"> </el-table-column>
  309. <el-table-column prop="userRoleTypeName" label="用户身份">
  310. </el-table-column>
  311. <el-table-column label="状态">
  312. <template slot-scope="{ row }">
  313. {{ row.lockFlag == 0 ? "启用" : "禁用" }}
  314. </template>
  315. </el-table-column>
  316. <el-table-column prop="createTime" label="添加时间"> </el-table-column>
  317. <el-table-column prop="address" label="操作" fixed="right" width="150">
  318. <template slot-scope="scope" v-if="scope.row.userRoleType!=11&&scope.row.userRoleType!=12&&scope.row.userRoleType!=13">
  319. <el-button
  320. @click="editTwo(scope.row)"
  321. v-if="sys_user_edit1"
  322. type="text"
  323. size="small"
  324. >编辑</el-button
  325. >
  326. <el-button
  327. v-if="
  328. scope.row.orgType == 3 &&
  329. sys_user_choseHouse &&
  330. scope.row.userRoleType != 8 &&
  331. scope.row.userRoleType != 7
  332. "
  333. @click="gochosehouse(scope.row)"
  334. type="text"
  335. size="small"
  336. >楼盘选择</el-button
  337. >
  338. <el-button
  339. v-if="sys_user_bind"
  340. @click="startorg(scope.row)"
  341. type="text"
  342. size="small"
  343. >
  344. {{ scope.row.lockFlag == 0 ? "禁用" : "启用" }}</el-button
  345. >
  346. <el-button
  347. v-if="sys_user_del"
  348. @click="deletes(scope.row)"
  349. type="text"
  350. size="small"
  351. >移除</el-button
  352. >
  353. </template>
  354. </el-table-column>
  355. </el-table>
  356. <el-pagination
  357. style="text-align: center; margin-top: 18px"
  358. background
  359. @size-change="handleSizeChange"
  360. @current-change="handleCurrentChange"
  361. :current-page.sync="page.current"
  362. :page-sizes="[10, 30, 50]"
  363. :page-size="page.size"
  364. layout="total, sizes,prev, pager, next, jumper"
  365. :total="page.total"
  366. >
  367. </el-pagination>
  368. </div>
  369. <el-dialog
  370. :title="formTitle"
  371. :visible.sync="dialogFormVisible"
  372. @close="resetForm"
  373. >
  374. <el-form
  375. :model="form"
  376. label-width="120px"
  377. ref="form"
  378. :rules="rules"
  379. :disabled="editFlag"
  380. >
  381. <el-form-item label="登录手机" prop="username">
  382. <el-input
  383. v-model="form.username"
  384. onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));"
  385. :disabled="phoneFlag"
  386. style="width: 370px"
  387. ></el-input>
  388. </el-form-item>
  389. <el-form-item label="用户名" prop="name">
  390. <el-input
  391. v-model="form.name"
  392. maxlength="10"
  393. clearable
  394. :disabled="phoneFlag"
  395. style="width: 370px"
  396. ></el-input>
  397. </el-form-item>
  398. <el-form-item label="性别" prop="sex">
  399. <el-radio-group v-model="form.sex">
  400. <el-radio label="0">男</el-radio>
  401. <el-radio label="1">女</el-radio>
  402. </el-radio-group>
  403. </el-form-item>
  404. <el-form-item label="手机号加密" prop="showPhoneStatus" v-if="addFlag">
  405. <el-radio-group v-model="form.showPhoneStatus">
  406. <el-radio :label="0">是</el-radio>
  407. <el-radio :label="1">否</el-radio>
  408. </el-radio-group>
  409. </el-form-item>
  410. <el-form-item
  411. label="登录密码"
  412. prop="password"
  413. v-if="!phoneFlag && addFlag"
  414. >
  415. <el-input
  416. v-model="form.password"
  417. style="width: 370px"
  418. show-password
  419. ></el-input>
  420. </el-form-item>
  421. <el-form-item label="组织类型:" prop="orgType" v-if="addFlag">
  422. <el-select
  423. v-model="form.orgType"
  424. placeholder="请选择组织类型"
  425. style="width: 370px"
  426. :disabled="losorgType != 2"
  427. @change="typeChange"
  428. >
  429. <el-option
  430. v-if="losorgType != 2"
  431. label="平台"
  432. :value="0"
  433. ></el-option>
  434. <el-option
  435. v-if="losorgType != 2"
  436. label="代理商"
  437. :value="1"
  438. ></el-option>
  439. <el-option label="公司" :value="2"></el-option>
  440. <el-option label="楼盘" :value="3"></el-option>
  441. </el-select>
  442. </el-form-item>
  443. <el-form-item
  444. label="身份"
  445. prop="userRoleType"
  446. v-if="identityFlag && addFlag"
  447. >
  448. <el-select
  449. v-model="form.userRoleType"
  450. value-key="key"
  451. style="width: 370px"
  452. clearable
  453. filterable
  454. placeholder="请选择身份"
  455. >
  456. <!-- <el-option label="项目总" value="2"></el-option>
  457. <el-option label="客服" value="3"></el-option>
  458. <el-option label="策划" value="4"></el-option>
  459. <el-option label="经理" value="5"></el-option>
  460. <el-option label="置业顾问" value="6"></el-option> -->
  461. <el-option
  462. v-for="item in identityList"
  463. :key="item.dictValue"
  464. :label="item.dictName"
  465. :value="item.dictValue"
  466. >
  467. </el-option>
  468. </el-select>
  469. </el-form-item>
  470. <!-- <el-form-item
  471. label="选择公司:"
  472. v-if="orgFlag && addFlag"
  473. prop="orgCode"
  474. >
  475. <el-select
  476. v-model="form.orgCode"
  477. filterable
  478. placeholder="请选择公司"
  479. style="width: 370px"
  480. @change="orgCodeChange($event, 0)"
  481. >
  482. <el-option
  483. v-for="item in orgList"
  484. :key="item.id"
  485. :label="item.name"
  486. :value="item.orgCode"
  487. >
  488. </el-option>
  489. </el-select>
  490. </el-form-item>
  491. <el-form-item
  492. label="选择代理商:"
  493. v-if="agentFlag && addFlag"
  494. prop="agentId"
  495. >
  496. <el-select
  497. v-model="form.agentId"
  498. filterable
  499. placeholder="请选择代理商"
  500. style="width: 370px"
  501. @change="orgCodeChange($event, 1)"
  502. >
  503. <el-option
  504. v-for="item in agentList"
  505. :key="item.id"
  506. :label="item.agentName"
  507. :value="item.id"
  508. >
  509. </el-option>
  510. </el-select>
  511. </el-form-item> -->
  512. <el-form-item label="角色:" v-if="roleFlag && addFlag" prop="roleId">
  513. <el-select
  514. v-model="form.roleId"
  515. filterable
  516. clearable
  517. value-key="key"
  518. style="width: 370px"
  519. placeholder="请选择角色"
  520. >
  521. <el-option
  522. v-for="item in userList"
  523. :key="item.roleId"
  524. :label="item.roleName"
  525. :value="item.roleId"
  526. >
  527. </el-option>
  528. </el-select>
  529. </el-form-item>
  530. <el-form-item
  531. label="部门:"
  532. v-if="orgFlag && addFlag && losorgType == 3"
  533. prop="deptId"
  534. >
  535. <el-select
  536. v-model="form.deptId"
  537. filterable
  538. clearable
  539. value-key="key"
  540. style="width: 370px"
  541. placeholder="请选择部门"
  542. >
  543. <el-option
  544. v-for="item in deptList"
  545. :key="item.deptId"
  546. :label="item.name"
  547. :value="item.deptId"
  548. >
  549. </el-option>
  550. </el-select>
  551. </el-form-item>
  552. </el-form>
  553. <div slot="footer" class="dialog-footer">
  554. <el-button @click="dialogFormVisible = false">取 消</el-button>
  555. <el-button type="primary" @click="add">确 定</el-button>
  556. </div>
  557. </el-dialog>
  558. <!-- 组织用户编辑 -->
  559. <el-dialog title="编辑用户" :visible.sync="dialogFormVisibleTwo">
  560. <el-form
  561. :model="formTwo"
  562. label-width="120px"
  563. ref="formTwo"
  564. :rules="rulesTwo"
  565. >
  566. <el-form-item label="登录手机" prop="username">
  567. <el-input
  568. v-model="formTwo.username"
  569. disabled
  570. style="width: 370px"
  571. ></el-input>
  572. </el-form-item>
  573. <el-form-item label="手机号加密" prop="showPhoneStatus">
  574. <el-radio-group v-model="formTwo.showPhoneStatus">
  575. <el-radio :label="0">是</el-radio>
  576. <el-radio :label="1">否</el-radio>
  577. </el-radio-group>
  578. </el-form-item>
  579. <el-form-item label="角色:" prop="newRoleId">
  580. <el-select
  581. v-model="formTwo.newRoleId"
  582. filterable
  583. clearable
  584. value-key="key"
  585. style="width: 370px"
  586. placeholder="请选择角色"
  587. >
  588. <el-option
  589. v-for="item in userList"
  590. :key="item.roleId"
  591. :label="item.roleName"
  592. :value="item.roleId"
  593. >
  594. </el-option>
  595. </el-select>
  596. </el-form-item>
  597. <!-- <el-form-item label="身份:" prop="newRoleId" v-if="formTwo.userRoleType!=6&&formTwo.userRoleType!=7&&formTwo.userRoleType!=8"> -->
  598. <el-form-item label="身份:" v-if="orgFlag" prop="newRoleId">
  599. <el-select
  600. v-model="formTwo.userRoleType"
  601. filterable
  602. clearable
  603. :disabled="
  604. formTwo.userRoleType == 6 ||
  605. formTwo.userRoleType == 7 ||
  606. formTwo.userRoleType == 8
  607. "
  608. value-key="key"
  609. style="width: 370px"
  610. placeholder="请选择身份"
  611. >
  612. <el-option
  613. v-for="item in userRoleTypeList"
  614. :key="item.dictValue"
  615. :label="item.dictName"
  616. :value="item.dictValue"
  617. >
  618. </el-option>
  619. </el-select>
  620. </el-form-item>
  621. <!-- <el-form-item label="部门:" prop="deptId" v-if="orgFlag">
  622. <el-select
  623. v-model="formTwo.deptId"
  624. filterable
  625. value-key="key"
  626. style="width: 370px"
  627. placeholder="请选择部门"
  628. >
  629. <el-option
  630. v-for="item in deptList"
  631. :key="item.deptId"
  632. :label="item.name"
  633. :value="item.deptId"
  634. >
  635. </el-option>
  636. </el-select>
  637. </el-form-item> -->
  638. </el-form>
  639. <div slot="footer" class="dialog-footer">
  640. <el-button @click="dialogFormVisibleTwo = false">取 消</el-button>
  641. <el-button type="primary" @click="editSureTwo">确 定</el-button>
  642. </div>
  643. </el-dialog>
  644. <el-dialog
  645. title="手机号验证"
  646. :visible.sync="phoneVisible"
  647. @close="$refs.phoneForm.resetFields()"
  648. width="400px"
  649. >
  650. <el-form
  651. :model="phoneForm"
  652. label-width="100px"
  653. ref="phoneForm"
  654. :rules="phoneRules"
  655. >
  656. <el-form-item label="登陆手机:" prop="phone">
  657. <el-input
  658. style="width: 200px"
  659. type="tel"
  660. maxlength="11"
  661. v-model.number="phoneForm.phone"
  662. onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));"
  663. ></el-input>
  664. </el-form-item>
  665. </el-form>
  666. <div style="display: flex; justify-content: space-around">
  667. <el-button @click="phoneVisible = false">取 消</el-button>
  668. <el-button type="primary" @click="nextshow">确 定</el-button>
  669. </div>
  670. </el-dialog>
  671. <el-dialog
  672. title="密码重置"
  673. :visible.sync="passwordVisible"
  674. @close="$refs.passwordForm.resetFields()"
  675. width="400px"
  676. >
  677. <el-form
  678. :model="passwordForm"
  679. label-width="100px"
  680. ref="passwordForm"
  681. :rules="passwordRules"
  682. >
  683. <el-form-item label="重置密码:" prop="password">
  684. <el-input v-model="passwordForm.password" show-password></el-input>
  685. </el-form-item>
  686. </el-form>
  687. <div style="display: flex; justify-content: space-around">
  688. <el-button @click="passwordVisible = false">取 消</el-button>
  689. <el-button type="primary" @click="editpwd">确 定</el-button>
  690. </div>
  691. </el-dialog>
  692. <el-dialog
  693. title="绑定楼盘"
  694. :visible.sync="houseVisible"
  695. width="800px"
  696. @close="houseClose"
  697. >
  698. <div class="bindchoice">
  699. <div style="line-height: 15px; margin-right: 10px">绑定方式</div>
  700. <el-radio-group v-model="bindFlag" @change="radioChange">
  701. <el-radio label="0">指定楼盘绑定</el-radio>
  702. <el-radio v-if="code.userRoleType!=6" label="1">按区域绑定</el-radio>
  703. </el-radio-group>
  704. </div>
  705. <div v-if="bindFlag == 0" class="con">
  706. <!-- 指定楼盘绑定 -->
  707. <el-form
  708. :inline="true"
  709. :model="searchhouseMsg"
  710. class="demo-form-inline"
  711. ref="searchhouseMsg"
  712. >
  713. <el-form-item label="楼盘名称" prop="orgName">
  714. <el-input
  715. v-model="searchhouseMsg.propertyName"
  716. maxlength="10"
  717. clearable
  718. placeholder="请输入楼盘名称"
  719. ></el-input>
  720. </el-form-item>
  721. <el-form-item label="省市" prop="">
  722. <el-cascader
  723. :props="props"
  724. @change="locationsChange"
  725. placeholder="省/市"
  726. size="small"
  727. separator="/"
  728. v-model="provice"
  729. clearable
  730. ></el-cascader>
  731. </el-form-item>
  732. <el-form-item label="绑定状态" prop="">
  733. <el-select
  734. v-model="searchhouseMsg.isSelected"
  735. clearable
  736. placeholder="请选择"
  737. >
  738. <el-option label="未绑定" value="1"></el-option>
  739. <el-option label="已绑定" value="0"></el-option>
  740. </el-select>
  741. </el-form-item>
  742. <el-form-item>
  743. <el-button type="primary" @click="searchHouse">查询</el-button>
  744. <el-button type="primary" @click="resetHouse">重置</el-button>
  745. </el-form-item>
  746. </el-form>
  747. <!-- table -->
  748. <div>
  749. <el-table
  750. :data="housedata"
  751. ref="multipleTable"
  752. @selection-change="handleSelectionChange1"
  753. border
  754. style="width: 100%"
  755. :header-cell-style="{ textAlign: 'center' }"
  756. :cell-style="{ textAlign: 'center' }"
  757. >
  758. <el-table-column type="selection" width="55"> </el-table-column>
  759. <el-table-column prop="propertyName" label="楼盘">
  760. </el-table-column>
  761. <el-table-column label="省市">
  762. <template slot-scope="{ row }">
  763. {{ row.provinceName || "--" }}-{{ row.cityName || "--" }}
  764. </template>
  765. </el-table-column>
  766. <el-table-column label="绑定">
  767. <template slot-scope="{ row }">
  768. {{ row.isSelected == 0 ? "已绑定" : "未绑定" }}
  769. </template>
  770. </el-table-column>
  771. <!-- <el-table-column
  772. prop="address"
  773. label="操作">
  774. <template slot-scope="scope">
  775. <el-button @click="bindhouse(scope.row)" type="text" size="small">{{scope.row.isSelected==0?'解绑':'绑定'}}</el-button>
  776. </template>
  777. </el-table-column> -->
  778. </el-table>
  779. <el-pagination
  780. style="text-align: center"
  781. background
  782. @size-change="handleSizeChange1"
  783. @current-change="handleCurrentChange1"
  784. :current-page.sync="page1.current"
  785. :page-size="page1.size"
  786. :total="page1.total"
  787. >
  788. </el-pagination>
  789. </div>
  790. </div>
  791. <div v-else class="cons">
  792. <!--区域楼盘绑定 -->
  793. <!-- 2 -->
  794. <div>
  795. <div class="area">
  796. <div style="line-height: 30px">选择大区:</div>
  797. <el-select
  798. v-model="managerStr"
  799. clearable
  800. collapse-tags
  801. multiple
  802. placeholder="请选择"
  803. @change="managerChange"
  804. >
  805. <!-- 选择大区 -->
  806. <el-option
  807. v-for="item1 in managerList"
  808. :key="item1.id"
  809. :label="item1.areaName"
  810. :value="item1.id"
  811. :disabled="item1.disabled"
  812. >
  813. </el-option>
  814. </el-select>
  815. </div>
  816. <div class="province" style="margin-top: 10px">
  817. <div class="left" style="line-height: 30px">选择城市:</div>
  818. <div class="right">
  819. <div v-for="(item, index) in firstList" :key="item.id">
  820. <div style="display: flex; margin: 5px">
  821. <div style="line-height: 32px; margin-right: 10px">
  822. {{ item.name }}
  823. </div>
  824. <el-select
  825. v-model="item.cityIds"
  826. clearable
  827. multiple
  828. placeholder="默认为全部"
  829. style="width: 400px"
  830. >
  831. <el-option
  832. v-for="item1 in item.cityAreaList"
  833. :key="item1.id"
  834. :label="item1.name"
  835. :value="item1.id"
  836. >
  837. </el-option>
  838. </el-select>
  839. <div
  840. style="line-height: 30px; margin-left: 10px; cursor: pointer;"
  841. @click="delArea(index, 0)"
  842. >
  843. 取消
  844. </div>
  845. </div>
  846. </div>
  847. <div v-for="(item, index) in thirdList" :key="item.id">
  848. <div style="display: flex">
  849. <div>
  850. <el-select
  851. v-model="item.areaId"
  852. clearable
  853. :disabled="item.disabled"
  854. @change="areaChange(index, 0)"
  855. placeholder="请选择"
  856. style="width: 200px; margin-right: 20px"
  857. >
  858. <el-option
  859. v-for="item1 in secondList"
  860. :key="item1.id"
  861. :label="item1.name"
  862. :value="item1.id"
  863. :disabled="item1.disabled"
  864. >
  865. </el-option>
  866. </el-select>
  867. </div>
  868. <el-select
  869. v-model="item.cityIds"
  870. clearable
  871. multiple
  872. placeholder="默认为全部"
  873. style="width: 400px"
  874. >
  875. <el-option
  876. v-for="item1 in item.arr"
  877. :key="item1.id"
  878. :label="item1.name"
  879. :value="item1.id"
  880. >
  881. </el-option>
  882. </el-select>
  883. <div
  884. style="line-height: 30px; margin-left: 10px;cursor: pointer;"
  885. @click="delArea(index, 1)"
  886. >
  887. 取消
  888. </div>
  889. </div>
  890. </div>
  891. <!-- 当没有选择区域的时候 -->
  892. <div v-if="managerStr.length == 0">
  893. <div v-for="(item, index) in fourthList" :key="item.id">
  894. <div style="display: flex">
  895. <div>
  896. <el-select
  897. v-if="!item.cityAreaList"
  898. v-model="item.areaId"
  899. clearable
  900. :disabled="item.disabled"
  901. @change="areaChange(index, 1)"
  902. placeholder="请选择"
  903. style="width: 200px; margin-right: 20px"
  904. >
  905. <el-option
  906. v-for="item1 in allCityList"
  907. :key="item1.id"
  908. :label="item1.name"
  909. :value="item1.id"
  910. :disabled="item1.disabled"
  911. >
  912. </el-option>
  913. </el-select>
  914. <div v-else style="line-height: 32px; margin-right: 10px">
  915. {{ item.name }}
  916. </div>
  917. </div>
  918. <el-select
  919. v-model="item.cityIds"
  920. clearable
  921. multiple
  922. placeholder="默认为全部"
  923. style="width: 400px"
  924. >
  925. <el-option
  926. v-for="item1 in item.arr"
  927. :key="item1.id"
  928. :label="item1.name"
  929. :value="item1.id"
  930. >
  931. </el-option>
  932. </el-select>
  933. <div
  934. style="line-height: 30px; margin-left: 10px; cursor: pointer;"
  935. @click="delArea(index, 1)"
  936. >
  937. 取消
  938. </div>
  939. </div>
  940. </div>
  941. </div>
  942. <div style="line-height: 30px; cursor: pointer;" @click="addArea">添加条件</div>
  943. </div>
  944. </div>
  945. </div>
  946. </div>
  947. <div style="display: flex; justify-content: space-around">
  948. <el-button @click="houseVisible = false">取 消</el-button>
  949. <el-button type="primary" @click="addHouse">确 定</el-button>
  950. </div>
  951. </el-dialog>
  952. </div>
  953. </template>
  954. <script>
  955. import { getAreaList } from "@/api/modules/api";
  956. import {
  957. addObj,
  958. delObj,
  959. delObj1,
  960. del1Obj,
  961. fetchList,
  962. putObj,
  963. } from "@/api/admin/user";
  964. import { getStore, setStore } from "@/util/store";
  965. import { deptRoleList } from "@/api/admin/role";
  966. import { fetchTree } from "@/api/admin/dept";
  967. import { tableOption } from "@/const/crud/admin/user";
  968. import { mapGetters } from "vuex";
  969. import sidebarItemVue from "../../../page/index/sidebar/sidebarItem.vue";
  970. export default {
  971. name: "SysUser",
  972. data() {
  973. var validatePass = (rule, value, callback) => {
  974. if (value === "") {
  975. callback(new Error("请输入手机号"));
  976. } else {
  977. if (value) {
  978. if (!/^1[3456789]\d{9}$/.test(value)) {
  979. // alert("手机号码不合法,请重新输入");
  980. callback(new Error("手机号格式错误,请重新输入"));
  981. }
  982. }
  983. callback();
  984. }
  985. };
  986. return {
  987. props: {
  988. lazy: true,
  989. async lazyLoad(node, resolve) {
  990. const { level } = node;
  991. if (level == 0) {
  992. // console.log(23);
  993. const { data } = await getAreaList({ parentId: 0 }); //获取省接口
  994. var nodes = data.map((item) => {
  995. return {
  996. value: item.id,
  997. label: item.name,
  998. leaf: false,
  999. };
  1000. });
  1001. resolve(nodes);
  1002. } else if (level == 1) {
  1003. const { data } = await getAreaList({ parentId: node.data.value }); //获取市接口
  1004. var nodes = data.map((item) => {
  1005. return {
  1006. value: item.id,
  1007. label: item.name,
  1008. leaf: true,
  1009. };
  1010. });
  1011. resolve(nodes);
  1012. }
  1013. },
  1014. },
  1015. managerStr: [],
  1016. identityList: [],
  1017. choseFlag: true,
  1018. // 获取的区域列表
  1019. arealist: [],
  1020. parentAndKidList: [],
  1021. originalData: [],
  1022. firstList: [],
  1023. secondList: [],
  1024. thirdList: [],
  1025. fourthList: [],
  1026. allCityList: [],
  1027. managerList: [],
  1028. houseUserRoleType: "",
  1029. bindFlag: "0",
  1030. treeClick: "", //点击样式
  1031. keywork: "", //搜索关键字
  1032. selectLabel: "", //下拉框显示名称
  1033. selectValue: "",
  1034. orgFlag: false,
  1035. roleFlag: false,
  1036. identityFlag: false,
  1037. editVisible: false,
  1038. agentFlag: false,
  1039. treeProps: {
  1040. children: "children",
  1041. label: "label",
  1042. }, //下拉框显示ID
  1043. searchForm: {},
  1044. housedata: [],
  1045. treeOption: {
  1046. nodeKey: "id",
  1047. addBtn: false,
  1048. menu: false,
  1049. props: {
  1050. label: "name",
  1051. value: "id",
  1052. },
  1053. },
  1054. defaultProps1: {
  1055. label: "name",
  1056. value: "aid",
  1057. },
  1058. treeData: [],
  1059. option: tableOption,
  1060. treeDeptData: [],
  1061. checkedKeys: [],
  1062. roleProps: {
  1063. label: "roleName",
  1064. value: "roleId",
  1065. },
  1066. defaultProps: {
  1067. label: "name",
  1068. value: "id",
  1069. },
  1070. page: {
  1071. total: 0, // 总页数
  1072. current: 1, // 当前页数
  1073. size: 10, // 每页显示多少条,
  1074. isAsc: false, // 是否倒序
  1075. },
  1076. page1: {
  1077. total: 0, // 总页数
  1078. current: 1, // 当前页数
  1079. size: 10, // 每页显示多少条,
  1080. isAsc: false, // 是否倒序
  1081. },
  1082. list: [],
  1083. listLoading: true,
  1084. role: [],
  1085. houseIdList: [],
  1086. agentList: [],
  1087. codeOrg: "",
  1088. form: {
  1089. name: "", //用户名
  1090. username: "", //手机号
  1091. sex: "0", //性别
  1092. password: "", //密码
  1093. orgType: "", //组织类型
  1094. roleId: "", //角色id
  1095. agentId: "", //代理商id
  1096. orgCode: "", //公司标识
  1097. userRoleType: "", //身份
  1098. deptId: "", //部门
  1099. houseId: "",
  1100. showPhoneStatus: 0, //手机号显隐
  1101. },
  1102. formTwo: {
  1103. username: "", //手机号
  1104. userRoleType: "", //身份
  1105. deptId: "", //部门
  1106. roleId: "", //角色
  1107. newRoleId: "",
  1108. showPhoneStatus: 0, //手机号显隐
  1109. userRoleType: "",
  1110. },
  1111. userRoleTypeList: [],
  1112. userRoleList: [],
  1113. phoneFlag: false,
  1114. rolesOptions: [],
  1115. checkHouse: [],
  1116. searchMsg: {
  1117. flag: "1",
  1118. name: "", //用户名
  1119. username: "", //登录名
  1120. orgName: "", //所属组织
  1121. },
  1122. searchMsg1: {
  1123. flag: "1",
  1124. name: "", //用户名
  1125. username: "", //登录名
  1126. orgName: "", //所属组织
  1127. userRoleType: "", //用户身份
  1128. lockFlag: "", //状态
  1129. queryOrgType: "", //组织类型
  1130. },
  1131. searchhouseMsg: {
  1132. propertyName: "",
  1133. isSelected: "",
  1134. provinceId: "",
  1135. cityId: "",
  1136. },
  1137. sign: "", //用户标示,0系统用户,1公司用户 2运营用户
  1138. roleNameList: [],
  1139. editFlag: false,
  1140. addFlag: true,
  1141. userList: [],
  1142. provice: [],
  1143. orgNameList: [],
  1144. RoleByOrgCodeList: [],
  1145. tableData: [],
  1146. tableData1: [],
  1147. checkRole: [],
  1148. code: {},
  1149. formTitle: "新增",
  1150. deptList: [],
  1151. dialogFormVisible: false,
  1152. houseVisible: false,
  1153. deptTreeList: [], //部门树
  1154. roelFlag: false,
  1155. losorgType: localStorage.getItem("orgType"),
  1156. systemFlag: true, //判断是否为系统用户
  1157. accountId: "",
  1158. passwordForm: {
  1159. password: "",
  1160. userId: null,
  1161. },
  1162. phoneForm: {
  1163. phone: "",
  1164. },
  1165. phoneVisible: false, //验证手机号
  1166. userRoleFlag: true,
  1167. passwordVisible: false,
  1168. dialogFormVisibleTwo: false,
  1169. orgList: [],
  1170. phoneRules: {
  1171. phone: [
  1172. { required: true, message: "请填写手机号", trigger: "blur" },
  1173. { validator: validatePass, trigger: "blur" },
  1174. ],
  1175. },
  1176. passwordRules: {
  1177. password: [
  1178. { required: true, message: "请填写密码", trigger: "blur" },
  1179. { min: 6, max: 11, message: "长度在 6 到 11 位", trigger: "blur" },
  1180. ],
  1181. },
  1182. rulesTwo: {
  1183. newRoleId: [{ required: true, message: "请选择角色", trigger: "blur" }],
  1184. },
  1185. rules: {
  1186. username: [
  1187. { required: true, message: "请填写登录手机", trigger: "blur" },
  1188. ],
  1189. name: [{ required: true, message: "请填写用户名", trigger: "blur" }],
  1190. password: [
  1191. { required: true, message: "请填写密码", trigger: "blur" },
  1192. { min: 6, max: 11, message: "长度在 6 到 11 位", trigger: "blur" },
  1193. ],
  1194. orgType: [
  1195. { required: true, message: "请选择组织类型", trigger: "blur" },
  1196. ],
  1197. agentId: [{ required: true, message: "请选择代理商", trigger: "blur" }],
  1198. orgCode: [{ required: true, message: "请选择公司", trigger: "blur" }],
  1199. roleId: [{ required: true, message: "请选择角色", trigger: "blur" }],
  1200. userRoleType: [
  1201. { required: true, message: "请选择角色身份", trigger: "blur" },
  1202. ],
  1203. },
  1204. // 数据权限
  1205. // sys_user_add:true,
  1206. // sys_user_edit:true,
  1207. // sys_user_del:true,
  1208. // resetPassword:true,
  1209. };
  1210. },
  1211. computed: {
  1212. ...mapGetters(["permissions"]),
  1213. },
  1214. watch: {
  1215. choseFlag(newval, oldval) {
  1216. console.log(newval, oldval);
  1217. this.page.current = 1;
  1218. this.roleList();
  1219. if (newval) {
  1220. // 注册用户
  1221. } else {
  1222. //组织用户
  1223. }
  1224. },
  1225. role() {
  1226. this.form.role = this.role;
  1227. },
  1228. keywork(val) {
  1229. // console.log(val);
  1230. this.$refs.tree.filter(val);
  1231. },
  1232. },
  1233. created() {
  1234. // 权限
  1235. this.sys_user_add = this.permissions["sys_user_add"];
  1236. this.sys_user_edit = this.permissions["sys_user_edit"];
  1237. this.sys_user_edit1 = this.permissions["sys_user_edit1"];
  1238. this.sys_user_del = this.permissions["sys_user_del"];
  1239. this.resetPassword = this.permissions["resetPassword"];
  1240. this.sys_user_choseHouse = this.permissions["sys_user_choseHouse"];
  1241. this.sys_user_bind = this.permissions["sys_user_bind"];
  1242. // return
  1243. // 获取用户信息
  1244. let info = getStore({ name: "userInfo" });
  1245. // this.sign=info.sign
  1246. // this.orgCode = info.orgCode;
  1247. this.orgCode = localStorage.getItem('orgCode');
  1248. // 权限判断
  1249. // 当他是系统用户时,显示所有,除系统用户之外只显示组织用户
  1250. if (localStorage.getItem("orgType") != 0) {
  1251. this.systemFlag = false;
  1252. this.choseFlag = false;
  1253. } else {
  1254. this.systemFlag = true;
  1255. }
  1256. // console.log(info);
  1257. this.roleList(); //table 列表
  1258. // this.userDeptTree()// 获取部门树
  1259. this.deptGetOrgList(); //获取公司列表
  1260. this.getAgentList(); //获取代理商列表
  1261. this.userDict(
  1262. {
  1263. dictKey: localStorage.getItem('orgType'),
  1264. dictType: 3,
  1265. },
  1266. "userRoleList"
  1267. );
  1268. },
  1269. methods: {
  1270. // 区域改变
  1271. managerChange() {
  1272. console.log(this.managerStr);
  1273. // 初始化数据
  1274. this.firstList = [];
  1275. this.secondList = [];
  1276. this.thirdList = [];
  1277. this.fourthList = [];
  1278. if (this.managerStr.length == 0) {
  1279. return;
  1280. }
  1281. this.getParentAndKidList();
  1282. },
  1283. // 通过地区串获取省市
  1284. getParentAndKidList() {
  1285. this.$api.api
  1286. .getParentAndKidList({
  1287. areaIds: this.managerStr.join(","),
  1288. })
  1289. .then((res) => {
  1290. // console.log(res)
  1291. // 获取区域下的省数据,对数据进行处理,首先将数据分为三个数组,一个是用来存储没有多选框的,一个用来存储有多选的,一个原始数据
  1292. // 原始数据,用来比对数据和添加使用
  1293. this.originalData = res.data;
  1294. // 渲染第一个是text的数组
  1295. // 这里不考虑禁用
  1296. res.data.map((item) => {
  1297. item.cityIds = "";
  1298. });
  1299. this.firstList = res.data;
  1300. // 初始化数据
  1301. this.secondList = [];
  1302. this.thirdList = [];
  1303. this.fourthList = [];
  1304. });
  1305. },
  1306. // 删除区域
  1307. delArea(idx, flag) {
  1308. console.log(flag, idx);
  1309. // 第一个删除
  1310. if (flag == 0) {
  1311. // 先获取删除数组的内容,将其内容放到第三个数组里面
  1312. let obj = this.firstList[idx];
  1313. // obj.areaId=''
  1314. // // 这里需要有禁用选项
  1315. // obj.disabled=false
  1316. // // 给定一个空数组,当他的选择时将数组内容改变
  1317. // obj.children=[]
  1318. this.secondList.push(obj);
  1319. console.log(this.secondList);
  1320. // 删除数组的指定项
  1321. this.firstList.splice(idx, 1);
  1322. } else {
  1323. let obj = this.fourthList[idx];
  1324. this.secondList.push(obj);
  1325. // console.log(this.fourthList);
  1326. // 删除数组的指定项
  1327. this.fourthList.splice(idx, 1);
  1328. // console.log(this.fourthList);
  1329. }
  1330. },
  1331. // 点击添加时的操作
  1332. addArea() {
  1333. // 这是第一种情况
  1334. if (this.managerStr.length > 0) {
  1335. // 先判断第二个数组里面是否有数据,有的时候就可以添加没的时候提示
  1336. if (this.secondList.length == 0) {
  1337. this.$message.warning("没有更多啦!");
  1338. return;
  1339. }
  1340. let num = 0;
  1341. this.secondList.map((item) => {
  1342. if (item.disabled) {
  1343. num++;
  1344. }
  1345. });
  1346. if (num == this.secondList.length) {
  1347. this.$message.warning("不能选择更多啦");
  1348. return;
  1349. }
  1350. // 在判断最后一项是否选择如果没选择则返回
  1351. if (
  1352. this.thirdList.length > 0 &&
  1353. this.thirdList[this.thirdList.length - 1].areaId == ""
  1354. ) {
  1355. this.$message.warning("请选择最后一项在说");
  1356. return;
  1357. }
  1358. // 然后将所有的都变为禁用
  1359. // this.secondList.map(item=>{
  1360. // item.disabled=true
  1361. // })
  1362. this.thirdList.map((item) => {
  1363. item.disabled = true;
  1364. });
  1365. // 在数组里面放入一个对象
  1366. let obj = {
  1367. cityIds: "",
  1368. areaId: "",
  1369. arr: [],
  1370. disabled: false,
  1371. };
  1372. this.thirdList.push(obj);
  1373. } else {
  1374. if (
  1375. this.fourthList.length > 0 &&
  1376. this.fourthList[this.fourthList.length - 1].areaId == ""
  1377. ) {
  1378. this.$message.warning("请选择最后一项在说");
  1379. return;
  1380. }
  1381. this.fourthList.map((item) => {
  1382. item.disabled = true;
  1383. });
  1384. // 第二种情况,当没选择的时候
  1385. let obj = {
  1386. cityIds: "",
  1387. areaId: "",
  1388. arr: [],
  1389. disabled: false,
  1390. };
  1391. this.fourthList.push(obj);
  1392. }
  1393. },
  1394. houseClose() {
  1395. this.managerStr = [];
  1396. this.firstList = [];
  1397. this.secondList = [];
  1398. this.thirdList = [];
  1399. this.fourthList = [];
  1400. this.bindFlag = "0";
  1401. this.provice = [];
  1402. this.searchhouseMsg = {
  1403. orgName: "",
  1404. isSelected: "",
  1405. provinceId: "",
  1406. cityId: "",
  1407. };
  1408. },
  1409. // 选择的区域地区改变时给数组的arr赋值
  1410. async areaChange(idx, flag) {
  1411. console.log(idx);
  1412. // 第一种情况
  1413. if (flag == 0) {
  1414. // this.thirdList[idx].areaId
  1415. // 循环数组获取到当前区域id下的数据给定第三个数组
  1416. let num = this.secondList.findIndex(
  1417. (item) => item.id == this.thirdList[idx].areaId
  1418. );
  1419. if (num != -1) {
  1420. this.thirdList[idx].arr = this.secondList[num].cityAreaList;
  1421. // this.secondList.splice(num,1)
  1422. this.secondList[num].disabled = true;
  1423. }
  1424. } else {
  1425. // 获取选中的id并且赋值
  1426. let num = this.allCityList.findIndex(
  1427. (item) => item.id == this.fourthList[idx].areaId
  1428. );
  1429. if (num != -1) {
  1430. this.fourthList[idx].arr = await this.getValueByCondition(
  1431. this.fourthList[idx].areaId
  1432. );
  1433. // this.secondList.splice(num,1)
  1434. this.allCityList[num].disabled = true;
  1435. }
  1436. }
  1437. },
  1438. // 获取所有省
  1439. async getValueByCondition(e) {
  1440. let res = await this.$api.api.getValueByCondition({ pid: e });
  1441. // console.log(res)
  1442. return res.data;
  1443. },
  1444. // 下一步
  1445. nextshow() {
  1446. let that = this;
  1447. this.$refs.phoneForm.validate((valid) => {
  1448. if (valid) {
  1449. // 验证电话号码
  1450. this.$api.api.verPhone(this.phoneForm.phone).then((res) => {
  1451. console.log(res);
  1452. // 判断数据是否已经有了
  1453. if (res.data) {
  1454. // 由用户
  1455. this.$api.api
  1456. .userVerify({
  1457. orgType: localStorage.getItem("orgType"),
  1458. accountId: res.data.sysUser.accountId,
  1459. username: res.data.sysUser.username,
  1460. agentId: localStorage.getItem("agentId"),
  1461. orgCode: localStorage.getItem("orgCode"),
  1462. })
  1463. .then((res1) => {
  1464. // console.log(res1);
  1465. this.phoneFlag = true;
  1466. // console.log(res.data.sysUser);
  1467. this.form.name = res.data.sysUser.name;
  1468. this.form.username = res.data.sysUser.username;
  1469. this.form.sex = res.data.sysUser.sex;
  1470. this.phoneVisible = false;
  1471. this.dialogFormVisible = true;
  1472. })
  1473. .catch((err) => {
  1474. console.log(err);
  1475. });
  1476. } else {
  1477. // 没有用户
  1478. console.log("没有用户");
  1479. this.form.username = this.phoneForm.phone;
  1480. this.phoneFlag = false;
  1481. this.phoneVisible = false;
  1482. this.dialogFormVisible = true;
  1483. }
  1484. });
  1485. // return
  1486. }
  1487. });
  1488. },
  1489. search() {
  1490. this.page.current=1;
  1491. console.log(this.searchMsg, "搜索内容1");
  1492. // return
  1493. this.roleList();
  1494. },
  1495. search1() {
  1496. this.page.current = 1;
  1497. console.log(this.searchMsg1, "搜索内容2");
  1498. // return
  1499. this.roleList();
  1500. },
  1501. flagchange(val) {
  1502. // if(val==1){
  1503. // }
  1504. this.searchMsg.name = "";
  1505. this.searchMsg.username = "";
  1506. },
  1507. flagchange1() {
  1508. this.searchMsg1.name = "";
  1509. this.searchMsg1.username = "";
  1510. },
  1511. reset() {
  1512. this.page.current=1;
  1513. this.searchMsg = {
  1514. flag: "1",
  1515. name: "", //用户名
  1516. username: "", //登录名
  1517. orgName: "", //所属组织
  1518. };
  1519. this.roleList();
  1520. },
  1521. reset1() {
  1522. this.page.current=1;
  1523. this.searchMsg1 = {
  1524. flag: "1",
  1525. name: "", //用户名
  1526. username: "", //登录名
  1527. orgName: "", //所属组织
  1528. userRoleType: "", //用户身份
  1529. lockFlag: "", //状态
  1530. queryOrgType: "", //组织类型
  1531. };
  1532. this.roleList();
  1533. },
  1534. // 绑定方式改变
  1535. radioChange(e) {
  1536. console.log(e);
  1537. this.firstList = [];
  1538. this.secondList = [];
  1539. this.thirdList = [];
  1540. this.fourthList = [];
  1541. this.managerStr = [];
  1542. this.provice = [];
  1543. this.searchhouseMsg = {
  1544. propertyName: "",
  1545. isSelected: "",
  1546. provinceId: "",
  1547. cityId: "",
  1548. };
  1549. },
  1550. // 查询楼盘
  1551. searchHouse() {
  1552. this.gethouseList();
  1553. },
  1554. // /清空楼盘
  1555. resetHouse() {
  1556. this.searchhouseMsg = {
  1557. propertyName: "",
  1558. isSelected: "",
  1559. provinceId: "",
  1560. cityId: "",
  1561. };
  1562. this.provice = [];
  1563. this.gethouseList();
  1564. },
  1565. // 绑定楼盘
  1566. addHouse() {
  1567. // 楼盘
  1568. if (this.bindFlag == 0) {
  1569. if (this.checkHouse.length == 0) {
  1570. this.houseVisible = false;
  1571. return;
  1572. }
  1573. this.$api.api
  1574. .saveHouse({
  1575. accountId: this.accountId,
  1576. houseIds: this.checkHouse.join(","),
  1577. orgCode: this.code.orgCode,
  1578. })
  1579. .then((res) => {
  1580. console.log(res);
  1581. this.houseVisible = false;
  1582. this.roleList();
  1583. });
  1584. } else {
  1585. // 省市json串
  1586. let areaJsonString = [];
  1587. // 地区id拼成串
  1588. let areaIds = this.managerStr.join(",");
  1589. // 区域选择
  1590. // 两种情况
  1591. if (areaIds) {
  1592. // 当选择的是区域的时候
  1593. this.firstList.map((item) => {
  1594. let obj = {
  1595. // 省
  1596. provinceList: item.id,
  1597. // 市
  1598. cityList: item.cityIds.join(","),
  1599. };
  1600. areaJsonString.push(obj);
  1601. });
  1602. this.thirdList.map((item) => {
  1603. let obj = {
  1604. // 省
  1605. provinceList: item.areaId,
  1606. // 市
  1607. cityList: item.cityIds.join(","),
  1608. };
  1609. areaJsonString.push(obj);
  1610. });
  1611. } else {
  1612. this.fourthList.map((item) => {
  1613. let obj = {
  1614. // 省
  1615. provinceList: item.areaId,
  1616. // 市
  1617. cityList: item.cityIds.join(","),
  1618. };
  1619. areaJsonString.push(obj);
  1620. });
  1621. }
  1622. if (areaJsonString.length == 0) {
  1623. this.houseVisible = false;
  1624. return;
  1625. }
  1626. // console.log(areaJsonString,areaIds,'数据')
  1627. // return
  1628. this.$api.api
  1629. .areaAdd({
  1630. accountId: this.accountId,
  1631. areaJsonString: JSON.stringify(areaJsonString),
  1632. orgCode: this.code.orgCode,
  1633. areaIds,
  1634. })
  1635. .then((res) => {
  1636. console.log(res);
  1637. this.houseVisible = false;
  1638. this.roleList();
  1639. });
  1640. }
  1641. },
  1642. // 楼盘绑定解绑
  1643. // bindhouse(e){
  1644. // // if(e.isSelected)
  1645. // this.$api.api.saveHouse()
  1646. // .then(res=>{
  1647. // })
  1648. // },
  1649. // 获取用户列表
  1650. roleList() {
  1651. // console.log(this.searchMsg1);
  1652. // return
  1653. if (this.choseFlag) {
  1654. let orgId = "";
  1655. if (localStorage.getItem("orgType") == 0) {
  1656. orgId = "";
  1657. } else if (localStorage.getItem("orgType") == 1) {
  1658. orgId = localStorage.getItem("agentId");
  1659. } else {
  1660. orgId = localStorage.getItem("orgCode");
  1661. }
  1662. // 注册用户列表
  1663. this.$api.api
  1664. .registerUserList({
  1665. ...this.page,
  1666. ...this.searchMsg,
  1667. orgType: localStorage.getItem("orgType"),
  1668. orgId,
  1669. })
  1670. .then((res) => {
  1671. // console.log(res);
  1672. if (res.code == 0) {
  1673. this.tableData = res.data.records;
  1674. this.page.total = res.data.total;
  1675. } else {
  1676. this.$message.waring(res.msg);
  1677. }
  1678. });
  1679. } else {
  1680. // 组织用户列表
  1681. this.$api.api
  1682. .orgUserList({
  1683. ...this.page,
  1684. ...this.searchMsg1,
  1685. orgType: localStorage.getItem("orgType"),
  1686. orgCode: localStorage.getItem("orgCode"),
  1687. agentId: localStorage.getItem("agentId"),
  1688. houseId: localStorage.getItem("houseId"),
  1689. })
  1690. .then((res) => {
  1691. // console.log(res);
  1692. if (res.code == 0) {
  1693. this.tableData1 = res.data.records;
  1694. this.page.total = res.data.total;
  1695. } else {
  1696. this.$message.waring(res.msg);
  1697. }
  1698. });
  1699. }
  1700. },
  1701. // 获取部门树
  1702. userDeptTree() {
  1703. this.$api.api.userDeptTree().then((res) => {
  1704. // console.log(res);
  1705. if (res.code == 0) {
  1706. this.deptTreeList = res.data;
  1707. this.codeOrg = res.data[0].orgCode;
  1708. }
  1709. });
  1710. },
  1711. // 去楼盘管理
  1712. async gochosehouse(row) {
  1713. console.log(row);
  1714. this.code = row;
  1715. this.houseUserRoleType = row.userRoleType;
  1716. this.accountId = row.accountId;
  1717. this.houseVisible = true;
  1718. // 判断是否有绑定以及绑定方式
  1719. // console.log(row.selectHouseType)
  1720. if (row.selectHouseType == 1) {
  1721. console.log("这里是单个楼盘勾选");
  1722. this.bindFlag = "0";
  1723. }
  1724. else if (row.selectHouseType == 2) {
  1725. this.bindFlag = "1";
  1726. console.log("这里是区域选择");
  1727. this.userAreaFind(row.accountId, row.username);
  1728. }else{
  1729. this.bindFlag = "0";
  1730. }
  1731. this.gethouseList();
  1732. // 获取区域列表
  1733. this.areamanagerList(row.orgCode);
  1734. // 获取所有省列表
  1735. // console.log(await this.getValueByCondition(0))
  1736. this.allCityList = await this.getValueByCondition(0);
  1737. },
  1738. userAreaFind(accountId, username) {
  1739. this.$api.api
  1740. .userAreaFind({
  1741. accountId,
  1742. username,
  1743. })
  1744. .then((res) => {
  1745. console.log(res);
  1746. if (res.data.flag == "true") {
  1747. // 区域
  1748. // 给区域多选赋值,同时列表渲染给第一个数组firstList
  1749. this.managerStr = [];
  1750. res.data.user.areaIds.split(",").map((item) => {
  1751. this.managerStr.push(item / 1);
  1752. });
  1753. this.firstList = res.data.area;
  1754. this.firstList.map((item) => {
  1755. let arr = [];
  1756. if (item.cityIds == "empty") {
  1757. return;
  1758. } else {
  1759. item.cityIds = item.cityIds.split(",").map(Number);
  1760. }
  1761. // console.log(arr);
  1762. });
  1763. } else {
  1764. // 当不是区域的时候
  1765. // 数据由于最后的判断原因应该给fourthlist
  1766. this.fourthList = res.data.area;
  1767. this.fourthList.map((item) => {
  1768. // let arr = [];
  1769. item.areaId = item.id;
  1770. if (item.cityIds == "empty") {
  1771. // 为所有,不做任何操作
  1772. } else {
  1773. item.cityIds = item.cityIds.split(",").map(Number);
  1774. console.log(item.cityIds);
  1775. // item.arr = item.cityAreaList;
  1776. }
  1777. item.arr = item.cityAreaList;
  1778. // 再次对数据allCityList数据进行禁用处理
  1779. let num = this.allCityList.findIndex(
  1780. (item1) => item1.id == item.areaId
  1781. );
  1782. if (num != -1) {
  1783. // this.secondList.splice(num,1)
  1784. this.allCityList[num].disabled = true;
  1785. }
  1786. // console.log(arr);
  1787. });
  1788. }
  1789. });
  1790. },
  1791. // 获取区域
  1792. areamanagerList(orgCode) {
  1793. this.$api.api
  1794. .areamanagerList({
  1795. orgCode,
  1796. })
  1797. .then((res) => {
  1798. // console.log(res)
  1799. this.managerList = res.data.records;
  1800. });
  1801. },
  1802. // 获取楼盘列表
  1803. gethouseList() {
  1804. this.$api.api
  1805. .houseListWhenAddUser({
  1806. orgType: localStorage.getItem("orgType"),
  1807. accountId: this.accountId,
  1808. orgCode: this.orgCode,
  1809. current: this.page1.current,
  1810. size: this.page1.size,
  1811. ...this.searchhouseMsg,
  1812. })
  1813. .then((res) => {
  1814. // console.log(res)
  1815. this.page1.total = res.data.total;
  1816. this.housedata = res.data.records;
  1817. let arr = [];
  1818. res.data.records.map((item) => {
  1819. if (item.isSelected == 0) {
  1820. arr.push(item);
  1821. }
  1822. });
  1823. // console.log(arr,'123');
  1824. if (arr.length != 0 && this.bindFlag == 0) {
  1825. setTimeout(() => {
  1826. arr.map((item) => {
  1827. this.$refs.multipleTable.toggleRowSelection(item);
  1828. });
  1829. }, 50);
  1830. }
  1831. });
  1832. },
  1833. // 获取用户信息
  1834. getUserMsg(userId) {
  1835. this.$api.api.getUserMsg({ userId }).then((res) => {
  1836. console.log(res);
  1837. });
  1838. },
  1839. // 多选
  1840. handleSelectionChange(e) {
  1841. this.checkRole = [];
  1842. console.log(e);
  1843. e.map((item) => {
  1844. this.checkRole.push(item.id);
  1845. });
  1846. },
  1847. handleSelectionChange1(e) {
  1848. this.checkHouse = [];
  1849. console.log(e);
  1850. if (this.houseUserRoleType == 6 && e.length > 1) {
  1851. // 单选
  1852. // this.$refs.multipleTable.clearSelection();
  1853. let idx = this.housedata.findIndex((item) => item.id == e[0].id);
  1854. if (idx != -1) {
  1855. this.$refs.multipleTable.toggleRowSelection(this.housedata[idx]);
  1856. }
  1857. this.$message.warning("您只能选择一个楼盘");
  1858. return;
  1859. }
  1860. e.map((item) => {
  1861. this.checkHouse.push(item.id);
  1862. });
  1863. },
  1864. delIds() {
  1865. console.log(this.checkRole);
  1866. this.$api.api
  1867. .userDelByIds({ ids: this.checkRole.join(",") })
  1868. .then((res) => {
  1869. console.log(res);
  1870. if (res.code == 0) {
  1871. this.$message.success("批量删除成功");
  1872. this.roleList();
  1873. }
  1874. });
  1875. },
  1876. addRole() {
  1877. this.phoneVisible = true;
  1878. // this.dialogFormVisible=true
  1879. this.addFlag = true;
  1880. this.editFlag = false;
  1881. this.form.orgType = localStorage.getItem("orgType") / 1;
  1882. this.typeChange(this.form.orgType);
  1883. this.formTitle = "添加";
  1884. },
  1885. // 编辑
  1886. editRole(row, flag) {
  1887. this.getUserMsg(row.username);
  1888. flag ? (this.formTitle = "查看") : (this.formTitle = "编辑");
  1889. this.addFlag = false;
  1890. this.editFlag = flag;
  1891. this.dialogFormVisible = true;
  1892. },
  1893. // 查询用户信息
  1894. getUserMsg(username) {
  1895. this.userRoleFlag = false;
  1896. this.$api.api.getUserMsg({ username }).then((res) => {
  1897. console.log(res);
  1898. this.form = res.data.user;
  1899. // 公司id
  1900. // this.form.orgId = res.data.role.orgId;
  1901. // res.data.houseList.map((item) => {
  1902. // this.houseIdList.push(item.id);
  1903. // });
  1904. // console.log(this.houseIdList);
  1905. // 更改类型
  1906. // this.codeOrg = res.data.org.orgCode;
  1907. // this.form.houseIdList = this.houseIdList.join(",");
  1908. // this.form.userRoleId = res.data.role.roleId;
  1909. this.form.userRoleType = res.data.user.userRoleType / 1;
  1910. this.form.deptId = res.data.user.id;
  1911. // this.form.deptName = res.data.org.name;
  1912. // this.roleChange(res.data.org.orgCode)
  1913. console.log(this.form);
  1914. this.roelFlag = true;
  1915. });
  1916. },
  1917. // 添加
  1918. add() {
  1919. if (this.editFlag) {
  1920. this.dialogFormVisible = false;
  1921. return;
  1922. }
  1923. // console.log(this.form);
  1924. if (this.addFlag) {
  1925. this.$refs.form.validate((valid) => {
  1926. if (valid) {
  1927. if (
  1928. localStorage.getItem("orgType") == 2 ||
  1929. localStorage.getItem("orgType") == 3
  1930. ) {
  1931. // console.log(123);
  1932. this.form.orgCode = localStorage.getItem("orgCode");
  1933. }
  1934. this.$api.api.addUser(this.form).then((res) => {
  1935. console.log(res);
  1936. this.roleList();
  1937. this.dialogFormVisible = false;
  1938. // this.phoneFlag = false;
  1939. });
  1940. } else {
  1941. console.log("error submit!!");
  1942. return false;
  1943. }
  1944. });
  1945. } else {
  1946. this.$refs.form.validate((valid) => {
  1947. if (valid) {
  1948. this.$api.api.editUserMsg(this.form).then((res) => {
  1949. // console.log(res);
  1950. this.roleList();
  1951. this.dialogFormVisible = false;
  1952. // this.phoneFlag = false;
  1953. });
  1954. } else {
  1955. console.log("error submit!!");
  1956. return false;
  1957. }
  1958. });
  1959. }
  1960. },
  1961. resetForm() {
  1962. this.$refs.form.resetFields();
  1963. // this.form.deptName=''
  1964. // this.form.deptId=''
  1965. // this.form.userRoleId=''
  1966. this.form = {
  1967. name: "", //用户名
  1968. username: "", //手机号
  1969. sex: "0", //性别
  1970. password: "", //密码
  1971. orgType: "", //组织类型
  1972. houseId: "",
  1973. roleId: "", //角色id
  1974. agentId: "", //代理商id
  1975. orgCode: "", //公司标识
  1976. userRoleType: "", //身份
  1977. deptId: "",
  1978. showPhoneStatus: 0,
  1979. };
  1980. this.roelFlag = false;
  1981. this.houseIdList = [];
  1982. this.orgFlag = false;
  1983. this.roleFlag = false;
  1984. this.identityFlag = false;
  1985. this.agentFlag = false;
  1986. this.phoneFlag = false;
  1987. },
  1988. // 重置用户密码
  1989. resetPwd(row) {
  1990. // console.log(row);
  1991. this.passwordForm.userId = row.userId;
  1992. this.passwordVisible = true;
  1993. },
  1994. queryOrgTypeChange(e){
  1995. this.userDict(
  1996. {
  1997. dictKey: e,
  1998. dictType: 3,
  1999. },
  2000. "userRoleList"
  2001. );
  2002. },
  2003. editpwd() {
  2004. // console.log(this.passwordForm);
  2005. // return
  2006. this.$refs.passwordForm.validate((valid) => {
  2007. if (valid) {
  2008. this.$api.api.resetPassword(this.passwordForm).then((res) => {
  2009. // console.log(res);
  2010. if (res.code == 0) {
  2011. this.$notify.success("修改成功");
  2012. }
  2013. this.roleList();
  2014. this.passwordVisible = false;
  2015. });
  2016. }
  2017. });
  2018. },
  2019. // 删除用户信息
  2020. delRole(row) {
  2021. console.log(row);
  2022. },
  2023. startorg(row) {
  2024. this.$confirm(
  2025. "确定修改客户信息状态为" +
  2026. (row.lockFlag == 0 ? "禁用" : "启用") +
  2027. ", 是否继续?",
  2028. "提示",
  2029. {
  2030. confirmButtonText: "确定",
  2031. cancelButtonText: "取消",
  2032. type: "warning",
  2033. }
  2034. ).then(() => {
  2035. let obj = {};
  2036. obj.accountId = row.accountId;
  2037. obj.orgType = row.orgType;
  2038. obj.lockFlag = row.lockFlag == 0 ? 1 : 0;
  2039. this.$api.api.updateLockFlag(obj).then((res) => {
  2040. console.log(res);
  2041. if (res.code == 0) {
  2042. this.$notify.success("修改成功");
  2043. this.roleList();
  2044. }
  2045. });
  2046. // delObj(row.userId)
  2047. // .then(() => {
  2048. // this.list.splice(index, 1)
  2049. // this.$notify.success('删除成功')
  2050. // }).catch(() => {
  2051. // this.$notify.error('删除失败')
  2052. // })
  2053. });
  2054. },
  2055. // 修改客户信息状态
  2056. editStatus(row) {
  2057. // console.log(row);
  2058. this.$confirm(
  2059. "确定修改客户信息状态为" +
  2060. (row.showPhoneStatus == 0 ? "隐藏" : "显示") +
  2061. ", 是否继续?",
  2062. "提示",
  2063. {
  2064. confirmButtonText: "确定",
  2065. cancelButtonText: "取消",
  2066. type: "warning",
  2067. }
  2068. ).then(() => {
  2069. let obj = {};
  2070. obj.userId = row.id;
  2071. obj.showPhoneStatus = row.showPhoneStatus == 0 ? 1 : 0;
  2072. this.$api.api.updateShowPhoneStatus(obj).then((res) => {
  2073. console.log(res);
  2074. if (res.code == 0) {
  2075. this.$notify.success("修改成功");
  2076. this.roleList();
  2077. }
  2078. });
  2079. // delObj(row.userId)
  2080. // .then(() => {
  2081. // this.list.splice(index, 1)
  2082. // this.$notify.success('删除成功')
  2083. // }).catch(() => {
  2084. // this.$notify.error('删除失败')
  2085. // })
  2086. });
  2087. },
  2088. // 获取公司列表
  2089. deptGetOrgList() {
  2090. this.$api.api
  2091. .findMyOrg({ orgType: localStorage.getItem("orgType") })
  2092. .then((res) => {
  2093. console.log(res);
  2094. this.orgList = res.data;
  2095. });
  2096. },
  2097. getAgentList() {
  2098. // console.log(localStorage.getItem('orgType'))
  2099. this.$api.api
  2100. .findMyAgent({ orgType: localStorage.getItem("orgType") })
  2101. .then((res) => {
  2102. // console.log(res)
  2103. this.agentList = res.data;
  2104. });
  2105. },
  2106. //分页器
  2107. handleSizeChange(val) {
  2108. this.page.size = val;
  2109. this.roleList();
  2110. console.log(`每页 ${val} 条`);
  2111. },
  2112. handleCurrentChange(val) {
  2113. console.log(`当前页: ${val}`);
  2114. this.page.current = val;
  2115. this.roleList();
  2116. },
  2117. //分页器
  2118. handleSizeChange1(val) {
  2119. this.page1.size = val;
  2120. this.gethouseList();
  2121. console.log(`每页 ${val} 条`);
  2122. },
  2123. handleCurrentChange1(val) {
  2124. console.log(`当前页: ${val}`);
  2125. this.page1.current = val;
  2126. this.gethouseList();
  2127. },
  2128. roleChange(e = "") {
  2129. this.roelFlag = true;
  2130. this.$api.api
  2131. .roleList({
  2132. orgCode: e,
  2133. })
  2134. .then((res) => {
  2135. console.log(res);
  2136. if (res.code == 0) {
  2137. this.RoleByOrgCodeList = res.data;
  2138. }
  2139. });
  2140. },
  2141. selectClear() {
  2142. this.treeClick = "";
  2143. this.form.deptName = "";
  2144. this.form.deptId = "";
  2145. this.roelFlag = false;
  2146. },
  2147. filterNode(value, data) {
  2148. // console.log(value,data);
  2149. if (!value) {
  2150. return true;
  2151. }
  2152. return data.name.indexOf(value) !== -1;
  2153. },
  2154. radioBlur() {
  2155. this.roleChange(this.codeOrg);
  2156. },
  2157. nodeClick(e) {
  2158. // console.log('e改变');
  2159. if (!e) return;
  2160. if (this.userRoleFlag) {
  2161. this.form.userRoleId = "";
  2162. }
  2163. if (!this.addFlag) {
  2164. try {
  2165. this.userRoleFlag = true;
  2166. this.roleChange(this.$refs.tree.node[0].orgCode);
  2167. } catch {
  2168. this.roleChange(this.codeOrg);
  2169. }
  2170. console.log(this.codeOrg, 123);
  2171. } else {
  2172. // console.log('触发');
  2173. console.log(this.$refs.tree.node[0]);
  2174. this.codeOrg = this.$refs.tree.node[0].orgCode;
  2175. this.roleChange(this.$refs.tree.node[0].orgCode);
  2176. }
  2177. },
  2178. // nodeClick(e){
  2179. // if(e) return
  2180. // console.log(this.$refs.tree.node[0].orgCode);
  2181. // // return
  2182. // this.treeClick = obj.aid;
  2183. // this.form.deptName = obj.name;
  2184. // this.form.deptId = obj.aid;
  2185. // this.form.userRoleId=''
  2186. // this.roleChange(obj.orgCode)
  2187. // },
  2188. checkChange(obj, node) {
  2189. console.log(obj, node);
  2190. },
  2191. orgCodeChange(e, idx) {
  2192. // console.log(e);
  2193. this.form.roleId = "";
  2194. if (idx == 0) {
  2195. this.$api.api
  2196. .findRoleByOrgCode({
  2197. orgType: this.form.orgType,
  2198. orgCode: e,
  2199. })
  2200. .then((res) => {
  2201. this.userList = res.data;
  2202. });
  2203. } else {
  2204. this.$api.api
  2205. .findRoleByOrgCode({
  2206. orgType: this.form.orgType,
  2207. agentId: e,
  2208. })
  2209. .then((res) => {
  2210. this.userList = res.data;
  2211. });
  2212. }
  2213. this.$forceUpdate();
  2214. },
  2215. editTwo(row) {
  2216. this.formTwo.username = row.username;
  2217. this.formTwo.showPhoneStatus = row.showPhoneStatus;
  2218. this.formTwo.roleId = row.roleId;
  2219. this.form.orgType = row.orgType;
  2220. this.formTwo.accountId = row.accountId;
  2221. this.formTwo.orgType = row.orgType;
  2222. this.formTwo.houseId = row.houseId;
  2223. this.formTwo.newRoleId = row.roleId;
  2224. this.formTwo.deptId = row.deptId;
  2225. this.formTwo.userRoleType = row.userRoleType + "";
  2226. console.log(this.formTwo);
  2227. // 获取角色列表
  2228. this.typeChange1(row);
  2229. let obj = {
  2230. dictKey: row.orgType,
  2231. dictType: 3,
  2232. };
  2233. if (row.userRoleType != 6) {
  2234. obj.notInValue = 6;
  2235. }
  2236. this.userDict(obj, "userRoleTypeList");
  2237. // 获取部门列表
  2238. this.dialogFormVisibleTwo = true;
  2239. },
  2240. editSureTwo() {
  2241. this.$refs.formTwo.validate((valid) => {
  2242. if (valid) {
  2243. console.log(this.formTwo);
  2244. this.$api.api.editRoleAndDept(this.formTwo).then((res) => {
  2245. this.$message.success("修改成功");
  2246. this.dialogFormVisibleTwo = false;
  2247. this.roleList();
  2248. });
  2249. }
  2250. });
  2251. },
  2252. getDeptList(houseId) {
  2253. this.$api.api
  2254. .deptFindList({
  2255. houseId,
  2256. })
  2257. .then((res) => {
  2258. this.deptList = res.data;
  2259. });
  2260. },
  2261. typeChange1(row) {
  2262. console.log(row);
  2263. this.userList = [];
  2264. this.identityList = [];
  2265. if (row.orgType == 0) {
  2266. // 平台 只显示角色
  2267. this.orgFlag = false;
  2268. this.$api.api
  2269. .findRoleByOrgCode({
  2270. orgType: this.form.orgType,
  2271. orgCode: null,
  2272. agentId: null,
  2273. })
  2274. .then((res) => {
  2275. this.userList = res.data;
  2276. });
  2277. } else if (row.orgType == 1) {
  2278. // 代理商 选择代理商和角色
  2279. this.orgFlag = false;
  2280. this.orgCodeChange(row.agentId, 1);
  2281. } else if (row.orgType == 2) {
  2282. // 公司 选择公司和角色
  2283. this.orgFlag = false;
  2284. this.orgCodeChange(row.orgCode, 0);
  2285. } else {
  2286. // 楼盘 选择公司 角色 角色身份
  2287. this.orgFlag = true;
  2288. this.orgCodeChange(row.orgCode, 0);
  2289. this.getDeptList(row.houseId);
  2290. }
  2291. },
  2292. typeChange(e) {
  2293. console.log(e);
  2294. this.userList = [];
  2295. this.form.userRoleType = "";
  2296. this.identityList = [];
  2297. if (e == 0) {
  2298. // 平台 只显示角色
  2299. // this.orgFlag = false;
  2300. this.roleFlag = true;
  2301. this.identityFlag = true;
  2302. // this.agentFlag = false;
  2303. this.$api.api
  2304. .findRoleByOrgCode({
  2305. orgType: this.form.orgType,
  2306. orgCode: null,
  2307. agentId: null,
  2308. })
  2309. .then((res) => {
  2310. this.userList = res.data;
  2311. });
  2312. } else if (e == 1) {
  2313. // 代理商 选择代理商和角色
  2314. // this.orgFlag = false;
  2315. this.roleFlag = true;
  2316. this.identityFlag = true;
  2317. // this.agentFlag = true;
  2318. this.form.agentId = localStorage.getItem("agentId");
  2319. this.orgCodeChange(localStorage.getItem("agentId"), 1);
  2320. } else if (e == 2) {
  2321. // 公司 选择公司和角色
  2322. // this.orgFlag = true;
  2323. this.roleFlag = true;
  2324. this.identityFlag = true;
  2325. // this.agentFlag = false;
  2326. this.form.orgCode = localStorage.getItem("orgCode");
  2327. this.orgCodeChange(localStorage.getItem("orgCode"), 0);
  2328. } else {
  2329. // 楼盘 选择公司 角色 角色身份
  2330. this.orgFlag = true;
  2331. this.roleFlag = true;
  2332. this.identityFlag = true;
  2333. // this.agentFlag = false;
  2334. this.form.houseId = localStorage.getItem("houseId");
  2335. this.orgCodeChange(localStorage.getItem("orgCode"), 0);
  2336. this.getDeptList(localStorage.getItem("houseId"));
  2337. }
  2338. // 字典表接口
  2339. this.userDict(
  2340. {
  2341. dictKey: e,
  2342. dictType: 3,
  2343. },
  2344. "identityList"
  2345. );
  2346. },
  2347. userDict(obj, str) {
  2348. this.$api.api.userDict(obj).then((res) => {
  2349. console.log(res);
  2350. this[str] = res.data;
  2351. });
  2352. },
  2353. getList(page, params) {
  2354. this.listLoading = true;
  2355. fetchList(
  2356. Object.assign(
  2357. {
  2358. current: page.currentPage,
  2359. size: page.size,
  2360. },
  2361. params,
  2362. this.searchForm
  2363. )
  2364. ).then((response) => {
  2365. console.log(response);
  2366. this.list = response.data.records;
  2367. this.page.total = response.data.total;
  2368. this.listLoading = false;
  2369. });
  2370. },
  2371. searchChange(param, done) {
  2372. this.searchForm = param;
  2373. this.page.currentPage = 1;
  2374. this.getList(this.page, param);
  2375. done();
  2376. },
  2377. sizeChange(size) {
  2378. this.page.size = size;
  2379. },
  2380. currentChange(current) {
  2381. this.page.currentPage = current;
  2382. },
  2383. refreshChange() {
  2384. this.getList(this.page);
  2385. },
  2386. handleOpenBefore(show, type) {
  2387. window.boxType = type;
  2388. // 查询部门树
  2389. fetchTree().then((response) => {
  2390. this.treeDeptData = response.data;
  2391. });
  2392. // 查询角色列表
  2393. deptRoleList().then((response) => {
  2394. this.rolesOptions = response.data;
  2395. });
  2396. if (["edit", "views"].includes(type)) {
  2397. this.role = [];
  2398. for (let i = 0; i < this.form.roleList.length; i++) {
  2399. this.role[i] = this.form.roleList[i].roleId;
  2400. }
  2401. } else if (type === "add") {
  2402. this.role = [];
  2403. this.form.username = undefined;
  2404. this.form.phone = undefined;
  2405. this.form.password = undefined;
  2406. }
  2407. show();
  2408. },
  2409. handleUpdate(row, index) {
  2410. this.$refs.crud.rowEdit(row, index);
  2411. this.form.password = undefined;
  2412. },
  2413. create(row, done, loading) {
  2414. if (this.form.phone && this.form.phone.indexOf("*") > 0) {
  2415. this.form.phone = undefined;
  2416. }
  2417. addObj(this.form)
  2418. .then(() => {
  2419. this.getList(this.page);
  2420. done();
  2421. this.$notify.success("创建成功");
  2422. })
  2423. .catch(() => {
  2424. loading();
  2425. });
  2426. },
  2427. update(row, index, done, loading) {
  2428. if (this.form.phone && this.form.phone.indexOf("*") > 0) {
  2429. this.form.phone = undefined;
  2430. }
  2431. putObj(this.form)
  2432. .then(() => {
  2433. this.getList(this.page);
  2434. done();
  2435. this.$notify.success("修改成功");
  2436. })
  2437. .catch(() => {
  2438. loading();
  2439. });
  2440. },
  2441. deletes(row) {
  2442. this.$confirm(
  2443. "此操作将永久删除该用户(用户名:" + row.username + "), 是否继续?",
  2444. "提示",
  2445. {
  2446. confirmButtonText: "确定",
  2447. cancelButtonText: "取消",
  2448. type: "warning",
  2449. }
  2450. ).then(() => {
  2451. console.log(row);
  2452. console.log(row.userId, "123");
  2453. if (this.choseFlag) {
  2454. delObj(row.userId).then(() => {
  2455. this.roleList();
  2456. this.$notify.success("删除成功");
  2457. });
  2458. } else {
  2459. delObj1({
  2460. id: row.id,
  2461. orgType: row.orgType,
  2462. accountId: row.accountId,
  2463. }).then(() => {
  2464. this.roleList();
  2465. this.$notify.success("删除成功");
  2466. });
  2467. }
  2468. // .catch(() => {
  2469. // this.$notify.error('删除失败')
  2470. // })
  2471. });
  2472. },
  2473. locationsChange(e) {
  2474. console.log(e);
  2475. if (!e) return;
  2476. this.searchhouseMsg.provinceId = e[0];
  2477. this.searchhouseMsg.cityId = e[1];
  2478. },
  2479. },
  2480. };
  2481. </script>
  2482. <style lang="scss" scoped>
  2483. .cons {
  2484. margin-top: 10px;
  2485. }
  2486. .user {
  2487. height: 100%;
  2488. &__tree {
  2489. padding-top: 3px;
  2490. padding-right: 20px;
  2491. }
  2492. &__main {
  2493. .el-card__body {
  2494. padding-top: 0;
  2495. }
  2496. }
  2497. }
  2498. .tree-click {
  2499. color: #4d74d6;
  2500. font-weight: 600;
  2501. }
  2502. .tabcenbox {
  2503. display: flex;
  2504. width: 100%;
  2505. height: 38px;
  2506. text-align: center;
  2507. margin: 10px;
  2508. .ch1 {
  2509. background: cornflowerblue;
  2510. color: #fff;
  2511. }
  2512. .ch2 {
  2513. color: #ccc;
  2514. }
  2515. }
  2516. .tabcenbox div {
  2517. width: 120px;
  2518. border: 1px solid #ccc;
  2519. text-align: center;
  2520. line-height: 38px;
  2521. }
  2522. // .top{
  2523. // /deep/ .el-form-item__content{
  2524. // display: inline-flex ;
  2525. // }
  2526. // }
  2527. .input-with-select .el-input-group__prepend {
  2528. background-color: #fff;
  2529. }
  2530. .bindchoice {
  2531. display: flex;
  2532. margin-top: 20px;
  2533. }
  2534. .con {
  2535. margin-top: 20px;
  2536. padding: 20px;
  2537. border-radius: 4px;
  2538. background: #ffff;
  2539. }
  2540. .area {
  2541. display: flex;
  2542. }
  2543. .province {
  2544. display: flex;
  2545. .right {
  2546. // display: flex;
  2547. }
  2548. }
  2549. </style>