index.vue 51 KB

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