index.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. <template>
  2. <div :style="pageTableHeight" class="TablePage">
  3. <PublicPageHeader class="TablePage_header" :page-title="dataTitle ? dataTitle : pageTitle">
  4. <template slot="d_foot">
  5. <SimpleQuery v-if="simpleQueryFlag" :selectOptions="advancedQueryValue" :simple-query-item="simpleQueryItem" @queryValue="queryValue" />
  6. </template>
  7. <template v-if="pageAuthBtnInstall">
  8. <el-button size="small" type="primary" @click="onInstall">初始化</el-button>
  9. </template>
  10. <AuthButton :auth="pageAuthBtnAdd" />
  11. <AuthButton :auth="pageAuthBtnQuery" />
  12. <AuthButton :auth="pageAuthBtnExport" />
  13. </PublicPageHeader>
  14. <div :style="pageTableContentHeight" class="TablePage_content flex-wrap">
  15. <template v-if="!dataFlag">
  16. <div v-if="treeData.length" class="TablePage_content_left">
  17. <PublicPageTree ref="pageTree" :tree-data="treeData" :dep-math="depMath" :tree-map="treeNodeMap" @treeNodeClick="treeNodeClick" />
  18. </div>
  19. </template>
  20. <div :class="dataFlag ? 'tableAuto' : treeData.length ? 'tableSacle' : 'tableAuto'" class="TablePage_content_right">
  21. <div class="check_header">
  22. <el-scrollbar style="height: 100%" :horizontal="false">
  23. <el-form ref="ruleFormw" :model="tableForm" :label-width="labelWidth">
  24. <el-row :gutter="2">
  25. <el-col v-for="(item, index) in formItemArr" :key=" index" :span="4" v-show="isShow(item.isdisplay)">
  26. <el-form-item :rules="fromDataReq(item)" :prop="item.pagecode" :label="item.pagename">
  27. <span slot="label">
  28. {{ item.pagename }}
  29. <el-tooltip :content="item.pagedescribe" placement="top">
  30. <i class="el-icon-question"></i>
  31. </el-tooltip>
  32. </span>
  33. <template v-if="fromDataType(item.datatype) == 'SELECT' || fromDataType(item.datatype) == 'SELECTS'">
  34. <el-select class="input-shadow" size="small" :multiple="fromDataType(item.datatype) == 'SELECTS'?true:false" filterable default-first-option style="width: 100%" v-model="tableForm[item.pagecode]" @change="changeSelect(item.pagecode, item)" placeholder="请选择" clearable @clear="tableForm[item.pagecode] = ''">
  35. <el-option v-for="itemParams in tableOptions[item.pagecode]" :key="itemParams[item['dropdownlistid']]" :label="itemParams[item['dropdownlistlabel']]" :value="itemParams[item['dropdownlistid']]">
  36. </el-option>
  37. </el-select>
  38. </template>
  39. <template v-else-if="fromDataType(item.datatype) == 'DROP'">
  40. <el-select class="input-shadow" size="small" multiple filterable default-first-option style="width: 100%" v-model="tableForm[item.pagecode]" @change="changeSelect(item.pagecode, item)" placeholder="请选择" clearable @clear="tableForm[item.pagecode] = ''">
  41. <el-option v-for="itemParams in tableOptions[item.pagecode]" :key="itemParams['dropdownlistid']" :label="itemParams['dropdownlistlabel']" :value="itemParams['dropdownlistid']">
  42. </el-option>
  43. </el-select>
  44. </template>
  45. <template v-else-if="fromDataType(item.datatype) == 'ICON' || fromDataType(item.datatype) == 'icon'">
  46. <el-select size="small" clearable v-model="tableForm[item.pagecode]" placeholder="请选择图标">
  47. <el-option v-for="(item,index) in formIcons" :key="index" :label="item.name" :value="item.value">
  48. <i style="font-size: 18px;" :class="item.name"></i>
  49. </el-option>
  50. </el-select>
  51. </template>
  52. <template v-else-if="fromDataType(item.datatype) == 'TEXT' || fromDataType(item.datatype) == 'VARCHAR'">
  53. <el-input size="small" @change="inputChangeHandler(item.pagecode)" v-model="tableForm[item.pagecode]"></el-input>
  54. </template>
  55. <template v-else-if="fromDataType(item.datatype) == 'TEXTAREA'">
  56. <el-input type="textarea" @focus="setText(item.pagecode)" v-model="tableForm[item.pagecode]"></el-input>
  57. </template>
  58. <template v-else-if="fromDataType(item.datatype) == 'PASSWORD'">
  59. <el-input show-password v-model="tableForm[item.pagecode]"></el-input>
  60. </template>
  61. <template v-else-if="fromDataType(item.datatype) == 'UNPASSWORD'">
  62. <el-input show-password v-model="tableForm[item.pagecode]"></el-input>
  63. </template>
  64. <template v-else-if="fromDataType(item.datatype) == 'UPLOAD'">
  65. <upload-item :id="index" :base-img="tableForm[item.pagecode]" ref="upload" />
  66. </template>
  67. <template v-else-if="fromDataType(item.datatype) == 'SWITCH'">
  68. <el-switch v-model="tableForm[item.pagecode]"></el-switch>
  69. </template>
  70. <template v-else-if="fromDataType(item.datatype) == 'CASCADER'">
  71. <el-cascader v-model="tableForm[item.pagecode]" :options="tableOptions[item.pagecode]"></el-cascader>
  72. </template>
  73. <template v-else-if="fromDataType(item.datatype) == 'CHECKBOX'">
  74. <el-checkbox-group v-model="tableForm[item.pagecode]">
  75. <el-checkbox v-for="itemParams in tableOptions[item.pagecode]" :key="itemParams[item['dropdownlistid']]" :label="itemParams[item['dropdownlistid']]" name="type">{{ [item['dropdownlistlabel']] }}</el-checkbox>
  76. </el-checkbox-group>
  77. </template>
  78. <template v-else-if="fromDataType(item.datatype) == 'RADIO'">
  79. <el-radio-group v-model="tableForm[item.pagecode]">
  80. <el-radio v-for="itemParams in tableOptions[item.pagecode]" :key="itemParams[item['dropdownlistid']]" :label="itemParams[item['dropdownlistid']]" name="type">{{ [item['dropdownlistlabel']] }}</el-radio>
  81. </el-radio-group>
  82. </template>
  83. <template v-else-if="fromDataType(item.datatype) == 'TIME'">
  84. <el-time-picker size="small" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}" v-model="tableForm[item.pagecode]" placeholder="选择任意时间段" @change="inputChangeHandler(item.pagecode)">
  85. </el-time-picker>
  86. </template>
  87. <template v-else-if="fromDataType(item.datatype) == 'DATE'">
  88. <el-date-picker size="small" class="datetimes" value-format="yyyy-MM-dd" v-model="tableForm[item.pagecode]" type="date" placeholder="选择日期" @change="inputChangeHandler(item.pagecode)">
  89. </el-date-picker>
  90. </template>
  91. <template v-else-if="fromDataType(item.datatype) == 'DATETIME'">
  92. <el-date-picker size="small" class="datetimes" value-format="yyyy-MM-dd HH:mm:ss" v-model="tableForm[item.pagecode]" type="datetime" placeholder="选择日期时间" @change="inputChangeHandler(item.pagecode)">
  93. </el-date-picker>
  94. </template>
  95. <template v-else-if="fromDataType(item.datatype) == 'INT' || fromDataType(item.datatype) == 'tinyint' || fromDataType(item.datatype) == 'NUMBER'">
  96. <el-input size="small" v-model.number="tableForm[item.pagecode]" onkeyup="value=value.replace(/[^1-9]/g,'')" @change="inputChangeHandler(item.pagecode)"></el-input>
  97. </template>
  98. <template v-else>
  99. <el-input size="small" v-model="tableForm[item.pagecode]" @change="inputChangeHandler(item.pagecode)"></el-input>
  100. </template>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="4" style="height: 41px;display: flex;align-items: center;">
  104. <el-checkbox v-model="checkedtre" label="显示树" @change="handleCheckedCitiesChange"></el-checkbox>
  105. </el-col>
  106. <el-col :span="4" style="height: 41px;display: flex;align-items: center;">
  107. <el-checkbox v-model="checkedtable" label="显示表格" @change="handleCheckedCitiesChanges"></el-checkbox>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. </el-scrollbar>
  112. </div>
  113. <div class="TablePage_child flex-wrap">
  114. <template v-if="leftFlag">
  115. <div v-if="treeData.length" class="TablePage_content_left">
  116. <PublicPageTree ref="pageTree" :tree-data="treeData" :dep-math="depMath" :tree-map="treeNodeMap" @treeNodeClick="treeNodeClick" />
  117. </div>
  118. </template>
  119. <PublicPageTable v-if="tableFlag" ref="table" :loading="loading" :selected="selected" :table-cols="tableCols" :table-btns="authBtns" :data="tableData" :header-cell-class-name="headerCellClass" :row-class-name="rowClass" :cell-class-name="cellClass" :formatter="tableFormatter" :selectedDatas="selectedDatas" :selectedCheck="selectedDataCheck" :show-summary="summaryFlag" @mounted="tableMountedHandler" @load="load" @cell-click="cellClickHandler" @handleDetail="handleDetail" @handleEdit="handleEdit" @handleOther="handleOther" @handleRemove="handleRemove" @handleSelectionChange="handleSelectionChange" />
  120. </div>
  121. </div>
  122. </div>
  123. <div class="TablePage_dialog">
  124. <!--新增/编辑-->
  125. <PublicPageDialog :dialog-body="authId ? true : false " :dialog-loading="dialogLoading" :dialog-title="tableTitle" dialogSize="630px" :form-auth="formAuth" :dialog-drawer="flag" @handleClose="submitClickClose('ruleForm')" @handleSubmit="submitClickHandler">
  126. <PublicPageForm ref="ruleForm" :label-width="labelWidth" :form-pass="tableData" :form-type="tableType" :form-item="formItem" :form-data="tableForm" />
  127. </PublicPageDialog>
  128. <!--高级查询-->
  129. <PublicPageDialog dialog-title="高级查询" dialogSize="600px" :dialog-drawer="advancedDrawer" @handleClose="advancedClose" @handleSubmit="advancedTable('advancedDialogForm')">
  130. <AdvancedQuery ref="advancedDialogForm" :selectOptions="simpleQueryValue" @getAdvancedQueryData="getAdvancedQueryData" />
  131. <template slot="d_foot">
  132. <el-button size="small" @click="restCollect('advancedDialogForm')" type="warning">重置</el-button>
  133. <el-button size="small" @click="queryCollect('advancedDialogForm')" type="primary">收藏</el-button>
  134. </template>
  135. </PublicPageDialog>
  136. <!--初始化-->
  137. <PublicPageDialog dialog-title="初始化" dialogSize="600px" :dialog-drawer="installFlag" @handleClose="installClose" @handleSubmit="installTable('installForm')">
  138. <AuthInstall ref="installForm" />
  139. </PublicPageDialog>
  140. </div>
  141. </div>
  142. </template>
  143. <script>
  144. import PublicPageHeader from '@/components/PublicPageHeader'
  145. import PublicPageTable from '@/components/SimpleTable'
  146. import PublicPageTree from '@/components/publicPageTree'
  147. import PublicPageDialog from '@/components/PublicPageDialog'
  148. import PublicPageForm from '@/components/publicPageForm'
  149. import AdvancedQuery from '@/components/AdvancedQuery'
  150. import AuthButton from '@/components/AuthButton'
  151. import AuthInstall from '@/components/AuthInstall'
  152. import SimpleQuery from '@/components/SimpleQuery'
  153. import allIcons from '@/utils/icons'
  154. import { mapGetters } from 'vuex'
  155. import { Query, newData, modifyData, moveData, start, stop, startAll, stopAll } from "@/api/webApi"
  156. import { formatChange, listToTree } from '@/utils/validate'
  157. import { exportToExcel } from '@/utils/table'
  158. export default {
  159. name: 'TablePage',
  160. components: { PublicPageHeader, PublicPageTable, PublicPageDialog, PublicPageTree, PublicPageForm, AdvancedQuery, AuthButton, SimpleQuery, AuthInstall },
  161. props: {
  162. dataTitle: {
  163. type: String,
  164. default: ''
  165. },
  166. dataFlag: {
  167. type: Boolean,
  168. default: false
  169. },
  170. msgContent: {
  171. type: Object,
  172. default: () => new Object()
  173. },
  174. authId: {
  175. type: Number,
  176. default: 0
  177. },
  178. authQuery: {
  179. type: Object,
  180. default: () => new Object()
  181. },
  182. },
  183. data () {
  184. return {
  185. page: 0, //当前table页面
  186. noMore: false, //当前table是否加载到最后开关
  187. loading: false, //页面加载
  188. dialogLoading: false, //新增/编辑确认按钮禁用
  189. advancedDrawer: false, //高级查询弹框开关
  190. defaultfilter: { 1: 1 }, //默认查询参数
  191. pageQuery: {},
  192. installFlag: false,
  193. dialogFlag: false,
  194. dialogName: '', //弹框名称
  195. pageTitle: '', //页面名称
  196. treeData: [], //tree数据
  197. treeParameters: {}, //tree传递参数
  198. treeNodeMap: {}, //tree传递map
  199. tableCols: [], //表头数据
  200. tableData: [], //表格数据
  201. tableBtns: [], //表格按钮权限
  202. authBtns: [], //表格里面的操作按钮
  203. tableBtnForms: [], //表格按钮下的form表单权限
  204. dataContent: {}, //表格查询数据
  205. pageServiceId: null, //表格serviceid
  206. formItem: [], //弹框表单渲染数据
  207. flag: false, //弹框表单开关
  208. formAuth: true, //弹框表单按钮开关
  209. tableType: "add", //弹框表单弹框类型
  210. tableTitle: "新增", //弹框表单标题
  211. tableForm: {}, //弹框表单数据
  212. rmFlag: false, //删除弹框开关
  213. rmTitle: '', //删除弹框标题
  214. tableObj: {}, //删除数据
  215. tableOptions: {}, //表单数据下拉
  216. labelWidth: '120px', //表单文字距离
  217. fromDataReqCatch: [], //表单规则缓存
  218. tableKey: null,//表格主键
  219. depMath: 0,
  220. selected: 0, //是否勾选
  221. selectedDatas: [], //回显勾选的数据
  222. selectedDatasCath: [],//回显数据缓存
  223. selectedDataAlls: [], //勾选数据
  224. selectedDataCheck: {}, //勾选树-选中
  225. triggerserviceid: null, //勾选后查询的serviceid
  226. summaryFlag: false, //是否显示合计行
  227. simpleQueryFlag: false, //是否开启了简易查询
  228. simpleQueryItem: [], //简易查询表单数据项
  229. simpleQueryValue: [], //简易查询缓存值
  230. advancedQueryValue: [], //高级查询缓存值
  231. formItemArr: [],
  232. pageSizeDatas: ['outairportpage', 'landairportpage', 'transairportpage'],
  233. pageInstall: 'creatManagementPage',
  234. formIcons: allIcons,
  235. checkedtre: true,
  236. checkedtable: true,
  237. leftFlag: true,
  238. tableFlag:true
  239. }
  240. },
  241. computed: {
  242. ...mapGetters(['authArrs']),
  243. pageTableHeight () {
  244. if (this.dataFlag) return 'height:100%'
  245. if (this.authId) return 'height:calc(100vh - 180px);padding:0'
  246. return ''
  247. },
  248. pageTableContentHeight () {
  249. if (this.dataFlag) return 'height:calc(100% - 60px)'
  250. if (this.authId) return 'height:calc(100% - 130px)'
  251. return ''
  252. },
  253. pageAuthBtnQuery () {
  254. return this.tableBtns.filter(item => item.servicetype == 0)[0]
  255. },
  256. pageAuthBtnDetail () {
  257. return this.tableBtns.filter(item => item.servicetype == 1)[0]
  258. },
  259. pageAuthBtnAdd () {
  260. return this.tableBtns.filter(item => item.servicetype == 2)[0]
  261. },
  262. pageAuthBtnEdit () {
  263. return this.tableBtns.filter(item => item.servicetype == 3)[0]
  264. },
  265. pageAuthBtnDel () {
  266. return this.tableBtns.filter(item => item.servicetype == 4)[0]
  267. },
  268. pageAuthBtnOther () {
  269. return this.tableBtns.filter(item => item.servicetype == 5)[0]
  270. },
  271. pageAuthBtnExport () {
  272. return this.tableBtns.filter(item => item.servicetype == 6)[0]
  273. },
  274. pageAuthBtnInstall () {
  275. return this.pageInstall == this.$route.path.replace('/', '')
  276. },
  277. //设置新增修改表单类型
  278. fromDataType () {
  279. return function (type) {
  280. if (type) {
  281. return type.toLocaleUpperCase().replace(/\([^\)]*\)/g, "");
  282. }
  283. }
  284. },
  285. //设置新增修改表单必填类型
  286. fromDataReq () {
  287. return function (item) {
  288. const { dropdownlist, datatype, pagename, isrequired, formatrule } = item
  289. const itemType = datatype ? datatype.replace(/\([^\)]*\)/g, "") : datatype
  290. const itemReq = isrequired ? true : false
  291. const itemRule = formatrule ? true : false
  292. if (dropdownlist || dropdownlist == 0) return [{ required: itemReq, message: `${pagename}不能为空`, trigger: 'change' }]
  293. else if (itemType == 'date' || itemType == 'datetime') return [{ required: itemReq, type: 'date', message: `${pagename}不能为空`, trigger: 'change' }]
  294. else
  295. if (itemReq && itemRule) return [{ required: itemReq, message: `${pagename}不能为空`, trigger: 'blur' }, { pattern: new RegExp(formatrule), message: `请输入合法的${pagename}规则`, trigger: 'blur' }]
  296. return [{ required: itemReq, message: `${pagename}不能为空`, trigger: 'blur' }]
  297. }
  298. },
  299. },
  300. watch: {
  301. msgContent: {
  302. handler (row) {
  303. if (row && Object.keys(row).length) {
  304. const { passparameters } = row
  305. const filterItem = this.formatDefault(passparameters, row)
  306. if (!Object.keys(filterItem).length) return
  307. this.defaultfilter = filterItem
  308. this.queryTableData(true)
  309. }
  310. },
  311. deep: true,
  312. immediate: true
  313. },
  314. authQuery: {
  315. handler (row) {
  316. if (row && Object.keys(row).length) {
  317. this.defaultfilter = row
  318. this.queryTableData(true)
  319. }
  320. },
  321. deep: true,
  322. }
  323. },
  324. mounted () {
  325. this.authId ? this.pageInit(this.authId) : this.pageInit()
  326. this.queryTableData(true)
  327. },
  328. methods: {
  329. //页面初始化
  330. pageInit (authId) {
  331. //获取页面查询参数
  332. const { query } = this.$route
  333. authId ? this.pageQuery = this.authQuery : this.pageQuery = query
  334. //获取页面配置
  335. const { pagecode, qid, auth_id } = this.$route.meta
  336. //获取页面权限类型组件  pagetype 1模块  2页面  3按钮 4表格 5树形  6弹窗
  337. const pageAuths = this.authArrs
  338. if (!pageAuths.length) return
  339. let pageAuthArrs = null
  340. authId ? pageAuthArrs = pageAuths.filter(item => item['superiorid'] == authId) : pageAuthArrs = pageAuths.filter(item => item['superiorid'] == auth_id)
  341. //获取当前页面权限类型
  342. if (!pageAuthArrs.length) return
  343. //获取tree权限
  344. const pageAuthtrees = pageAuthArrs.filter(item => item.pagetype == 'tree')
  345. if (pageAuthtrees?.length) this.getPageTreeSetting(pageAuthtrees)
  346. //获取table权限
  347. const pageAuthtables = pageAuthArrs.filter(item => item.pagetype == 'table')
  348. if (pageAuthtables?.length) this.getPageTableSetting(pageAuths, pageAuthtables)
  349. //获取按钮权限
  350. const pageAuthbtns = pageAuthArrs.filter(item => item.pagetype == 'button')
  351. if (pageAuthbtns?.length) this.getPageBtnSetting(pageAuthbtns)
  352. const pageAuthFforms = pageAuthArrs.filter(item => item.pagetype == 'form')
  353. //获取form表单弹框权限
  354. if (pageAuthFforms?.length) this.getPageBtnFormSetting(pageAuths, pageAuthFforms)
  355. },
  356. //根据页面tree设置数据
  357. getPageTreeSetting (pageAuthtrees) {
  358. const { defaultfilter, dropdownlistid, dropdownlistlabel } = pageAuthtrees[0]
  359. this.treeNodeMap = { nodeKey: dropdownlistid, nodeValue: dropdownlistlabel }
  360. this.treeParameters = defaultfilter
  361. this.treeData = pageAuthtrees
  362. },
  363. //根据页面table设置数据
  364. getPageTableSetting (pageAuths, pageAuthtables) {
  365. const authTableObj = pageAuthtables[0]
  366. //获取当前页面table的配置
  367. const { pagename, pageconfigurationid, serviceid, pagecode, userpermissionsid, defaultfilter, selected, triggerserviceid } = authTableObj
  368. //获取当前页面table的按钮权限
  369. const currPageBtns = pageAuths.filter(item => item['superiorid'] == pageconfigurationid && item.pagetype == 'button')
  370. if (currPageBtns?.length) this.tableBtns.push(...currPageBtns)
  371. this.authBtns = pageAuths.filter(item => item.superiorid == pageconfigurationid && item.pagetype == 'button')
  372. this.pageServiceId = Object.keys(this.msgContent).length ? this.msgContent.serviceid : serviceid;
  373. this.pageTitle = pagename
  374. this.selected = selected
  375. this.triggerserviceid = triggerserviceid
  376. this.defaultfilter = Object.keys(this.pageQuery).length ? this.pageQuery : defaultfilter ? this.formatDefault(defaultfilter, authTableObj) : { 1: 1 }
  377. const tableColumnArrs = pageAuths.filter(item => item['superiorid'] == pageconfigurationid && item['pagetype'] == 'column')
  378. this.getColumnData(tableColumnArrs)
  379. },
  380. //根据页面按钮设置数据
  381. getPageBtnSetting (pageAuthbtns) {
  382. this.tableBtns.push(...pageAuthbtns)
  383. },
  384. //根据页面按钮设置表单form数据
  385. getPageBtnFormSetting (pageAuths, pageAuthForms) {
  386. const { pageconfigurationid } = [...pageAuthForms][0]
  387. const tableColumnArrs = pageAuths.filter(item => item['superiorid'] == pageconfigurationid && item['pagetype'] == 'column')
  388. const formItemCopy = tableColumnArrs.filter((item) => item.isdisplay != 0)
  389. this.formItem = _.orderBy(formItemCopy, ['displaynumber'], ['asc'])
  390. this.getSelectData(this.formItem)
  391. },
  392. //获取表头数据
  393. getColumnData (columnArrs = []) {
  394. const returnData = [...columnArrs]
  395. this.$store.dispatch('auth/changeAuthMsg', returnData)
  396. const tableColsCopy = _.cloneDeep(returnData).filter((item) => item.isdisplay != 0)
  397. const tableColsCopyOrder = _.orderBy(tableColsCopy, ['displaynumber'], ['asc'])
  398. // const formItemCopy = _.cloneDeep(returnData).filter((item) => item.isdisplay == 2 || item.isdisplay == 3);
  399. // this.formItem = _.orderBy(formItemCopy, ['displaynumber'], ['asc']);
  400. const msgCounts = tableColsCopyOrder.filter(item => item.enablecount)
  401. const simpleQueryItem = _.cloneDeep(returnData).filter((item) => item.easysearch && item.isfiltercolumn)
  402. if (msgCounts.length) {
  403. this.summaryFlag = true
  404. }
  405. this.tableCols = listToTree(tableColsCopyOrder, 'groupid', 'pagecode')
  406. const columncode = returnData.find(
  407. (item) => item.isprimarykey == 1
  408. )
  409. if (columncode && Object.keys(columncode).length) {
  410. this.tableKey = columncode['pagecode']
  411. }
  412. if (simpleQueryItem?.length) {
  413. this.simpleQueryFlag = true
  414. this.simpleQueryItem = simpleQueryItem
  415. }
  416. },
  417. //获取tree点击
  418. treeNodeClick (data) {
  419. const nrow = _.cloneDeep(data)
  420. this.selectedDataCheck = nrow
  421. if (this.selected) {
  422. this.treeCheckQuery(nrow)
  423. } else {
  424. const values = Object.values(data)
  425. const filterItem = this.formatDefault(this.treeParameters, data)
  426. if (!Object.keys(filterItem).length) return
  427. this.defaultfilter = values.includes(-1) || values.includes('全部') ? { 1: 1 } : filterItem
  428. this.queryTableData(true)
  429. }
  430. },
  431. //存在勾选-点击树-查询
  432. async treeCheckQuery (data) {
  433. const values = Object.values(data)
  434. const filterItem = this.formatDefault(this.treeParameters, data)
  435. if (!Object.keys(filterItem).length) return
  436. const itemFilter = values.includes(-1) || values.includes('全部') ? { 1: 1 } : filterItem
  437. const datacontent = { filter: itemFilter }
  438. this.loading = true
  439. this.selectedDataAlls = []
  440. try {
  441. const { code, returnData } = await Query({
  442. page: 1,
  443. serviceid: this.triggerserviceid,
  444. datacontent,
  445. event: '0',
  446. size: 9999
  447. });
  448. if (code == 0) {
  449. const datas = []
  450. this.tableData.filter(item => {
  451. [...returnData].forEach(pt => {
  452. if (item['serviceid'] == pt['serviceid']) {
  453. datas.push(item)
  454. }
  455. })
  456. })
  457. this.selectedDatas = [...datas]
  458. this.selectedDatasCath = [...returnData]
  459. this.selectedDataAlls.push([...datas])
  460. } else {
  461. this.$message.error("获取表格数据失败")
  462. }
  463. } catch (error) {
  464. this.$message.error("获取表格数据失败")
  465. }
  466. this.loading = false
  467. },
  468. //格式化传递参数数据
  469. formatDefault (item, data = {}) {
  470. if (typeof item != 'string') return {}
  471. const filterItem = {}
  472. const parameters = item.replace('{', '').replace('}', '')
  473. const parametersSplit = parameters?.split(',')
  474. parametersSplit.map(item => {
  475. const [key, val] = item?.split(':')
  476. filterItem[key] = data[val]
  477. })
  478. return filterItem
  479. },
  480. //根据按钮权限查询表单权限
  481. findBtntoForm (pageroute) {
  482. return this.tableBtnForms.filter(item => item.pagecode == pageroute)
  483. },
  484. //表单-查看
  485. handleDetail (row) {
  486. const { openmode, pageroute } = this.pageAuthBtnDetail
  487. if (!openmode) return
  488. if (openmode != 2) this.autoBtnClick(openmode, pageroute)
  489. this.flag = true
  490. this.formAuth = false
  491. this.tableType = "detail"
  492. this.tableTitle = "查看"
  493. this.tableForm = _.cloneDeep(row)
  494. },
  495. //表单-新增
  496. async handleAdd () {
  497. const { openmode, pageroute, pagecode } = this.pageAuthBtnAdd
  498. if (!openmode) return
  499. // if (!this.findBtntoForm(pageroute).length) return
  500. if (openmode != 2) this.autoBtnClick(openmode, pageroute)
  501. // const { pageconfigurationid } = this.findBtntoForm(pageroute)[0]
  502. // const pageAuths = this.authArrs
  503. // const tableColumnArrs = pageAuths.filter(item => item['superiorid'] == pageconfigurationid && item['pagetype'] == 'column')
  504. // this.dialogName = pageroute
  505. if (pagecode == 'startBtnAll') {
  506. if (!Object.keys(this.selectedDataCheck).length) {
  507. this.$message.error('请选中容器后再操作')
  508. return
  509. }
  510. const { code, message } = await startAll(this.selectedDataCheck)
  511. if (code == 0) {
  512. this.$message.success(message || '操作成功')
  513. this.queryTableData(true)
  514. } else {
  515. this.$message.error(message || '操作失败')
  516. }
  517. } else {
  518. if (this.$refs['ruleForm']) {
  519. this.$nextTick(() => {
  520. this.$refs['ruleForm'].restForm()
  521. })
  522. }
  523. this.flag = true;
  524. this.tableType = "add"
  525. this.tableTitle = "新增"
  526. this.tableForm = {}
  527. for (let k in this.defaultfilter) {
  528. if (k != 1) {
  529. this.tableForm[k] = this.defaultfilter[k]
  530. }
  531. }
  532. for (let k in this.formItem) {
  533. if (this.formItem[k].defaultvalue && this.formItem[k].defaultvalue != "") {
  534. this.$set(this.tableForm, this.formItem[k].pagecode, this.formItem[k].defaultvalue)
  535. }
  536. }
  537. }
  538. // this.formItem = tableColumnArrs.filter(item => item.isdisplay == 1)
  539. },
  540. formatData (returnData) {
  541. return typeof returnData == 'string' ? this.retParse(returnData) : returnData
  542. },
  543. retParse (returnData) {
  544. try {
  545. return JSON.parse(returnData) ? JSON.parse(returnData) : returnData
  546. } catch (error) {
  547. return returnData
  548. }
  549. },
  550. //回显下拉数据
  551. resPassters (obj) {
  552. const narr = []
  553. const nitem = _.cloneDeep(obj)
  554. const { passparameters } = nitem
  555. if (!passparameters) return ''
  556. const ndata = this.formatData(passparameters)
  557. if (!Array.isArray(ndata)) return ''
  558. ndata.map(({ pageconfigurationid }) => { narr.push(pageconfigurationid) })
  559. return narr
  560. },
  561. //表格-编辑
  562. handleEdit (row) {
  563. const { openmode, pageroute } = this.pageAuthBtnEdit
  564. if (!openmode) return
  565. if (openmode != 2) this.autoBtnClick(openmode, pageroute)
  566. this.flag = true
  567. this.tableType = "edit"
  568. this.tableTitle = "编辑"
  569. const nrow = _.cloneDeep(row)
  570. if (nrow.passparameters) {
  571. nrow.passparameters = this.resPassters(row)
  572. }
  573. if (nrow.dropdownlist) {
  574. nrow.dropdownlist = Number(nrow.dropdownlist)
  575. }
  576. this.tableForm = nrow
  577. },
  578. //表格-其他类型按钮操作
  579. handleOther (row, auth) {
  580. const { openmode, pageroute, passparameters } = this.pageAuthBtnOther
  581. if (!openmode) return
  582. if (openmode != 2) this.autoBtnClick(openmode, pageroute, passparameters, row)
  583. const { pagecode } = auth
  584. if (pagecode == 'stopBtn' || pagecode == 'startBtn') {
  585. this.stateChange(row)
  586. }
  587. },
  588. //启动 & 停止
  589. async stateChange (row) {
  590. const { runstate, serviceid, containercode } = row
  591. const filter = { serviceid, containercode }
  592. if (runstate == 1) {
  593. const { code, returnData } = await stop(filter)
  594. if (code == 0) {
  595. this.$message.success(returnData || '操作成功')
  596. this.queryTableData(true)
  597. } else {
  598. this.$message.error(returnData || '操作失败')
  599. }
  600. } else {
  601. const { code, returnData } = await start(filter)
  602. if (code == 0) {
  603. this.$message.success(returnData || '操作成功')
  604. this.queryTableData(true)
  605. } else {
  606. this.$message.error(returnData || '操作失败')
  607. }
  608. }
  609. },
  610. //表格-删除
  611. handleRemove (row) {
  612. const { openmode, pageroute } = this.pageAuthBtnDel
  613. if (!openmode) return
  614. if (openmode != 2) this.autoBtnClick(openmode, pageroute)
  615. let name = ''
  616. const nrow = _.cloneDeep(row)
  617. for (const key in nrow) {
  618. if (key.includes('name')) {
  619. name = nrow[key] || ''
  620. }
  621. }
  622. this.$confirm(`确认要删除 ${name} 这条信息吗?`, '提示', {
  623. confirmButtonText: '确定',
  624. cancelButtonText: '取消',
  625. type: 'warning'
  626. }).then(() => {
  627. this.generalDataReception(3, row, this.tableKey)
  628. }).catch(() => {
  629. this.$message({
  630. type: 'info',
  631. message: '已取消删除'
  632. });
  633. });
  634. },
  635. //表格-勾选
  636. handleSelectionChange (val) {
  637. this.selectedDataAlls.push([...val])
  638. const ndatas = _.cloneDeep(this.selectedDataAlls)
  639. if (ndatas.length == 1) {
  640. this.sendCheckData('add', ndatas[0])
  641. } else {
  642. const [nitems1, nitems2] = [ndatas.at(-1), ndatas.at(-2)]
  643. if (nitems1.length > nitems2.length) {
  644. const res = this.findRepetData(nitems1, nitems2)
  645. this.sendCheckData('add', res)
  646. } else {
  647. const res = this.findRepetData(nitems1, nitems2)
  648. this.sendCheckData('del', res)
  649. }
  650. }
  651. },
  652. findRepetData (nitems1, nitems2) {
  653. const key = 'serviceid'
  654. const res = [...nitems1, ...nitems2].filter(
  655. (item) =>
  656. !(
  657. nitems1.some((p) => item[key] == p[key]) &&
  658. nitems2.some((c) => item[key] == c[key])
  659. )
  660. )
  661. return res
  662. },
  663. //发送新增编辑删除数据
  664. sendCheckData (types, data, key = 'serviceid') {
  665. const event = types == 'add' ? 1 : types == 'edit' ? 2 : 3
  666. const querys = []
  667. const items = _.cloneDeep(data)
  668. const { serviceid, servicename } = items[0]
  669. const { containerid, containercode, containername } = this.selectedDataCheck
  670. const pitem = {
  671. serviceid,
  672. servicename,
  673. containerid,
  674. containercode,
  675. containername
  676. }
  677. const params = {
  678. serviceid: this.triggerserviceid,
  679. datacontent: formatChange(pitem, event, key),
  680. event,
  681. }
  682. if (event == 3) {
  683. params.datacontent[0].filter.containerid = containerid
  684. delete params.datacontent[0].value.containerid
  685. }
  686. event == 1 ? querys.push(newData(params)) : querys.push(moveData(params))
  687. this.getAnscyData(querys)
  688. },
  689. //获取异步数据
  690. async getAnscyData (allResult) {
  691. if (!allResult.length) return
  692. this.loading = true
  693. const results = await Promise.allSettled(allResult)
  694. results.map((item) => {
  695. const { status, value } = item
  696. if (status == 'fulfilled') {
  697. const { code } = value
  698. if (code == 0) {
  699. this.treeCheckQuery(this.selectedDataCheck)
  700. this.$message.success('操作成功')
  701. } else {
  702. this.$message.error('操作失败')
  703. }
  704. } else {
  705. this.$message.error('网络错误')
  706. }
  707. })
  708. // this.loading = false
  709. },
  710. // 新增/编辑-取消
  711. submitClickClose (formName) {
  712. this.formAuth = true
  713. this.flag = false
  714. this.$refs[formName].restForm()
  715. },
  716. // 新增/编辑-确认
  717. submitClickHandler () {
  718. const flag = this.$refs["ruleForm"].submitClickHandler()
  719. if (flag) this.tableType == "add" ? this.generalDataReception(1, this.tableForm) : this.generalDataReception(2, this.tableForm, this.tableKey)
  720. },
  721. //表格-增/删/改
  722. async generalDataReception (event, data, key) {
  723. this.dialogLoading = true
  724. try {
  725. const params = {
  726. serviceid: this.pageServiceId,
  727. datacontent: formatChange(data, event, key),
  728. event: `${event}`,
  729. };
  730. const { code } =
  731. event == 1
  732. ? await newData(params)
  733. : event == 2
  734. ? await modifyData(params)
  735. : await moveData(params);
  736. if (code == 0) {
  737. this.$message.success("操作成功")
  738. this.flag = false
  739. this.rmFlag = false
  740. this.dialogLoading = false
  741. this.tableObj = {}
  742. this.tableForm = {}
  743. this.resetTable()
  744. this.load();
  745. this.depMath = Math.random()
  746. // this.$router.go(0);
  747. } else {
  748. this.$message.error("操作失败");
  749. this.flag = false
  750. this.rmFlag = false
  751. this.dialogLoading = false
  752. this.tableObj = {};
  753. this.tableForm = {};
  754. }
  755. } catch (error) {
  756. this.flag = false
  757. this.rmFlag = false
  758. this.dialogLoading = false
  759. this.tableObj = {}
  760. this.tableForm = {}
  761. }
  762. },
  763. autoBtnClick (id, url, passparameters, row = {}) {
  764. switch (Number(id)) {
  765. case 1:
  766. if (passparameters && Object.keys(row).length) {
  767. const filterItem = this.formatDefault(passparameters, row)
  768. this.$router.push({
  769. path: url,
  770. query: filterItem
  771. })
  772. }
  773. break;
  774. case 2:
  775. this.$router.push(url)
  776. break;
  777. default:
  778. break;
  779. }
  780. },
  781. //高级查询-弹框打开
  782. async handleQuery () {
  783. const { openmode, pageroute, pagecode } = this.pageAuthBtnQuery
  784. if (!openmode) return
  785. if (pagecode == 'stopBtnAll') {
  786. if (!Object.keys(this.selectedDataCheck).length) {
  787. this.$message.error('请选中容器后再操作')
  788. return
  789. }
  790. const { code, message } = await stopAll(this.selectedDataCheck)
  791. if (code == 0) {
  792. this.$message.success(message || '操作成功')
  793. this.queryTableData(true)
  794. } else {
  795. this.$message.error(message || '操作失败')
  796. }
  797. } else {
  798. if (openmode != 3) this.advancedDrawer = true // this.autoBtnClick(openmode, pageroute)
  799. }
  800. },
  801. //简易查询-确定
  802. queryValue (dataRules) {
  803. const arr = [...dataRules]
  804. if (arr && arr.length) {
  805. arr.forEach(item => {
  806. item.value = typeof item.value == 'string' ? item.value.replace(/\s*/g, "") : item.value
  807. })
  808. }
  809. this.defaultfilter = arr.length ? arr : { 1: 1 }
  810. this.simpleQueryValue = arr
  811. this.queryTableData(true)
  812. },
  813. //高级查询-确定
  814. advancedTable (refName) {
  815. this.$refs[refName].advancedQueryHandler()
  816. },
  817. //高级查询-取消
  818. advancedClose () {
  819. this.advancedDrawer = false
  820. // this.defaultfilter = { 1: 1 }
  821. // this.queryTableData(true)
  822. },
  823. //初始化
  824. onInstall () {
  825. if (!Object.keys(this.selectedDataCheck).length) {
  826. this.$message.error('请选中权限后再操作')
  827. return
  828. }
  829. const { pagetype } = this.selectedDataCheck
  830. if (pagetype != 'table') {
  831. this.$message.error('请选择表格后再操作')
  832. return
  833. }
  834. this.installFlag = true
  835. },
  836. //初始化-关闭
  837. installClose () {
  838. this.installFlag = false
  839. },
  840. //初始化-确定
  841. installTable () {
  842. this.installSubmit()
  843. this.installFlag = false
  844. },
  845. async installSubmit () {
  846. const { pageconfigurationid } = this.selectedDataCheck
  847. const { code, returnData } = await Query({
  848. serviceid: 134,
  849. datacontent: {
  850. tableName: this.$refs['installForm'].tableinfo,
  851. datasourceid: this.$refs['installForm'].datasourceid,
  852. pageconfigurationid
  853. },
  854. deletedatacontent: {
  855. datacontent: [
  856. {
  857. filter: {
  858. superiorid: pageconfigurationid
  859. },
  860. value: {}
  861. }
  862. ],
  863. event: '3'
  864. },
  865. event: '0'
  866. })
  867. if (code == 0 && returnData?.length) {
  868. this.$message.success('数据初始化成功')
  869. this.$refs['pageTree'].pageInit()
  870. this.queryTableData(true)
  871. this.$refs['installForm'].tableinfo = ''
  872. this.$refs['installForm'].datasourceid = ''
  873. }
  874. },
  875. //高级查询-确定-数据
  876. getAdvancedQueryData (dataRules) {
  877. const arr = [...dataRules]
  878. if (arr && arr.length) {
  879. arr.forEach(item => {
  880. item.value = typeof item.value == 'string' ? item.value.replace(/\s*/g, "") : item.value
  881. })
  882. }
  883. this.defaultfilter = arr
  884. this.advancedQueryValue = arr
  885. this.queryTableData(true)
  886. },
  887. //高级查询-收藏
  888. queryCollect (refName) {
  889. this.$refs[refName].advancedQueryCollect()
  890. },
  891. //高级查询-重置
  892. restCollect (refName) {
  893. this.defaultfilter = { 1: 1 }
  894. this.queryTableData(true)
  895. this.$refs[refName].advancedRestCollect()
  896. },
  897. // 给表头单元格加上 ascending 或 descending 使用 element 自带的排序箭头变色
  898. headerCellClass () {
  899. return function ({ row, column, rowIndex, columnIndex }) {
  900. const classes = []
  901. const rule = this.tableDataSortRules[column.property]
  902. if (rule) {
  903. classes.push(rule)
  904. }
  905. return classes.join(' ')
  906. }
  907. },
  908. //添加-表格-行样式
  909. rowClass () {
  910. return function ({ row, rowIndex }) {
  911. const classes = []
  912. if (row.deleted === 'DEL') {
  913. classes.push('bgl-deleted')
  914. }
  915. return classes.join(' ')
  916. }
  917. },
  918. //添加-表格-单元格样式
  919. cellClass () {
  920. return function ({ row, column, rowIndex, columnIndex }) {
  921. const classes = []
  922. const { property } = column
  923. const ndata = _.cloneDeep(this.tableCols).filter(item => item.pagecode == property)
  924. if (ndata?.length) {
  925. const { pageroute } = ndata[0]
  926. if (pageroute) classes.push('cell-click')
  927. }
  928. return classes.join(' ')
  929. }
  930. },
  931. formatPass (pass = []) {
  932. if (typeof pass != 'string') return {}
  933. const ndata = JSON.parse(pass)
  934. if (!ndata) return {}
  935. const nitem = {}
  936. ndata.map(item => {
  937. const ns = Object.values(item)
  938. nitem[ns[0]] = ns[1]
  939. })
  940. return nitem
  941. },
  942. //添加-表格-单元格-点击事件
  943. cellClickHandler (row, column, cell, event) {
  944. const { property } = column
  945. const ndata = _.cloneDeep(this.tableCols).filter(item => item.pagecode == property)
  946. const params = {}
  947. if (ndata?.length) {
  948. const { defaultfilter, pageroute, passparameters } = ndata[0]
  949. if (!pageroute) return
  950. if (defaultfilter || passparameters) {
  951. if (passparameters) {
  952. // const nitem = this.formatPass(passparameters)
  953. const passparametersArray = JSON.parse(passparameters)
  954. passparametersArray.map(item => {
  955. if (row[item.pagecode]) {
  956. const alias = item.alias
  957. const pagecode = item.pagecode
  958. if (alias) {
  959. params[alias] = row[item['pagecode']]
  960. }
  961. else {
  962. params[pagecode] = row[item['pagecode']]
  963. }
  964. }
  965. })
  966. this.$router.push({
  967. path: pageroute,
  968. query: params
  969. })
  970. return
  971. }
  972. if (defaultfilter) {
  973. const filterItem = this.formatDefault(defaultfilter, row)
  974. this.$router.push({
  975. path: pageroute,
  976. query: filterItem
  977. })
  978. return
  979. }
  980. }
  981. else {
  982. this.$router.push(pageroute)
  983. }
  984. }
  985. },
  986. //导出
  987. handleExport () {
  988. if (!this.tableData.length) {
  989. this.$message.info('无数据')
  990. return
  991. }
  992. const table = this.$refs['table'].$el.cloneNode(true)
  993. const fileName = this.pageTitle + '.xlsx'
  994. exportToExcel(table, this.pageTitle, fileName)
  995. },
  996. tableFormatter () {
  997. return function (row, column, cellValue) {
  998. switch (column.property) {
  999. case 'departureTime':
  1000. return (cellValue ?? '').replace('T', ' ')
  1001. case 'deleted':
  1002. return cellValue === 'DEL' ? cellValue : ''
  1003. case 'activated':
  1004. return Number(cellValue) === 1 ? '激活' : '未激活'
  1005. default:
  1006. return cellValue ?? ''
  1007. }
  1008. }
  1009. },
  1010. tableMountedHandler (refName, ref) {
  1011. this.$refs[refName] = ref
  1012. },
  1013. resetTable () {
  1014. this.dataContent = {}
  1015. this.page = 0;
  1016. this.noMore = false;
  1017. this.tableData = [];
  1018. },
  1019. load () {
  1020. if (this.noMore || this.loading) {
  1021. return
  1022. }
  1023. this.queryTableData()
  1024. },
  1025. async queryTableData (jumpSing = false) {
  1026. if (jumpSing) {
  1027. const initialize = _.once(this.resetTable)
  1028. initialize()
  1029. }
  1030. this.loading = true;
  1031. const datacontent = { filter: this.defaultfilter }
  1032. const parmas = {
  1033. page: ++this.page,
  1034. serviceid: this.pageServiceId,
  1035. datacontent,
  1036. event: '0'
  1037. }
  1038. if (this.selected || this.pageSizeDatas.includes(this.$route.path.replace('/', ''))) {
  1039. parmas.size = 9999
  1040. }
  1041. try {
  1042. const { code, returnData } = await Query(parmas);
  1043. if (code == 0) {
  1044. if (returnData.length === 0) {
  1045. this.page--
  1046. this.noMore = true
  1047. }
  1048. this.tableData.push(...returnData)
  1049. this.setPassters(this.tableData)
  1050. // this.formItemArr = this.tableData
  1051. } else {
  1052. this.page--
  1053. this.noMore = true
  1054. this.$message.error("获取表格数据失败")
  1055. }
  1056. } catch (error) {
  1057. this.page--
  1058. this.noMore = true
  1059. }
  1060. if (this.selected || this.pageSizeDatas.includes(this.$route.path.replace('/', ''))) {
  1061. this.noMore = true
  1062. }
  1063. this.loading = false
  1064. },
  1065. //格式化传递参数数据
  1066. formatDefaults (item) {
  1067. if (typeof item != 'string') return {}
  1068. const filterItem = {}
  1069. const parameters = item.replace('{', '').replace('}', '')
  1070. const parametersSplit = parameters?.split(',')
  1071. parametersSplit.map(item => {
  1072. const [key, val] = item?.split(':')
  1073. filterItem[key] = val
  1074. })
  1075. return filterItem
  1076. },
  1077. //去除重复请求
  1078. reduceHttp (arr = [], formItem = []) {
  1079. const datas = _.cloneDeep(arr)
  1080. const dataMap = new Map()
  1081. const [columnArrs1, columnArrs2, allResult, allResultKey] = [[], [], [], []]
  1082. if (!datas.length) return
  1083. datas.map(item => {
  1084. const { datacontent, dropdownlist } = item
  1085. const nameter = Object.entries(datacontent.filter)[0]
  1086. const namekey = dropdownlist + nameter[0] + nameter[1]
  1087. if (!dataMap.get(namekey)) {
  1088. dataMap.set(namekey, item)
  1089. columnArrs1.push(item)
  1090. } else {
  1091. columnArrs2.push(item)
  1092. }
  1093. })
  1094. columnArrs1.map(({ dropdownlist, pagecode, datacontent }) => {
  1095. allResultKey.push(pagecode)
  1096. allResult.push(Query({ serviceid: dropdownlist, datacontent, event: '0', page: 1, size: 9999 }))
  1097. })
  1098. console.log(columnArrs1)
  1099. this.getAnscyData(allResultKey, allResult, _.cloneDeep(formItem), _.cloneDeep(columnArrs1), _.cloneDeep(columnArrs2))
  1100. },
  1101. //获取表单下拉数据
  1102. getSelectData (formItem = []) {
  1103. if (!formItem.length || !Array.isArray(formItem)) return
  1104. const formItemCopy = _.cloneDeep(formItem)
  1105. const [allResult, allResultKey, allResultList] = [[], [], []]
  1106. formItemCopy.map(({ dropdownlist, pagecode, defaultparameters }) => {
  1107. if (((dropdownlist || dropdownlist == 0) && dropdownlist != "")) {
  1108. const datacontent = defaultparameters ? { filter: this.formatDefaults(defaultparameters) } : { filter: { 1: 1 } }
  1109. const params = {
  1110. dropdownlist,
  1111. pagecode,
  1112. datacontent
  1113. }
  1114. allResultList.push(params)
  1115. }
  1116. })
  1117. if (allResultList?.length) {
  1118. this.reduceHttp(allResultList, formItemCopy)
  1119. } else {
  1120. this.formItemArr = formItemCopy
  1121. }
  1122. },
  1123. //获取异步数据
  1124. async getAnscyData (allResultKey = [], allResult = [], formItem = [], columnArrs1 = [], columnArrs2 = []) {
  1125. this.loading = true
  1126. if (allResult.length && allResultKey.length) {
  1127. const results = await Promise.allSettled(allResult)
  1128. const resultDatas = []
  1129. results.map((item, index) => {
  1130. const { status, value } = item
  1131. if (status == 'fulfilled') {
  1132. const { code, returnData } = value
  1133. const nitem = {
  1134. pagecode: allResultKey[index],
  1135. dropdownlist: columnArrs1[index].dropdownlist,
  1136. returnData
  1137. }
  1138. resultDatas.push(nitem)
  1139. this.tableOptions[allResultKey[index]] = code == 0 && returnData?.length ? this.formatData(returnData) : []
  1140. }
  1141. })
  1142. if (resultDatas?.length) this.serRepets(_.cloneDeep(resultDatas), columnArrs1, columnArrs2)
  1143. this.formItemArr = formItem
  1144. } else {
  1145. this.formItemArr = formItem
  1146. }
  1147. this.setPassters(this.formPass)
  1148. this.loading = false
  1149. },
  1150. //设置重复下拉数据
  1151. serRepets (resultDatas = [], columnArrs1, columnArrs2) {
  1152. resultDatas.map(item => {
  1153. columnArrs1.map(ci => {
  1154. if (item.pagecode == ci.pagecode) {
  1155. item.datacontent = ci.datacontent
  1156. }
  1157. })
  1158. })
  1159. const result = [...resultDatas]
  1160. result.map(item => {
  1161. const { datacontent, dropdownlist, returnData } = item
  1162. const nameterItem = Object.entries(datacontent.filter)[0]
  1163. const namekeyItem = dropdownlist + nameterItem[0] + nameterItem[1]
  1164. columnArrs2.map(ci => {
  1165. const { datacontent, dropdownlist, pagecode } = ci
  1166. const nameterCi = Object.entries(datacontent.filter)[0]
  1167. const namekeyCi = dropdownlist + nameterCi[0] + nameterCi[1]
  1168. if (namekeyItem == namekeyCi) {
  1169. this.tableOptions[pagecode] = _.cloneDeep(returnData)
  1170. }
  1171. })
  1172. })
  1173. },
  1174. //设置下拉数据
  1175. setPassters (array = []) {
  1176. const passitem = this.formItemArr.filter(item => item.pagecode == 'passparameters')
  1177. if (passitem?.length) {
  1178. const ndata = _.cloneDeep(array)
  1179. const passitemkey = passitem[0]
  1180. passitemkey.datatype = 'DROP'
  1181. ndata.map(item => {
  1182. item.dropdownlistid = item.pageconfigurationid
  1183. item.dropdownlistlabel = item.pagename
  1184. })
  1185. this.tableOptions['passparameters'] = ndata
  1186. this.formPassCopy = ndata
  1187. }
  1188. },
  1189. isShow (isdisplay) {
  1190. let show = false
  1191. if (eval(isdisplay)) {
  1192. show = true
  1193. }
  1194. else {
  1195. show = false
  1196. }
  1197. return show
  1198. },
  1199. handleCheckedCitiesChange (value) {
  1200. this.leftFlag = value
  1201. },
  1202. handleCheckedCitiesChanges (value) {
  1203. this.tableFlag = value
  1204. }
  1205. },
  1206. }
  1207. </script>
  1208. <style lang="scss" scoped>
  1209. .TablePage {
  1210. height: calc(100vh - 90px);
  1211. padding: 20px;
  1212. &_content {
  1213. margin-top: 20px;
  1214. height: calc(100vh - 190px);
  1215. &_left {
  1216. width: 360px;
  1217. margin-right: 20px;
  1218. }
  1219. &_right {
  1220. height: calc(100% - 100px);
  1221. }
  1222. .tableAuto {
  1223. width: 100%;
  1224. }
  1225. .tableSacle {
  1226. width: calc(100% - 380px);
  1227. }
  1228. .check_header{
  1229. width: 100%;
  1230. height:100px;
  1231. overflow: hidden;
  1232. }
  1233. .TablePage{
  1234. &_child {
  1235. height:100%;
  1236. &_left {
  1237. width: 360px;
  1238. margin-right: 20px;
  1239. }
  1240. }
  1241. }
  1242. }
  1243. }
  1244. </style>