index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 人力资源表
  6. </h2>
  7. <div class="m-core">
  8. <!-- 搜索标题 -->
  9. <saveform
  10. :inline="true"
  11. ref="searchForm"
  12. class="searchForm"
  13. :model.sync="searchForm"
  14. >
  15. <el-form-item prop="userNameOrIdOrMobile">
  16. <el-input
  17. placeholder="姓名手机号"
  18. v-model.trim="searchForm.userNameOrIdOrMobile"
  19. clearable
  20. ></el-input>
  21. </el-form-item>
  22. <el-form-item prop="sourceFrom">
  23. <el-select
  24. v-model.trim="searchForm.sourceFrom"
  25. clearable
  26. filterable
  27. placeholder="请选择信息来源"
  28. >
  29. <el-option label="BOSS" value="BOSS"></el-option>
  30. <el-option label="转介绍" value="转介绍"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item prop="status">
  34. <el-select
  35. v-model.trim="searchForm.status"
  36. clearable
  37. filterable
  38. placeholder="请选择人员状态"
  39. >
  40. <el-option label="未录用" value="NOT_EMPLOYED"></el-option>
  41. <el-option label="面试中" value="INTERVIEWING"></el-option>
  42. <el-option label="储备" value="RESERVE"></el-option>
  43. <el-option label="兼职" value="PART_TIME"></el-option>
  44. <el-option label="全职" value="FULL_TIME"></el-option>
  45. <el-option label="离职" value="DIMISSION"></el-option>
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item prop="position">
  49. <el-select
  50. v-model.trim="searchForm.position"
  51. clearable
  52. filterable
  53. placeholder="请选择职位"
  54. >
  55. <el-option label="指导老师" value="ADVISER"></el-option>
  56. <el-option label="乐团主管" value="ACADEMIC"></el-option>
  57. <el-option label="乐队指导" value="TEACHING"></el-option>
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item prop="organId">
  61. <el-select
  62. v-model.trim="searchForm.organId"
  63. placeholder="请选择分部"
  64. clearable
  65. filterable
  66. >
  67. <el-option
  68. v-for="(item, index) in organList"
  69. :key="index"
  70. :value="item.id"
  71. :label="item.name"
  72. >
  73. </el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item prop="subjectId" :label-width="formLabelWidth">
  77. <el-select
  78. v-model.trim="searchForm.subjectId"
  79. clearable
  80. filterable
  81. placeholder="请选择声部"
  82. >
  83. <el-option
  84. v-for="(item, index) in subjectList"
  85. :key="index"
  86. :value="item.id"
  87. :label="item.name"
  88. >
  89. </el-option>
  90. </el-select>
  91. </el-form-item>
  92. <el-form-item prop="notMobileAndWechat">
  93. <el-select
  94. v-model.trim="searchForm.notMobileAndWechat"
  95. clearable
  96. filterable
  97. placeholder="是否手机微信双无"
  98. >
  99. <el-option label="是" value="1"></el-option>
  100. <el-option label="否" value="0"></el-option>
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item prop="dates" :label-width="formLabelWidth">
  104. <el-date-picker
  105. v-model="searchForm.dates"
  106. type="daterange"
  107. style="width: 405px"
  108. range-separator="至"
  109. start-placeholder="操作开始日期"
  110. end-placeholder="操作结束日期"
  111. >
  112. </el-date-picker>
  113. </el-form-item>
  114. <el-form-item prop="hrbp">
  115. <!-- <el-input
  116. placeholder="归属管理HR"
  117. v-model.trim="searchForm.operator"
  118. clearable
  119. ></el-input> -->
  120. <el-select
  121. v-model.trim="searchForm.hrbp"
  122. clearable
  123. filterable
  124. placeholder="请选择HRBP"
  125. >
  126. <el-option
  127. v-for="(item, index) in roleList"
  128. :key="index"
  129. :value="item.userId"
  130. :label="item.userName"
  131. >
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item prop="intentionCity">
  136. <el-input
  137. placeholder="意向城市"
  138. v-model.trim="searchForm.intentionCity"
  139. clearable
  140. ></el-input>
  141. </el-form-item>
  142. <el-form-item>
  143. <el-button @click="search" type="danger">搜索</el-button>
  144. <el-button @click="onReSet" type="primary">重置</el-button>
  145. <el-button
  146. type="primary"
  147. v-if="$helpers.permission('export/employeeInfo')"
  148. @click="employeeExport"
  149. >导出</el-button
  150. >
  151. <!-- style="background-color: #409eff; border-color: #409eff" -->
  152. </el-form-item>
  153. </saveform>
  154. <el-button
  155. v-permission="'employeeInfo/insert'"
  156. @click="openTypes('create')"
  157. type="primary"
  158. style="margin-bottom:20px"
  159. >
  160. 添加
  161. </el-button>
  162. <div class="tableWrap">
  163. <el-table
  164. :data="tableList"
  165. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  166. >
  167. <el-table-column
  168. width="120px"
  169. align="center"
  170. prop="id"
  171. label="编号"
  172. ></el-table-column>
  173. <el-table-column align="center" prop="realName" label="姓名">
  174. <template slot-scope="scope">
  175. <el-tooltip
  176. class="item"
  177. effect="dark"
  178. :content="scope.row.realName"
  179. placement="top"
  180. >
  181. <copy-text>{{ scope.row.realName }}</copy-text>
  182. </el-tooltip>
  183. </template>
  184. </el-table-column>
  185. <el-table-column align="center" prop="mobileNo" label="手机号" width="140px">
  186. <template slot-scope="scope">
  187. <div>
  188. <copy-text>{{ scope.row.mobileNo }}</copy-text>
  189. </div>
  190. </template>
  191. </el-table-column>
  192. <el-table-column
  193. align="center"
  194. prop="wechatNo"
  195. label="微信"
  196. ></el-table-column>
  197. <el-table-column align="center" label="学历信息">
  198. <template slot-scope="scope">
  199. <el-button @click="openEducation(scope.row)" type="text"
  200. >查看学历</el-button
  201. >
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. align="center"
  206. prop="subjectName"
  207. label="声部"
  208. width="200px"
  209. >
  210. <template slot-scope="scope">
  211. <el-tooltip
  212. class="item"
  213. effect="dark"
  214. :content="scope.row.subjectName"
  215. placement="top"
  216. >
  217. <span>{{ scope.row.subjectName }}</span>
  218. </el-tooltip>
  219. </template>
  220. </el-table-column>
  221. <el-table-column
  222. align="center"
  223. prop="liveCity"
  224. label="所在城市"
  225. ></el-table-column>
  226. <el-table-column
  227. align="center"
  228. prop="intentionCity"
  229. label="意向城市"
  230. width="100px"
  231. >
  232. <template slot-scope="scope">
  233. <el-tooltip
  234. class="item"
  235. effect="dark"
  236. :content="scope.row.intentionCity"
  237. placement="top"
  238. >
  239. <span>{{ scope.row.intentionCity }}</span>
  240. </el-tooltip>
  241. </template>
  242. </el-table-column>
  243. <!-- <el-table-column
  244. align="center"
  245. prop="assessmentResult"
  246. label="评估结果"
  247. width="200px"
  248. >
  249. <template slot-scope="scope">
  250. <el-tooltip
  251. class="item"
  252. effect="dark"
  253. :content="scope.row.assessmentResult"
  254. placement="top"
  255. >
  256. <span>{{ scope.row.assessmentResult }}</span>
  257. </el-tooltip>
  258. </template>
  259. </el-table-column>
  260. <el-table-column
  261. align="center"
  262. prop="otherComment"
  263. label="其它综合情况"
  264. width="200px"
  265. >
  266. <template slot-scope="scope">
  267. <el-tooltip
  268. class="item"
  269. effect="dark"
  270. :content="scope.row.otherComment"
  271. placement="top"
  272. >
  273. <span>{{ scope.row.otherComment }}</span>
  274. </el-tooltip>
  275. </template>
  276. </el-table-column> -->
  277. <el-table-column
  278. align="center"
  279. prop="sourceFrom"
  280. label="信息来源"
  281. ></el-table-column>
  282. <el-table-column
  283. align="center"
  284. prop="nextVisitDate"
  285. label="下次沟通时间"
  286. width="150px"
  287. >
  288. <template slot-scope="scope">
  289. {{ scope.row.nextVisitDate | dayjsFormat }}
  290. </template>
  291. </el-table-column>
  292. <el-table-column
  293. align="center"
  294. prop="entryDate"
  295. label="入职时间"
  296. width="150px"
  297. >
  298. <template slot-scope="scope">
  299. {{ scope.row.entryDate | dayjsFormat }}
  300. </template>
  301. </el-table-column>
  302. <el-table-column align="center" prop="position" label="职位">
  303. <template slot-scope="scope">
  304. {{ scope.row.position | jobType }}
  305. </template>
  306. </el-table-column>
  307. <el-table-column
  308. align="center"
  309. prop="organName"
  310. label="分部"
  311. ></el-table-column>
  312. <!-- <el-table-column
  313. align="center"
  314. prop="isProbationPeriod"
  315. label="是否试用期"
  316. >
  317. <template slot-scope="scope">
  318. {{
  319. typeof scope.row.isProbationPeriod === "boolean"
  320. ? scope.row.isProbationPeriod
  321. ? "是"
  322. : "否"
  323. : ""
  324. }}
  325. </template>
  326. </el-table-column> -->
  327. <el-table-column align="center" prop="status" label="人员状态">
  328. <template slot-scope="scope">
  329. {{ scope.row.status | hrStatus }}
  330. </template>
  331. </el-table-column>
  332. <el-table-column
  333. align="center"
  334. prop="idCard"
  335. label="证件号码"
  336. width="200px"
  337. ></el-table-column>
  338. <el-table-column align="center" prop="age" label="年龄">
  339. <template slot-scope="scope">
  340. {{ scope.row.age > 0 ? scope.row.age : "" }}
  341. </template>
  342. </el-table-column>
  343. <el-table-column align="center" prop="gender" label="性别">
  344. <template slot-scope="scope">
  345. {{
  346. typeof scope.row.gender === "boolean"
  347. ? scope.row.gender
  348. ? "男"
  349. : "女"
  350. : ""
  351. }}
  352. </template>
  353. </el-table-column>
  354. <el-table-column
  355. align="center"
  356. prop="bankCardNo"
  357. label="银行卡号"
  358. width="200px"
  359. ></el-table-column>
  360. <el-table-column
  361. align="center"
  362. prop="bankAddress"
  363. label="开户行"
  364. width="200px"
  365. ></el-table-column>
  366. <el-table-column
  367. align="center"
  368. prop="emergencyContactName"
  369. label="紧急联系人"
  370. ></el-table-column>
  371. <el-table-column
  372. align="center"
  373. prop="emergencyContactRelation"
  374. label="紧急联系人关系"
  375. ></el-table-column>
  376. <el-table-column
  377. align="center"
  378. prop="emergencyContactPhone"
  379. label="紧急联系人电话"
  380. ></el-table-column>
  381. <el-table-column
  382. align="center"
  383. prop="updateTime"
  384. label="最后一次操作时间时间"
  385. width="160px"
  386. ></el-table-column>
  387. <el-table-column align="center" label="HRBP">
  388. <template slot-scope="scope">
  389. <div>
  390. <copy-text>{{ roleFormat(scope.row.hrbp) }}</copy-text>
  391. </div>
  392. </template>
  393. </el-table-column>
  394. <el-table-column
  395. align="center"
  396. prop="resignationDate"
  397. label="离职时间"
  398. width="150px"
  399. >
  400. <template slot-scope="scope">
  401. {{ scope.row.resignationDate | dayjsFormat }}
  402. </template>
  403. </el-table-column>
  404. <el-table-column align="center" label="操作" fixed="right">
  405. <template slot-scope="scope">
  406. <el-button
  407. v-permission="'employeeInfo/update'"
  408. @click="openTypes('update', scope.row)"
  409. type="text"
  410. >修改</el-button
  411. >
  412. </template>
  413. </el-table-column>
  414. </el-table>
  415. <pagination
  416. :total.sync="pageInfo.total"
  417. :page.sync="pageInfo.page"
  418. :limit.sync="pageInfo.limit"
  419. :page-sizes="pageInfo.page_size"
  420. sync
  421. @pagination="getList"
  422. />
  423. </div>
  424. </div>
  425. <el-dialog
  426. :title="formTitle[formActionTitle]"
  427. :visible.sync="typeStatus"
  428. destroy-on-close
  429. :close-on-click-modal="false"
  430. @close="onFormClose('ruleForm')"
  431. width="1150px"
  432. >
  433. <hrform
  434. :detail.sync="rowDetail"
  435. v-if="typeStatus"
  436. :organList="organList"
  437. :subjectList="subjectList"
  438. :roleList="roleList"
  439. :close="onFormClose"
  440. :formActionTitle="formActionTitle"
  441. :getList="getList"
  442. />
  443. </el-dialog>
  444. <el-dialog
  445. title="查看学历信息"
  446. :visible.sync="educationVisible"
  447. destroy-on-close
  448. :close-on-click-modal="false"
  449. @close="educationVisible = false"
  450. width="600px"
  451. >
  452. <el-table
  453. :data="educationList"
  454. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  455. >
  456. <el-table-column
  457. align="center"
  458. prop="level"
  459. label="学历"
  460. ></el-table-column>
  461. <el-table-column
  462. align="center"
  463. prop="school"
  464. label="毕业学校"
  465. ></el-table-column>
  466. <el-table-column align="center" prop="year" label="毕业时间">
  467. <template slot-scope="scope">
  468. {{ scope.row.year | dayjsFormat }}
  469. </template>
  470. </el-table-column>
  471. </el-table>
  472. </el-dialog>
  473. </div>
  474. </template>
  475. <script>
  476. import pagination from "@/components/Pagination/index";
  477. import saveform from "@/components/save-form";
  478. import dayjs from "dayjs";
  479. import hrform from "./form";
  480. import { Export } from "@/utils/downLoadFile";
  481. import cleanDeep from "clean-deep";
  482. // import store from '@/store'
  483. import {
  484. helpCenterCatalogList,
  485. employeeInfo,
  486. helpCenterContentModify,
  487. helpCenterContentDelete,
  488. } from "@/api/appTenant";
  489. import { getEmployeeOrgan, getSubject } from "@/api/buildTeam";
  490. import { subjectListTree } from "@/api/specialSetting";
  491. export const getTimes = (times, keys = []) => {
  492. if (times && times.length) {
  493. return {
  494. [keys[0] || "start"]: dayjs(times[0]).format("YYYY-MM-DD"),
  495. [keys[1] || "start"]: dayjs(times[1]).format("YYYY-MM-DD"),
  496. };
  497. }
  498. return {};
  499. };
  500. const initSearch = {
  501. organId: "",
  502. jobNature: "",
  503. position: "",
  504. subjectId: "",
  505. userNameOrIdOrMobile: "",
  506. operator: "",
  507. dates: [],
  508. intentionCity: "",
  509. hrbp: "",
  510. notMobileAndWechat:""
  511. };
  512. export default {
  513. components: { pagination, hrform, saveform },
  514. name: "helpCategory",
  515. data() {
  516. return {
  517. searchForm: {
  518. ...initSearch,
  519. },
  520. educationVisible: false,
  521. treeList: [],
  522. tableList: [],
  523. educationList: [],
  524. formActionTitle: "create",
  525. formTitle: {
  526. create: "添加人员",
  527. update: "修改人员",
  528. },
  529. typeStatus: false, // 添加教学点
  530. formLabelWidth: "100px",
  531. form: {
  532. title: null, // 标题
  533. content: null, // 内容
  534. catalogId: null, // 分类编号
  535. },
  536. rules: {
  537. title: [{ required: true, message: "请输入标题", trigger: "blur" }],
  538. content: [{ required: true, message: "请输入内容", trigger: "blur" }],
  539. catalogId: [
  540. { required: true, message: "请输入选择分类", trigger: "blur" },
  541. ],
  542. // subjectIds: [{ required: true, message: "请选择声部组合", trigger: "change" }]
  543. },
  544. pageInfo: {
  545. // 分页规则
  546. limit: 10, // 限制显示条数
  547. page: 1, // 当前页
  548. total: 0, // 总条数
  549. page_size: [10, 20, 40, 50], // 选择限制显示条数
  550. },
  551. rowDetail: null,
  552. tempTreeList: [],
  553. organList: [],
  554. subjectList: [],
  555. roleList: [],
  556. };
  557. },
  558. activated() {
  559. this.getList();
  560. this.getSubjectList();
  561. //
  562. },
  563. async mounted() {
  564. this.getList();
  565. this.getSubjectList();
  566. this.getTreeList();
  567. },
  568. computed: {
  569. subjectListObj() {
  570. const data = {};
  571. for (let i = 0; i < this.subjectList.length; i++) {
  572. const item = this.subjectList[i];
  573. data[item.id] = item.name;
  574. }
  575. return data;
  576. },
  577. organListObj() {
  578. const data = {};
  579. for (let i = 0; i < this.organList.length; i++) {
  580. const item = this.organList[i];
  581. data[item.id] = item.name;
  582. }
  583. return data;
  584. },
  585. },
  586. async mounted() {
  587. await this.$store.dispatch("setOrganRole");
  588. this.roleList = this.selects.roles.hrId;
  589. this.getList();
  590. // this.getTreeList()
  591. getEmployeeOrgan().then((res) => {
  592. if (res.code == 200) {
  593. this.organList = res.data;
  594. }
  595. });
  596. this.getSubjectList();
  597. },
  598. methods: {
  599. employeeExport() {
  600. const { dates, ...rest } = this.searchForm;
  601. let params = {
  602. ...rest,
  603. ...getTimes(dates, ["startDate", "endDate"]),
  604. };
  605. Export(
  606. this,
  607. {
  608. url: "/api-web/export/employeeInfo",
  609. fileName: `人力资源导出.xls`,
  610. params: cleanDeep({
  611. ...params,
  612. }),
  613. },
  614. "是否确认导出人力资源?"
  615. );
  616. },
  617. getSubjectList() {
  618. getSubject({
  619. delFlag: 0,
  620. tenantId: 1,
  621. }).then((res) => {
  622. let result = res.data;
  623. if (res.code == 200) {
  624. // let tempArray = []
  625. // result.rows.forEach((item, index) => {
  626. // let subject = []
  627. // item.subjects.forEach(s => {
  628. // subject.push({
  629. // value: s.id,
  630. // label: s.name
  631. // })
  632. // })
  633. // tempArray[index] = {
  634. // label: item.name,
  635. // options: subject
  636. // }
  637. // })
  638. this.subjectList = result;
  639. }
  640. });
  641. },
  642. openEducation(row) {
  643. try {
  644. this.educationList = row.educationalBackground
  645. ? JSON.parse(row.educationalBackground)
  646. : [];
  647. this.educationVisible = true;
  648. } catch (error) {
  649. this.$message.error("数据解析失败");
  650. }
  651. },
  652. onTypeDelOpeation(row) {
  653. this.$confirm("您是否删除该内容?", "提示", {
  654. confirmButtonText: "确定",
  655. cancelButtonText: "取消",
  656. type: "warning",
  657. })
  658. .then(() => {
  659. helpCenterContentDelete({ id: row.id }).then((res) => {
  660. this.messageTips("删除", res);
  661. });
  662. })
  663. .catch(() => {});
  664. },
  665. search() {
  666. this.$refs.searchForm.validate((valid) => {
  667. this.pageInfo = {
  668. ...this.pageInfo,
  669. page: 1,
  670. };
  671. this.getList();
  672. });
  673. },
  674. onReSet() {
  675. this.pageInfo = {
  676. ...this.pageInfo,
  677. page: 1,
  678. };
  679. this.$refs.searchForm.resetFields();
  680. this.getList();
  681. },
  682. onTypeSubmit(formName) {
  683. // 添加数据
  684. this.$refs[formName].validate((valid) => {
  685. if (valid) {
  686. if (this.formActionTitle == "create") {
  687. let params = {
  688. title: this.form.title, // 标题
  689. content: this.form.content, // 内容
  690. catalogId: this.form.catalogId[this.form.catalogId.length - 1], // 分类编号
  691. };
  692. helpCenterContentModify(params).then((res) => {
  693. this.messageTips("添加", res);
  694. });
  695. } else if (this.formActionTitle == "update") {
  696. let params = {
  697. id: this.form.id,
  698. title: this.form.title, // 标题
  699. content: this.form.content, // 内容
  700. catalogId: this.form.catalogId[this.form.catalogId.length - 1], // 分类编号
  701. };
  702. helpCenterContentModify(params).then((res) => {
  703. this.messageTips("修改", res);
  704. });
  705. }
  706. } else {
  707. return false;
  708. }
  709. });
  710. },
  711. messageTips(title, res) {
  712. if (res.code == 200) {
  713. this.$message.success(title + "成功");
  714. this.typeStatus = false;
  715. this.getList();
  716. } else {
  717. this.$message.error(res.msg);
  718. }
  719. },
  720. getList() {
  721. const { dates, ...rest } = this.searchForm;
  722. console.log(dates);
  723. let params = {
  724. ...rest,
  725. ...getTimes(dates, ["startDate", "endDate"]),
  726. page: this.pageInfo.page,
  727. rows: this.pageInfo.limit,
  728. };
  729. employeeInfo(params).then((res) => {
  730. let result = res.data;
  731. if (res.code == 200) {
  732. this.tableList = result.rows;
  733. this.pageInfo.total = result.total;
  734. }
  735. });
  736. },
  737. getTreeList() {
  738. helpCenterCatalogList({
  739. parentId: 0,
  740. }).then((res) => {
  741. let result = res.data;
  742. if (res.code == 200) {
  743. this.treeList = this.setTableData(result);
  744. }
  745. });
  746. },
  747. setTableData(result) {
  748. let list = [];
  749. list = result.map((res) => {
  750. let tempList = {};
  751. tempList = {
  752. value: res.id,
  753. label: res.text,
  754. parentId: res.parentId,
  755. };
  756. if (res.children && res.children.length > 0) {
  757. tempList.children = this.setTableData(res.children);
  758. }
  759. return tempList;
  760. });
  761. return list;
  762. },
  763. openTypes(type, row) {
  764. this.rowDetail = { ...row };
  765. this.typeStatus = true;
  766. this.formActionTitle = type;
  767. if (type == "update") {
  768. // 修改的时候赋值
  769. this.form = {
  770. id: row.id,
  771. title: row.title, // 标题
  772. content: row.content, // 内容
  773. catalogId: this.getAllIds(row), // 分类编号
  774. };
  775. }
  776. },
  777. onToUrl() {
  778. this.$router.push("/helpCategory");
  779. },
  780. getAllIds(row) {
  781. let idAndParent = []; // idAndParent保存 Tree所有节点的id和parentId
  782. this.getIdAndParent(this.treeList, idAndParent);
  783. let parentIds = []; // 用于保存选中节点的父节点及父节点的父节点
  784. this.getId(row.catalogId, parentIds, idAndParent);
  785. return parentIds.reverse(); //反转数组
  786. },
  787. getIdAndParent(tree, idAndParentIds) {
  788. // idAndParentIds用来保存所有节点的id,parentId
  789. // 对原有的数据结构进行遍历,拿出所有节点的id,parentId到一个一维数组中。
  790. tree.forEach((item) => {
  791. let mid = {
  792. id: item.value,
  793. parentId: item.parentId,
  794. };
  795. idAndParentIds.push(mid);
  796. if (item.children) {
  797. this.getIdAndParent(item.children, idAndParentIds);
  798. }
  799. });
  800. },
  801. getId(id, parentIds, idAndParent) {
  802. idAndParent.forEach((item) => {
  803. if (item.id == id) {
  804. parentIds.push(id);
  805. if (item.parentId != -1) {
  806. this.getId(item.parentId, parentIds, idAndParent);
  807. }
  808. }
  809. });
  810. },
  811. onFormClose(formName) {
  812. this.rowDetail = null;
  813. this.typeStatus = false;
  814. // 关闭弹窗重置验证
  815. this.form = {
  816. title: null, // 标题
  817. content: null, // 内容
  818. catalogId: [], // 分类编号
  819. };
  820. this.getList();
  821. // this.$refs.cascader.handleClear()
  822. // this.$refs[formName].resetFields();
  823. },
  824. roleFormat(value) {
  825. const roleList = this.roleList;
  826. let userName = null;
  827. roleList.forEach((item) => {
  828. if (item.userId == value) {
  829. userName = item.userName;
  830. }
  831. });
  832. return userName;
  833. },
  834. },
  835. };
  836. </script>
  837. <style lang="scss" scoped>
  838. /deep/.el-date-editor.el-input {
  839. width: 100% !important;
  840. }
  841. /deep/.el-select {
  842. width: 100% !important;
  843. }
  844. /deep/.el-table .cell {
  845. display: -webkit-box;
  846. overflow: hidden;
  847. max-height: 45px;
  848. text-overflow: ellipsis;
  849. -webkit-line-clamp: 3;
  850. -webkit-box-orient: vertical;
  851. }
  852. /deep/.el-dialog__body {
  853. padding: 10px 20px;
  854. }
  855. .newBand {
  856. display: inline-block;
  857. }
  858. </style>