index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  1. <template>
  2. <div class="MutipleSelectPop">
  3. <div class="dialog_left">
  4. <div class="left_top">
  5. <Input
  6. @on-change="inputchange"
  7. @on-keydown="inputkeydown"
  8. search
  9. @on-search="inputsearch"
  10. :placeholder="tree.placeholder"
  11. v-model="tree.search"
  12. ></Input>
  13. </div>
  14. <div class="left_center">
  15. <div class="complex-spin-fix" v-if="treeLoading">
  16. <Spin fix>
  17. <Icon type="ios-loading" size="30" class="demo-spin-icon-load"></Icon>
  18. </Spin>
  19. </div>
  20. <Tree
  21. :data="treeLists"
  22. show-checkbox
  23. ref="Tree"
  24. :query="tree.search"
  25. :queryStyle="queryStyle"
  26. @on-select-change="getSelectedNodes"
  27. @on-check-change="getCheckedNodes"
  28. ></Tree>
  29. <!-- <el-tree
  30. :props="treeLists"
  31. show-checkbox
  32. @check-change="handleCheckChange">
  33. </el-tree> -->
  34. </div>
  35. </div>
  36. <div class="dialog_center">
  37. <div class="complex-spin-fix" v-if="tableLoading">
  38. <Spin fix>
  39. <Icon type="ios-loading" size="30" class="demo-spin-icon-load"></Icon>
  40. </Spin>
  41. </div>
  42. <div class="dialog_center_top">
  43. <div class="dialog_center_top_fix">
  44. <Input
  45. @on-change="inputchange"
  46. @on-keydown="inputkeydown"
  47. search
  48. @on-search="inputsearch"
  49. :placeholder="table.placeholder"
  50. v-model="table.search"
  51. ></Input>
  52. </div>
  53. </div>
  54. <div>
  55. <Tabs size="small" @on-click="tabClick" :animated="false">
  56. <TabPane v-for="(item,key) in TabPaneData" :key="key" :label="item.tab">
  57. <div class="dialog_center_page">
  58. <div>
  59. <Table
  60. border
  61. :columns="item.columns"
  62. ref="Table"
  63. :highlight-row="true"
  64. :clickTimerTask="300"
  65. :height="item.height"
  66. @on-select="Onselect"
  67. @on-select-cancel="onSelectCancel"
  68. @on-select-all="onSelectAll"
  69. @on-select-all-cancel="onSelectAllCancel"
  70. @on-selection-change="onSelectChange"
  71. @on-row-dblclick="rowdbClick"
  72. @on-row-click="rowClick"
  73. :data="item.list"
  74. ></Table>
  75. </div>
  76. <div class="dialog_p10">
  77. <Page
  78. :total="item.total"
  79. :page-size="item.pageSize"
  80. :current="item.pageNum"
  81. @on-change="pageChange"
  82. :page-size-opts="item.pageOptions"
  83. show-total
  84. size="small"
  85. />
  86. </div>
  87. </div>
  88. </TabPane>
  89. </Tabs>
  90. </div>
  91. </div>
  92. <div class="dialog-operation" v-if="index === 0">
  93. <div>
  94. <Button v-if="isUse" class="operatebtn" type="primary" ghost @click="operationTwo">选择部门</Button>
  95. <Button class="operatebtn" type="primary" ghost @click="operation">选择人员</Button>
  96. </div>
  97. </div>
  98. <div class="dialog_right">
  99. <div class="left_top right_top">
  100. <div>已选中({{resultMessage.total || 0 }})</div>
  101. <div>
  102. <i class="el-icon-delete" @click="delecFun"></i>
  103. </div>
  104. </div>
  105. <div class="right_center">
  106. <ul v-if="resultMessage.list.length>0">
  107. <li v-for="(item,index) in resultMessage.list" :key="index">
  108. <p>{{item.string}}</p>
  109. <i class="iconfont iconbj_delete2" @click="deleteLi(index,item)"></i>
  110. </li>
  111. </ul>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import {
  118. addGenmutipor,
  119. addGenmutiporuder,
  120. addGenmutiportree
  121. } from "@/api/activiti/definition";
  122. export default {
  123. name: "Mutiple",
  124. props: {
  125. // treedata: {
  126. // type: Array,
  127. // default() {
  128. // return [];
  129. // }
  130. // },
  131. // componentData: {
  132. // type: Array,
  133. // default() {
  134. // return [];
  135. // }
  136. // },
  137. resultData: {
  138. type: Object,
  139. default() {
  140. return {};
  141. }
  142. },
  143. loading: {
  144. type: Boolean,
  145. default: false
  146. },
  147. // treeLoading: {
  148. // type: Boolean,
  149. // default: false
  150. // },
  151. // tableLoading: {
  152. // type: Boolean,
  153. // default: false
  154. // },
  155. open: {
  156. type: Boolean,
  157. default: false
  158. },
  159. icon_delect: {
  160. type: String,
  161. default: "iconfont icon-bj_delete"
  162. },
  163. checkedList: {
  164. type: Array,
  165. default() {
  166. return [];
  167. }
  168. },
  169. // tableSearch: {
  170. // type: String,
  171. // default: ""
  172. // },
  173. isUse: {
  174. type: Boolean,
  175. default: true
  176. },
  177. isMutiple: {
  178. //是否多选
  179. type: Boolean,
  180. default: true
  181. },
  182. // isResultShow: {
  183. // //result.list是否反显
  184. // type: Boolean,
  185. // default: true
  186. // },
  187. isCallInterface: {
  188. //用来控制调用接口拿到数据 //也可以理解为弹框关闭状态
  189. type: Boolean,
  190. default: false
  191. }
  192. },
  193. data() {
  194. return {
  195. tableLoading: false,
  196. treeLoading: false,
  197. tree: {
  198. placeholder: "可搜索店仓/部门",
  199. search: ""
  200. },
  201. table: {
  202. //表格显示部分搜索
  203. placeholder: "直接输入人员姓名搜索",
  204. search: ""
  205. },
  206. columns: [],
  207. treeNewData: [],
  208. showTree: this.open,
  209. componentt: [
  210. {
  211. tab: "筛选结果",
  212. columns: [
  213. { key: "NAME", title: "用户名" },
  214. { key: "ENAME", title: "用户姓名" }
  215. ],
  216. list: [],
  217. total: 0,
  218. pageSize: 10,
  219. pageNum: 1, //当前页码
  220. pageOptions: [10, 20, 50, 100],
  221. height: 340
  222. }
  223. ],
  224. resultRightData: {
  225. total: 0,
  226. list: []
  227. },
  228. templateName: "",
  229. index: 0,
  230. queryStyle: {
  231. color: "#fd6442"
  232. },
  233. selectRow: [], //表格选中的数据
  234. selectDatas: {}, //单行选中
  235. obj: {} //
  236. };
  237. },
  238. computed: {
  239. treeLists() {
  240. // this.treeNewData = this.treedata;
  241. return this.treeNewData;
  242. },
  243. TabPaneData() {
  244. // let data = Object.assign(this.component, this.componentData);
  245. // return data;
  246. if (this.isMutiple) {
  247. // this.componentt[0].columns.unshift({
  248. // type: "selection",
  249. // align: "center",
  250. // fixed: "left",
  251. // width: 30
  252. // });
  253. }
  254. return this.componentt;
  255. },
  256. resultMessage() {
  257. // let data = Object.assign(this.resultRightData, this.resultData);
  258. return this.resultRightData;
  259. }
  260. },
  261. watch: {
  262. isCallInterface: {
  263. handler(newValue, oldValue) {
  264. if (newValue) {
  265. //执行请求
  266. this.componentt[0].pageNum = 1
  267. this.getTreeData();
  268. if (this.resultData.list) {
  269. this.resultRightData = this.deepCopy(this.resultData);
  270. }
  271. } else {
  272. if (this.selectRow.length > 0) {
  273. this.selectRow = [];
  274. }
  275. if (Object.keys(this.selectDatas).length > 0) {
  276. this.selectDatas = {};
  277. }
  278. if (this.table.search) {
  279. this.table.search = "";
  280. }
  281. }
  282. }
  283. }
  284. },
  285. methods: {
  286. deepCopy(obj) {
  287. //兑现深拷贝
  288. var result = Array.isArray(obj) ? [] : {};
  289. for (var key in obj) {
  290. if (obj.hasOwnProperty(key)) {
  291. if (typeof obj[key] === "object" && obj[key] !== null) {
  292. result[key] = this.deepCopy(obj[key]); //递归复制
  293. } else {
  294. result[key] = obj[key];
  295. }
  296. }
  297. }
  298. return result;
  299. },
  300. getSelectedNodes(val) {
  301. // if (this.isMutiple) {
  302. if (val.length > 0) {
  303. this.obj = {};
  304. this.saveObj = val[0];
  305. let self = this;
  306. let valID = "";
  307. if (val[0].ID.indexOf(".") !== -1) {
  308. valID = val[0].ID.split(".")[1];
  309. valID = parseInt(valID);
  310. } else {
  311. valID = parseInt(val[0].ID);
  312. }
  313. if (val[0].CP_C_ORGUP_ID === null) {
  314. //根节点
  315. this.findUser({});
  316. } else {
  317. //当item的TYPE为店仓时
  318. if (val[0].TYPE === "CP_C_STORE_ID") {
  319. this.obj.CP_C_STORE_ID = "in(" + valID + ")";
  320. self.findUser(self.obj);
  321. }
  322. //当item的TYPE为供应商时
  323. // 当item的TYPE为组织时
  324. if (val[0].TYPE === "CP_C_HRORG_ID") {
  325. addGenmutipor({ CP_C_ORGUP_ID: valID })
  326. .then(res => {
  327. if (res.data.resultCode === 0) {
  328. let HRORG = "in ("; //储存键名为CP_C_HRORG_ID对象的ID
  329. let STORE = "in ("; //储存键名为CP_C_STORE_ID对象的ID
  330. if (
  331. res.data.data.CP_C_HRORG &&
  332. res.data.data.CP_C_HRORG.length > 0
  333. ) {
  334. res.data.data.CP_C_HRORG.forEach(item => {
  335. HRORG += item.ID + ","; // in 1,2,3,5,6,87,8,6
  336. });
  337. if (res.data.data.CP_C_HRORG.length > 0) {
  338. self.obj.CP_C_HRORG_ID =
  339. HRORG.substring(0, HRORG.length - 1) + ")";
  340. }
  341. }
  342. if (
  343. res.data.data.CP_C_STORE &&
  344. res.data.data.CP_C_STORE.length > 0
  345. ) {
  346. res.data.data.CP_C_STORE.forEach(item => {
  347. STORE += item.ID + ",";
  348. });
  349. if (res.data.data.CP_C_STORE.length > 0) {
  350. self.obj.CP_C_STORE_ID =
  351. STORE.substring(0, STORE.length - 1) + ")";
  352. }
  353. }
  354. self.findUser(self.obj);
  355. } else {
  356. this.$Modal.fcError({
  357. title: "错误提示",
  358. content: res.data.resultMsg
  359. });
  360. }
  361. });
  362. }
  363. // setTimeout(function() {
  364. // self.findUser(self.obj);
  365. // });
  366. }
  367. }
  368. // }
  369. this.$emit("on-select-tree", val, this);
  370. },
  371. getCheckedNodes(obj) {
  372. this.$emit("on-change-tree", obj, this);
  373. },
  374. tabClick(index) {
  375. this.index = index;
  376. this.$emit("on-click-tab", index, this);
  377. },
  378. pageChange(index) {
  379. this.$emit("on-change-page", index, this);
  380. this.componentt[0].pageNum = index;
  381. let param = Object.assign(this.obj, { page: index, pageSize: 10 });
  382. if (this.table.search !== "") {
  383. param.ENAME = this.table.search;
  384. }
  385. this.findUser(param);
  386. },
  387. pageChangeSize(index) {
  388. this.$emit("on-change-pageSize", index, this);
  389. this.componentt[0].pageSize = index;
  390. let param = Object.assign(this.obj, { page: 1, pageSize: index });
  391. if (this.table.search !== "") {
  392. param.ENAME = this.table.search;
  393. }
  394. this.findUser(param);
  395. },
  396. rowdbClick(row, index) {
  397. let selectObj = Object.assign({}, row);
  398. if (!this.isMutiple) {
  399. selectObj.string = selectObj.ENAME;
  400. if (this.resultRightData.list) {
  401. this.resultRightData.list = [];
  402. this.resultRightData.list.push(selectObj);
  403. } else {
  404. this.$set(this.resultRightData, "list", [selectObj]);
  405. }
  406. } else {
  407. let selectObj = Object.assign({ approve_type: 4 }, row);
  408. selectObj.string = selectObj.ENAME;
  409. if (this.resultRightData.list && this.resultRightData.list.length > 0) {
  410. let flagIndex = this.resultRightData.list.findIndex(inner => {
  411. return (
  412. selectObj.ID === inner.ID || selectObj.ID === Number(inner.approve_value)
  413. );
  414. });
  415. if (flagIndex === -1) {
  416. //没有找到相同的就加入
  417. this.resultRightData.list.push(selectObj);
  418. } else {
  419. this.$message({
  420. message: selectObj.ENAME + "已经选择过了,请不要重复选择!",
  421. type: 'warning'
  422. });
  423. }
  424. } else {
  425. this.$set(this.resultRightData, "list", [selectObj]);
  426. }
  427. }
  428. this.resultRightData.total
  429. ? (this.resultRightData.total = this.resultRightData.list.length)
  430. : this.$set(
  431. this.resultRightData,
  432. "total",
  433. this.resultRightData.list.length
  434. );
  435. this.$emit("getResult", this.resultRightData);
  436. this.$refs.Table[0].clearCurrentRow();
  437. this.$emit("on-row-dblclick", row, index, this);
  438. },
  439. rowClick(row, index) {
  440. if (!this.isMutiple) {
  441. this.selectDatas = Object.assign(this.selectDatas, row);
  442. }
  443. this.$emit("on-row-click", row, index, this);
  444. },
  445. Onselect(selection, row) {
  446. if (this.isMutiple) {
  447. this.componentt[0].list.map(item => {
  448. if (row.ID === item.ID) {
  449. item._checked = true;
  450. }
  451. });
  452. this.selectRow = [];
  453. this.selectRow = selection;
  454. }
  455. this.$emit("on-select", selection, row);
  456. },
  457. onSelectCancel(selection, row) {
  458. this.componentt[0].list.map(item => {
  459. if (row.ID === item.ID) {
  460. item._checked = false;
  461. }
  462. });
  463. this.selectRow = [];
  464. this.selectRow = selection;
  465. this.$emit("on-select-cancel", selection, row);
  466. },
  467. onSelectAll(selection) {
  468. this.selectRow = [];
  469. this.componentt[0].list.map(item => {
  470. item._checked = true;
  471. });
  472. this.selectRow = selection;
  473. this.$emit("on-select-all", selection);
  474. },
  475. onSelectAllCancel(selection) {
  476. this.componentt[0].list.map(item => {
  477. item._checked = false;
  478. });
  479. this.selectRow = [];
  480. this.$emit("on-select-all-cancel", selection);
  481. },
  482. onSelectChange(selection) {
  483. this.$emit("on-select-change", selection);
  484. },
  485. inputchange(event) {
  486. // if(!this.isUse&&!this.isMutiple){
  487. this.table.search = event.target.value;
  488. // }
  489. this.$emit("on-change", event, this);
  490. },
  491. inputkeydown(event) {
  492. this.$emit("on-keydown", event, this);
  493. },
  494. inputsearch(event) {
  495. let param = Object.assign(this.obj, {
  496. page: 1,
  497. pageSize: 10,
  498. ENAME: event
  499. });
  500. this.findUser(param);
  501. this.$emit("on-search", event, this);
  502. },
  503. operationTwo() {
  504. let selectNode = this.$refs.Tree.getCheckedNodes();
  505. selectNode = selectNode.filter(item => item.title !=='全部')
  506. if (this.isMutiple) {
  507. if (selectNode.length > 0) {
  508. this.resultRightData.total
  509. ? this.$set(this.resultRightData, "total", this.resultData.total + selectNode.length)
  510. : this.$set(this.resultRightData, "total", selectNode.length);
  511. selectNode.map(item => {
  512. let selectObj = Object.assign({ approve_type: 2 }, item);
  513. selectObj.string = item.ENAME;
  514. if (
  515. this.resultRightData.list &&
  516. this.resultRightData.list.length > 0
  517. ) {
  518. let flagIndex = this.resultRightData.list.findIndex(inner => {
  519. return item.ID === inner.ID || item.ID === Number(inner.approve_value);
  520. });
  521. if (flagIndex === -1) {
  522. //没有找到相同的就加入
  523. this.resultRightData.list.push(selectObj);
  524. } else {
  525. this.$message({
  526. message: item.ENAME + "已经选择过了,请不要重复选择!",
  527. type: 'warning'
  528. });
  529. }
  530. } else {
  531. this.$set(this.resultRightData, "list", [selectObj]);
  532. }
  533. });
  534. } else {
  535. his.$message({
  536. message:"请选择部门!",
  537. type: 'warning'
  538. });
  539. // this.$Message.warning("请选择部门");
  540. }
  541. this.getTreeData();
  542. }
  543. if (this.selectRow.length > 0) {
  544. //选中状态的清除
  545. this.selectRow = [];
  546. }
  547. if (Object.keys(this.selectDatas).length > 0) {
  548. this.selectDatas = {};
  549. }
  550. this.$emit("getResult", this.resultRightData);
  551. this.$emit("on-transfer-two", selectNode, this);
  552. },
  553. operation() {
  554. if (!this.isMutiple) {
  555. //单选逻辑
  556. if (Object.keys(this.selectDatas).length === 0) {
  557. this.$message({
  558. message: '请选择人员',
  559. type: 'warning'
  560. });
  561. // this.$Message.warning("请选择人员");
  562. return;
  563. }
  564. this.resultRightData.total
  565. ? (this.resultRightData.total = 1)
  566. : this.$set(this.resultRightData, "total", 1);
  567. let selectObj = Object.assign({}, this.selectDatas);
  568. selectObj.string = selectObj.ENAME;
  569. if (this.resultRightData.list) {
  570. this.resultRightData.list = [];
  571. this.resultRightData.list.push(selectObj);
  572. } else {
  573. this.$set(this.resultRightData, "list", [selectObj]);
  574. }
  575. } else {
  576. //多选逻辑
  577. if (this.selectRow.length > 0) {
  578. this.selectRow.map(item => {
  579. let selectObj = Object.assign({ approve_type: 4 }, item);
  580. selectObj.string = item.ENAME;
  581. if (
  582. this.resultRightData.list &&
  583. this.resultRightData.list.length > 0
  584. ) {
  585. let flagIndex = this.resultRightData.list.findIndex(inner => {
  586. return item.ID === inner.ID || item.ID === Number(inner.approve_value);
  587. });
  588. if (flagIndex === -1) {
  589. //没有找到相同的就加入
  590. this.resultRightData.list.push(selectObj);
  591. } else {
  592. this.$message({
  593. message: item.ENAME + "已经选择过了,请不要重复选择!",
  594. type: 'warning'
  595. });
  596. // this.$Message.warning(
  597. // item.ENAME + "已经选择过了,请不要重复选择!"
  598. // );
  599. }
  600. } else {
  601. this.$set(this.resultRightData, "list", [selectObj]);
  602. }
  603. });
  604. this.resultRightData.total
  605. ? (this.resultRightData.total = this.resultRightData.list.length)
  606. : this.$set(
  607. this.resultRightData,
  608. "total",
  609. this.resultRightData.list.length
  610. );
  611. } else {
  612. this.$message({
  613. message: '请选择人员',
  614. type: 'warning'
  615. });
  616. // this.$Message.warning("请选择人员");
  617. }
  618. }
  619. //刷新表格数据
  620. this.componentt[0].list.map(item => {
  621. item._checked = false;
  622. });
  623. this.componentt[0].list = this.componentt[0].list.concat([]);
  624. if (this.selectRow.length > 0) {
  625. //选中状态的清除
  626. this.selectRow = [];
  627. }
  628. if (Object.keys(this.selectDatas).length > 0) {
  629. this.selectDatas = {};
  630. }
  631. this.$emit("getResult", this.resultRightData);
  632. this.$emit("on-transfer", this);
  633. },
  634. deleteLi(index, tem) {
  635. let selectNode = this.$refs.Tree.getCheckedNodes();
  636. if (selectNode && selectNode.length > 0) {
  637. selectNode.map(inItem => {
  638. if (inItem.ID === tem.ID) {
  639. this.$refs.Tree.handleCheck({
  640. checked: false,
  641. nodeKey: inItem.nodeKey
  642. });
  643. }
  644. });
  645. }
  646. let selectrow = this.TabPaneData[0].list; //表格数据
  647. selectrow.map((row, Index) => {
  648. if (row.ID === tem.ID) {
  649. row._checked = false;
  650. }
  651. });
  652. this.resultRightData.list.splice(index, 1);
  653. this.resultRightData.total = this.resultRightData.list.length;
  654. this.$emit("getResult", this.resultRightData);
  655. this.$emit("on-delectli", index, tem, this);
  656. },
  657. treeOpen(checked) {
  658. this.showTree = !checked;
  659. this.treeNewData.forEach(item => {
  660. item.expand = !item.expand;
  661. });
  662. },
  663. delecFun() {
  664. let selectNode = this.$refs.Tree.getCheckedNodes();
  665. if (selectNode && selectNode.length > 0) {
  666. selectNode.map(inItem => {
  667. this.$refs.Tree.handleCheck({
  668. checked: false,
  669. nodeKey: inItem.nodeKey
  670. });
  671. });
  672. }
  673. let selectrow = this.TabPaneData[0].list; //表格数据
  674. if (selectrow && selectrow.length > 0) {
  675. selectrow.map((row, Index) => {
  676. row._checked = false;
  677. });
  678. }
  679. this.$emit("on-deleBtn", this);
  680. this.resultRightData.total = 0;
  681. this.resultRightData.list = [];
  682. this.componentt[0].list.map(item => {
  683. item._checked = false;
  684. });
  685. this.componentt[0].list = this.componentt[0].list.concat([]);
  686. this.$emit("getResult", this.resultRightData);
  687. },
  688. //查找用户信息
  689. findUser(param) {
  690. this.tableLoading = true;
  691. addGenmutiporuder( param).then(res => {
  692. this.tableLoading = false;
  693. let data = res;
  694. if (res.code === 0) {
  695. if (data.data) {
  696. this.transferTbody(data.data);
  697. }
  698. if (data.datas) {
  699. this.transferTbody(data.datas);
  700. }
  701. }
  702. });
  703. },
  704. //表格体数据转化
  705. transferTbody(data) {
  706. this.componentt[0].total = data.totalRowCount;
  707. this.componentt[0].pageOptions = data.selectrange;
  708. this.componentt[0].list = [];
  709. data.row.map(item => {
  710. let tem = {};
  711. let temval = {};
  712. Object.keys(item).map(inner => {
  713. tem[inner] = item[inner].val;
  714. });
  715. temval = Object.assign({}, tem);
  716. this.componentt[0].list.push(tem);
  717. });
  718. },
  719. //获取树数据
  720. getTreeData() {
  721. this.tree_loading = true;
  722. addGenmutiportree().then(res => {
  723. this.tree_loading = false;
  724. if (res.resultCode === 0) {
  725. console.log(345678)
  726. this.treeNewData = [];
  727. let newArr = [];
  728. let root = {};
  729. if (res.data.records.length > 0) {
  730. console.log(3456788)
  731. res.data.records.forEach(item => {
  732. let tem = Object.assign(item);
  733. newArr.push(tem);
  734. if (
  735. item["CP_C_ORGUP_ID"] === null ||
  736. item["CP_C_ORGUP_ID"] === ""
  737. ) {
  738. root = Object.assign({}, item);
  739. }
  740. });
  741. this.treeNewData = this.arrayTransTree(newArr, "CP_C_ORGUP_ID");
  742. console.log(this.treeNewData)
  743. }
  744. this.findUser({}); //显示所有的用户
  745. }
  746. });
  747. },
  748. //改造树数据的结构
  749. arrayTransTree(list, key) {
  750. let parent = [];
  751. let children = [];
  752. list.map(item => {
  753. item.expand = false;
  754. item.title = item.ENAME;
  755. if (
  756. !item[key]||
  757. (item[key].indexOf('.')!==-1&&!item[key].split(".")[1])
  758. ) {
  759. //根节点
  760. parent.push(item);
  761. } else {
  762. //有父节点的
  763. children.push(item);
  764. }
  765. });
  766. if (parent.length < 1) {
  767. //没有根节点
  768. let newParent = this.findTreeRootFirstChild(list, key); //拿到一级节点
  769. let rootArr = newParent.map(item => {
  770. return item[key];
  771. });
  772. let rootTem = Array.from(new Set([...rootArr]));
  773. if (rootTem.length === 1) {
  774. parent = [
  775. {
  776. CP_C_ORGUP_ID: null,
  777. ECODE: "00000",
  778. ENAME: "全部",
  779. ID: rootTem[0],
  780. MIXNAME: "[00000]全部",
  781. ORGTYPE: "IN",
  782. TYPE: "CP_C_HRORG_ID",
  783. title:'全部'
  784. }
  785. ];
  786. this.translator(parent, children, key);
  787. return parent;
  788. } else {
  789. this.$message({
  790. message: '数据有问题,请检查...',
  791. type: 'warning'
  792. });
  793. // this.$Message.warning("数据有问题,请检查...");
  794. return;
  795. }
  796. } else {
  797. this.translator(parent, children, key);
  798. return parent;
  799. }
  800. },
  801. translator(parents, children, key) {
  802. let temp = [];
  803. children.map(item => {
  804. //对子节点数据进行深复制,这里只支持部分类型的数据深复制
  805. let temItem = Object.assign({}, item);
  806. temp.push(temItem);
  807. });
  808. //遍历父节点数据
  809. parents.map(parent => {
  810. //遍历子节点数据
  811. children.map((current, index) => {
  812. //此时找到父节点对应的一个子节点
  813. if (current[key] === parent.ID) {
  814. //让当前子节点从temp中移除,temp作为新的子节点数据,这里是为了让递归时,子节点的遍历次数更少,如果父子关系的层级越多,越有利
  815. temp.splice(index, 1);
  816. //让当前子节点作为唯一的父节点,去递归查找其对应的子节点
  817. this.translator([current], temp, key);
  818. //把找到子节点放入父节点的children属性中
  819. parent.children
  820. ? parent.children.push(current)
  821. : (parent.children = [current]);
  822. }
  823. });
  824. });
  825. },
  826. treeTransArray(tree, key) {
  827. return tree
  828. .reduce(function iteration(con, item) {
  829. con.push(item);
  830. if (item[key] && item[key].length > 0)
  831. item[key].reduce(iteration, con);
  832. return con;
  833. }, [])
  834. .map(function(item) {
  835. item[key] = [];
  836. return item;
  837. });
  838. },
  839. findTreeRootFirstChild(Arr, key) {
  840. let idArr = [];
  841. let result = [];
  842. idArr = Arr.map(item => {
  843. return item["ID"];
  844. });
  845. Arr.map(item => {
  846. if (!idArr.includes(item[key])) {
  847. //一级节点的特点是存在父节点 但是已父节点为ID的节点是不存在的
  848. result.push(item);
  849. }
  850. });
  851. return result;
  852. },
  853. handleCheckChange(){
  854. }
  855. },
  856. mounted() {
  857. // if(this.isCallInterface){
  858. // this.getTreeData();
  859. // if (this.resultData.list) {
  860. // this.resultRightData = this.deepCopy(this.resultData);
  861. // }
  862. // }else{
  863. // if (this.selectRow.length > 0) {
  864. // this.selectRow = [];
  865. // }
  866. // if (Object.keys(this.selectDatas).length > 0) {
  867. // this.selectDatas = {};
  868. // }
  869. // if (this.table.search) {
  870. // this.table.search = "";
  871. // }
  872. // }
  873. },
  874. destroyed() {
  875. if (this.selectRow.length > 0) {
  876. this.selectRow = [];
  877. }
  878. if (Object.keys(this.selectDatas).length > 0) {
  879. this.selectDatas = {};
  880. }
  881. if (this.table.search) {
  882. this.table.search = "";
  883. }
  884. }
  885. };
  886. </script>
  887. <style lang="scss">
  888. .MutipleSelectPop {
  889. width: 800px;
  890. display: flex;
  891. height: 484px;
  892. position: relative;
  893. .demo-spin-icon-load {
  894. animation: ani-demo-spin 1s linear infinite;
  895. }
  896. .complex-spin-fix {
  897. z-index: 20;
  898. }
  899. @keyframes ani-demo-spin {
  900. from {
  901. transform: rotate(0deg);
  902. }
  903. 50% {
  904. transform: rotate(180deg);
  905. }
  906. to {
  907. transform: rotate(360deg);
  908. }
  909. }
  910. overflow: hidden;
  911. .dialog_left {
  912. width: 170px;
  913. display: -ms-flexbox;
  914. display: flex;
  915. -ms-flex-direction: column;
  916. flex-direction: column;
  917. padding: 10px;
  918. border: 1px solid #dcdee2;
  919. border-right: none;
  920. .left_top {
  921. height: 32px;
  922. line-height: 32px;
  923. box-sizing: border-box;
  924. border-bottom: 1px solid #e8eaec;
  925. font-size: 12px;
  926. color: #575757;
  927. display: flex;
  928. input {
  929. line-height: 32px;
  930. height: 32px;
  931. }
  932. div:first-child {
  933. flex: 1;
  934. }
  935. i {
  936. margin-right: 10px;
  937. }
  938. }
  939. .left_center {
  940. flex: 1;
  941. padding-top: 10px;
  942. position: relative;
  943. height: 390px;
  944. padding-bottom: 10px;
  945. width: 156px;
  946. overflow-y: auto;
  947. }
  948. }
  949. .dialog_center {
  950. width: 400px;
  951. position: relative;
  952. height: 484px;
  953. border: 1px solid #dcdee2;
  954. border-right: none;
  955. //box-shadow: 2px -2px 9px @shadow-color;
  956. padding: 10px;
  957. display: -ms-flexbox;
  958. display: flex;
  959. -ms-flex-direction: column;
  960. flex-direction: column;
  961. .dialog_p10 {
  962. padding: 10px 0;
  963. }
  964. .dialog_center_top {
  965. display: flex;
  966. line-height: 32px;
  967. vertical-align: middle;
  968. box-sizing: border-box;
  969. .dialog_center_top_fix {
  970. width: 270px;
  971. box-sizing: border-box;
  972. padding-right: 20px;
  973. input {
  974. line-height: 32px;
  975. height: 32px;
  976. }
  977. }
  978. }
  979. }
  980. .dialog-operation {
  981. width: 92px;
  982. padding: 0px;
  983. border-left: 1px solid #dcdee2;
  984. background-color: #fff;
  985. position: relative;
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. div {
  990. text-align: center;
  991. .operatebtn {
  992. margin-bottom: 10px;
  993. padding: 8px 12px;
  994. &:last-child {
  995. margin-bottom: 0;
  996. }
  997. }
  998. }
  999. }
  1000. .dialog_right {
  1001. width: 220px;
  1002. padding: 10px;
  1003. border: 1px solid #dcdee2;
  1004. box-sizing: border-box;
  1005. display: -ms-flexbox;
  1006. display: flex;
  1007. -ms-flex-direction: column;
  1008. flex-direction: column;
  1009. .left_top {
  1010. height: 30px;
  1011. line-height: 30px;
  1012. box-sizing: border-box;
  1013. border-bottom: 1px solid #e8eaec;
  1014. font-size: 12px;
  1015. color: #575757;
  1016. display: flex;
  1017. div:first-child {
  1018. flex: 1;
  1019. }
  1020. i {
  1021. margin-right: 10px;
  1022. }
  1023. }
  1024. ul {
  1025. height: 390px;
  1026. overflow: auto;
  1027. li {
  1028. margin-bottom: 4px;
  1029. display: -ms-flexbox;
  1030. display: flex;
  1031. -ms-flex-align: center;
  1032. align-items: center;
  1033. background-color: #f8f8f8;
  1034. border-radius: 2px;
  1035. font-size: 12px;
  1036. p {
  1037. flex: 1;
  1038. line-height: 18px;
  1039. margin-left: 4px;
  1040. box-sizing: border-box;
  1041. border-radius: 4px;
  1042. padding: 4px 6px;
  1043. color: #0f8ee9;
  1044. word-wrap: break-word;
  1045. word-break: break-all;
  1046. }
  1047. }
  1048. }
  1049. }
  1050. .right_center {
  1051. flex: 1;
  1052. padding-top: 10px;
  1053. }
  1054. }
  1055. </style>