plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

547 lines
20 KiB

2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <main class="site-content" :class="{ 'site-content--tabs': $route.meta.isTab }">
  4. <!-- 主入口标签页 s -->
  5. <el-tabs
  6. v-if="$route.meta.isTab"
  7. v-model="mainTabsActiveName"
  8. :closable="true"
  9. @tab-click="selectedTabHandle"
  10. @tab-remove="removeTabHandle">
  11. <el-dropdown class="site-tabs__tools" :show-timeout="0">
  12. <i class="el-icon-arrow-down el-icon--right"></i>
  13. <el-dropdown-menu slot="dropdown">
  14. <el-dropdown-item @click.native="tabsCloseCurrentHandle">关闭当前标签页</el-dropdown-item>
  15. <el-dropdown-item @click.native="tabsCloseOtherHandle">关闭其它标签页</el-dropdown-item>
  16. <el-dropdown-item @click.native="tabsCloseAllHandle">关闭全部标签页</el-dropdown-item>
  17. <el-dropdown-item @click.native="refresh()">刷新当前标签页</el-dropdown-item>
  18. <!-- <el-dropdown-item @click.native="flag = true">筛选条件</el-dropdown-item>-->
  19. </el-dropdown-menu>
  20. </el-dropdown>
  21. <el-tab-pane
  22. v-for="item in mainTabs"
  23. :key="item.name"
  24. :label="item.title"
  25. :name="item.name">
  26. <el-card :body-style="siteContentViewHeight">
  27. <iframe
  28. v-if="item.type === 'iframe'"
  29. :src="item.iframeUrl"
  30. width="100%" height="100%" frameborder="0" scrolling="yes">
  31. </iframe>
  32. <keep-alive v-else>
  33. <router-view v-if="item.name === mainTabsActiveName" />
  34. </keep-alive>
  35. </el-card>
  36. </el-tab-pane>
  37. </el-tabs>
  38. <!-- 主入口标签页 e -->
  39. <el-card v-else :body-style="siteContentViewHeight">
  40. <keep-alive>
  41. <router-view />
  42. </keep-alive>
  43. </el-card>
  44. </main>
  45. <el-dialog title="查询" append-to-body v-drag @close="closeSiftDialog" @open="openSiftDialog" :visible.sync="flag" width="65%">
  46. <el-container>
  47. <el-aside width="90%">
  48. <el-autocomplete :hide-loading="false" v-if="!settingFlag" style="width: 100%;" @select="handleSelect" :fetch-suggestions="querySaveRecord" v-model="querySavedVo.itemDesc">
  49. <el-button @click="searchQuerySavedVo" style="width: 80px" slot="append" icon="el-icon-search"></el-button>
  50. </el-autocomplete>
  51. <el-table ref="siftTable" :row-key="getRowKeys" @selection-change="handleSelectionChange" :data="siftList" height="40vh" border>
  52. <el-table-column
  53. type="selection"
  54. width="40" align="center" v-if="settingFlag">
  55. </el-table-column>
  56. <el-table-column label="操作" align="left" header-align="center" width="70" v-if="settingFlag">
  57. <template slot-scope="{row,$index}">
  58. <el-link style="cursor:pointer;" @click="moveSetting($index,-1)" v-if="$index !== 0">上移</el-link>
  59. <el-link style="cursor:pointer;" @click="moveSetting($index,1)" v-if="$index !== siftList.length-1">下移</el-link>
  60. </template>
  61. </el-table-column>
  62. <!-- <el-table-column label="属性" align="center" show-overflow-tooltip width="120" prop="fieldName"></el-table-column>-->
  63. <el-table-column label="属性名称" align="center" show-overflow-tooltip width="120" prop="fieldCaption"></el-table-column>
  64. <el-table-column label="条件" align="center">
  65. <template slot-scope="{row,$index}">
  66. <el-input v-model="row.formula" clearable>
  67. <el-select slot="prepend" clearable v-model="row.symbol" style="width: 100px;cursor:pointer;">
  68. <el-option value="eq" label="等于"></el-option>
  69. <el-option value="gt" label="大于"></el-option>
  70. <el-option value="ge" label="大于等于"></el-option>
  71. <el-option value="lt" label="小于"></el-option>
  72. <el-option value="le" label="小于等于"></el-option>
  73. <el-option value="between" label="之间"></el-option>
  74. <el-option value="in" label="或者"></el-option>
  75. <el-option value="ne" label="不等于"></el-option>
  76. <el-option value="like" label="LIKE"></el-option>
  77. </el-select>
  78. </el-input>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="排序" align="center" prop="sortBy" show-overflow-tooltip width="120">
  82. <template slot-scope="{row,$index}">
  83. <el-select v-model="row.sortBy" clearable style="width: 100%">
  84. <el-option value="asc" label="升序"></el-option>
  85. <el-option value="desc" label="降序"></el-option>
  86. </el-select>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="次序" align="center" prop="orderSeq" width="120">
  90. <template slot-scope="{row,$index}">
  91. <el-input-number v-model="row.orderSeq" clearable style="width: 100%;" :controls="false"></el-input-number>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="数据库字段" align="center" prop="originalField" show-overflow-tooltip width="120"></el-table-column>
  95. </el-table>
  96. </el-aside>
  97. <el-container>
  98. <el-main style="padding: 0px;">
  99. <el-card class="box-card" style="height: 100%;margin-left: 3px">
  100. <div style="text-align: center;">
  101. <div class="box-div" style="margin-top: 70px">
  102. <button @click="openSaveQueryHeaderDialog" v-if="!settingFlag">条件保存</button>
  103. </div>
  104. <div class="box-div">
  105. <button @click="flushedSiftList">刷新</button>
  106. </div>
  107. <div class="box-div">
  108. <button @click="clearSetting">清除</button>
  109. </div>
  110. <div class="box-div">
  111. <button @click="queryUserSettingSave">{{ settingFlag?'保存':'配置' }}</button>
  112. </div>
  113. <div class="box-div" v-if="settingFlag">
  114. <button @click="settingFlag = false">取消</button>
  115. </div>
  116. <div class="box-div" v-if="!settingFlag">
  117. <el-checkbox v-model="querySavedVo.caseSensitiveFlag" true-label="Y" false-label="N">不区分大小写</el-checkbox>
  118. </div>
  119. </div>
  120. </el-card>
  121. </el-main>
  122. </el-container>
  123. </el-container>
  124. <div style="height: 20px;width: 100%"></div>
  125. </el-dialog>
  126. <el-dialog title="记录名称" center :visible.sync="saveQueryHeader" @open="selectData = {itemDesc: undefined}" top="20vh" width="20%">
  127. <el-input v-model="selectData.itemDesc"></el-input>
  128. <span slot="footer" class="dialog-footer">
  129. <el-button type="primary" @click="saveQueryHeaderDetail"> </el-button>
  130. <el-button type="primary" @click="saveQueryHeader = false"> </el-button>
  131. </span>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script>
  136. import { isURL } from '@/utils/validate'
  137. import {
  138. saveOrUpdateBatch, saveQueryHeaderDetail,
  139. searchUserSettingList,
  140. searchUserSettingRecording,
  141. searchUserSettingRecordList
  142. } from "../api/sift/queryUserSetting";
  143. import {Decimal} from "decimal.js";
  144. export default {
  145. inject: ['refresh'],
  146. data () {
  147. return {
  148. cloneSiftList:[],
  149. flag:false,
  150. settingFlag:false,
  151. selectionSiftList:[],
  152. recordList:[],
  153. selectData:{
  154. itemDesc:undefined,
  155. },
  156. querySavedVo:{
  157. menuId:this.$route.meta.menuId,
  158. userId:this.$store.state.user.id,
  159. itemNo:undefined,
  160. itemDesc:undefined,
  161. caseSensitiveFlag:'N'
  162. },
  163. saveQueryHeader:false,
  164. }
  165. },
  166. computed: {
  167. documentClientHeight: {
  168. get () { return this.$store.state.common.documentClientHeight }
  169. },
  170. menuActiveName: {
  171. get () { return this.$store.state.common.menuActiveName },
  172. set (val) { this.$store.commit('common/updateMenuActiveName', val) }
  173. },
  174. mainTabs: {
  175. get () { return this.$store.state.common.mainTabs },
  176. set (val) { this.$store.commit('common/updateMainTabs', val) }
  177. },
  178. mainTabsActiveName: {
  179. get () { return this.$store.state.common.mainTabsActiveName },
  180. set (val) { this.$store.commit('common/updateMainTabsActiveName', val) }
  181. },
  182. siteContentViewHeight () {
  183. var height = this.documentClientHeight - 50 - 2
  184. if (this.$route.meta.isTab) {
  185. height -= 40
  186. return isURL(this.$route.meta.iframeUrl) ? { height: height + 'px' } : { minHeight: height + 'px' }
  187. }
  188. return { minHeight: height + 'px' }
  189. },
  190. siftList:{
  191. get(){
  192. return this.$store.state.sift.siftList.filter(e => e.visible === 'Y'|| this.settingFlag)
  193. },
  194. }
  195. },
  196. methods: {
  197. // tabs, 选中tab
  198. selectedTabHandle (tab) {
  199. tab = this.mainTabs.filter(item => item.name === tab.name)
  200. if (tab.length >= 1) {
  201. this.$router.push({ name: tab[0].name, query: tab[0].query, params: tab[0].params })
  202. }
  203. },
  204. // tabs, 删除tab
  205. removeTabHandle (tabName) {
  206. this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
  207. if (this.mainTabs.length >= 1) {
  208. // 当前选中tab被删除
  209. if (tabName === this.mainTabsActiveName) {
  210. var tab = this.mainTabs[this.mainTabs.length - 1]
  211. this.$router.push({ name: tab.name, query: tab.query, params: tab.params }, () => {
  212. this.mainTabsActiveName = this.$route.name
  213. })
  214. }
  215. } else {
  216. this.menuActiveName = ''
  217. this.$router.push({ name: 'home' })
  218. }
  219. },
  220. // tabs, 关闭当前
  221. tabsCloseCurrentHandle () {
  222. console.log(this.$route.meta.menuId)
  223. this.removeTabHandle(this.mainTabsActiveName)
  224. },
  225. // tabs, 关闭其它
  226. tabsCloseOtherHandle () {
  227. this.mainTabs = this.mainTabs.filter(item => item.name === this.mainTabsActiveName)
  228. },
  229. // tabs, 关闭全部
  230. tabsCloseAllHandle () {
  231. this.mainTabs = []
  232. this.menuActiveName = ''
  233. this.$router.push({ name: 'home' })
  234. },
  235. // tabs, 刷新当前
  236. tabsRefreshCurrentHandle () {
  237. var tab = this.$route
  238. this.removeTabHandle(tab.name)
  239. this.$nextTick(() => {
  240. this.$router.push({ name: tab.name, query: tab.query, params: tab.params })
  241. })
  242. },
  243. openSiftDialog(){
  244. this.cloneSiftList = JSON.parse(JSON.stringify(this.$store.state.sift.siftList))
  245. },
  246. closeSiftDialog(){
  247. if (this.settingFlag){
  248. this.$confirm('存在未保存的数据,是否保存?', '提示', {
  249. confirmButtonText: '确定',
  250. cancelButtonText: '取消',
  251. type: 'warning'
  252. }).then(() => {
  253. this.queryUserSettingSave();
  254. this.settingFlag = false;
  255. }).catch(() => {
  256. this.settingFlag = false;
  257. });
  258. }
  259. this.$store.commit("sift/commitSiftList",this.cloneSiftList);
  260. this.querySavedVo={
  261. menuId:this.$route.meta.menuId,
  262. userId:this.$store.state.user.id,
  263. itemNo:undefined,
  264. itemDesc:undefined,
  265. caseSensitiveFlag:'N'
  266. };
  267. },
  268. searchSiftList(){
  269. let params = {
  270. menuId:this.$route.meta.menuId,
  271. userId:this.$store.state.user.id
  272. }
  273. searchUserSettingList(params).then(({data})=>{
  274. if (data && data.code === 0){
  275. this.$store.commit("sift/commitSiftList",data.rows)
  276. this.cloneSiftList = data.rows
  277. }else {
  278. this.$message.warning(data.msg)
  279. }
  280. }).catch((error)=>{
  281. this.$message.warning(error)
  282. })
  283. },
  284. queryUserSettingSave(){
  285. if (this.settingFlag === false){
  286. this.settingFlag = true
  287. this.$store.commit("sift/commitSiftList",this.cloneSiftList)
  288. this.$nextTick(()=>{
  289. this.$refs.siftTable.clearSelection()
  290. this.siftList.forEach(row=>{
  291. this.$refs.siftTable.toggleRowSelection(row,row.visible === 'Y')
  292. })
  293. })
  294. return
  295. }
  296. // 修改选择值切换
  297. // this.showSetting();
  298. // 发起新增或修改请求
  299. saveOrUpdateBatch(this.showSetting()).then(({data})=>{
  300. if (data && data.code === 0){
  301. this.searchSiftList()
  302. this.querySavedVo={
  303. menuId:this.$route.meta.menuId,
  304. userId:this.$store.state.user.id,
  305. itemNo:undefined,
  306. itemDesc:undefined,
  307. caseSensitiveFlag:'N'
  308. }
  309. this.settingFlag = false
  310. this.$message.success(data.msg)
  311. }else {
  312. this.$message.warning(data.msg)
  313. }
  314. }).catch((error)=>{
  315. this.$message.error(error)
  316. })
  317. },
  318. handleSelectionChange(val){
  319. this.selectionSiftList = val
  320. },
  321. getRowKeys(row){
  322. return row.fieldName
  323. },
  324. moveSetting(i,num){
  325. let arr = [...this.siftList]
  326. arr[i+num].showSeqNo = new Decimal(arr[i+num].showSeqNo).toNumber() - num
  327. arr[i].showSeqNo = new Decimal(arr[i+num].showSeqNo).toNumber() + num
  328. arr = arr.sort((a,b)=> a.showSeqNo-b.showSeqNo)
  329. this.$store.commit("sift/commitSiftList",arr)
  330. this.$nextTick(()=>{
  331. this.siftList.forEach(row =>{
  332. this.$refs.siftTable.toggleRowSelection(row,row.visible === 'Y')
  333. })
  334. })
  335. },
  336. showSetting(){
  337. let arr = [...this.siftList]
  338. arr.map(i=>{
  339. i.visible = 'N'
  340. return i
  341. })
  342. this.selectionSiftList.forEach(item=>{
  343. for (let i = 0; i < arr.length; i++) {
  344. let setting = arr[i]
  345. if (item.fieldName === setting.fieldName){
  346. setting.visible = 'Y'
  347. break
  348. }
  349. }
  350. })
  351. return arr
  352. },
  353. clearSetting(){
  354. let arr = JSON.parse(JSON.stringify(this.siftList));
  355. for (let i = 0; i < this.siftList.length; i++) {
  356. arr[i].symbol = null;
  357. arr[i].formula = null;
  358. arr[i].sortBy = null;
  359. }
  360. this.querySavedVo = {
  361. menuId:this.$route.meta.menuId,
  362. userId:this.$store.state.user.id,
  363. itemNo:undefined,
  364. itemDesc:undefined,
  365. caseSensitiveFlag:'N'
  366. };
  367. this.$store.commit("sift/commitSiftList",arr)
  368. this.$nextTick(()=>{
  369. this.siftList.forEach(row =>{
  370. this.$refs.siftTable.toggleRowSelection(row,row.visible === 'Y')
  371. })
  372. })
  373. },
  374. flushedSiftList(){
  375. let params = {
  376. menuId:this.$route.meta.menuId,
  377. userId:this.$store.state.user.id
  378. }
  379. this.querySavedVo={
  380. menuId:this.$route.meta.menuId,
  381. userId:this.$store.state.user.id,
  382. itemNo:undefined,
  383. itemDesc:undefined,
  384. caseSensitiveFlag:'N'
  385. }
  386. searchUserSettingList(params).then(({data})=>{
  387. if (data && data.code === 0){
  388. this.$store.commit("sift/commitSiftList",data.rows)
  389. this.$nextTick(()=>{
  390. this.siftList.forEach(row =>{
  391. this.$refs.siftTable.toggleRowSelection(row,row.visible === 'Y')
  392. })
  393. })
  394. }else {
  395. this.$message.warning(data.msg)
  396. }
  397. }).catch((error)=>{
  398. this.$message.error(error)
  399. })
  400. },
  401. flushedSiftRecording(){
  402. let params = {
  403. menuId:this.$route.meta.menuId,
  404. userId:this.$store.state.user.id
  405. }
  406. searchUserSettingRecordList(params).then(({data})=>{
  407. if (data && data.code === 0){
  408. this.recordList = data.rows
  409. }else {
  410. this.$message.warning(data.msg)
  411. }
  412. }).catch((error)=>{
  413. this.$message.error(error)
  414. })
  415. },
  416. flushSift(){
  417. if (this.$route.meta.menuId){
  418. this.flushedSiftList()
  419. this.flushedSiftRecording()
  420. }
  421. },
  422. querySaveRecord(queryString, cb){
  423. let results = this.recordList;
  424. results = queryString?results.filter((item)=>{
  425. return item.itemDesc.toUpperCase().match(queryString)
  426. }):results;
  427. results = results.map(item=>{
  428. item.value = item.itemDesc
  429. return item
  430. })
  431. cb(results)
  432. },
  433. handleSelect(item){
  434. this.selectData = JSON.parse(JSON.stringify(item))
  435. searchUserSettingRecording(item).then(({data})=>{
  436. if (data && data.code === 0){
  437. let rows = data.rows
  438. let list = [...this.siftList]
  439. rows.forEach((row)=>{
  440. for (let i = 0; i < list.length; i++) {
  441. let sift = list[i]
  442. if (sift.menuId === row.menuId && sift.userId === row.userId && sift.fieldName === row.fieldName){
  443. sift.symbol = row.symbol
  444. sift.formula = row.formula
  445. sift.sortBy = row.sortBy
  446. break
  447. }
  448. }
  449. })
  450. this.$store.commit("sift/commitSiftList",list);
  451. // 处理数据
  452. }else {
  453. this.$message.warning(data.msg)
  454. }
  455. }).catch((error)=>{
  456. this.$message.error(error)
  457. })
  458. },
  459. openSaveQueryHeaderDialog(){
  460. if (!this.querySavedVo.itemDesc){
  461. this.saveQueryHeader = true
  462. return
  463. }
  464. this.saveQueryHeaderDetail();
  465. },
  466. saveQueryHeaderDetail(){
  467. let param = {...this.selectData}
  468. // 打开了新增弹框即新增查询记录 否则修改查询记录
  469. if (this.saveQueryHeader){
  470. param.menuId = this.$route.meta.menuId
  471. param.userId = this.$store.state.user.id
  472. param.dtsName = 'ADOQResult'
  473. }
  474. param.querySavedDetailList = JSON.parse(JSON.stringify(this.siftList))
  475. saveQueryHeaderDetail(param).then(({data})=>{
  476. if (data && data.code === 0){
  477. this.flushedSiftRecording();
  478. this.saveQueryHeader = false
  479. this.$message.success(data.msg)
  480. }else {
  481. this.$message.warning(data.msg)
  482. }
  483. }).catch((error)=>{
  484. this.$message.error(error)
  485. })
  486. },
  487. searchQuerySavedVo(){
  488. let params = {...this.querySavedVo}
  489. params.querySavedDetailList = this.siftList
  490. this.$store.state.sift.searchFunction(params)
  491. }
  492. },
  493. watch:{
  494. // 监听路由变化调用筛选查询
  495. // $route:'flushSift'
  496. },
  497. mounted() {
  498. // this.flushSift()
  499. }
  500. }
  501. </script>
  502. <style scoped>
  503. /deep/ .el-table .cell{
  504. height: auto;
  505. }
  506. .box-div{
  507. width: 100%;
  508. margin-bottom: 5px;
  509. padding-bottom: 5px;
  510. //border-bottom: 1px solid #eee;
  511. }
  512. .box-div button{
  513. height: 32px;
  514. width: 80px;
  515. background: rgb(22,179,163);
  516. border: none;
  517. border-radius: 5px;
  518. color: #fff;
  519. cursor: pointer;
  520. }
  521. .box-div button:hover{
  522. background: rgb(97, 217, 204);
  523. }
  524. /deep/ .el-input .el-input-group__prepend{
  525. background-color: #fff;
  526. }
  527. /deep/ .el-autocomplete .el-input .el-input-group__append{
  528. background-color: rgb(22,179,163);
  529. color: #fff;
  530. border: 1px solid rgb(22,179,163);
  531. }
  532. .el-input-number /deep/ .el-input__inner{
  533. text-align: right;
  534. padding-right: 5px !important;
  535. }
  536. /deep/ .el-input-number--medium{
  537. line-height: 20px;
  538. }
  539. </style>