123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065 |
- <template>
- <div class="MutipleSelectPop">
- <div class="dialog_left">
- <div class="left_top">
- <Input
- @on-change="inputchange"
- @on-keydown="inputkeydown"
- search
- @on-search="inputsearch"
- :placeholder="tree.placeholder"
- v-model="tree.search"
- ></Input>
- </div>
- <div class="left_center">
- <div class="complex-spin-fix" v-if="treeLoading">
- <Spin fix>
- <Icon type="ios-loading" size="30" class="demo-spin-icon-load"></Icon>
- </Spin>
- </div>
- <Tree
- :data="treeLists"
- show-checkbox
- ref="Tree"
- :query="tree.search"
- :queryStyle="queryStyle"
- @on-select-change="getSelectedNodes"
- @on-check-change="getCheckedNodes"
- ></Tree>
- <!-- <el-tree
- :props="treeLists"
- show-checkbox
- @check-change="handleCheckChange">
- </el-tree> -->
- </div>
- </div>
- <div class="dialog_center">
- <div class="complex-spin-fix" v-if="tableLoading">
- <Spin fix>
- <Icon type="ios-loading" size="30" class="demo-spin-icon-load"></Icon>
- </Spin>
- </div>
- <div class="dialog_center_top">
- <div class="dialog_center_top_fix">
- <Input
- @on-change="inputchange"
- @on-keydown="inputkeydown"
- search
- @on-search="inputsearch"
- :placeholder="table.placeholder"
- v-model="table.search"
- ></Input>
- </div>
- </div>
- <div>
- <Tabs size="small" @on-click="tabClick" :animated="false">
- <TabPane v-for="(item,key) in TabPaneData" :key="key" :label="item.tab">
- <div class="dialog_center_page">
- <div>
- <Table
- border
- :columns="item.columns"
- ref="Table"
- :highlight-row="true"
- :clickTimerTask="300"
- :height="item.height"
- @on-select="Onselect"
- @on-select-cancel="onSelectCancel"
- @on-select-all="onSelectAll"
- @on-select-all-cancel="onSelectAllCancel"
- @on-selection-change="onSelectChange"
- @on-row-dblclick="rowdbClick"
- @on-row-click="rowClick"
- :data="item.list"
- ></Table>
- </div>
- <div class="dialog_p10">
- <Page
- :total="item.total"
- :page-size="item.pageSize"
- :current="item.pageNum"
- @on-change="pageChange"
- :page-size-opts="item.pageOptions"
- show-total
- size="small"
- />
- </div>
- </div>
- </TabPane>
- </Tabs>
- </div>
- </div>
- <div class="dialog-operation" v-if="index === 0">
- <div>
- <Button v-if="isUse" class="operatebtn" type="primary" ghost @click="operationTwo">选择部门</Button>
- <Button class="operatebtn" type="primary" ghost @click="operation">选择人员</Button>
- </div>
- </div>
- <div class="dialog_right">
- <div class="left_top right_top">
- <div>已选中({{resultMessage.total || 0 }})</div>
- <div>
- <i class="el-icon-delete" @click="delecFun"></i>
- </div>
- </div>
- <div class="right_center">
- <ul v-if="resultMessage.list.length>0">
- <li v-for="(item,index) in resultMessage.list" :key="index">
- <p>{{item.string}}</p>
- <i class="iconfont iconbj_delete2" @click="deleteLi(index,item)"></i>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- addGenmutipor,
- addGenmutiporuder,
- addGenmutiportree
- } from "@/api/activiti/definition";
- export default {
- name: "Mutiple",
- props: {
- // treedata: {
- // type: Array,
- // default() {
- // return [];
- // }
- // },
- // componentData: {
- // type: Array,
- // default() {
- // return [];
- // }
- // },
- resultData: {
- type: Object,
- default() {
- return {};
- }
- },
- loading: {
- type: Boolean,
- default: false
- },
- // treeLoading: {
- // type: Boolean,
- // default: false
- // },
- // tableLoading: {
- // type: Boolean,
- // default: false
- // },
- open: {
- type: Boolean,
- default: false
- },
- icon_delect: {
- type: String,
- default: "iconfont icon-bj_delete"
- },
- checkedList: {
- type: Array,
- default() {
- return [];
- }
- },
- // tableSearch: {
- // type: String,
- // default: ""
- // },
- isUse: {
- type: Boolean,
- default: true
- },
- isMutiple: {
- //是否多选
- type: Boolean,
- default: true
- },
- // isResultShow: {
- // //result.list是否反显
- // type: Boolean,
- // default: true
- // },
- isCallInterface: {
- //用来控制调用接口拿到数据 //也可以理解为弹框关闭状态
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- tableLoading: false,
- treeLoading: false,
- tree: {
- placeholder: "可搜索店仓/部门",
- search: ""
- },
- table: {
- //表格显示部分搜索
- placeholder: "直接输入人员姓名搜索",
- search: ""
- },
- columns: [],
- treeNewData: [],
- showTree: this.open,
- componentt: [
- {
- tab: "筛选结果",
- columns: [
- { key: "NAME", title: "用户名" },
- { key: "ENAME", title: "用户姓名" }
- ],
- list: [],
- total: 0,
- pageSize: 10,
- pageNum: 1, //当前页码
- pageOptions: [10, 20, 50, 100],
- height: 340
- }
- ],
- resultRightData: {
- total: 0,
- list: []
- },
- templateName: "",
- index: 0,
- queryStyle: {
- color: "#fd6442"
- },
- selectRow: [], //表格选中的数据
- selectDatas: {}, //单行选中
- obj: {} //
- };
- },
- computed: {
- treeLists() {
- // this.treeNewData = this.treedata;
- return this.treeNewData;
- },
- TabPaneData() {
- // let data = Object.assign(this.component, this.componentData);
- // return data;
- if (this.isMutiple) {
- // this.componentt[0].columns.unshift({
- // type: "selection",
- // align: "center",
- // fixed: "left",
- // width: 30
- // });
- }
- return this.componentt;
- },
- resultMessage() {
- // let data = Object.assign(this.resultRightData, this.resultData);
- return this.resultRightData;
- }
- },
- watch: {
- isCallInterface: {
- handler(newValue, oldValue) {
- if (newValue) {
- //执行请求
- this.componentt[0].pageNum = 1
- this.getTreeData();
- if (this.resultData.list) {
- this.resultRightData = this.deepCopy(this.resultData);
- }
- } else {
- if (this.selectRow.length > 0) {
- this.selectRow = [];
- }
- if (Object.keys(this.selectDatas).length > 0) {
- this.selectDatas = {};
- }
- if (this.table.search) {
- this.table.search = "";
- }
- }
- }
- }
- },
- methods: {
- deepCopy(obj) {
- //兑现深拷贝
- var result = Array.isArray(obj) ? [] : {};
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (typeof obj[key] === "object" && obj[key] !== null) {
- result[key] = this.deepCopy(obj[key]); //递归复制
- } else {
- result[key] = obj[key];
- }
- }
- }
- return result;
- },
- getSelectedNodes(val) {
- // if (this.isMutiple) {
- if (val.length > 0) {
- this.obj = {};
- this.saveObj = val[0];
- let self = this;
- let valID = "";
- if (val[0].ID.indexOf(".") !== -1) {
- valID = val[0].ID.split(".")[1];
- valID = parseInt(valID);
- } else {
- valID = parseInt(val[0].ID);
- }
- if (val[0].CP_C_ORGUP_ID === null) {
- //根节点
- this.findUser({});
- } else {
- //当item的TYPE为店仓时
- if (val[0].TYPE === "CP_C_STORE_ID") {
- this.obj.CP_C_STORE_ID = "in(" + valID + ")";
- self.findUser(self.obj);
- }
- //当item的TYPE为供应商时
- // 当item的TYPE为组织时
- if (val[0].TYPE === "CP_C_HRORG_ID") {
- addGenmutipor({ CP_C_ORGUP_ID: valID })
- .then(res => {
- if (res.data.resultCode === 0) {
- let HRORG = "in ("; //储存键名为CP_C_HRORG_ID对象的ID
- let STORE = "in ("; //储存键名为CP_C_STORE_ID对象的ID
- if (
- res.data.data.CP_C_HRORG &&
- res.data.data.CP_C_HRORG.length > 0
- ) {
- res.data.data.CP_C_HRORG.forEach(item => {
- HRORG += item.ID + ","; // in 1,2,3,5,6,87,8,6
- });
- if (res.data.data.CP_C_HRORG.length > 0) {
- self.obj.CP_C_HRORG_ID =
- HRORG.substring(0, HRORG.length - 1) + ")";
- }
- }
- if (
- res.data.data.CP_C_STORE &&
- res.data.data.CP_C_STORE.length > 0
- ) {
- res.data.data.CP_C_STORE.forEach(item => {
- STORE += item.ID + ",";
- });
- if (res.data.data.CP_C_STORE.length > 0) {
- self.obj.CP_C_STORE_ID =
- STORE.substring(0, STORE.length - 1) + ")";
- }
- }
- self.findUser(self.obj);
- } else {
- this.$Modal.fcError({
- title: "错误提示",
- content: res.data.resultMsg
- });
- }
- });
- }
- // setTimeout(function() {
- // self.findUser(self.obj);
- // });
- }
- }
- // }
- this.$emit("on-select-tree", val, this);
- },
- getCheckedNodes(obj) {
- this.$emit("on-change-tree", obj, this);
- },
- tabClick(index) {
- this.index = index;
- this.$emit("on-click-tab", index, this);
- },
- pageChange(index) {
- this.$emit("on-change-page", index, this);
- this.componentt[0].pageNum = index;
- let param = Object.assign(this.obj, { page: index, pageSize: 10 });
- if (this.table.search !== "") {
- param.ENAME = this.table.search;
- }
- this.findUser(param);
- },
- pageChangeSize(index) {
- this.$emit("on-change-pageSize", index, this);
- this.componentt[0].pageSize = index;
- let param = Object.assign(this.obj, { page: 1, pageSize: index });
- if (this.table.search !== "") {
- param.ENAME = this.table.search;
- }
- this.findUser(param);
- },
- rowdbClick(row, index) {
- let selectObj = Object.assign({}, row);
- if (!this.isMutiple) {
- selectObj.string = selectObj.ENAME;
- if (this.resultRightData.list) {
- this.resultRightData.list = [];
- this.resultRightData.list.push(selectObj);
- } else {
- this.$set(this.resultRightData, "list", [selectObj]);
- }
- } else {
- let selectObj = Object.assign({ approve_type: 4 }, row);
- selectObj.string = selectObj.ENAME;
- if (this.resultRightData.list && this.resultRightData.list.length > 0) {
- let flagIndex = this.resultRightData.list.findIndex(inner => {
- return (
- selectObj.ID === inner.ID || selectObj.ID === Number(inner.approve_value)
- );
- });
- if (flagIndex === -1) {
- //没有找到相同的就加入
- this.resultRightData.list.push(selectObj);
- } else {
- this.$message({
- message: selectObj.ENAME + "已经选择过了,请不要重复选择!",
- type: 'warning'
- });
- }
- } else {
- this.$set(this.resultRightData, "list", [selectObj]);
- }
- }
- this.resultRightData.total
- ? (this.resultRightData.total = this.resultRightData.list.length)
- : this.$set(
- this.resultRightData,
- "total",
- this.resultRightData.list.length
- );
- this.$emit("getResult", this.resultRightData);
- this.$refs.Table[0].clearCurrentRow();
- this.$emit("on-row-dblclick", row, index, this);
- },
- rowClick(row, index) {
- if (!this.isMutiple) {
- this.selectDatas = Object.assign(this.selectDatas, row);
- }
- this.$emit("on-row-click", row, index, this);
- },
- Onselect(selection, row) {
- if (this.isMutiple) {
- this.componentt[0].list.map(item => {
- if (row.ID === item.ID) {
- item._checked = true;
- }
- });
- this.selectRow = [];
- this.selectRow = selection;
- }
- this.$emit("on-select", selection, row);
- },
- onSelectCancel(selection, row) {
- this.componentt[0].list.map(item => {
- if (row.ID === item.ID) {
- item._checked = false;
- }
- });
- this.selectRow = [];
- this.selectRow = selection;
- this.$emit("on-select-cancel", selection, row);
- },
- onSelectAll(selection) {
- this.selectRow = [];
- this.componentt[0].list.map(item => {
- item._checked = true;
- });
- this.selectRow = selection;
- this.$emit("on-select-all", selection);
- },
- onSelectAllCancel(selection) {
- this.componentt[0].list.map(item => {
- item._checked = false;
- });
- this.selectRow = [];
- this.$emit("on-select-all-cancel", selection);
- },
- onSelectChange(selection) {
- this.$emit("on-select-change", selection);
- },
- inputchange(event) {
- // if(!this.isUse&&!this.isMutiple){
- this.table.search = event.target.value;
- // }
- this.$emit("on-change", event, this);
- },
- inputkeydown(event) {
- this.$emit("on-keydown", event, this);
- },
- inputsearch(event) {
- let param = Object.assign(this.obj, {
- page: 1,
- pageSize: 10,
- ENAME: event
- });
- this.findUser(param);
- this.$emit("on-search", event, this);
- },
- operationTwo() {
- let selectNode = this.$refs.Tree.getCheckedNodes();
- selectNode = selectNode.filter(item => item.title !=='全部')
- if (this.isMutiple) {
- if (selectNode.length > 0) {
- this.resultRightData.total
- ? this.$set(this.resultRightData, "total", this.resultData.total + selectNode.length)
- : this.$set(this.resultRightData, "total", selectNode.length);
- selectNode.map(item => {
- let selectObj = Object.assign({ approve_type: 2 }, item);
- selectObj.string = item.ENAME;
- if (
- this.resultRightData.list &&
- this.resultRightData.list.length > 0
- ) {
- let flagIndex = this.resultRightData.list.findIndex(inner => {
- return item.ID === inner.ID || item.ID === Number(inner.approve_value);
- });
- if (flagIndex === -1) {
- //没有找到相同的就加入
- this.resultRightData.list.push(selectObj);
- } else {
- this.$message({
- message: item.ENAME + "已经选择过了,请不要重复选择!",
- type: 'warning'
- });
- }
- } else {
- this.$set(this.resultRightData, "list", [selectObj]);
- }
- });
- } else {
- his.$message({
- message:"请选择部门!",
- type: 'warning'
- });
- // this.$Message.warning("请选择部门");
- }
- this.getTreeData();
- }
- if (this.selectRow.length > 0) {
- //选中状态的清除
- this.selectRow = [];
- }
- if (Object.keys(this.selectDatas).length > 0) {
- this.selectDatas = {};
- }
- this.$emit("getResult", this.resultRightData);
- this.$emit("on-transfer-two", selectNode, this);
- },
- operation() {
- if (!this.isMutiple) {
- //单选逻辑
- if (Object.keys(this.selectDatas).length === 0) {
- this.$message({
- message: '请选择人员',
- type: 'warning'
- });
- // this.$Message.warning("请选择人员");
- return;
- }
- this.resultRightData.total
- ? (this.resultRightData.total = 1)
- : this.$set(this.resultRightData, "total", 1);
- let selectObj = Object.assign({}, this.selectDatas);
- selectObj.string = selectObj.ENAME;
- if (this.resultRightData.list) {
- this.resultRightData.list = [];
- this.resultRightData.list.push(selectObj);
- } else {
- this.$set(this.resultRightData, "list", [selectObj]);
- }
- } else {
- //多选逻辑
- if (this.selectRow.length > 0) {
- this.selectRow.map(item => {
- let selectObj = Object.assign({ approve_type: 4 }, item);
- selectObj.string = item.ENAME;
- if (
- this.resultRightData.list &&
- this.resultRightData.list.length > 0
- ) {
- let flagIndex = this.resultRightData.list.findIndex(inner => {
- return item.ID === inner.ID || item.ID === Number(inner.approve_value);
- });
- if (flagIndex === -1) {
- //没有找到相同的就加入
- this.resultRightData.list.push(selectObj);
- } else {
- this.$message({
- message: item.ENAME + "已经选择过了,请不要重复选择!",
- type: 'warning'
- });
- // this.$Message.warning(
- // item.ENAME + "已经选择过了,请不要重复选择!"
- // );
- }
- } else {
- this.$set(this.resultRightData, "list", [selectObj]);
- }
- });
- this.resultRightData.total
- ? (this.resultRightData.total = this.resultRightData.list.length)
- : this.$set(
- this.resultRightData,
- "total",
- this.resultRightData.list.length
- );
- } else {
- this.$message({
- message: '请选择人员',
- type: 'warning'
- });
- // this.$Message.warning("请选择人员");
- }
- }
- //刷新表格数据
- this.componentt[0].list.map(item => {
- item._checked = false;
- });
- this.componentt[0].list = this.componentt[0].list.concat([]);
- if (this.selectRow.length > 0) {
- //选中状态的清除
- this.selectRow = [];
- }
- if (Object.keys(this.selectDatas).length > 0) {
- this.selectDatas = {};
- }
- this.$emit("getResult", this.resultRightData);
- this.$emit("on-transfer", this);
- },
- deleteLi(index, tem) {
- let selectNode = this.$refs.Tree.getCheckedNodes();
- if (selectNode && selectNode.length > 0) {
- selectNode.map(inItem => {
- if (inItem.ID === tem.ID) {
- this.$refs.Tree.handleCheck({
- checked: false,
- nodeKey: inItem.nodeKey
- });
- }
- });
- }
- let selectrow = this.TabPaneData[0].list; //表格数据
- selectrow.map((row, Index) => {
- if (row.ID === tem.ID) {
- row._checked = false;
- }
- });
- this.resultRightData.list.splice(index, 1);
- this.resultRightData.total = this.resultRightData.list.length;
- this.$emit("getResult", this.resultRightData);
- this.$emit("on-delectli", index, tem, this);
- },
- treeOpen(checked) {
- this.showTree = !checked;
- this.treeNewData.forEach(item => {
- item.expand = !item.expand;
- });
- },
- delecFun() {
- let selectNode = this.$refs.Tree.getCheckedNodes();
- if (selectNode && selectNode.length > 0) {
- selectNode.map(inItem => {
- this.$refs.Tree.handleCheck({
- checked: false,
- nodeKey: inItem.nodeKey
- });
- });
- }
- let selectrow = this.TabPaneData[0].list; //表格数据
- if (selectrow && selectrow.length > 0) {
- selectrow.map((row, Index) => {
- row._checked = false;
- });
- }
- this.$emit("on-deleBtn", this);
- this.resultRightData.total = 0;
- this.resultRightData.list = [];
- this.componentt[0].list.map(item => {
- item._checked = false;
- });
- this.componentt[0].list = this.componentt[0].list.concat([]);
- this.$emit("getResult", this.resultRightData);
- },
- //查找用户信息
- findUser(param) {
- this.tableLoading = true;
- addGenmutiporuder( param).then(res => {
- this.tableLoading = false;
- let data = res;
- if (res.code === 0) {
- if (data.data) {
- this.transferTbody(data.data);
- }
- if (data.datas) {
- this.transferTbody(data.datas);
- }
- }
- });
- },
- //表格体数据转化
- transferTbody(data) {
- this.componentt[0].total = data.totalRowCount;
- this.componentt[0].pageOptions = data.selectrange;
- this.componentt[0].list = [];
- data.row.map(item => {
- let tem = {};
- let temval = {};
- Object.keys(item).map(inner => {
- tem[inner] = item[inner].val;
- });
- temval = Object.assign({}, tem);
- this.componentt[0].list.push(tem);
- });
- },
- //获取树数据
- getTreeData() {
- this.tree_loading = true;
- addGenmutiportree().then(res => {
- this.tree_loading = false;
- if (res.resultCode === 0) {
- console.log(345678)
- this.treeNewData = [];
- let newArr = [];
- let root = {};
- if (res.data.records.length > 0) {
- console.log(3456788)
- res.data.records.forEach(item => {
- let tem = Object.assign(item);
- newArr.push(tem);
- if (
- item["CP_C_ORGUP_ID"] === null ||
- item["CP_C_ORGUP_ID"] === ""
- ) {
- root = Object.assign({}, item);
- }
- });
- this.treeNewData = this.arrayTransTree(newArr, "CP_C_ORGUP_ID");
- console.log(this.treeNewData)
- }
- this.findUser({}); //显示所有的用户
- }
- });
- },
- //改造树数据的结构
- arrayTransTree(list, key) {
- let parent = [];
- let children = [];
- list.map(item => {
- item.expand = false;
- item.title = item.ENAME;
- if (
- !item[key]||
- (item[key].indexOf('.')!==-1&&!item[key].split(".")[1])
- ) {
- //根节点
- parent.push(item);
- } else {
- //有父节点的
- children.push(item);
- }
- });
- if (parent.length < 1) {
- //没有根节点
- let newParent = this.findTreeRootFirstChild(list, key); //拿到一级节点
- let rootArr = newParent.map(item => {
- return item[key];
- });
- let rootTem = Array.from(new Set([...rootArr]));
- if (rootTem.length === 1) {
- parent = [
- {
- CP_C_ORGUP_ID: null,
- ECODE: "00000",
- ENAME: "全部",
- ID: rootTem[0],
- MIXNAME: "[00000]全部",
- ORGTYPE: "IN",
- TYPE: "CP_C_HRORG_ID",
- title:'全部'
- }
- ];
- this.translator(parent, children, key);
- return parent;
- } else {
- this.$message({
- message: '数据有问题,请检查...',
- type: 'warning'
- });
- // this.$Message.warning("数据有问题,请检查...");
- return;
- }
- } else {
- this.translator(parent, children, key);
- return parent;
- }
- },
- translator(parents, children, key) {
- let temp = [];
- children.map(item => {
- //对子节点数据进行深复制,这里只支持部分类型的数据深复制
- let temItem = Object.assign({}, item);
- temp.push(temItem);
- });
- //遍历父节点数据
- parents.map(parent => {
- //遍历子节点数据
- children.map((current, index) => {
- //此时找到父节点对应的一个子节点
- if (current[key] === parent.ID) {
- //让当前子节点从temp中移除,temp作为新的子节点数据,这里是为了让递归时,子节点的遍历次数更少,如果父子关系的层级越多,越有利
- temp.splice(index, 1);
- //让当前子节点作为唯一的父节点,去递归查找其对应的子节点
- this.translator([current], temp, key);
- //把找到子节点放入父节点的children属性中
- parent.children
- ? parent.children.push(current)
- : (parent.children = [current]);
- }
- });
- });
- },
- treeTransArray(tree, key) {
- return tree
- .reduce(function iteration(con, item) {
- con.push(item);
- if (item[key] && item[key].length > 0)
- item[key].reduce(iteration, con);
- return con;
- }, [])
- .map(function(item) {
- item[key] = [];
- return item;
- });
- },
- findTreeRootFirstChild(Arr, key) {
- let idArr = [];
- let result = [];
- idArr = Arr.map(item => {
- return item["ID"];
- });
- Arr.map(item => {
- if (!idArr.includes(item[key])) {
- //一级节点的特点是存在父节点 但是已父节点为ID的节点是不存在的
- result.push(item);
- }
- });
- return result;
- },
- handleCheckChange(){
-
- }
- },
- mounted() {
- // if(this.isCallInterface){
- // this.getTreeData();
- // if (this.resultData.list) {
- // this.resultRightData = this.deepCopy(this.resultData);
- // }
- // }else{
- // if (this.selectRow.length > 0) {
- // this.selectRow = [];
- // }
- // if (Object.keys(this.selectDatas).length > 0) {
- // this.selectDatas = {};
- // }
- // if (this.table.search) {
- // this.table.search = "";
- // }
- // }
- },
- destroyed() {
- if (this.selectRow.length > 0) {
- this.selectRow = [];
- }
- if (Object.keys(this.selectDatas).length > 0) {
- this.selectDatas = {};
- }
- if (this.table.search) {
- this.table.search = "";
- }
- }
- };
- </script>
- <style lang="scss">
- .MutipleSelectPop {
- width: 800px;
- display: flex;
- height: 484px;
- position: relative;
- .demo-spin-icon-load {
- animation: ani-demo-spin 1s linear infinite;
- }
- .complex-spin-fix {
- z-index: 20;
- }
- @keyframes ani-demo-spin {
- from {
- transform: rotate(0deg);
- }
- 50% {
- transform: rotate(180deg);
- }
- to {
- transform: rotate(360deg);
- }
- }
- overflow: hidden;
- .dialog_left {
- width: 170px;
- display: -ms-flexbox;
- display: flex;
- -ms-flex-direction: column;
- flex-direction: column;
- padding: 10px;
- border: 1px solid #dcdee2;
- border-right: none;
- .left_top {
- height: 32px;
- line-height: 32px;
- box-sizing: border-box;
- border-bottom: 1px solid #e8eaec;
- font-size: 12px;
- color: #575757;
- display: flex;
- input {
- line-height: 32px;
- height: 32px;
- }
- div:first-child {
- flex: 1;
- }
- i {
- margin-right: 10px;
- }
- }
- .left_center {
- flex: 1;
- padding-top: 10px;
- position: relative;
- height: 390px;
- padding-bottom: 10px;
- width: 156px;
- overflow-y: auto;
- }
- }
- .dialog_center {
- width: 400px;
- position: relative;
- height: 484px;
- border: 1px solid #dcdee2;
- border-right: none;
- //box-shadow: 2px -2px 9px @shadow-color;
- padding: 10px;
- display: -ms-flexbox;
- display: flex;
- -ms-flex-direction: column;
- flex-direction: column;
- .dialog_p10 {
- padding: 10px 0;
- }
- .dialog_center_top {
- display: flex;
- line-height: 32px;
- vertical-align: middle;
- box-sizing: border-box;
- .dialog_center_top_fix {
- width: 270px;
- box-sizing: border-box;
- padding-right: 20px;
- input {
- line-height: 32px;
- height: 32px;
- }
- }
- }
- }
- .dialog-operation {
- width: 92px;
- padding: 0px;
- border-left: 1px solid #dcdee2;
- background-color: #fff;
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- div {
- text-align: center;
- .operatebtn {
- margin-bottom: 10px;
- padding: 8px 12px;
- &:last-child {
- margin-bottom: 0;
- }
- }
- }
- }
- .dialog_right {
- width: 220px;
- padding: 10px;
- border: 1px solid #dcdee2;
- box-sizing: border-box;
- display: -ms-flexbox;
- display: flex;
- -ms-flex-direction: column;
- flex-direction: column;
- .left_top {
- height: 30px;
- line-height: 30px;
- box-sizing: border-box;
- border-bottom: 1px solid #e8eaec;
- font-size: 12px;
- color: #575757;
- display: flex;
- div:first-child {
- flex: 1;
- }
- i {
- margin-right: 10px;
- }
- }
- ul {
- height: 390px;
- overflow: auto;
- li {
- margin-bottom: 4px;
- display: -ms-flexbox;
- display: flex;
- -ms-flex-align: center;
- align-items: center;
- background-color: #f8f8f8;
- border-radius: 2px;
- font-size: 12px;
- p {
- flex: 1;
- line-height: 18px;
- margin-left: 4px;
- box-sizing: border-box;
- border-radius: 4px;
- padding: 4px 6px;
- color: #0f8ee9;
- word-wrap: break-word;
- word-break: break-all;
- }
- }
- }
- }
- .right_center {
- flex: 1;
- padding-top: 10px;
- }
- }
- </style>
|