123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829 |
- <template>
- <div class="app-container">
- <el-row :gutter="20">
- <el-col :span="18" :class="{ edit: menudata }">
- <el-card
- v-show="tabIndex == '0'"
- shadow="always"
- :body-style="{ padding: '20px' }"
- >
- <template #header>
- <div>
- <span>基础信息</span>
- </div>
- </template>
- <el-select
- v-model="tableName"
- placeholder="请选择数据表"
- filterable
- @change="getList"
- class="mb10"
- >
- <el-option
- v-for="item in tableList"
- :key="item.tableName"
- :label="item.tableComment"
- :value="item.tableName"
- >
- <span style="float: left">{{ item.tableComment }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{
- item.tableName
- }}</span>
- </el-option>
- </el-select>
- <el-table
- :data="tableFieldList"
- border
- ref="dragTable"
- row-key="id"
- max-height="500px"
- >
- >
- <el-table-column
- type="index"
- label="序号"
- width="50"
- class-name="allowDrag"
- >
- </el-table-column>
- <el-table-column prop="fieldName" label="数据字段">
- </el-table-column>
- <el-table-column prop="fieldDescription" label="字段描述">
- <template slot-scope="scope">
- <input
- :class="{
- isNullDesc:
- scope.row.fieldDescription == '' &&
- scope.row.isShow &&
- isInputInvalid
- ? true
- : false,
- ipt: true,
- }"
- v-model="scope.row.fieldDescription"
- />
- </template>
- </el-table-column>
- <el-table-column prop="relationTable" label="关联表">
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.relationTable"
- :disabled="
- !scope.row.relationTableList ||
- !scope.row.relationTableList.length
- "
- placeholder="请选择关联的表"
- clearable
- filterable
- @change="ralationTableChange(scope.row)"
- >
- <el-option
- v-for="item in scope.row.relationTableList"
- :key="item.tableName"
- :label="item.tableComment"
- :value="item.tableName"
- >
- <span style="float: left">{{ item.tableComment }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ item.tableName }}</span
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column prop="relationFieldName" label="关联条件字段">
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.relationFieldName"
- @change="relationFieldChange(scope.row)"
- :disabled="!scope.row.disableRelaFieldName"
- placeholder="关联字段"
- filterable
- >
- <el-option
- v-for="item in scope.row.relaFieldNameList"
- :key="item.fieldName"
- :label="item.fieldDescription"
- :value="item.fieldName"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column prop="relationType" label="关联方式">
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.relationType"
- placeholder="请选择关联方式"
- :disabled="!scope.row.disableRelaType"
- @change="relationTypeChangeHandler(scope.row)"
- filterable
- >
- <el-option
- v-for="item in relaTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column prop="isShow" label="是否显示">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.isShow"> </el-switch>
- </template>
- </el-table-column>
- <el-table-column prop="isShowRelaDialog" label="添加依赖关系">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.isShowRelaDialog"
- @change="isShowRelaDialogHandler(scope.row)"
- >
- </el-switch>
- </template>
- </el-table-column>
- </el-table>
- </el-card>
- <SubList
- ref="subList"
- v-show="tabIndex == '1'"
- :tableListName="'tableList1'"
- :menudata="menudata"
- :tableList="tableList"
- :echoData="subEchoData.echoData"
- :btnGroupOptions="btnGroupOptions"
- @tableNameChange="subNameHandler"
- @fieldListChange="filedListHandler"
- />
- <SubList
- ref="StatusTable"
- v-show="tabIndex == '2'"
- :tableListName="'tableList2'"
- :menudata="menudata"
- :tableList="tableList"
- :echoData="countEchoData.echoData"
- :btnGroupOptions="btnGroupOptions"
- @tableNameChange="statusTableHandler"
- @fieldListChange="statusFieldListHandler"
- />
- </el-col>
- <el-col :span="6" :class="{ menudata: menudata }">
- <el-tabs v-model="activeName" @tab-click="tabhandleClick">
- <el-tab-pane label="基础信息" name="menuedit">
- <el-card shadow="always" :body-style="{ padding: '10px' }">
- <el-form
- ref="formData"
- :model="formData"
- label-width="100px"
- :rules="rules"
- >
- <el-form-item label="组名称" prop="groupName">
- <el-input v-model="formData.groupName"></el-input>
- </el-form-item>
- <el-form-item label="组描述" prop="groupDescription">
- <el-input v-model="formData.groupDescription"></el-input>
- </el-form-item>
- <el-form-item label="时间格式" prop="timeFormate">
- <el-select
- v-model="formData.timeFormate"
- placeholder="请选择时间格式"
- >
- <el-option
- v-for="val in dict.type.sys_time_format"
- :key="val.value"
- :label="val.label"
- :value="val.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="表格主键" prop="primaryKey">
- <el-select
- v-model="formData.primaryKey"
- placeholder="请选择表格主键"
- >
- <el-option
- v-for="val in primaryKeyList"
- :key="val.fieldName"
- :label="val.fieldDescription"
- :value="val.fieldName"
- >
- <span style="float: left">{{
- val.fieldDescription
- }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ val.fieldName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="操作列按钮" prop="btnGroupList">
- <el-select
- v-model="formData.btnGroupList"
- placeholder="请选择按钮组"
- clearable
- multiple
- >
- <el-option
- v-for="val in btnGroupOptions"
- :key="val.btnKey"
- :label="val.btnGroupName"
- :value="val.btnKey"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="排序依赖字段">
- <el-select
- v-model="formData.orderByColumn"
- placeholder="请选择排序依赖"
- >
- <el-option
- v-for="val in primaryKeyList"
- :key="val.fieldName"
- :label="val.fieldDescription"
- :value="val.fieldName"
- >
- <span style="float: left">{{
- val.fieldDescription
- }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ val.fieldName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="排序方式" v-show="formData.orderByColumn">
- <el-radio v-model="formData.isAsc" :label="false"
- >升序</el-radio
- >
- <el-radio v-model="formData.isAsc" :label="true"
- >降序</el-radio
- >
- </el-form-item>
- <!-- <el-form-item label="当前表字段">
- <el-select
- v-model="formData.relyFile"
- placeholder="请选择当前表字段"
- >
- <el-option
- v-for="item in orderByFieldList"
- :key="item.fieldName"
- :label="item.fieldDescription"
- :value="item.tableName + '.' + item.fieldName"
- >
- </el-option>
- </el-select>
- </el-form-item> -->
- <!-- <el-form-item label="依赖表格">
- <el-select
- v-model="formData.relytableName"
- placeholder="请选择依赖表"
- filterable
- @change="getrelyList"
- class="mb10"
- >
- <el-option
- v-for="item in dragTableList"
- :key="item.dtName"
- :label="item.dtName"
- :value="item.dtName"
- >
- <span style="float: left">{{ item.dtName }}</span>
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="依赖表格字段">
- <el-select
- v-model="formData.relaykey"
- placeholder="请选择依赖字段"
- >
- <el-option
- v-for="item in dragTableFilds"
- :key="item.keu"
- :label="item.val"
- :value="item.key"
- ></el-option>
- </el-select>
- </el-form-item> -->
- <!-- <el-form-item label="依赖表">
- <el-select
- v-model="formData.relytableName"
- placeholder="请选择依赖表"
- filterable
- @change="getrelalist"
- class="mb10"
- >
- <el-option
- v-for="item in tableList"
- :key="item.tableName"
- :label="item.tableComment"
- :value="item.tableName"
- >
- <span style="float: left">{{ item.tableComment }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ item.tableName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="依赖表字段">
- <el-select
- v-model="formData.relaykey"
- placeholder="请选择依赖字段"
- >
- <el-option
- v-for="val in relayTableList"
- :key="val.fieldName"
- :label="val.fieldDescription"
- :value="val.fieldName"
- >
- <span style="float: left">{{
- val.fieldDescription
- }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ val.fieldName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item> -->
- <el-form-item>
- <el-button size="mini" @click="previewHandle">预览</el-button>
- <el-button size="mini" type="primary" @click="createHandle">{{
- tId ? "确认修改" : "确认创建"
- }}</el-button>
- </el-form-item>
- </el-form>
- </el-card>
- </el-tab-pane>
- <el-tab-pane label="关联子表" name="styleEdit">
- <el-card shadow="always" :body-style="{ padding: '10px' }">
- <relayTable
- ref="styleTableRef"
- :echoData="echoData"
- :btnGroupOptions="btnGroupOptions"
- :subFieldList="subFiledList"
- @subFormData="subFormDataHandler"
- :dragTableList="dragTableList"
- :tableList="tableList"
- />
- <el-button
- type="primary"
- class="inline-large-button addcount"
- icon="el-icon-plus"
- size="mini"
- @click="addDataDialog"
- >
- 添加数据字段
- </el-button>
- <el-table
- :data="dragTableStatisticList"
- border
- class="mb10"
- style="width: 100%"
- >
- <!-- <el-table-column prop="number" label="序号" width="50"> -->
- <!-- style="width: 100%"> -->
- <el-table-column
- type="index"
- label="序号"
- width="50"
- class-name="allowDrag"
- >
- </el-table-column>
- <el-table-column
- prop="statisticTitle"
- label="统计标题"
- width="83"
- >
- </el-table-column>
- <el-table-column
- prop="statisticField"
- label="统计数据"
- width="80"
- >
- </el-table-column>
- <el-table-column
- prop="statisticType"
- label="统计类型"
- width="50"
- >
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-dropdown>
- <el-button type="warning" plain size="small">
- 处理<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdateStat(scope.row)"
- >修改
- </el-button>
- </el-dropdown-item>
- <el-dropdown-item>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDeleteStat(scope.row)"
- >删除
- </el-button>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- </el-table-column>
- </el-table>
- </el-card>
- </el-tab-pane>
- <el-tab-pane label="数据统计" name="datacount">
- <el-card shadow="always" :body-style="{ padding: '10px' }">
- <el-form ref="countData" :model="countData" label-width="100px">
- <el-form-item label="按钮组" prop="btnGroupList">
- <el-select
- v-model="countData.btnGroupList"
- placeholder="请选择按钮组"
- clearable
- multiple
- >
- <el-option
- v-for="val in btnGroupOptions"
- :key="val.btnKey"
- :label="val.btnGroupName"
- :value="val.btnKey"
- ></el-option>
- </el-select>
- </el-form-item>
- <!-- <el-form-item label="状态展示标题" prop="title">
- <el-input
- @input="iptChange()"
- v-model="countData.title"
- placeholder="请输入展示标题"
- ></el-input>
- </el-form-item> -->
- <!-- <el-form-item label="选择数据表" prop="table">
- <el-select
- @input="iptChange()"
- v-model="countData.countName"
- placeholder="请选择数据表"
- filterable
- @change="getCountList"
- class="mb10"
- >
- <el-option
- v-for="item in countList"
- :key="item.tableName"
- :label="item.tableComment"
- :value="item.tableName"
- >
- <span style="float: left">{{ item.tableComment }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ item.tableName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item> -->
- <el-form-item label="表格主键" prop="primaryKey">
- <el-select
- @input="iptChange()"
- v-model="countData.primaryKey"
- placeholder="请选择表格主键"
- >
- <el-option
- v-for="val in countPrimaryKeyList"
- :key="val.fieldName"
- :label="val.fieldDescription"
- :value="val.fieldName"
- >
- <span style="float: left">{{
- val.fieldDescription
- }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ val.fieldName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item>
- <!-- <el-form-item label="统计字段">
- <el-select
- v-model="countData.countFile"
- placeholder="请选择统计字段"
- @input="iptChange()"
- >
- <el-option
- v-for="item in countByFieldList"
- :key="item.fieldName"
- :label="item.fieldDescription"
- :value="item.fieldName"
- >
- <span style="float: left">{{
- item.fieldDescription
- }}</span>
- <span
- style="float: right; color: #8492a6; font-size: 13px"
- >{{ item.fieldName }}</span
- >
- </el-option>
- </el-select>
- </el-form-item> -->
- </el-form>
- </el-card>
- </el-tab-pane>
- </el-tabs>
- </el-col>
- </el-row>
- <el-dialog title="效果预览" :visible.sync="isShowPreview" width="50%">
- <div class="cardBox">
- <el-card
- shadow="hover"
- :body-style="{ padding: '20px' }"
- class="card"
- v-for="(item, index) in deepragTableStatisticList"
- :key="index"
- >
- <el-tooltip
- class="item"
- effect="dark"
- :content="item.statisticTitle"
- placement="top-start"
- >
- <div class="title">
- {{
- item.statisticTitle
- ? item.statisticTitle
- : item.statisticDescription
- }}
- </div>
- </el-tooltip>
- <div class="type">
- <div class="count">统计结果</div>
- </div>
- </el-card>
- </div>
- <el-row :gutter="10" class="mb8">
- <el-col :span="18">
- <el-input placeholder="请输入" clearable />
- </el-col>
- <el-col :span="6" class="previewbtn">
- <el-button
- type="primary"
- icon="el-icon-search"
- size="small"
- @click="() => {}"
- >搜索</el-button
- >
- <el-button icon="el-icon-refresh" size="small" @click="() => {}"
- >重置</el-button
- >
- </el-col>
- </el-row>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="() => {}"
- >新增
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="success"
- plain
- icon="el-icon-edit"
- size="mini"
- :disabled="false"
- @click="() => {}"
- >修改
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="danger"
- plain
- icon="el-icon-delete"
- size="mini"
- :disabled="false"
- @click="() => {}"
- >删除
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button plain icon="el-icon-upload2" size="mini" @click="() => {}"
- >导入
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="() => {}"
- >导出
- </el-button>
- </el-col>
- </el-row>
- <el-table :data="tableDataList" @selection-change="() => {}">
- <el-table-column
- type="selection"
- width="55"
- align="center"
- ></el-table-column>
- <el-table-column
- v-for="item in columns"
- :key="item.key + item.value"
- :label="item.value"
- align="center"
- :prop="toUpperCase(item.key)"
- />
- <el-table-column
- label="操作"
- align="center"
- class-name="small-padding fixed-width"
- >
- <template>
- <el-dropdown>
- <el-button type="warning" plain size="small">
- 处理<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- ><el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="() => {}"
- >修改</el-button
- ></el-dropdown-item
- >
- <el-dropdown-item
- ><el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="() => {}"
- >删除</el-button
- >
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="pageList"
- />
- <template #footer>
- <span>
- <el-button @click="isShowPreview = false">关闭</el-button>
- <el-button type="primary" @click="createHandle">{{
- tId ? "确认修改" : "确认关联"
- }}</el-button>
- </span>
- </template>
- </el-dialog>
- <!-- 添加数据统计对话框 -->
- <el-dialog :title="staictitle" :visible.sync="isShowAddData" width="30%">
- <el-form label-width="100px" :model="dataCountFormData">
- <el-form-item label="统计标题" prop="statisticTitle">
- <el-input v-model="dataCountFormData.statisticTitle"></el-input>
- </el-form-item>
- <el-form-item label="统计数据">
- <el-select
- v-model="dataCountFormData.statisticField"
- placeholder="请选择统计字段"
- >
- <el-option
- v-for="item in dataArr"
- :key="item.id"
- :label="item.fieldDescription"
- :value="item.tableName + '.' + item.fieldName"
- >
- <span style="float: left; margin-right: 5px"
- >{{ item.fieldDescription }}
- </span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{
- item.fieldName
- }}</span>
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="统计类型">
- <el-select
- v-model="dataCountFormData.statisticType"
- placeholder="请选择统计类型"
- >
- <el-option
- v-for="item in dataType"
- :key="item.dictCode"
- :label="item.dictLabel"
- :value="item.dictValue"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeAddDialog">取 消</el-button>
- <el-button
- v-if="staictitle == '修改统计数据字段'"
- type="primary"
- @click="upadtaData"
- >确 定</el-button
- >
- <el-button v-else type="primary" @click="addData">确 定</el-button>
- </span>
- </el-dialog>
- <!-- 添加依赖关系 -->
- <RelayDialog ref="relayRef" @saveRelayRes="saveRelayRes"></RelayDialog>
- </div>
- </template>
- <script>
- import { getTableInfo } from "@/api/system/table.js";
- import {
- dragTableInfo,
- addStatistic,
- updateStatistic,
- addGroupTableStatistic,
- updateGroupTableStatistic,
- } from "@/api/tablelist/commonTable";
- import { listTable } from "@/api/dragform/tableList";
- import {
- getFormName,
- getListName,
- dragTablePreview,
- } from "@/api/dragform/form.js";
- import { getTable } from "@/api/relateTable/index.js";
- import { addDialogGroup, undataDialogGroup } from "@/api/dialogMange/index.js";
- import { listType } from "@/api/system/dict/type.js";
- import { mapState } from "vuex";
- import Sortable from "sortablejs";
- import { v4 as uuidv4 } from "uuid";
- import { listBtn } from "@/api/system/btn";
- import relayTable from "./components/relayTable.vue";
- import SubList from "./relayTableMange/tablelist.vue";
- import RelayDialog from "./components/RelayDialog.vue";
- export default {
- name: "tableMange",
- dicts: ["sys_time_format", "table_statistic_type"],
- props: [],
- components: { relayTable, SubList, RelayDialog },
- data() {
- return {
- // 关联子表数据回显
- echoData: {},
- dragTableList: [],
- countdragTableList: [],
- dragTableFilds: {},
- // 统计子表
- countdragTableFilds: [],
- // 子表tablename
- subTableName: "",
- subFiledList: [],
- statusFieldList: [], //状态按钮 字段数据
- // 依赖表名称
- // relytableName: '',
- staictitle: this.$t('dialog.addStatisticField'),
- isInputInvalid: false,
- // 修改表格时的menuId
- menuId: "",
- // 修改表格的id
- tId: "",
- // 当前模板信息
- templateInfo: {},
- // 排序方式 默认降序
- sortState: true,
- // 列信息
- columns: {},
- // 查询条件
- queryFromWhere: {},
- // 当前table唯一标识
- sqlKey: "",
- // 动态数据sqlkey
- staticSqlKey: "",
- // 表格的高度
- tableKey: "",
- // tableHeight: document.documentElement.scrollHeight - 245 + "px",
- tableList: [], //所有表格列表
- tableFieldList: [], // 当前表格字段数据
- relayFieldList: [],
- tableName: "", // 当前表名称
- relationTableList: [], //关联表格列表
- relationFieldList: [], //关联字段列表
- relationTypeList: [], //关联方式列表
- total: 0, //表格数据总数
- relyOptions: [
- {
- value: "0",
- label: this.$t('dialog.customDependency'),
- },
- {
- value: "1",
- label: this.$t('dialog.dependOnOtherField'),
- }
- ],
- // 依赖值
- relayValue: "",
- // 依赖字段
- relyFileds: {},
- relaTypeList: [
- {
- label: this.$t('dialog.equalJoin'),
- value: "INNER JOIN",
- },
- {
- label: this.$t('dialog.leftJoin'),
- value: "LEFT JOIN",
- },
- {
- label: this.$t('dialog.rightJoin'),
- value: "RIGHT JOIN",
- }
- ],
- headerList: [
- {
- prop: "fieldName",
- label: "数据字段",
- },
- {
- prop: "fieldDescription",
- label: "字段描述",
- },
- {
- prop: "relationTable",
- label: "关联表",
- },
- {
- prop: "relationFieldName",
- label: "关联字段",
- },
- {
- prop: "relationType",
- label: "关联方式",
- },
- {
- prop: "isShow",
- label: "是否显示",
- },
- {
- prop: "isSearch",
- label: "是否包含查询",
- },
- {
- prop: "isExport",
- label: "是否导出",
- },
- {
- prop: "isCount",
- label: "是否统计",
- },
- ], //表头列表
- // 基础信息编辑
- formData: {
- groupName: "",
- groupDescription: "",
- routePath: undefined,
- isShowList: true,
- timeFormate: "",
- orderByColumn: "",
- isAsc: false,
- primaryKey: "",
- btnGroupList: [],
- },
- // 统计信息
- countData: {},
- rules: {
- groupName: [
- { required: true, message: "请输入组名称", trigger: "blur" },
- ],
- groupDescription: [
- { required: true, message: "请输入组描述", trigger: "blur" },
- ],
- timeFormate: [
- { required: true, message: "请选择时间格式", trigger: "change" },
- ],
- primaryKey: [
- { required: true, message: "请选择表格主键", trigger: "blur" },
- ],
- fieldDescription: [
- { required: true, message: "请输入字段描述", trigger: "blur" },
- ],
- },
- // tab切换
- tabIndex: "0",
- menus: [], //路由列表数据
- // 预览弹窗相关
- isShowPreview: false, //弹窗显示与隐藏
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- orderByColumn: "",
- isAsc: false,
- basicMap: {
- sql: "",
- },
- },
- loading: false, //表格加载
- tableDataList: [], //数据
- // 基础信息数据回显
- editData: {},
- // 关联子表数据回显
- subEchoData: {},
- // 统计数据回显
- countEchoData: {},
- gruopKey: "",
- menuOrderNum: 0,
- // tab动态切换
- activeName: "menuedit",
- // 数据统计对象
- dataCountFormData: {},
- // 添加数据统计表格
- dragTableStatisticList: [],
- deepragTableStatisticList: [],
- tableSqlList: [],
- searchFieldList: [],
- // 是否切换到数据统计
- menudata: false,
- // 显示添加字段对话框dataArr
- isShowAddData: false,
- dataType: [],
- uuid: "",
- // 样式编辑tab数据
- // dragTableStyleList: [],
- //操作列按钮组数据
- btnGroupOptions: [],
- // 统计展示字段
- countFiledsList: [
- {
- label: "直接展示",
- value: "0",
- },
- {
- label: "字段关联展示",
- value: "1",
- },
- ],
- // 关联字段字典
- countDicts: [],
- // 子表表单数据
- subformData: {},
- // 数据统计
- countName: "",
- countFieldList: [],
- // 统计状态信息回显
- statusCount: [],
- // 回显数据单表列表
- lists: [],
- relayField: [],
- countrelayFieldList: [],
- relaytableField: [],
- // 依赖相关数据
- row: null,
- };
- },
- computed: {
- // 数据字段
- dataArr() {
- // console.log(this.subFiledList);
- return this.subFiledList?.filter((item) => item.isShow);
- },
- // 数据表
- countList() {
- return this.tableList;
- },
- // 统计数据依赖表
- countRelayList() {
- return this.tableList;
- },
- // 依赖表
- relayList() {
- return this.tableList;
- },
- infoTableList() {
- return this.tableList;
- },
- // 数据统计字段表名中文
- isShowTableName() {
- let tableComment;
- this.subFiledList.forEach((item) => {
- if (item.tableName === this.subTableName) {
- tableComment = item.tableComment;
- }
- });
- // console.log(tableComment);
- return tableComment;
- },
- ...mapState({
- databaseName: (state) => state.user.dataSource.databaseName,
- databaseType: (state) => state.user.dataSource.databaseType,
- username: (state) => state.user.dataSource.username,
- tenantId: (state) => state.user.tenant.tenantId,
- }),
- searchArr() {
- if (!this.templateInfo?.where?.length) return [];
- return this.templateInfo.where.map((item) => item.conditionName);
- },
- checkedWhere() {
- if (!this.templateInfo?.where?.length) return [];
- return this.templateInfo?.where.filter((item) => {
- return this.checkedList.includes(item.conditionName);
- });
- },
- // 当前表字段
- orderByFieldList() {
- // return this.tableFieldList.filter((item) => item.isShow);
- return this.tableFieldList;
- },
- // 统计字段
- countByFieldList() {
- return this.countFieldList;
- },
- // 表格主键
- primaryKeyList: {
- get() {
- return this.tableFieldList.filter((item) => !item.isChildren);
- },
- },
- // 数据统计表格主键
- countPrimaryKeyList() {
- // console.log(this.countFieldList);
- return this.countFieldList.filter((item) => !item.isChildren);
- },
- // 依赖表字段
- relayTableList() {
- return this.relaytableField.filter((item) => !item.isChildren);
- },
- relayKeyList() {
- return this.relayFieldList.filter((item) => !item.isChildren);
- },
- // 数据统计依赖表字段
- countRelayField() {
- return this.countrelayFieldList.filter((item) => !item.isChildren);
- },
- },
- watch: {
- tableName: function (val) {
- if (val) {
- this.relationTableList = this.tableList
- .filter((item) => item.tableName != val)
- .map((item) => {
- return {
- tableName: item.tableName,
- tableComment: item.tableComment,
- };
- });
- } else {
- this.relationTableList = [];
- }
- },
- },
- methods: {
- // 数据统计tag选择数据表
- getCountList() {
- if (!this.countData.countName) return;
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- tableName: this.countData.countName,
- };
- let tableComment = this.getTableCommont(
- this.countData.countName,
- this.tableList
- );
- // 获取当前表单结构信息
- getListName(data).then((res) => {
- // console.log(res);
- this.countFieldList = res.map((item, index) => {
- return {
- id: this.countData.countName + "_" + item.fieldName,
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- relationTable: "",
- relationFieldName: "",
- relaFieldNameList: [],
- disableRelaFieldName: false,
- relationType: "",
- relationShowField: [],
- relationShowFiledList: [],
- disableRelaType: false,
- isShowRelaDialog: false, //关联关系弹窗
- relaData: {}, //关联数据
- isShow: false,
- isSearch: false,
- isExport: true,
- relationTableList: this.relationTableList,
- tableName: this.tableName,
- tableComment,
- relationFieldList: [],
- };
- });
- });
- },
- // 数据统计依赖表
- getCountrelayList() {
- if (!this.countData.relytableName) return;
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- tableName: this.countData.relytableName,
- };
- let tableComment = this.getTableCommont(
- this.countData.relytableName,
- this.tableList
- );
- // 获取当前表单结构信息
- getListName(data).then((res) => {
- // console.log(res);
- this.countrelayFieldList = res.map((item, index) => {
- return {
- id: this.countData.countName + "_" + item.fieldName,
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- relationTable: "",
- relationFieldName: "",
- relaFieldNameList: [],
- disableRelaFieldName: false,
- relationType: "",
- relationShowField: [],
- relationShowFiledList: [],
- isShowRelaDialog: false, //关联关系弹窗
- relaData: {}, //关联数据
- disableRelaType: false,
- isShow: false,
- isSearch: false,
- isExport: true,
- relationTableList: this.relationTableList,
- tableName: this.countData.relytableName,
- tableComment,
- relationFieldList: [],
- };
- });
- });
- },
- // 关联字典字段
- async getDictType() {
- let data = {
- isEnablePaging: false,
- };
- let res = await listType(data);
- // console.log('字典数据', res);
- this.countDicts = res.rows;
- },
- // 关联子表名
- subNameHandler(val) {
- this.subTableName = val;
- },
- // 统计状态 表名
- statusTableHandler(val) {
- this.countData.countName = val;
- },
- // 关联子表字段
- filedListHandler(list) {
- this.subFiledList = list;
- },
- // 数据统计字段
- statusFieldListHandler(list) {
- this.statusFieldList = list;
- this.countFieldList = list;
- },
- // 关联子表
- subFormDataHandler(data) {
- this.subformData = data;
- },
- /** 查询列表 */
- getList(queryParams) {
- if (!this.tableName) return;
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- tableName: this.tableName,
- };
- let tableComment = this.getTableCommont(this.tableName, this.tableList);
- // 获取当前表单结构信息
- getListName(data).then((res) => {
- // console.log(res);
- this.tableFieldList = res.map((item, index) => {
- return {
- id: this.tableName + "_" + item.fieldName,
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- relationTable: "",
- relationFieldName: "",
- relaFieldNameList: [],
- disableRelaFieldName: false,
- relationType: "",
- relationShowField: [],
- relationShowFiledList: [],
- disableRelaType: false,
- isShow: false,
- isShowRelaDialog: false, //关联关系弹窗
- relaData: "", //关联数据
- isSearch: false,
- isExport: true,
- relationTableList: this.relationTableList,
- tableName: this.tableName,
- tableComment,
- relationFieldList: [],
- };
- });
- // console.log(this.tableFieldList);
- });
- },
- // 依赖表字段
- getrelalist() {
- if (!this.formData.relytableName) return;
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- tableName: this.formData.relytableName,
- };
- let tableComment = this.getTableCommont(
- this.formData.relytableName,
- this.tableList
- );
- // 获取当前表单结构信息
- getListName(data).then((res) => {
- // console.log(res);
- this.relaytableField = res.map((item, index) => {
- return {
- id: this.formData.relytableName + "_" + item.fieldName,
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- relationTable: "",
- relationFieldName: "",
- relaFieldNameList: [],
- disableRelaFieldName: false,
- relationType: "",
- relationShowField: [],
- relationShowFiledList: [],
- disableRelaType: false,
- isShow: false,
- isShowRelaDialog: false, //关联关系弹窗
- relaData: "", //关联数据
- isSearch: false,
- isExport: true,
- relationTableList: this.relationTableList,
- tableName: this.formData.relytableName,
- tableComment,
- relationFieldList: [],
- };
- });
- // console.log(this.relayField);
- });
- },
- // 依赖表格
- getrelyList() {
- // console.log(this.formData.relytableName);
- this.dragTableList.forEach((item) => {
- if (this.formData.relytableName == item.dtName) {
- this.dragTableFilds = JSON.parse(item.dtColumnName);
- }
- });
- this.dragTableFilds.forEach((item) => {
- for (let val in item) {
- item.key = val;
- item.val = item[val];
- }
- });
- },
- // 依赖表格
- getCountrelyList() {
- if (this.countdragTableList) {
- this.countdragTableList?.forEach((item) => {
- // console.log(this.countData.relytableName);
- if (this.countData.relytableName == item.dtName) {
- this.countdragTableFilds = JSON.parse(item.dtColumnName);
- }
- });
- this.countdragTableFilds?.forEach((item) => {
- for (let val in item) {
- item.key = val;
- item.val = item[val];
- }
- });
- }
- },
- // 依赖表格列表数据
- getdragTable() {
- let queryParams = {
- isEnablePaging: false,
- dtType: 0,
- };
- listTable(queryParams).then((res) => {
- this.dragTableList = res.rows;
- this.countdragTableList = res.rows;
- });
- },
- // 关联表变化回调
- async ralationTableChange(row) {
- this.tableFieldList = this.tableFieldList.filter((item) => {
- return !row.relationFieldList.some((val) => {
- return val.id == item.id;
- });
- });
- row.relationFieldName = "";
- row.relationType = "";
- row.disableRelaFieldName = false;
- row.disableRelaType = false;
- row.relationFieldList = [];
- if (!row.relationTable) {
- return;
- }
- // 获取关联表的字段
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- tableName: row.relationTable,
- };
- let tableComment = this.getTableCommont(
- row.relationTable,
- this.tableList
- );
- let res = await getListName(data);
- // 关联字段下拉列表数据
- row.relaFieldNameList = res.map((item) => {
- return {
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- };
- });
- let relationTableList = row.relationTableList.filter(
- (item) => row.relationTable != item.tableName
- );
- row.relationFieldList = row.relaFieldNameList.map((item, index) => {
- return {
- id: row.relationTable + "_" + item.fieldName,
- fieldName: item.fieldName,
- fieldDescription: item.fieldDescription,
- relationTable: "",
- relationFieldName: "",
- relaFieldNameList: [],
- disableRelaFieldName: false,
- relationType: "",
- relationShowField: [],
- relationShowFiledList: [],
- disableRelaType: false,
- isShowRelaDialog: false, //关联关系弹窗
- relaData: "", //关联数据
- isShow: false,
- isSearch: false,
- isExport: true,
- relationTableList,
- tableName: row.relationTable,
- tableComment,
- relationFieldList: [],
- isChildren: true,
- };
- });
- // this.tableFieldList = [...this.tableFieldList, ...row.relationFieldList];
- row.disableRelaFieldName = true;
- },
- // 关联类型变化回调
- relationTypeChangeHandler(row) {
- let tempRelationFieldList = row.relationFieldList.filter((item) => {
- return !this.tableFieldList.find((val) => val.id === item.id);
- });
- this.tableFieldList = [...this.tableFieldList, ...tempRelationFieldList];
- },
- // 关联字段回调
- relationFieldChange(row) {
- if (!row.relationFieldName) {
- row.relationType = "";
- row.disableRelaType = false;
- row.relaFieldNameList = [];
- return;
- }
- row.disableRelaType = true;
- },
- // 勾选框回调
- handleSelectionChange(selection) {
- this.ids = selection.map((item) => item.id);
- // this.single = selection.length != 1;
- this.multiple = !selection.length;
- },
- // 分页查询
- pageList(row) {
- this.$refs.mychild.pageList(
- row == undefined
- ? {
- limit: this.queryParams.pageSize,
- page: this.queryParams.pageNum,
- }
- : row
- );
- },
- // 多选框改变回调
- checkedChangeHandle(val) {},
- // 获取所有表格
- async getAllTable() {
- let data = {
- databaseName: this.databaseName,
- databaseType: this.databaseType,
- };
- let res = await getFormName(data);
- const baseTable = await this.getDicts("base_table");
- this.tableList = res.data.filter((item) => {
- return !baseTable.data.some(
- (value) =>
- value.dictValue.toLowerCase() == item.tableName.toLowerCase()
- );
- });
- },
- //处理表格行拖拽
- initDragTable() {
- const el = this.$refs.dragTable.$el.querySelectorAll(
- ".el-table__body-wrapper > table > tbody"
- )[0];
- const sortable = Sortable.create(el, {
- handle: ".allowDrag",
- onEnd: (evt) => {
- const targetRow = this.tableFieldList.splice(evt.oldIndex, 1)[0];
- this.tableFieldList.splice(evt.newIndex, 0, targetRow);
- for (let index in this.tableFieldList) {
- this.tableFieldList[index].sort = parseInt(index) + 1;
- }
- },
- });
- },
- // 校验字段合法性(递归版)
- validateField(tableFieldList, validateParams) {
- if (!tableFieldList.length) {
- return;
- }
- for (let i = 0; i < tableFieldList.length; i++) {
- let temp = tableFieldList[i];
- if (!temp.fieldDescription?.trim() && temp.isShow) {
- //描述字段不能为空
- validateParams.isFieldDescrib = true;
- }
- if (
- temp.relationTable &&
- (!temp.relationFieldName || !temp.relationType)
- ) {
- // 关联条件不足
- validateParams.isRelationFieldAll = true;
- }
- if (temp.relationFieldList.length) {
- this.validateField(temp.relationFieldList, validateParams);
- }
- }
- },
- // 校验字段合法性(非递归版)
- validateTableData(tableFieldList) {
- if (!tableFieldList.length) {
- return {
- val: false,
- meg: "字段个数不能为空",
- };
- }
- for (let i = 0; i < tableFieldList.length; i++) {
- let temp = tableFieldList[i];
- if (!temp.fieldDescription?.trim() && temp.isShow) {
- return {
- val: false,
- msg: "显示的字段,字段描述不能为空",
- };
- }
- if (
- temp.relationTable &&
- (!temp.relationFieldName || !temp.relationType)
- ) {
- return {
- val: false,
- msg: "关联条件不足,请完善关联条件",
- };
- }
- }
- if (tableFieldList.filter((item) => item.isShow).length == 0) {
- return {
- val: false,
- msg: "显示的字段数不能为空",
- };
- }
- // if (
- // tableFieldList.filter((item) => item.isExport && !item.isChildren)
- // .length == 0
- // ) {
- // return {
- // val: false,
- // msg: "导出字段中至少应有一个主表字段",
- // };
- // }
- // 导出的字段的描述不能重复
- // let describeArr = tableFieldList
- // .filter((item) => item.isExport)
- // .map((item) => item.fieldDescription);
- // let isRepeat = false;
- // describeArr.map((item) => {
- // if (describeArr.indexOf(item) != describeArr.lastIndexOf(item)) {
- // isRepeat = true;
- // }
- // });
- // if (isRepeat) {
- // return {
- // val: false,
- // msg: "导出的字段描述不能重复",
- // };
- // }
- return {
- val: true,
- msg: "",
- };
- },
- // 递归拼接查询语句
- getSQLString(
- tableFieldList,
- fieldArr,
- tableArr,
- sqlType = "mysql",
- formData
- ) {
- let prefix = "{DBNAME}.";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- for (let i = 0; i < tableFieldList.length; i++) {
- let temp = tableFieldList[i];
- if (temp.isShow) {
- let tempArr = prefix + temp.tableName + "." + temp.fieldName;
- if (temp.isChildren) {
- tempArr += asOrSpace + temp.tableName + "_" + temp.fieldName;
- }
- fieldArr.push(tempArr);
- }
- if (temp.relationTable && temp.relationFieldName && temp.relationType) {
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- tableArr.push(
- temp.relationType +
- " " +
- isNeedUsername +
- prefix +
- temp.relationTable +
- asOrSpace +
- temp.relationTable +
- " ON " +
- prefix +
- temp.relationTable +
- "." +
- temp.relationFieldName +
- " = " +
- prefix +
- temp.tableName +
- "." +
- temp.fieldName
- );
- }
- }
- // 如果主键不包含显示,则添加至sql语句中
- let isNotInclude = formData.primaryKeyList.find(
- (val) => !val.isShow && val.fieldName == formData.primaryKey
- );
- if (isNotInclude) {
- fieldArr.push(
- prefix + isNotInclude.tableName + "." + isNotInclude.fieldName
- );
- }
- },
- // 递归拼接查询语句
- getSQLCountString(tableFieldList, fieldArr, tableArr, sqlType = "mysql") {
- let prefix = "{DBNAME}.";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- for (let i = 0; i < tableFieldList.length; i++) {
- let temp = tableFieldList[i];
- if (temp.isShow) {
- let tempArr = prefix + temp.tableName + "." + temp.fieldName;
- if (temp.isChildren) {
- tempArr += asOrSpace + temp.tableName + "_" + temp.fieldName;
- }
- fieldArr.push(tempArr);
- }
- if (temp.relationTable && temp.relationFieldName && temp.relationType) {
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- tableArr.push(
- temp.relationType +
- " " +
- isNeedUsername +
- prefix +
- temp.relationTable +
- asOrSpace +
- temp.relationTable +
- " ON " +
- prefix +
- temp.relationTable +
- "." +
- temp.relationFieldName +
- " = " +
- prefix +
- temp.tableName +
- "." +
- temp.fieldName
- );
- }
- }
- // 如果主键不包含显示,则添加至sql语句中
- let isNotInclude = this.countPrimaryKeyList.find(
- (val) => !val.isShow && val.fieldName == this.countData.primaryKey
- );
- if (isNotInclude) {
- fieldArr.push(
- prefix + isNotInclude.tableName + "." + isNotInclude.fieldName
- );
- }
- },
- // 拼接查询sql语句
- getSQLStr() {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- this.getSQLString(
- this.tableFieldList,
- fieldNameArr,
- relaTypeArr,
- sqlType,
- {
- ...this.formData,
- primaryKeyList: this.primaryKeyList,
- }
- );
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- fieldNameArr.join(",") +
- " FROM " +
- isNeedUsername +
- prefix +
- this.tableName +
- asOrSpace +
- this.tableName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 拼接查询sql语句
- getSQLStr2() {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- console.log(this.subFiledList);
- this.getSQLString(
- this.subFiledList,
- fieldNameArr,
- relaTypeArr,
- sqlType,
- this.subformData
- );
- console.log(fieldNameArr);
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- fieldNameArr.join(",") +
- " FROM " +
- isNeedUsername +
- prefix +
- this.subTableName +
- asOrSpace +
- this.subTableName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 拼接数据统计查询sql
- getSQLStr3(fieldList, tableName) {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- this.countData.primaryKeyList = fieldList.filter(
- (item) => !item.isChildren
- );
- this.getSQLString(
- fieldList,
- fieldNameArr,
- relaTypeArr,
- sqlType,
- this.countData
- );
- console.log(fieldNameArr);
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- fieldNameArr.join(",") +
- " FROM " +
- isNeedUsername +
- prefix +
- tableName +
- asOrSpace +
- tableName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 数据统计sql
- countGetSQLStr(countByFieldList, tableName) {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- console.log(countByFieldList);
- this.getSQLCountString(
- countByFieldList,
- fieldNameArr,
- relaTypeArr,
- sqlType
- );
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- fieldNameArr.join(",") +
- " FROM " +
- isNeedUsername +
- prefix +
- tableName +
- asOrSpace +
- tableName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 统计信息
- getStaticSQL(key) {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- this.getSQLString(this.subFiledList, fieldNameArr, relaTypeArr, sqlType, {
- ...this.countData,
- primaryKeyList: this.primaryKeyList,
- });
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- key +
- " FROM " +
- isNeedUsername +
- prefix +
- this.subTableName +
- asOrSpace +
- this.subTableName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 统计状态
- getstateSQL(formName, fieldName) {
- let prefix = "{DBNAME}.";
- let sqlType = this.databaseType; //数据库类型
- // let sqlType = "oracle";
- let sql = "";
- // mysql
- sql += "SELECT ";
- let fieldNameArr = [],
- relaTypeArr = [];
- this.getSQLString(this.subFiledList, fieldNameArr, relaTypeArr, sqlType, {
- ...this.formData,
- primaryKeyList: this.primaryKeyList,
- });
- let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
- let asOrSpace = sqlType == "oracle" ? " " : " AS ";
- sql +=
- fieldName +
- " FROM " +
- isNeedUsername +
- prefix +
- formName +
- asOrSpace +
- formName;
- if (relaTypeArr.length) {
- sql += " " + relaTypeArr.join(" ");
- }
- return sql;
- },
- // 处理列表信息
- columnsHandler(columns) {
- let resArr = [];
- columns.forEach((item) => {
- for (const key in item) {
- let tempObj = {};
- tempObj.key = key;
- tempObj.value = item[key];
- resArr.push(tempObj);
- }
- });
- return resArr;
- },
- // 依赖关系改变回调
- isShowRelaDialogHandler(row) {
- let isShow = row.isShowRelaDialog;
- if (isShow) {
- console.log(isShow);
- this.row = row;
- this.$refs.relayRef.openHandlder();
- } else {
- this.row = null;
- }
- console.log(row);
- },
- // 保存依赖结果
- saveRelayRes(res) {
- if (res.flag) {
- this.row.relaData = res.data;
- } else {
- this.row.isShowRelaDialog = false;
- }
- },
- // 下划线命名转驼峰命名
- toUpperCase(str) {
- let nstr = str.replace(/(?:_)+([^_])/g, function ($0, $1) {
- return $1.toUpperCase();
- });
- nstr = nstr.replace(nstr[0], nstr[0].toLowerCase());
- return nstr;
- },
- // 递归获取列表信息
- getCol(
- tableFieldList,
- columns,
- searchFieldList = [],
- tableExportField = {}
- ) {
- if (!tableFieldList.length) return;
- for (let i = 0; i < tableFieldList.length; i++) {
- let temp = tableFieldList[i];
- let tempFieldName = "",
- exportFieldName = "";
- if (temp.isChildren) {
- tempFieldName = temp.tableName + "_" + temp.fieldName;
- exportFieldName = temp.tableName + "@" + temp.fieldName;
- } else {
- tempFieldName = temp.fieldName;
- exportFieldName = temp.fieldName;
- }
- if (temp.isShow) {
- let tempObj = {};
- tempObj[tempFieldName] = temp.fieldDescription;
- columns.push(tempObj);
- }
- if (temp.isSearch) {
- searchFieldList.push(temp.tableName + "." + temp.fieldName);
- }
- if (temp.isExport) {
- tableExportField[exportFieldName] = temp.fieldDescription;
- }
- }
- },
- // 预览结果回调
- async previewHandle() {
- this.$refs.formData.validate(async (valid) => {
- // 至少包含一个查询项
- if (valid) {
- if (!this.tableName) {
- this.$message.error("请选择数据表");
- return;
- }
- // 检验表单合法性
- let validRes = this.validateTableData(this.tableFieldList);
- if (!validRes.val) {
- this.$message.error(validRes.msg);
- return;
- }
- // 拼接预览的sql查询语句
- this.queryParams.basicMap.sql = this.getSQLStr();
- // 获取表头信息
- let tempColumns = [],
- searchFieldList = [];
- this.getCol(this.tableFieldList, tempColumns, searchFieldList);
- if (!searchFieldList.length) {
- this.$message.warning("请至少选择一个包含查询字段");
- return false;
- }
- const dataType = await this.getDicts("table_statistic_type");
- this.deepragTableStatisticList = JSON.parse(
- JSON.stringify(this.dragTableStatisticList)
- );
- this.deepragTableStatisticList.forEach((item) => {
- dataType.data.forEach((val) => {
- if (val.dictValue == item.statisticType) {
- item.statisticType = val.dictLabel;
- }
- });
- });
- this.columns = this.columnsHandler(tempColumns);
- this.queryParams.isAsc = this.formData.isAsc;
- // 发送请求获取预览数据
- let res = await dragTablePreview(this.queryParams);
- this.tableDataList = [];
- res.rows.forEach((item) => {
- this.tableDataList.push(item.resultMap);
- });
- this.total = res.total;
- this.isShowPreview = true;
- } else {
- this.$message.warning("请完善表单");
- return false;
- }
- });
- },
- // 获取依赖条件对象
- getRelaObjAndSearchList(fieldList = []) {
- console.log(fieldList);
- let res = {
- relaObj: {},
- searchList: [],
- };
- fieldList.forEach((item) => {
- if (item.isShowRelaDialog) {
- // let { tableName as tName,fieldName} = item;
- let { tableName, fieldName } = item.relaData;
- res.relaObj[item.tableName + "." + item.fieldName] =
- "#{" + tableName + "." + fieldName;
- res.searchList.push(item.tableName + "." + item.fieldName);
- }
- });
- return res;
- },
- // 创建回调
- async createHandle() {
- this.isInputInvalid = true;
- this.$refs.formData.validate(async (valid) => {
- if (valid) {
- // 检验表单合法性
- let validRes = this.validateTableData(this.tableFieldList);
- if (!validRes.val) {
- this.$message.error(validRes.msg);
- return;
- }
- let relyName = "";
- let subrelayName = "";
- // 基础信息关联
- let searchData = this.getRelaObjAndSearchList(this.tableFieldList);
- let conditionDefault = searchData.relaObj;
- // 基础信息tableKey
- let table1tableKey = uuidv4();
- // 处理基础信息列数据
- let columns1 = [];
- // 基础信息查询条件
- let searchFieldList1 = searchData.searchList;
- this.getCol(this.tableFieldList, columns1);
- // 基础信息回显
- let echoData = {
- tableName: this.tableName,
- tableFieldData: this.tableFieldList,
- formData: this.formData,
- };
- // 处理基础信息依赖表
- // this.dragTableList.forEach((item) => {
- // if (item.dtName == this.formData.relytableName) {
- // relyName = item.dtTableName;
- // }
- // });
- // console.log(this.dragTableList);
- // return;
- // 基础信息判断表格依赖方式
- // if (this.formData.relyOption === "0") {
- // conditionDefault[this.formData.relyFile] = this.relayValue;
- // } else {
- // conditionDefault[this.formData.relyFile] =
- // "#{" + relyName + "." + this.formData.relaykey;
- // }
- // 基础信息查询条件
- // searchFieldList1.push(this.formData.relyFile);
- // 基础信息请求数据接口
- let tableList1 = {
- tId: this.tId,
- tableKey: table1tableKey, // 暂定
- dtTableName: this.tableName,
- primaryKey: this.formData.primaryKey,
- orderByColumn: this.formData.orderByColumn,
- sortOrder: this.formData.isAsc,
- sqlKey: uuidv4(),
- dtColumnName: columns1, //列字
- timeFormat: this.formData.timeFormate,
- searchFieldList: searchFieldList1, //搜索字段数组
- tableSql: this.getSQLStr(), // 暂定
- echoData: JSON.stringify(echoData),
- conditionDefaultValueMap: conditionDefault,
- };
- console.log(tableList1.tableKey, this.formData.btnGroupList);
- // 基础信息绑定按钮
- tableList1.dragTableBtnRelevanceList = this.getBtnMapList(
- tableList1.tableKey,
- this.formData.btnGroupList
- );
- // 关联子表回显
- let subTableData = this.$refs.subList.getTableInfo();
- this.subFiledList = subTableData.fieldInfo;
- let echoData2 = {
- tableName: subTableData.tableName,
- tableFieldData: subTableData.fieldInfo,
- // tableName: this.subTableName,
- // tableFieldData: this.subFiledList,
- formData: this.subformData,
- };
- // 处理关联子表依赖表
- this.dragTableList.forEach((item) => {
- if (item.dtName == this.subformData.relytableName) {
- subrelayName = item.dtTableName;
- }
- });
- let tempSubData = this.getRelaObjAndSearchList(
- subTableData.fieldInfo
- );
- let subCondition = tempSubData.relaObj;
- // 判断表格依赖方式
- // if (this.subformData.relyOption === "0") {
- // subCondition[this.subformData.relyFile] =
- // this.subformData.relayValue;
- // } else {
- // subCondition[this.subformData.relyFile] =
- // "#{" + subrelayName + "." + this.subformData.relaykey;
- // }
- // 关联子表类信息
- let columns2 = [],
- searchFieldList2 = tempSubData.searchList;
- this.getCol(this.subFiledList, columns2);
- let table2tableKey = uuidv4();
- // searchFieldList2.push(this.subformData.relyFile);
- // 关联子表请求数据
- let tableList2 = {
- tId: this.tId,
- tableKey: table2tableKey, // 暂定
- dtTableName: subTableData.tableName,
- primaryKey: this.subformData.primaryKey,
- orderByColumn: this.subformData.orderByColumn,
- sortOrder: this.subformData.isAsc,
- statisticTitle: this.subformData.title,
- sqlKey: uuidv4(),
- dtColumnName: columns2, //列字
- timeFormat: this.subformData.timeFormate,
- searchFieldList: searchFieldList2, //搜索字段数组
- tableSql: this.getSQLStr2(), // 暂定
- echoData: JSON.stringify(echoData2),
- conditionDefaultValueMap: subCondition,
- };
- console.log(2, tableList2.tableKey, this.subformData.btnGroupList);
- tableList2.dragTableBtnRelevanceList = this.getBtnMapList(
- tableList2.tableKey,
- this.subformData.btnGroupList
- );
- // 统计信息
- let countData = this.$refs.StatusTable?.getTableInfo();
- let countEchoData = {
- formData: this.countData,
- // tableFieldData: this.countFieldList,
- tableFieldData: countData.fieldInfo,
- tableName: countData.tableName,
- };
- let conutrelayName = "";
- // 处理关联子表依赖表
- this.dragTableList.forEach((item) => {
- if (item.dtName == this.countData.relytableName) {
- conutrelayName = item.dtTableName;
- }
- });
- let tempconut = this.getRelaObjAndSearchList(countData.fieldInfo);
- let countFieldLists = tempconut.searchList;
- // countFieldLists.push(this.countData.relyFile);
- let countTableKey = uuidv4();
- let conutCondition = tempconut.relaObj;
- let countColumnName = [];
- this.getCol(countData.fieldInfo, countColumnName);
- // 数据统计表格参数
- let countTableList = {
- tId: this.tId,
- tableKey: countTableKey, // 暂定
- dtTableName: countData.tableName,
- primaryKey: this.countData.primaryKey,
- orderByColumn: "",
- sortOrder: "",
- sqlKey: uuidv4(),
- dtColumnName: countColumnName, //列字
- timeFormat: "",
- searchFieldList: countFieldLists, //搜索字段数组
- // tableSql: this.countGetSQLStr(
- // countData.fieldInfo,
- // countData.tableName
- // ),
- tableSql: this.getSQLStr3(countData.fieldInfo, countData.tableName),
- echoData: JSON.stringify(countEchoData),
- conditionDefaultValueMap: conutCondition,
- };
- // return;
- console.log(3, countTableList.tableKey, this.countData.btnGroupList);
- countTableList.dragTableBtnRelevanceList = this.getBtnMapList(
- countTableList.tableKey,
- this.countData.btnGroupList
- );
- let stateSqlkey = uuidv4();
- let stateList = [
- {
- sqlKey: stateSqlkey,
- statisticTitle: this.countData.title,
- statisticField: this.countData.relaykey,
- statisticType: "等值",
- },
- ];
- let stateSql;
- let stateSqlList = [];
- let stateName = "";
- // console.log(this.dragTableList)
- // console.log(this.dragTableList);
- // 统计状态信息
- let search = [];
- let conditionDefaultValueMap = {};
- stateSqlList.push({
- sqlKey: stateSqlkey,
- tableSql: this.getCountSqlStr(
- this.countGetSQLStr(countData.fieldInfo, countData.tableName),
- countData.tableName
- ),
- });
- this.dragTableList.forEach(async (item) => {
- console.log(item.dtName, this.countData.relytableName);
- if (item.dtName == this.countData.relytableName) {
- // console.log(123);
- const info = await dragTableInfo({
- queryMap: { tableKey: item.tableKey },
- });
- // console.log('info', info);
- let infoSql = info.data.resultMap.querySql.tableSql;
- let state = this.getTableSql(infoSql, this.countData.relaykey);
- // stateSql = state + ' where ' + item.dtTableName + '.' + item.primaryKey + ' = #{' + item.dtTableName + '.' + item.primaryKey
- stateSql = state;
- search.push(item.dtTableName + "." + item.primaryKey);
- // console.log('sql', stateSql);
- conditionDefaultValueMap[
- item.dtTableName + "." + item.primaryKey
- ] = " #{" + item.dtTableName + "." + item.primaryKey;
- stateSqlList = [
- {
- sqlKey: stateSqlkey,
- tableSql: stateSql,
- },
- ];
- stateName = item.dtTableName;
- }
- });
- // return;
- // 统计信息
- this.dragTableStatisticList.forEach((item) => {
- if (this.tId == "") {
- item.tableKey = tableList2.tableKey;
- this.staticSqlKey = uuidv4();
- item.sqlKey = this.staticSqlKey;
- }
- if (item.sqlKey) {
- this.staticSqlKey = item.sqlKey;
- } else {
- this.staticSqlKey = uuidv4();
- item.sqlKey = this.staticSqlKey;
- }
- let key =
- item.statisticType +
- "(" +
- item.statisticField +
- ")" +
- " as result";
- this.tableSqlList.push({
- tableSql: this.getStaticSQL(key),
- sqlKey: this.staticSqlKey,
- });
- // this.searchFieldList = searchFieldList;
- });
- let res;
- let res1;
- // 判断修改还是新增
- if (this.tId) {
- // console.log('修改');
- // console.log(this.editData);
- // 基础信息
- tableList1.sqlKey = this.editData.sqlKey;
- tableList1.tableKey = this.editData.tableKey;
- tableList1.tId = this.lists[0].tId;
- console.log(tableList1.dragTableBtnRelevanceList);
- let btnTempList1 = tableList1.dragTableBtnRelevanceList.map(
- (item) => item.btnKey
- );
- tableList1.dragTableBtnRelevanceList = this.getBtnMapList(
- this.editData.tableKey,
- btnTempList1
- );
- // 关联子表
- tableList2.tableKey = this.subEchoData.tableKey;
- tableList2.sqlKey = this.subEchoData.sqlKey;
- tableList2.tId = this.lists[1].tId;
- let btnTempList2 = tableList2.dragTableBtnRelevanceList.map(
- (item) => item.btnKey
- );
- tableList2.dragTableBtnRelevanceList = this.getBtnMapList(
- this.subEchoData.tableKey,
- btnTempList2
- );
- // 数据统计
- console.log(this.countEchoData);
- countTableList.tableKey = this.countEchoData.tableKey;
- countTableList.sqlKey = this.countEchoData.sqlKey;
- let btnTempList3 = countTableList.dragTableBtnRelevanceList.map(
- (item) => item.btnKey
- );
- countTableList.dragTableBtnRelevanceList = this.getBtnMapList(
- this.countEchoData.tableKey,
- btnTempList3
- );
- countTableList.tId = this.lists[2].tId;
- let data = {
- id: this.tId,
- groupType: 1,
- groupKey: this.groupKey,
- groupName: this.formData.groupName,
- groupDescription: this.formData.groupDescription,
- groupTableInfo: [],
- dragTables: [],
- };
- data.groupTableInfo.push(
- {
- tableKey: tableList1.tableKey,
- sort: 0,
- },
- {
- tableKey: tableList2.tableKey,
- sort: 1,
- },
- {
- tableKey: countTableList.tableKey,
- sort: 2,
- }
- );
- data.groupTableInfo = JSON.stringify(data.groupTableInfo);
- data.dragTables.push(tableList1, tableList2, countTableList);
- res = await undataDialogGroup(data);
- this.dragTableStatisticList.forEach((item) => {
- item.tableKey = this.subEchoData.tableKey;
- });
- console.log("回显", this.statusCount);
- // stateList.forEach((item) => {
- // item.id = this.statusCount.id;
- // item.sqlKey = this.statusCount.sqlKey;
- // item.tableKey = this.statusCount.tableKey;
- // });
- // stateSqlList.forEach((item) => {
- // item.sqlKey = this.statusCount.sqlKey;
- // });
- // 修改统计数据
- await updateGroupTableStatistic({
- tableKey: this.subEchoData.tableKey,
- dragTableStatisticList: this.dragTableStatisticList,
- tableSqlList: this.tableSqlList,
- searchFieldList: searchFieldList2,
- conditionDefaultValueMap: subCondition,
- dtTableName: subTableData.tableName,
- });
- // 修改统计状态
- // await updateGroupTableStatistic({
- // tableKey: this.countEchoData.tableKey,
- // dragTableStatisticList: stateList,
- // tableSqlList: stateSqlList,
- // searchFieldList: countFieldLists,
- // dtTableName: countData.tableName,
- // conditionDefaultValueMap: conutCondition,
- // });
- } else {
- // 统计信息
- let graguuid = uuidv4();
- let statusuuid = uuidv4();
- let uuid = uuidv4();
- this.dragTableStatisticList.forEach((item) => {
- item.tableKey = tableList2.tableKey;
- });
- stateList.forEach((item) => {
- item.tableKey = countTableList.tableKey;
- });
- // 新增操作
- let groupKeyObj = { groupKey: uuid };
- let data = {
- groupType: 1,
- groupKey: groupKeyObj.groupKey,
- groupName: this.formData.groupName,
- groupDescription: this.formData.groupDescription,
- groupTableInfo: [],
- dragTables: [],
- templateType: "composeForm",
- };
- data.groupTableInfo.push(
- {
- tableKey: tableList1.tableKey,
- sort: 0,
- },
- {
- tableKey: tableList2.tableKey,
- sort: 1,
- },
- {
- tableKey: countTableList.tableKey,
- sort: 2,
- }
- );
- data.groupTableInfo = JSON.stringify(data.groupTableInfo);
- data.dragTables.push(tableList1, tableList2, countTableList);
- res = await addDialogGroup(data);
- // 统计数据
- await addGroupTableStatistic({
- tableKey: tableList2.tableKey,
- dragTableStatisticList: this.dragTableStatisticList,
- tableSqlList: this.tableSqlList,
- searchFieldList: searchFieldList2,
- dtTableName: subTableData.tableName,
- conditionDefaultValueMap: subCondition,
- });
- // console.log(stateList);
- // 统计状态
- // await addGroupTableStatistic({
- // tableKey: countTableList.tableKey,
- // dragTableStatisticList: stateList,
- // tableSqlList: stateSqlList,
- // searchFieldList: countFieldLists,
- // dtTableName: countData.tableName,
- // conditionDefaultValueMap: conutCondition,
- // });
- }
- if (this.tId) {
- if (res.code == 200) {
- this.$message.success("修改成功");
- } else {
- this.$message.warning("修改失败");
- }
- this.$tab.closePage();
- this.$router.push({
- path: "/system/fromModel/index/tableDialog",
- });
- } else {
- if (res.code == 200) {
- this.$message.success("创建成功");
- } else {
- this.$message.warning("创建失败");
- }
- this.isShowPreview = false;
- }
- } else {
- this.$message.warning("请完善表单");
- return false;
- }
- });
- },
- // 获取数据统计的sql
- getCountSqlStr(sql, tableName) {
- let tempList = sql.split("FROM");
- return (
- "SELECT " +
- tableName +
- "." +
- this.countData.countFile +
- " as result " +
- " FROM" +
- tempList[1]
- );
- },
- // 按钮
- getBtnMapList(tableKey, btnGroupList) {
- let res = btnGroupList.map((item) => {
- return {
- tableKey,
- btnKey: item,
- };
- });
- return res;
- },
- // 解决回显input不能输入问题
- iptChange() {
- this.$forceUpdate(); //强制刷新
- },
- // 处理统计sql语句
- getTableSql(sql, key, tableName) {
- // console.log(key);
- let Sql;
- let arrSql = sql.split("FROM");
- // console.log(arrSql);
- let fromFields = arrSql[1].split("AS");
- let tableArr = [];
- fromFields.forEach((item, index) => {
- if (index !== 0) {
- let arr = item.trim().split(" ");
- tableArr.push(arr[0]);
- }
- });
- tableArr.forEach((item, index) => {
- if (key.includes(item)) {
- // let keyfileld = keyarr[keyarr]
- let str = key.substring(item.length + 1);
- // Sql = 'SELECT ' + item +'.' + str + 'as result ' + ' FROM' + arrSql[1]
- console.log("表名", this.countData.countName);
- console.log("zidaun", this.countData.countFile);
- Sql =
- "SELECT " +
- tableName +
- "." +
- this.countData.countFile +
- " as result " +
- " FROM" +
- arrSql[1];
- }
- });
- console.log("sql", Sql);
- return Sql;
- },
- // 修改表格回显数据
- async initTableData(tId) {
- let res = await getTable({ id: tId });
- // console.log(res);
- if (res.code == 200) {
- this.groupKey = res.data.groupKey;
- this.lists = res.data.dragTables;
- this.formData.groupName = res.data.groupName;
- this.formData.groupDescription = res.data.groupDescription;
- let groupInfo = JSON.parse(res.data.groupTableInfo);
- this.lists.forEach(async (item) => {
- if (item.tableKey == groupInfo[0].tableKey) {
- this.editData = item;
- // console.log('123',this.editData);
- let echoData = JSON.parse(item.echoData);
- this.tableName = echoData.tableName;
- this.tableFieldList = echoData.tableFieldData;
- let {
- timeFormate,
- orderByColumn,
- isAsc,
- primaryKey,
- btnGroupList,
- relyFile,
- relytableName,
- relaykey,
- relyOption,
- } = echoData.formData;
- Object.assign(this.formData, {
- timeFormate,
- orderByColumn,
- isAsc,
- primaryKey,
- btnGroupList,
- relyFile,
- relytableName,
- relaykey,
- relyOption,
- });
- } else if (item.tableKey == groupInfo[1].tableKey) {
- let res = await getTableInfo(item.tId);
- // console.log('tji', res);
- this.subEchoData = item;
- this.echoData = JSON.parse(item.echoData);
- console.log(this.echoData);
- this.subTableName = this.echoData.tableName;
- this.subFiledList = this.echoData.tableFieldData;
- this.dragTableStatisticList = res.data.dragTableStatisticList;
- } else if (item.tableKey == groupInfo[2].tableKey) {
- let res = await getTableInfo(item.tId);
- console.log("统计", res.data);
- this.statusCount = res.data.dragTableStatisticList[0];
- console.log(this.statusCount);
- // console.log('zhuangt', res);
- let echoData = JSON.parse(item.echoData);
- this.countFieldList = echoData.tableFieldData;
- this.countData.title = this.statusCount?.statisticTitle;
- // this.countData.relaykey = this.statusCount.statisticField
- this.countEchoData = item;
- console.log(JSON.parse(this.countEchoData.echoData));
- // this.dragTableStatisticList = []
- let {
- relaykey,
- btnGroupList,
- countName,
- primaryKey,
- relyFile,
- countFile,
- relytableName,
- } = echoData.formData;
- Object.assign(this.countData, {
- relaykey,
- btnGroupList,
- countName,
- primaryKey,
- relyFile,
- countFile,
- relytableName,
- });
- }
- await this.getdragTable();
- });
- // this.getrelyList();
- // this.getCountrelyList();
- } else {
- this.$message.error("数据回显失败");
- }
- },
- // tab切换
- tabhandleClick(tab, event) {
- this.tabIndex = tab.index;
- console.log(this.tabIndex);
- if (this.tabIndex == "2") {
- // this.getCountrelyList();
- }
- this.menudata = this.activeName != "menuedit" ? true : false;
- },
- // 添加数据字段对话框
- async addDataDialog() {
- this.staictitle = "添加统计数据字段";
- this.isShowAddData = true;
- this.dataType = await this.getDicts("table_statistic_type");
- this.dataType = this.dataType.data;
- // console.log(this.dataType)
- },
- async updataDialog() {
- // console.log(this.dataType)
- },
- // 修改数据字段
- upadtaData() {
- this.dragTableStatisticList.forEach((item, index) => {
- // console.log(this.dataCountFormData);
- if (item.id !== undefined && item.id == this.dataCountFormData.id) {
- this.dragTableStatisticList[index] = this.dataCountFormData;
- } else if (item.xid == this.dataCountFormData.xid) {
- this.dragTableStatisticList[index] = this.dataCountFormData;
- }
- });
- this.isShowAddData = false;
- // console.log(this.dragTableStatisticList)
- this.dataCountFormData = {};
- },
- // 添加数据字段
- addData() {
- // console.log(this.dataCountFormData);
- this.dataCountFormData.xid = Date.now();
- this.dataCountFormData.tableKey = this.tableKey;
- this.dragTableStatisticList.push(this.dataCountFormData);
- this.isShowAddData = false;
- this.dataCountFormData = {};
- },
- // 关闭添加数据字段
- closeAddDialog() {
- this.isShowAddData = false;
- this.dataCountFormData = {};
- },
- // 修改统计信息
- async handleUpdateStat(row) {
- // console.log(row);
- this.dataCountFormData = row;
- this.dataCountFormData.xid = Date.now();
- this.staictitle = "修改统计数据字段";
- this.dataType = await this.getDicts("table_statistic_type");
- this.dataType = this.dataType.data;
- this.isShowAddData = true;
- // console.log(this.dataCountFormData)
- // console.log(this.dragTableStatisticList);
- },
- // 删除统计信息
- handleDeleteStat(row) {
- this.dragTableStatisticList.forEach((item, index) => {
- if (item.id == row.id) {
- this.dragTableStatisticList.splice(index, 1);
- }
- });
- },
- // 获取当前表描述
- getTableCommont(tableName, tableList) {
- return tableList.find((item) => item.tableName == tableName).tableComment;
- },
- // 获取按钮组数据
- async getBtnList() {
- let res = await listBtn({ isEnablePaging: false, btnParentId: 0 });
- this.btnGroupOptions = res.rows.filter((item) => !item.whetherBind);
- },
- },
- created() {},
- async mounted() {
- await this.getAllTable();
- this.getdragTable();
- this.initDragTable();
- this.getBtnList();
- this.getDictType();
- // await this.getMenuList();
- if (this.$route.query.tId) {
- this.tId = this.$route.query.tId;
- this.initTableData(this.tId);
- }
- },
- };
- </script>
- <style scoped lang="scss">
- .ipt {
- height: 36px;
- line-height: 36px;
- font-size: 14px;
- width: 100%;
- outline: none;
- text-align: center;
- background-color: #fff;
- border: 1px solid #dcdfe6;
- color: #606266;
- display: inline-block;
- border-radius: 4px;
- }
- .isNullDesc {
- border-color: #ff4949 !important;
- }
- .ipt:focus {
- border-color: #1890ff;
- }
- ::v-deep .right_card {
- min-height: 500px !important;
- }
- ::v-deep .vue-treeselect--has-value .vue-treeselect__input {
- vertical-align: middle !important;
- }
- .menudata {
- width: 30% !important;
- }
- .edit {
- width: 70% !important;
- }
- .mb10 {
- margin-top: 10px;
- }
- .cardBox {
- display: flex;
- align-content: space-between;
- flex-wrap: wrap;
- align-content: flex-start;
- }
- .card {
- /* width:15%; */
- height: 150px;
- flex-basis: 15%;
- margin-bottom: 10px;
- margin-right: 15px;
- min-width: 180px;
- .title {
- /* width:20%; */
- font-size: 18px;
- margin-bottom: 5px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .description {
- width: 70%;
- font-size: 13px;
- color: #9699a2;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 3;
- word-break: break-all;
- float: left;
- }
- .type {
- float: right;
- margin-top: 40px;
- .statisticType {
- font-size: 18px;
- }
- }
- .count {
- font-size: 25px;
- }
- }
- .mb8 {
- ::v-deep .el-col-18 {
- width: 30% !important;
- min-width: 220px !important;
- }
- ::v-deep .previewbtn {
- min-width: 190px !important;
- }
- }
- .addcount {
- margin-bottom: 5px;
- }
- </style>
|