123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317 |
- <template>
- <div class="boxswai">
- <div class="boxnei">
- <el-row
- :gutter="0"
- style="height:100%;"
- >
- <el-col
- :span="showLeft?5:0"
- style="height:99%;"
- >
- <div
- style="fontSize:18px; font-weight: 900;"
- class="marbottom5"
- >元素识别</div>
- <div style="height:98%;overflow: auto;width:auto;">
- <div class="flex">
- <el-input
- size="small"
- placeholder="输入关键字搜索"
- clearable
- @clear="allTreeShow = false"
- v-model="filterText">
- </el-input>
- <el-button size="small" class="mg-l-10" @click="treeFilter">搜索</el-button>
- </div>
- <el-tree
- :data="treeData"
- :props="treeProps"
- @node-click="handleNodeClick"
- :load="loadNode"
- :expand-on-click-node="false"
- lazy
- v-show="!allTreeShow"
- ></el-tree>
- <el-tree
- style="width:100%;"
- ref="treeall"
- v-loading="treeloading"
- :data="allTreeData"
- :props="treeProps"
- @node-click="handleNodeClick"
- node-key="id"
- :expand-on-click-node="false"
- :filter-node-method="filterNode"
- v-show="allTreeShow"
- >
- </el-tree>
- </div>
- </el-col>
- <el-col
- :span="showLeft?19:24"
- style="height:98%;display: flex;"
- >
- <div class="flex flex-center" style="width:20px;height:100%;cursor: pointer;" @click="showLeftChange">
- <i v-if="showLeft" class="el-icon-d-arrow-left"></i>
- <i v-else class="el-icon-d-arrow-right"></i>
- </div>
- <div class="flex1" style="padding-left:10px;">
- <div v-if="addElementForm.nodeName==''">表名称</div>
- <div v-else>{{addElementForm.nodeName}}</div>
- <el-row
- class="martop20"
- :gutter="20"
- style="height:96%;"
- >
- <el-col
- :span="showLeft?16:12"
- style="overflow:auto;height:100%;border:1px solid black; border-radius: 4px;box-sizing: border-box;padding: 10px 10px;"
- >
- <div
- class="parent"
- id='parent'
- @dblclick="dblBtnClick($event)"
- @click="parentClick($event)"
- >
- </div>
- </el-col>
- <el-col
- :span="showLeft?8:12" ref="tablescroll"
- style="height:100%;"
- :style="{'overflow':'auto'}"
- >
- <div class="region">
- <div class="flexBetween flexItemsC">
- <div>
- <!-- <el-button
- type="info"
- size="mini"
- :disabled="from.id==''"
- @click="automaticRecognition"
- >自动识别</el-button> -->
- <el-button
- type="success"
- size="mini"
- @click="establish()"
- :disabled="from.id==''"
- >关联WBS并创建元素</el-button>
- </div>
- <div
- class="el-icon-plus"
- @click="pushTableData"
- style="width:16px;height:16px;backgroundColor:#1DD81D;color:#fff;cursor: pointer;"
- ></div>
- </div>
- <el-table
- class="martop20"
- :data="tableData"
- border :row-class-name="tableRowClassName"
- style="width: 100%"
- >
- <el-table-column
- type="index"
- label="坐标"
- >
- </el-table-column>
- <el-table-column
- prop="textInfo"
- label="元素名称"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.textInfo"
- placeholder="请输入内容"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="textElementType"
- label="数据类型"
- >
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.textElementType"
- placeholder="请选择"
- >
- <el-option
- v-for="item in dataType"
- :key="item.dictKey"
- :label="item.dictValue"
- :value="item.dictKey"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- prop="textDeviation"
- label="允许偏差值"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.textDeviation"
- placeholder="请输入内容"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="100">
- <template slot-scope="scope">
- <el-link style="margin-right:16px;"
- type="success"
- @click="saveELe(scope.row)"
- >保存</el-link>
- <el-link
- type="danger"
- @click="deleteTableData(scope.$index)"
- >删除</el-link>
- </template>
- </el-table-column>
- </el-table>
- <!-- <el-button
- type="success"
- class="martop20 dingwei"
- @click="establish()"
- :disabled="from.id==''"
- >关联WBS并创建元素</el-button> -->
- <el-dialog
- title="编辑元素信息"
- :visible.sync="editTitleDialog"
- width="80%"
- :modal-append-to-body='false'
- :append-to-body="false"
- >
- <div>
- <draggable v-model="titleList">
- <div
- v-for="(item,key) in titleList"
- :key="key"
- class="flexBetween flexItemsC title-item"
- >
- <div>
- <span>{{item}}</span>
- </div>
- <div class="flexItemsC">
- <i
- @click="listUp(key)"
- class="el-icon-top"
- :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
- ></i>
- <i
- @click="listDown(key)"
- class="el-icon-bottom marleft5"
- :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor': key!=titleList.length-1?'pointer':'default'}"
- ></i>
- <i
- @click="deleTitle(key)"
- class="el-icon-circle-close marleft5"
- :style="{'font-size':'20px',
- 'color':'#ee7049','cursor':'pointer'}"
- ></i>
- </div>
- </div>
- </draggable>
- </div>
- <div style="margin-top:50px;">
- <div class="flex jc-sb mg-b-10">
- <div class="flex jc-al-c">
- <span style="margin-right:10px;">数据类型</span>
- <el-select
- v-model="titleForm.textElementType"
- placeholder="请选择" style="width:130px"
- >
- <el-option
- v-for="item in dataType"
- :key="item.dictKey"
- :label="item.dictValue"
- :value="item.dictKey"
- >
- </el-option>
- </el-select>
- <span style="margin:0 10px;">允许偏差值</span>
- <el-input
- v-model="titleForm.textDeviation"
- placeholder="请输入内容" style="width:150px"
- ></el-input>
- </div>
- <div>
- <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
- </div>
- </div>
- <el-input type="textarea" rows="5" v-model="titleForm.textInfo"></el-input>
- </div>
- <el-alert
- title="该输入框没有匹配到对应元素字段,确定修改将会新增一个元素字段" v-if="titleIndex < 0"
- type="warning" :closable="false"
- effect="dark" style="margin-top:10px;">
- </el-alert>
- <span
- slot="footer"
- class="dialog-footer"
- >
- <el-button @click="editTitleDialog = false">取 消</el-button>
- <el-button
- type="primary"
- v-throttle='2000'
- @click="editTitle()"
- >确定修改</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="添加新元素字段"
- :visible.sync="addNewElementDialog"
- :before-close="handleClose"
- width="80%"
- :modal-append-to-body='false'
- :append-to-body="false"
- >
- <div>
- <!-- <i
- @click="addNewElement"
- class="el-icon-circle-plus marbottom10"
- style="color:red; font-size:24px; float: right;cursor: pointer;"
- ></i> -->
- <div>
- <draggable v-model="titleList">
- <div
- v-for="(item,key) in titleList"
- :key="key"
- class="flexBetween flexItemsC title-item"
- >
- <div>
- <span>{{item}}</span>
- </div>
- <div class="flexItemsC">
- <i
- @click="listUp(key)"
- class="el-icon-top"
- :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
- ></i>
- <i
- @click="listDown(key)"
- class="el-icon-bottom marleft5"
- :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor': key!=titleList.length-1?'pointer':'default'}"
- ></i>
- <i
- @click="deleTitle(key)"
- class="el-icon-circle-close marleft5"
- :style="{'font-size':'20px',
- 'color':'#ee7049','cursor':'pointer'}"
- ></i>
- </div>
- </div>
- </draggable>
- <div class="flex jc-sb mg-b-10">
- <div class="flex jc-al-c">
-
- </div>
- <div>
- <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
- </div>
- </div>
- </div>
- <el-table
- :data="newElements"
- height="250"
- border
- style="width: 100%"
- >
- <el-table-column
- label="元素名称"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.textInfo"
- placeholder="请输入内容"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="textElementType"
- label="数据类型"
- >
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.textElementType"
- placeholder="请选择"
- >
- <el-option
- v-for="item in dataType"
- :key="item.dictKey"
- :label="item.dictValue"
- :value="item.dictKey"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- prop="textDeviation"
- label="允许偏差值"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.textDeviation"
- placeholder="请输入内容"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="date"
- align="center"
- width="120"
- label="操作"
- >
- <template slot-scope="scope">
- <el-button
- type="danger"
- size="mini"
- @click="deleteNewElement(scope.$index)"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <span
- slot="footer"
- class="dialog-footer"
- >
- <el-button @click="handleClose()">取 消</el-button>
- <el-button
- type="primary"
- v-throttle='2000'
- :disabled="newElements.length===0"
- @click="addNewElementHandle()"
- >确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </el-col>
- </el-row>
- </div>
- </el-col>
- </el-row>
- <!-- 关联公共WBS模板 -->
- <el-dialog
- title="关联公共WBS模板"
- class="excelBox"
- :visible.sync="AssociatedPublicTap"
- modal-append-to-body
- append-to-body
- :close-on-click-modal="false"
- >
- <el-row :gutter="20">
- <el-col :span="12">
- <el-select
- style="width:100%;"
- v-model="GLExcelFrom.name"
- placeholder="请选择"
- @change="changetherr()"
- >
- <el-option
- v-for="(item,key) in GLExcelData"
- :key="key"
- :label="item.wbsName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-scrollbar style="height:50vh;">
- <el-tree
- v-if="GLExcelFromtag"
- @node-click="handleNodeClickExcel"
- ref="tree"
- class="filter-tree"
- style="margin-top:10px;"
- :props="GLExcelProps"
- :data="exceldata"
- :load="loadNodeTan"
- lazy
- node-key="id"
- accordion
- :show-checkbox="activeName == 'add'"
- :check-strictly="true"
- >
- </el-tree>
- </el-scrollbar>
- </el-col>
- <el-col
- :span="12"
- v-if="addElementForm.wbsId"
- >
- <el-tabs v-model="activeName" type="card" >
- <el-tab-pane label="关联元素表" name="link">
- <el-table
- :data="addTableData"
- border
- style="width: 100%"
- class="martop20"
- >
- <el-table-column
- prop="tableName"
- label="已有元素表名称"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="name"
- label="操作"
- align="center"
- >
- <template slot-scope="scope">
- <el-button
- type="primary"
- size="mini"
- style="margin:0px;"
- @click="relationMD(scope.row,'关联')"
- v-show="!scope.row.checknd"
- :loading="scope.row.loading"
- >选择关联</el-button>
- <el-button
- type="danger"
- size="mini"
- style="margin:0px;"
- @click="relationMD(scope.row,'取消关联')"
- v-show="scope.row.checknd"
- :loading="scope.row.loading"
- >取消关联</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-tab-pane>
- <el-tab-pane label="新增元素表" name="add">
- <div>
- <div class="flexBetween martop20">
- <el-input
- v-model="addElementForm.nodeName"
- placeholder="请输入表名"
- ></el-input>
- <el-select
- class="marleft10"
- v-model="addElementForm.tableType"
- placeholder="请选择表类型"
- >
- <el-option
- v-for="(item,index) in exceltypeData"
- :key="index"
- :label="item.dictValue"
- :value="item.dictKey"
- ></el-option>
- </el-select>
- </div>
- <el-select
- style="width:100%;"
- class="martop20"
- v-model="addElementForm.tableOwner"
- placeholder="请选择所属方"
- >
- <el-option
- v-for="(item,index) in ownerTypeList"
- :key="index"
- :label="item.dictValue"
- :value="item.dictKey"
- ></el-option>
- </el-select>
- </div>
- </el-tab-pane>
- </el-tabs>
- </el-col>
- </el-row>
- <span
- slot="footer"
- class="dialog-footer"
- style="display: flex;justify-content: center;align-items: center;"
- >
- <el-button @click="AssociatedPublicClose()">取 消</el-button>
- <el-button
- style="margin-left:30px;"
- type="primary"
- @click="saveElementMD()"
- >确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables,tabLazytreeAll,exctabcellSave,exctabcellRemove , exctabcellUpdate} from "@/api/exctab/excelmodel";
- import { dictionarydataType } from "@/api/exctab/editelement";
- import { getColByTabId } from "@/api/manager/AdjustForm";
- import { selectByNodeTable } from "@/api/manager/wbstree";
- import { getDictionary } from "@/api/system/dict";
- import Vue from 'vue'
- import draggable from 'vuedraggable'
- export default {
- data () {
- return {
- //#region 左侧树节点
- treeData: [],
- treeProps: {
- label: 'name',
- children: 'children',
- isLeaf: 'hasChildren'
- },
- //#endregion
- excelSrc: '',
- from: {
- id: '',
- },
- tableData: [],//外层table
- dataType: [],
- filterText:"",//搜索关键字
- allTreeShow:false,//是否显示整棵树
- treeloading:false,
- AssociatedPublicTap: false,
- //#region 弹框属性
- GLExcelFrom: {
- id: "",
- name: '',
- search: '',//搜素框舒服的值
- },
- GLExcelData: [],//
- allTreeData:[],
- GLExcelProps: {
- label: 'title',
- children: 'children',
- isLeaf: function (data) {
- if (data.hasChildren && data.isExistForm != 1) {
- return false
- } else if (data.hasChildren && data.isExistForm == 1) {
- return true
- } else {
- return true
- }
- }
- },
- exceldata: [],//清表模板树数据
- addTableData: [],//新增元素信息表
- exceltypeData: [],//清表类型
- addElement: false,
- GLExcelFromtag: false,
- addElementForm: {
- id: "",
- initTableName: "",
- nodeName: '',
- tableType: '',
- tableOwner: '',
- wbsId: '',
- parentId: '',
- },
- //#endregion
- ownerTypeList: [],
- activeName:'link',
- showLeft:true,//左侧树是否显示
- addNewElementDialog:false,//新增元素弹窗
- newElements:[],
- editTitleDialog:false,//编辑标题弹窗
- titleList:[],//标题拆分的列表
- titleForm:{
- exctabId:'',
- id:'',
- textInfo:'',
- textElementType:'',
- textDeviation:'',
- },
- titleIndex:-1,
- }
- },
- components: {
- draggable,
- },
- methods: {
- //搜索树
- treeFilter(){
- if(this.filterText){
- this.allTreeShow = true;
- if(!this.allTreeData.length){
- this.treeloading = true;
- tabLazytreeAll({
- modeId: this.$route.params.id,
- name:'',
- }).then((res)=>{
- this.treeloading = false;
- this.allTreeData = res.data.data;
- this.$nextTick(()=>{
- this.$refs.treeall.filter(this.filterText);
- })
- })
- }else{
- this.$refs.treeall.filter(this.filterText);
- }
- }else{
- this.allTreeShow = false;
- }
- },
- filterNode(value, data) {
- if (!value) return true;
- return data.name.indexOf(value) !== -1;
- },
- //#region
- handleNodeClick (data) {//树节点点击事件
- console.log(data);
- if (data.fileType == 3) {
- this.getExcelHtmlCol(data.id)//获取excel模板
- if (this.dataType.length == 0) {
- this.dictionarydataType() //数据类型字典
- }
- this.addElement = false
- this.addElementForm.nodeName = data.name
- if(data.tabType > 0 && data.tabType < 100){
- this.addElementForm.tableType = data.tabType+'';
- }else{
- this.addElementForm.tableType = ''
- }
- this.from.id = data.id
- this.tableData = [];
- //触发自动识别按钮
- this.automaticRecognition();
- }
- },
- async loadNode (node, resolve) {//懒加载获取节点
- if (node.level === 0) {
- return resolve(await this.tabLazytree(this.$route.params.id, 0))
- }
- if (node.level > 0) {
- return resolve(await this.tabLazytree(this.$route.params.id, node.data.id))
- }
- },
- automaticRecognition () {//自动识别按钮
- this.getColByTabId()
- },
- pushTableData () {//
- // if (this.from.id) {
- // this.tableData.unshift({
- // eName: '',
- // eType: 1,
- // eAllowDeviation: ''
- // })
- // }
- if (this.from.id) {
- this.showLeft = false;
- this.addNewElementDialog = true;
- this.titleList = [];
- }
- },
- deleteTableData (key) {//删除
- exctabcellRemove(this.tableData[key].id).then(()=>{
- this.tableData.splice(key, 1)
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- })
- },
- async getColByTabId () {//获取字段信息
- const { data: res } = await getColByTabId({ tabId: this.from.id })
- console.log(res);
- if (res.code === 200) {
- res.data.forEach((element)=>{
- //element.eName = element.textInfo;
- if(element.textElementType < 1){
- element.textElementType = 1;
- }
- })
- this.tableData = res.data
- }
- },
- async getExcelHtmlCol (id) {//获取excel模板
- const { data: res } = await getExcelHtmlCol({ id })
- console.log(res);
- if (res.code == 200) {
- // let _that = this
- var MyComponent = await Vue.extend({
- data () {
- return {
- formData: {}
- }
- },
- template: res.data,
- })
- var component = new MyComponent().$mount()
- let na = document.getElementById('parent')
- na.innerHTML = `<div
- class='parent'
- id='parent'"
- ></div>`
- document.getElementById('parent').appendChild(component.$el);
- }
- },
- //#endregion
- //#region 关联公共WBS模板弹框
- establish () {//关联WBS并创建元素
- if(this.tableData.length == 0){
- this.$message({
- type: 'warning',
- message: '至少有一条元素才能创建元素表'
- })
- return;
- }
- let arr = [];
- this.tableData.forEach((element,index)=>{
- if(element.eName == ''){
- arr.push(index+1);
- }
- })
- if(arr.length > 0){
- this.$message({
- type: 'warning',
- message: arr.join(',')+'条的元素名称未填写'
- })
- return;
- }
- this.getWbsTypeList()
- this.AssociatedPublicTap = true
- },
- AssociatedPublicClose () {//关联公共WBS模板关闭事件
- // this.addElementForm = {
- // id: "",
- // initTableName: "",
- // nodeName: this.addElementForm.nodeName,
- // tableType: '',
- // tableOwner: '',
- // wbsId: '',
- // parentId: '',
- // }
- // this.GLExcelFrom = {
- // name: '',
- // search: ''
- // }
- // this.exceldata = []
- // this.addElement = false
- //清理之前填写的数据
- this.addElementForm.wbsId = '';
- // this.addElementForm.tableType = '';
- this.addElementForm.tableOwner = '';
- if(this.$refs.tree){
- this.$refs.tree.setCheckedKeys([]);
- this.$refs.tree.setCurrentKey(null);
- }
- this.addTableData = []
- this.AssociatedPublicTap = false
- },
- async loadNodeTan (node, resolve) {//懒加载
- console.log(node);
- if (node.level === 0) {
- return resolve(await this.getLazytree(0));
- } else {
- return resolve(await this.getLazytree(node.data.id));
- }
- },
- changetherr () {//下拉框change事件
- this.GLExcelFromtag = false
- if (this.GLExcelFrom.name != "") {
- this.GLExcelFrom.search = ''
- this.exceldata = []
- this.addTableData = []
- this.addElementForm.wbsId = ''
- this.$nextTick(() => {
- this.GLExcelFromtag = true
- })
- }
- },
- addElementMD () {//新增元素信息表按钮
- this.excelType()
- this.addElement = true
- },
- async getWbsTypeList () {//获取清表模板信息
- const { data: res } = await getWbsTypeList({ wbstype: 1 })
- console.log(res);
- if (res.code === 200 && res.msg === '操作成功') {
- this.GLExcelData = res.data
- }
- },
- async getLazytree (parentId) {//清表树信息
- const { data: res } = await getLazytree({
- parentId: parentId,
- wbsId: this.GLExcelFrom.name,
- wbsType: '1'
- })
- console.log(res);
- if (res.code === 200 && res.msg === '操作成功') {
- res.data.forEach(val => {
- val.isExistForm = !!val.isExistForm
- })
- return res.data
- } else {
- return []
- }
- },
- handleNodeClickExcel (data) {//点击节点事件
- this.addElementForm.wbsId = this.GLExcelFrom.name
- this.addElementForm.parentId = data.id
- //this.selectByNodeTable(data.id)
- this.searchNodeTables(data.id)
- },
- async selectByNodeTable (id) {//获取清表信息
- const { data: res } = await selectByNodeTable(id)
- console.log(res);
- if (res.code == 200) {
- if (res.data.length > 0) {
- res.data.forEach(val => {
- if (val.isLinkTable == 2) {
- val.checknd = true
- } else {
- val.checknd = false
- }
- val.loading = false;
- })
- this.addTableData = res.data
- }else{
- this.addTableData = []
- }
- }
- },
- //查看节点下已关联的元素表信息
- searchNodeTables(id){
- searchNodeTables(id,this.from.id).then((res)=>{
- if (res.data.data.length > 0) {
- res.data.data.forEach(val => {
- if (val.isLinkTable == 2) {
- val.checknd = true
- } else {
- val.checknd = false
- }
- val.loading = false;
- })
- this.addTableData = res.data.data
- }else{
- this.addTableData = []
- }
- })
- },
- async excelType () {//清表类型
- const { data: res } = await excelType({ code: 'sys_excltab_type' })
- console.log(res);
- if (res.code === 200) {
- this.exceltypeData = res.data
- }
- },
- relationMD (row, type) {//关联取消关联
- row.loading = true;
- if (type == '关联') {
- saveRelation(row.id,this.from.id,this.tableData).then(()=>{
- row.checknd = true;
- row.isLinkTable = 2;
- }).finally(()=>{
- row.loading = false;
- })
- } else {
- cancelRelation({
- id:row.id,
- excelTabId:this.from.id,
- }).then(()=>{
- row.checknd = false;
- row.isLinkTable = 1;
- }).finally(()=>{
- row.loading = false;
- })
- }
- },
- saveElementMD () {//保存按钮
- if (this.addElementForm.wbsId) {
- if (this.activeName == 'link') {
- this.submitExcelRelationWbsTreeAndElement({
- excelTabId:this.from.id,
- elementList: this.tableData,
- submitStatus:1
- })
- } else {
- if (this.addElementForm.nodeName && this.addElementForm.tableType && this.addElementForm.tableOwner) {
- let nodeIds = this.$refs.tree.getCheckedKeys();
- if(nodeIds.length < 1){
- this.$message({
- type: 'warning',
- message: '至少勾选一个节点'
- })
- return;
- }
- this.submitExcelRelationWbsTreeAndElement({
- nodeName: this.addElementForm.nodeName,
- tableType: this.addElementForm.tableType,
- tableOwner: this.addElementForm.tableOwner,
- wbsId: this.addElementForm.wbsId,
- elementList: this.tableData,
- nodeIds:nodeIds,
- excelTabId:this.from.id,
- submitStatus:2
- })
- }else{
- this.$message({
- type: 'warning',
- message: '请填写和选择新增的表名,表类型,表所属方'
- })
- }
- }
- } else {
- this.$message({
- type: 'warning',
- message: '请先选择WBS树节点表单'
- })
- }
- },
- async submitExcelRelationWbsTreeAndElement (da) {//保存接口
- da.elementList.forEach((ele)=>{
- ele.eName = ele.textInfo;
- ele.eType = ele.textElementType;
- ele.eAllowDeviation = ele.textDeviation;
- })
- const { data: res } = await submitExcelRelationWbsTreeAndElement(da)
- console.log(res);
- if (res.code == 200) {
- this.$message({
- type: 'success',
- message: '设置成功'
- })
- this.AssociatedPublicTap = false
- this.AssociatedPublicClose()
- }
- },
- //#endregion
- //#region 接口
- async tabLazytree (modeId, parentId) {
- const { data: res } = await tabLazytree({ modeId, parentId })
- console.log(res);
- if (res.code == 200) {
- if (res.data.length > 0) {
- res.data.forEach(val => {
- val.hasChildren = !val.hasChildren
- });
- }
- return res.data
- }
- },
- async dictionarydataType () {//数据类型字典
- const { data: res } = await dictionarydataType()
- console.log(res);
- if (res.code == 200) {
- res.data.forEach(element => {
- element.dictKey = Number(element.dictKey)
- });
- this.dataType = res.data
- }
- },
- //#endregion
- getOwnerTypelist () {
- if (this.ownerTypeList.length > 1) {
- return;
- }
- getDictionary({
- code: 'owner_type'
- }).then((res) => {
- res.data.data.forEach(element => {
- element.dictKey = Number(element.dictKey)
- });
- this.ownerTypeList = res.data.data;
- })
- },
- //修改树显示状态
- showLeftChange(){
- this.showLeft = !this.showLeft;
- },
- handleClose () {
- this.newElements = []
- this.addNewElementDialog = false;
- },
- addNewElement(){
- this.newElements.push({
- exctabId:this.from.id,
- textInfo: ''
- })
- },
- deleteNewElement(index){
- this.newElements.splice(index, 1);
- },
- addNewElementHandle(){
- exctabcellSave(this.newElements).then(()=>{
- this.handleClose();
- //触发自动识别按钮
- this.automaticRecognition();
- this.$message({
- type: "success",
- message: "保存成功!"
- });
- })
- },
- listUp(index){
- if(index != 0){
- this.titleList[index] = this.titleList.splice(index-1,1,this.titleList[index])[0];
- }
- },
- listDown(index){
- if(index != this.titleList.length-1){
- this.titleList[index] = this.titleList.splice(index+1,1,this.titleList[index])[0];
- }
- },
- deleTitle(index){
- this.titleList.splice(index,1);
- },
- setTitleText(){
- if(this.addNewElementDialog){
- this.newElements.push({
- exctabId:this.from.id,
- textInfo: this.titleList.join('_')
- })
- this.titleList = [];
- }else{
- this.titleForm.textInfo = this.titleList.join('_');
- }
- },
- editTitle(){
- if(this.titleIndex < 0){
- //新增
- exctabcellSave([{
- "exctabId": this.from.id,
- "textInfo": this.titleForm.textInfo,
- "textElementType": this.titleForm.textElementType,
- "textDeviation": this.titleForm.textDeviation
- }]).then(()=>{
- this.editTitleDialog = false;
- //触发自动识别按钮
- this.automaticRecognition();
- this.$message({
- type: "success",
- message: "新增成功!"
- });
- })
- }else{
- //修改
- exctabcellUpdate(this.titleForm).then(()=>{
- this.tableData[this.titleIndex].textInfo = this.titleForm.textInfo;
- //this.tableData[this.titleIndex].eName = this.titleForm.textInfo;
- this.tableData[this.titleIndex].textElementType = this.titleForm.textElementType;
- this.tableData[this.titleIndex].textDeviation = this.titleForm.textDeviation;
- //console.log(this.$refs.tablescroll)
- this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
- this.editTitleDialog = false;
- this.$message({
- type: "success",
- message: "保存成功!"
- });
- })
- }
- },
- dblBtnClick(e){
- //console.log(e)
- let target = e.target;
- //console.log(target.getAttribute('trindex'))
- if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
- this.titleIndex = -1;
- this.titleList = [];
- this.$refs.tablescroll.$el.scrollTop = 0;
- this.editTitleDialog = true;
- this.showLeft = false;
- let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
- for (let i = 0; i < this.tableData.length; i++) {
- let arr = this.tableData[i].xys.split(',')
- if(arr.indexOf(trtd) > -1){
- this.titleIndex = i;
- break;
- }
- }
- if(this.titleIndex > -1){
- this.titleForm.textInfo = this.tableData[this.titleIndex].textInfo;
- this.titleForm.textElementType = this.tableData[this.titleIndex].textElementType;
- this.titleForm.textDeviation = this.tableData[this.titleIndex].textDeviation;
- this.titleForm.exctabId = this.tableData[this.titleIndex].exctabId;
- this.titleForm.id = this.tableData[this.titleIndex].id;
- }
-
- // let tdEle = this.getParentTD(target);
- // if(tdEle){
- // this.$refs.tablescroll.$el.scrollTop = 0;
- // this.editTitleDialog = true;
- // this.titleForm.textInfo = tdEle.getAttribute('title');
- // //console.log(title)
- // this.titleList = this.titleForm.textInfo.split('_');
- // let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
- // for (let i = 0; i < this.tableData.length; i++) {
- // if(this.tableData[i].xys.indexOf(trtd) > -1){
- // this.titleIndex = i;
- // break;
- // }
- // }
- // }
- }else if(target.innerHTML && target.nodeName === "TD"){
- this.titleList.push(target.innerHTML)
- }
- },
-
- //excel父节点点击检测
- parentClick(e){
- let target = e.target;
- let bgs = document.querySelectorAll("#parent .oldlace-bg")
- //console.log(bgs)
- for (let i = 0; i < bgs.length; i++) {
- bgs[i].classList.remove("oldlace-bg");
- }
- //console.log(target.getAttribute('trindex'))
- if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
- let tdEle = this.getParentTD(target);
- if(tdEle){
- target.classList.add("oldlace-bg");
- let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
- for (let i = 0; i < this.tableData.length; i++) {
- let arr = this.tableData[i].xys.split(',')
- if(arr.indexOf(trtd) > -1){
- this.titleIndex = i;
- break;
- }
- }
-
- //this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
- //console.log(this.$refs.tablescroll.$el.scrollTop)
- this.$nextTick(()=>{
- let row = document.querySelectorAll(".warning-row");
- if(row.length){
- this.$refs.tablescroll.$el.scrollTop = row[0].offsetTop;
- }
- //console.dir(row[0])
- })
-
- }
- }
- },
- getParentTD(ele){
- let targetParent = ele.parentNode;
- while (targetParent.nodeName !== "TD") {
- if(targetParent.id == 'parent'){
- return null;
- }
- targetParent = targetParent.parentNode;
- }
- return targetParent;
- },
- tableRowClassName({rowIndex}) {
- if (rowIndex === this.titleIndex) {
- return 'warning-row';
- }
- return '';
- },
- //保存单条元素
- saveELe(row){
- if(row.textInfo){
- exctabcellUpdate(row).then(()=>{
- this.$message({
- type: "success",
- message: "保存成功!"
- });
- })
- }else{
- this.$message({
- type: "warning",
- message: "请填写元素名称"
- });
- }
- }
- },
- created () {
- this.getOwnerTypelist();
- this.excelType();
- }
- }
- </script>
- <style lang="scss" scoped>
- .boxswai {
- padding: 0px 14px 10px 14px !important;
- }
- .dingwei {
- position: fixed;
- bottom: 40px;
- right: 40px;
- }
- //树结构超长后产生滚动条
- .el-tree > .el-tree-node {
- min-width: 100%;
- display: inline-block;
- }
- .boxswai{
- height: 100%;
- box-sizing: border-box;
- padding-bottom: 10px;
- }
- .title-item{
- box-sizing: border-box;
- width:100%;
- font-size:16px;
- height:30px;
- padding:3px 20px;
- background-color: #f3f3f3;
- color: #ee7049;
- margin-bottom: 6px;
- cursor:pointer;
- }
- /deep/ .el-table .warning-row {
- background: oldlace;
- }
- .region{
- position: relative;
- height: 100%;
- }
- .region /deep/ .el-dialog__wrapper{
- position: absolute !important;
- }
- .region /deep/ .v-modal{
- position: absolute !important;
- }
- #parent /deep/ .oldlace-bg{
- background-color: oldlace;
- }
- </style>
|