salesman.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <div class="institution">
  3. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  4. <el-tab-pane :label="'待审核'+'('+countObj?.noAuditCount +')'" name="hold">
  5. <div class="institution-main">
  6. <el-form label-position="left" label-width="auto">
  7. <el-row :gutter="24">
  8. <el-col :span="6">
  9. <el-form-item label="成员信息">
  10. <el-input
  11. v-model="formAccessibility.firstName"
  12. placeholder="输入成员信息查找"
  13. :prefix-icon="Search"
  14. />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="6">
  18. <el-form-item label="归属机构">
  19. <el-select
  20. v-model="form.leaderId"
  21. placeholder="归属机构"
  22. clearable
  23. >
  24. <el-option
  25. v-for="item in memberList"
  26. :key="item.id"
  27. :label="item.name"
  28. :value="item.id"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="4">
  34. <el-form-item label="">
  35. <el-button type="primary">查询</el-button>
  36. <el-button type="primary" plain @click="reset"
  37. >重置</el-button
  38. >
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. </el-form>
  43. <Table
  44. :tableData="tableData"
  45. :columns="columns"
  46. :showIndex="false"
  47. :showSelect="true"
  48. :pageInfo="pageInfo"
  49. @getList="getList"
  50. :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  51. @select-all-change="selectAllChange"
  52. @select-change="selectChange"
  53. >
  54. <template v-slot:table-title-btn>
  55. <div>
  56. <!-- <el-button type="primary" @click="add(ruleFormRef)">
  57. <el-icon><Plus /></el-icon>添加机构</el-button
  58. > -->
  59. <el-dropdown placement="bottom-start">
  60. <el-button>
  61. 批量操作<el-icon class="el-icon--right">
  62. <arrow-down />
  63. </el-icon>
  64. </el-button>
  65. <template #dropdown>
  66. <el-dropdown-menu>
  67. <el-dropdown-item>审核</el-dropdown-item>
  68. <!-- <el-dropdown-item v-on:click="manySetDeptUser()">设置负责人</el-dropdown-item> -->
  69. </el-dropdown-menu>
  70. </template>
  71. </el-dropdown>
  72. </div>
  73. </template>
  74. <template v-slot:operation="scope">
  75. <el-button
  76. type="primary"
  77. link
  78. @click="toExamine(scope.operationData.row, 'success')"
  79. >
  80. 审核通过
  81. </el-button>
  82. <el-button
  83. type="primary"
  84. link
  85. @click="toExamine(scope.operationData.row, 'error')"
  86. >
  87. 审核不通过
  88. </el-button>
  89. <el-button
  90. type="primary"
  91. link
  92. @click="editor(scope.operationData.row)"
  93. >
  94. 详情
  95. </el-button>
  96. </template>
  97. <template v-slot:search="scope">
  98. {{ scope.slotData.label }}
  99. </template>
  100. </Table>
  101. </div>
  102. </el-tab-pane>
  103. <el-tab-pane :label="'审核不通过'+'('+countObj?.failAuditCount +')'" name="pass">
  104. <div class="institution-main">
  105. <el-form label-position="left" label-width="auto">
  106. <el-row :gutter="24">
  107. <el-col :span="6">
  108. <el-form-item label="成员信息">
  109. <el-input
  110. v-model="formAccessibility.firstName"
  111. placeholder="输入成员信息查找"
  112. :prefix-icon="Search"
  113. />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="6">
  117. <el-form-item label="归属机构">
  118. <el-select
  119. v-model="form.leaderId"
  120. placeholder="归属机构"
  121. clearable
  122. >
  123. <el-option
  124. v-for="item in memberList"
  125. :key="item.id"
  126. :label="item.name"
  127. :value="item.id"
  128. />
  129. </el-select>
  130. </el-form-item>
  131. </el-col>
  132. <el-col :span="4">
  133. <el-form-item label="">
  134. <el-button type="primary">查询</el-button>
  135. <el-button type="primary" plain @click="reset"
  136. >重置</el-button
  137. >
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. </el-form>
  142. <Table
  143. :tableData="tableData"
  144. :columns="columns"
  145. :showIndex="false"
  146. :showSelect="true"
  147. :pageInfo="pageInfo"
  148. @getList="getList"
  149. :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  150. @select-all-change="selectAllChange"
  151. @select-change="selectChange"
  152. >
  153. <template v-slot:table-title-btn>
  154. <div>
  155. <!-- <el-button type="primary" @click="add(ruleFormRef)">
  156. <el-icon><Plus /></el-icon>添加机构</el-button
  157. > -->
  158. <el-dropdown placement="bottom-start">
  159. <el-button>
  160. 批量操作<el-icon class="el-icon--right">
  161. <arrow-down />
  162. </el-icon>
  163. </el-button>
  164. <template #dropdown>
  165. <el-dropdown-menu>
  166. <el-dropdown-item>审核</el-dropdown-item>
  167. <!-- <el-dropdown-item v-on:click="manySetDeptUser()">设置负责人</el-dropdown-item> -->
  168. </el-dropdown-menu>
  169. </template>
  170. </el-dropdown>
  171. </div>
  172. </template>
  173. <template v-slot:operation="scope">
  174. <el-button
  175. type="primary"
  176. link
  177. @click="editor(scope.operationData.row)"
  178. >
  179. 详情
  180. </el-button>
  181. </template>
  182. <template v-slot:search="scope">
  183. {{ scope.slotData.label }}
  184. </template>
  185. </Table>
  186. </div>
  187. </el-tab-pane>
  188. </el-tabs>
  189. <el-dialog v-model="dialogVisible" title="审核不通过" width="500" draggable>
  190. <el-input
  191. type="textarea"
  192. placeholder="请输入审核不通过原因"
  193. v-model="textValue"
  194. />
  195. <template #footer>
  196. <div class="dialog-footer">
  197. <el-button @click="cancel()">取 消</el-button>
  198. <el-button type="primary" @click="confirm()"> 保 存 </el-button>
  199. </div>
  200. </template>
  201. </el-dialog>
  202. </div>
  203. </template>
  204. <script setup lang="ts">
  205. import { ref, reactive, watch, onMounted } from "vue";
  206. import type {
  207. ComponentSize,
  208. FormInstance,
  209. FormRules,
  210. TabsPaneContext,
  211. } from "element-plus";
  212. import { Plus, Search } from "@element-plus/icons-vue";
  213. import { useRouter } from "vue-router";
  214. import type Node from "element-plus/es/components/tree/src/model/node";
  215. // import universalTable from "../"
  216. import { ElMessage, ElMessageBox, ElPopconfirm, ElTree } from "element-plus";
  217. import api from "@/api";
  218. import { h } from "vue";
  219. import setDept from "@/components/DialogSetDeptLeader/index.vue";
  220. interface Tree {
  221. [key: string]: any;
  222. }
  223. const filterText = ref("");
  224. const treeRef = ref<InstanceType<typeof ElTree>>();
  225. const activeName = ref("hold");
  226. const defaultProps = {
  227. children: "children",
  228. label: "label",
  229. };
  230. //批量设置负责人
  231. watch(filterText, (val) => {
  232. treeRef.value!.filter(val);
  233. });
  234. const formAccessibility = reactive({
  235. fullName: "",
  236. firstName: "",
  237. lastName: "",
  238. phone: "",
  239. });
  240. const ruleFormRef = ref<FormInstance>();
  241. let form = reactive({
  242. name: "", //机构名称
  243. parentId: "", //上级机构id
  244. comType: "", //机构类型
  245. exhibitionScope: "", //展业范围
  246. address: "", //地址
  247. leaderId: "", //负责人id
  248. area: [], //地区
  249. });
  250. interface PageInfo {
  251. pageNum: number;
  252. pageSize: number;
  253. sizes: number[];
  254. total: number;
  255. show: boolean;
  256. }
  257. const dialogVisible = ref(false);
  258. // import Select from "@/components/select/selectMain.vue";
  259. // import TestTable from "@/components/Table/index.vue";
  260. //业务员列表
  261. type tableType = {
  262. id: string;
  263. name: string;
  264. };
  265. const tableData = ref<tableType[]>([]);
  266. const typeformatter = (row: any, column: any, cellValue: any) => {
  267. let comType = "";
  268. comTypeList.value.map((ele) => {
  269. if (ele.value == row.comType) {
  270. comType = ele.label;
  271. }
  272. });
  273. return () => h("div", {}, comType);
  274. };
  275. const columns = [
  276. { prop: "name", label: "姓名" },
  277. { prop: "mobile", label: "手机号" },
  278. // { prop: "id", label: "工号" },
  279. { prop: "deptName", label: "归属机构" },
  280. {
  281. prop: "username",
  282. label: "角色",
  283. },
  284. { prop: "createTime", label: "创建时间" },
  285. { prop: "createBy", label: "创建人" },
  286. ];
  287. const pageInfo = {
  288. pageNum: 1,
  289. pageSize: 10,
  290. sizes: [10, 20, 30, 40, 50],
  291. total: 0,
  292. show: true,
  293. };
  294. //分页列表功能
  295. const getList = (item: PageInfo) => {
  296. pageInfo.pageNum = item.pageNum;
  297. pageInfo.pageSize = item.pageSize;
  298. salesmanAuth();
  299. };
  300. const checkTableIdList = ref([]);
  301. //表格选择事件
  302. function selectAllChange(list: any) {
  303. checkTableIdList.value = list;
  304. }
  305. function selectChange(list: any) {
  306. checkTableIdList.value = list;
  307. }
  308. //审核
  309. const userInfoId = ref("");
  310. const toExamine = (item: any, type: string) => {
  311. if (type == "success") {
  312. ElMessageBox.confirm(`确定审核通过${item.name}账号吗?`, "审核通过", {
  313. confirmButtonText: "确认",
  314. cancelButtonText: "取消",
  315. type: "warning",
  316. center: true,
  317. })
  318. .then(() => {
  319. api.representativeApi
  320. .salesmanAuthSuccess({
  321. userInfoId: item.id,
  322. })
  323. .then((res: any) => {
  324. if (res.code == 200) {
  325. ElMessage.success("操作成功");
  326. salesmanAuth(); //业务员列表
  327. } else {
  328. ElMessage.error(res.msg);
  329. // salesmanAuth(); //业务员列表
  330. }
  331. });
  332. })
  333. .catch(() => {
  334. ElMessage.warning("用户取消操作");
  335. });
  336. } else {
  337. dialogVisible.value = true;
  338. userInfoId.value = item.id;
  339. // ElMessageBox.confirm(`<textarea placeholder='请输入审核不通过原因' oninput='handleText()' style="width:300px"></textarea>`, "审核不通过", {
  340. // confirmButtonText: "确认",
  341. // cancelButtonText: "取消",
  342. // dangerouslyUseHTMLString: true ,
  343. // type: "warning",
  344. // center: true,
  345. // })
  346. // .then(() => {
  347. // api.representativeApi.salesmanAuthFailed({}).then((res: any) => {
  348. // if (res.code == 200) {
  349. // ElMessage.success("操作成功");
  350. // salesmanAuth(); //业务员列表
  351. // } else {
  352. // ElMessage.error(res.msg);
  353. // // salesmanAuth(); //业务员列表
  354. // }
  355. // });
  356. // })
  357. // .catch(() => {
  358. // ElMessage.warning("用户取消操作");
  359. // });
  360. }
  361. };
  362. function cancel() {
  363. ElMessage.warning("用户取消操作");
  364. dialogVisible.value = false;
  365. }
  366. const textValue = ref("");
  367. //审核不通过
  368. function confirm() {
  369. api.representativeApi
  370. .salesmanAuthFailed({
  371. userInfoId: userInfoId.value,
  372. approvalOpinion: textValue.value,
  373. })
  374. .then((res: any) => {
  375. if (res.code == 200) {
  376. ElMessage.success("操作成功");
  377. salesmanAuth(); //业务员列表
  378. dialogVisible.value = false;
  379. }
  380. });
  381. }
  382. interface institutionData {
  383. typeAttr: string;
  384. deptId: string;
  385. status: number;
  386. }
  387. const info = ref<institutionData>({
  388. typeAttr: "1",
  389. deptId: "",
  390. status: 4,
  391. });
  392. const router = useRouter();
  393. //详情
  394. const editor = (item: any) => {
  395. console.log(item);
  396. router.push({
  397. path: "/representative/salesman/salesmanMessage",
  398. query: {
  399. id: item.userId,
  400. },
  401. });
  402. // pageInfo.pageNum=item.pageNum
  403. // pageInfo.pageSize=item.pageSize
  404. };
  405. //获取机构类型字典值
  406. type comType = {
  407. value: string;
  408. label: string;
  409. };
  410. let comTypeList = ref<comType[]>([]);
  411. const handleClick = (tab: TabsPaneContext, event: Event) => {
  412. // console.log(tab.props.name);
  413. if (tab.props.name == "pass") {
  414. info.value.status = 5;
  415. salesmanAuth();
  416. } else {
  417. info.value.status = 4;
  418. salesmanAuth();
  419. }
  420. };
  421. //获取成员员列表
  422. const salesmanAuth = () => {
  423. api.representativeApi
  424. .getUserInfoList({
  425. ...info.value,
  426. pages: pageInfo.pageNum,
  427. size: pageInfo.pageSize,
  428. })
  429. .then((res) => {
  430. tableData.value = res.data.records;
  431. pageInfo.total = res.data.total;
  432. });
  433. };
  434. //成员列表
  435. const countObj=ref({
  436. noAuditCount:'',
  437. failAuditCount:"",
  438. })
  439. const memberList = ref([]);
  440. const getAllMemberList = () => {
  441. api.userApi.AllMemberList({}).then((res: any) => {
  442. if (res.code === 200) memberList.value = res.data;
  443. });
  444. api.representativeApi.getAuditCount({
  445. typeAttr:'1'
  446. }).then((res:any)=>{
  447. // console.log(res)
  448. if(res.code===200){
  449. countObj.value=res.data
  450. }
  451. })
  452. // pageInfo.pageSize=item.pageSize
  453. };
  454. const reset = (item: any) => {
  455. // ElMessage({})
  456. };
  457. onMounted(() => {
  458. // 对 asyncRoutes 进行预处理并转换为树形结构
  459. salesmanAuth(); //业务员列表
  460. // getAreaList(); //省市区级联数据
  461. // getSystemList(); //机构类型字典
  462. // getExhibitionScopeSystemList(); //展业范围字段
  463. getAllMemberList(); //成员列表
  464. });
  465. </script>
  466. <style lang="scss" scoped>
  467. :deep(.table-title-btn) {
  468. display: flex;
  469. align-items: center;
  470. justify-content: space-between;
  471. > div {
  472. display: flex;
  473. }
  474. }
  475. .institution {
  476. background: #fff;
  477. width: 100%;
  478. // height: 100%;
  479. // padding: 20px;
  480. box-sizing: border-box;
  481. display: flex;
  482. :deep(.demo-tabs) {
  483. width: 100%;
  484. padding: 20px;
  485. box-sizing: border-box;
  486. }
  487. // .institution-main {
  488. // flex: 1;
  489. // // width: 80%;
  490. // padding: 20px;
  491. // box-sizing: border-box;
  492. // }
  493. }
  494. :deep(.el-dropdown-link) {
  495. cursor: pointer;
  496. color: var(--el-color-primary);
  497. display: flex;
  498. align-items: center;
  499. margin-left: 15px;
  500. }
  501. .custom-tree-node {
  502. flex: 1;
  503. display: flex;
  504. align-items: center;
  505. justify-content: space-between;
  506. font-size: 14px;
  507. padding-right: 8px;
  508. }
  509. :deep(.el-message-box__container) {
  510. width: 100% !important;
  511. .el-message-box__message {
  512. width: 100% !important;
  513. }
  514. }
  515. </style>