祥兆质量前端
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.

595 lines
17 KiB

2 years ago
1 year ago
2 years ago
  1. <template>
  2. <div class="hupdateFlaglo">
  3. <el-row>
  4. <el-col :span="24">
  5. <div>
  6. <span @click="favoriteFunction()">
  7. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  8. </span>
  9. </div>
  10. </el-col>
  11. <el-col :span="24">
  12. <el-form :inline="true" :model="querySysLanguagePack" @keyup.enter.native="getDataList()">
  13. <el-form-item>
  14. <el-input filterable v-model="querySysLanguagePack.key" clearable>
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button @click="getDataList()" type="primary">{{ buttons.search }}</el-button>
  19. <download-excel
  20. :fields="fields()"
  21. :data="exportData"
  22. type="xls"
  23. :name="exportName"
  24. :header="exportHeader"
  25. :footer="exportFooter"
  26. :fetch="createExportData"
  27. :before-generate="startDownload"
  28. :before-finish="finishDownload"
  29. worksheet="导出信息"
  30. class="el-button el-button--primary el-button--medium">
  31. {{ buttons.download }}
  32. </download-excel>
  33. </el-form-item>
  34. </el-form>
  35. </el-col>
  36. <el-col :span="24">
  37. <el-table
  38. id="commmon"
  39. :height="height"
  40. :data="dataList"
  41. border
  42. v-loading="dataListLoading"
  43. @selection-change="selectionChangeHandle"
  44. style="width: 100%;">
  45. <el-table-column
  46. v-for="(item,index) in columnList" :key="index"
  47. :sortable="item.columnSortable"
  48. :prop="item.columnProp"
  49. :header-align="item.headerAlign"
  50. :show-overflow-tooltip="item.showOverflowTooltip"
  51. :align="item.align"
  52. :fixed="item.fixed==''?false:item.fixed"
  53. :width="item.columnWidth"
  54. :label="item.columnLabel">
  55. <template slot-scope="scope">
  56. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  57. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  58. style="width: 100px; height: 80px"/></span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column
  62. fixed="right"
  63. header-align="center"
  64. align="center"
  65. width="150"
  66. :label="buttons.cz">
  67. <template slot-scope="scope">
  68. <a type="text" size="small"
  69. @click="addOrUpdateLanguageList(scope.row.functionId)">{{ buttons.settingLanguageList }}
  70. </a>
  71. |
  72. <a type="text" size="small" @click="addOrUpdateLanguage(scope.row)">{{ buttons.settingLanguage }}</a>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <el-pagination
  77. @size-change="sizeChangeHandle"
  78. @current-change="currentChangeHandle"
  79. :current-page="pageIndex"
  80. :page-sizes="[20, 50, 200, 500]"
  81. :page-size="pageSize"
  82. :total="totalPage"
  83. layout="total, sizes, prev, pager, next, jumper">
  84. </el-pagination>
  85. </el-col>
  86. </el-row>
  87. <!-- 动态列 -->
  88. <column v-if="visible" ref="column" @refreshData="getTableUserColumn" v-drag></column>
  89. <!-- 语言组件 -->
  90. <commonLanguageBase ref="commonLanguageAdd" v-drag></commonLanguageBase>
  91. <commonLanguageList ref="commonLanguageList" v-drag></commonLanguageList>
  92. </div>
  93. </template>
  94. <script>
  95. import column from "../../common/column";
  96. import contextButton from '../../common/right_click_menu'
  97. import commonLanguageBase from "./common-language-base";
  98. import commonLanguageList from "./common-language-list";
  99. import {
  100. searchSysLanguagePackList,
  101. searchFunctionButtonList,
  102. } from "@/api/sysLanguage.js"
  103. import {
  104. saveTableDefaultList,
  105. getTableDefaultListLanguage,
  106. getTableUserListLanguage,
  107. removerDefault,
  108. removerUser
  109. } from "@/api/table.js"
  110. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  111. export default {
  112. components: {
  113. column,
  114. commonLanguageBase,
  115. commonLanguageList,
  116. contextButton
  117. },
  118. data() {
  119. return {
  120. menuVisible: false,
  121. listShow: false,
  122. // table高度
  123. height: 450,
  124. // 是否收藏
  125. favorite: false,
  126. addLanguage: false,
  127. functionId: this.$route.meta.menuId,
  128. tableId: "common1001",
  129. value1: true,
  130. visible: false,
  131. showDefault: false,
  132. // 语言词典集合
  133. sysLanguageParams: [],
  134. // 用户table 配置集合
  135. userColumnList: [],
  136. // 展示列集
  137. columnList: [
  138. {
  139. "tableId": "common1001",
  140. "tableName": "common",
  141. "columnProp": "functionId",
  142. "columnLabel": "功能编码",
  143. "columnHidden": false,
  144. "columnImage": false,
  145. "columnSortable": false,
  146. "columnWidth": null,
  147. "format": null,
  148. "functionId": this.$route.meta.menuId,
  149. "sortLv": 0,
  150. "status": true,
  151. "fixed": '',
  152. "serialNumber": null,
  153. "columnType": null,
  154. "align": null
  155. },
  156. {
  157. "tableId": "common1001",
  158. "tableName": "common",
  159. "columnProp": "funDesc",
  160. "columnLabel": "功能名称",
  161. "columnHidden": false,
  162. "columnImage": false,
  163. "columnSortable": false,
  164. "columnWidth": null,
  165. "format": null,
  166. "functionId": this.$route.meta.menuId,
  167. "sortLv": 0,
  168. "status": true,
  169. "fixed": '',
  170. "serialNumber": null,
  171. "columnType": null,
  172. "align": null
  173. },
  174. {
  175. "tableId": "common1001",
  176. "tableName": "common",
  177. "columnProp": "objectId",
  178. "columnLabel": "控件编码",
  179. "columnHidden": false,
  180. "columnImage": false,
  181. "columnSortable": false,
  182. "columnWidth": null,
  183. "format": null,
  184. "functionId": this.$route.meta.menuId,
  185. "sortLv": 0,
  186. "status": true,
  187. "fixed": '',
  188. "serialNumber": null,
  189. "columnType": null,
  190. "align": null
  191. },
  192. {
  193. "tableId": "common1001",
  194. "tableName": "common",
  195. "columnProp": "objectType",
  196. "columnLabel": "类型",
  197. "columnHidden": false,
  198. "columnImage": false,
  199. "columnSortable": false,
  200. "columnWidth": null,
  201. "format": null,
  202. "functionId": this.$route.meta.menuId,
  203. "sortLv": 0,
  204. "status": true,
  205. "fixed": '',
  206. "serialNumber": null,
  207. "columnType": null,
  208. "align": null
  209. },
  210. {
  211. "tableId": "common1001",
  212. "tableName": "common",
  213. "columnProp": "languageValue",
  214. "columnLabel": "控件名称",
  215. "columnHidden": false,
  216. "columnImage": false,
  217. "columnSortable": false,
  218. "columnWidth": null,
  219. "format": null,
  220. "functionId": this.$route.meta.menuId,
  221. "sortLv": 0,
  222. "status": true,
  223. "fixed": '',
  224. "serialNumber": null,
  225. "columnType": null,
  226. "align": null
  227. }
  228. ],
  229. // 展示列集
  230. columnList1: [
  231. {
  232. "tableId": "common1002",
  233. "tableName": "commonLanguage",
  234. "columnProp": "functionId",
  235. "columnLabel": "功能编码",
  236. "columnHidden": false,
  237. "columnImage": false,
  238. "columnSortable": false,
  239. "columnWidth": null,
  240. "format": null,
  241. "functionId": this.$route.meta.menuId,
  242. "sortLv": 0,
  243. "status": true,
  244. "fixed": '',
  245. "serialNumber": null,
  246. "columnType": null,
  247. "align": null
  248. },
  249. {
  250. "tableId": "common1002",
  251. "tableName": "commonLanguage",
  252. "columnProp": "funDesc",
  253. "columnLabel": "功能名称",
  254. "columnHidden": false,
  255. "columnImage": false,
  256. "columnSortable": false,
  257. "columnWidth": null,
  258. "format": null,
  259. "functionId": this.$route.meta.menuId,
  260. "sortLv": 0,
  261. "status": true,
  262. "fixed": '',
  263. "serialNumber": null,
  264. "columnType": null,
  265. "align": null
  266. },
  267. {
  268. "tableId": "common1002",
  269. "tableName": "commonLanguage",
  270. "columnProp": "languageCode",
  271. "columnLabel": "控件语言编码",
  272. "columnHidden": false,
  273. "columnImage": false,
  274. "columnSortable": false,
  275. "columnWidth": null,
  276. "format": null,
  277. "functionId": this.$route.meta.menuId,
  278. "sortLv": 0,
  279. "status": true,
  280. "fixed": '',
  281. "serialNumber": null,
  282. "columnType": null,
  283. "align": null
  284. },
  285. {
  286. "tableId": "common1002",
  287. "tableName": "commonLanguage",
  288. "columnProp": "objectId",
  289. "columnLabel": "控件编码",
  290. "columnHidden": false,
  291. "columnImage": false,
  292. "columnSortable": false,
  293. "columnWidth": null,
  294. "format": null,
  295. "functionId": this.$route.meta.menuId,
  296. "sortLv": 1,
  297. "status": true,
  298. "fixed": '',
  299. "serialNumber": null,
  300. "columnType": null,
  301. "align": null
  302. },
  303. {
  304. "tableId": "common1002",
  305. "tableName": "commonLanguage",
  306. "columnProp": "objectType",
  307. "columnLabel": "控件类型",
  308. "columnHidden": false,
  309. "columnImage": false,
  310. "columnSortable": false,
  311. "columnWidth": null,
  312. "format": null,
  313. "functionId": this.$route.meta.menuId,
  314. "sortLv": 1,
  315. "status": true,
  316. "fixed": '',
  317. "serialNumber": null,
  318. "columnType": null,
  319. "align": null
  320. },
  321. {
  322. "tableId": "common1002",
  323. "tableName": "commonLanguage",
  324. "columnProp": "baseName",
  325. "columnLabel": "控件名称",
  326. "columnHidden": false,
  327. "columnImage": false,
  328. "columnSortable": false,
  329. "columnWidth": null,
  330. "format": null,
  331. "functionId": "9001",
  332. "sortLv": 2,
  333. "status": true,
  334. "fixed": '',
  335. "serialNumber": null,
  336. "columnType": null,
  337. "align": null
  338. },
  339. {
  340. "tableId": "common1002",
  341. "tableName": "commonLanguage",
  342. "columnProp": "languageValue",
  343. "columnLabel": "控件值",
  344. "columnHidden": false,
  345. "columnImage": false,
  346. "columnSortable": false,
  347. "columnWidth": null,
  348. "format": null,
  349. "functionId": this.$route.meta.menuId,
  350. "sortLv": 2,
  351. "status": true,
  352. "fixed": '',
  353. "serialNumber": null,
  354. "columnType": null,
  355. "align": null
  356. }
  357. ],
  358. // 数据集
  359. dataList: [],
  360. queryButton: {
  361. functionId: this.$route.meta.menuId,
  362. table_id: 'common1001',
  363. languageCode: this.$i18n.locale,
  364. objectType: 'button'
  365. },
  366. buttons: {
  367. settingLanguageList: '按语言设置',
  368. edit: '编辑',
  369. delete: '删除',
  370. deleteList: '批量删除',
  371. cz: '操作',
  372. search: '查询',
  373. download: '导出',
  374. settingTable: '设置列表',
  375. defaultTable: '设置默认配置',
  376. list: "列表",
  377. addList: '批量添加',
  378. settingLanguage: "按控件设置"
  379. },
  380. // 导出 start
  381. exportData: [],
  382. exportName: "页面功能语言",
  383. exportHeader: ["页面功能语言"],
  384. exportFooter: [],
  385. // 导出 end
  386. languageList: [],
  387. languageColumnList: [],
  388. languageDataList: [],
  389. queryLanguage: {},
  390. // 数据集条件
  391. querySysLanguagePack: {
  392. key: '',
  393. page: 1,
  394. limit: 1,
  395. languageValue: '',
  396. objectType: '',
  397. objectId: ''
  398. },
  399. addQuery: {
  400. functionId: '',
  401. languageCode: ''
  402. },
  403. // 批量选中对象
  404. // 分页
  405. pageIndex: 1,
  406. pageSize: 20,
  407. totalPage: 0,
  408. dataListLoading: false,
  409. dataListSelections: [],
  410. addOrUpdateVisible: false
  411. }
  412. },
  413. mounted() {
  414. this.$nextTick(() => {
  415. this.height = window.innerHeight - 180;
  416. })
  417. },
  418. activated() {
  419. this.getDataList()
  420. },
  421. methods: {
  422. // 校验用户是否收藏
  423. favoriteIsOk() {
  424. let userFavorite = {
  425. userId: this.$store.state.user.id,
  426. languageCode: this.$i18n.locale
  427. }
  428. userFavoriteList(userFavorite).then(({data}) => {
  429. console.log(data.list)
  430. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  431. console.log(size)
  432. if (size > 0) {
  433. this.favorite = true
  434. } else {
  435. this.favorite = false
  436. }
  437. })
  438. },
  439. // 收藏 OR 取消收藏
  440. favoriteFunction() {
  441. let userFavorite = {
  442. userId: this.$store.state.user.id,
  443. functionId: this.$route.meta.menuId,
  444. }
  445. if (this.favorite) {
  446. // 取消收藏
  447. this.$confirm(`确定取消收藏`, '提示', {
  448. confirmButtonText: '确定',
  449. cancelButtonText: '取消',
  450. type: 'warning'
  451. }).then(() => {
  452. removeUserFavorite(userFavorite).then(({data}) => {
  453. this.$message.success(data.msg)
  454. this.favorite = false
  455. })
  456. })
  457. } else {
  458. // 收藏
  459. saveUserFavorite(userFavorite).then(({data}) => {
  460. this.$message.success(data.msg)
  461. this.favorite = true
  462. })
  463. }
  464. },
  465. // 单个语言编辑
  466. addOrUpdateLanguage(val) {
  467. this.commonLanguageVisible = true
  468. this.$nextTick(() => {
  469. this.$refs.commonLanguageAdd.init(val)
  470. })
  471. },
  472. // 语言列表编辑
  473. addOrUpdateLanguageList(functionId) {
  474. this.$nextTick(() => {
  475. this.$refs.commonLanguageList.init(functionId, this.$route.meta.menuId)
  476. })
  477. },
  478. // 获取button的词典
  479. getFunctionButtonList() {
  480. searchFunctionButtonList(this.queryButton).then(({data}) => {
  481. if (data.code == 0) {
  482. this.buttons = data.data
  483. }
  484. })
  485. },
  486. // 获取 用户保存的 格式列
  487. getTableUserColumn(tableId) {
  488. let queryTableUser = {
  489. userId: this.$store.state.user.name,
  490. functionId: this.$route.meta.menuId,
  491. tableId: "common1001",
  492. status: true,
  493. languageCode: this.$i18n.locale
  494. }
  495. getTableUserListLanguage(queryTableUser).then(({data}) => {
  496. if (data.rows.length > 0) {
  497. this.columnList = data.rows
  498. } else {
  499. this.getColumnList()
  500. }
  501. })
  502. },
  503. // 获取 tableDefault 列
  504. getColumnList() {
  505. let queryTable = {
  506. functionId: this.$route.meta.menuId,
  507. tableId: "common1001",
  508. languageCode: this.$i18n.locale
  509. }
  510. getTableDefaultListLanguage(queryTable).then(({data}) => {
  511. if (data.code == 0 && !data.rows) {
  512. this.columnList = data.rows
  513. }
  514. })
  515. },
  516. // 获取数据列表
  517. getDataList() {
  518. this.dataListLoading = true
  519. this.querySysLanguagePack.limit = this.pageSize
  520. this.querySysLanguagePack.page = this.pageIndex
  521. searchSysLanguagePackList(this.querySysLanguagePack).then(({data}) => {
  522. if (data && data.code === 0) {
  523. this.dataList = data.page.list
  524. this.totalPage = data.page.totalCount
  525. } else {
  526. this.dataList = []
  527. this.totalPage = 0
  528. }
  529. this.dataListLoading = false
  530. })
  531. },
  532. // 每页数
  533. sizeChangeHandle(val) {
  534. this.pageSize = val
  535. this.pageIndex = 1
  536. this.getDataList()
  537. },
  538. // 当前页
  539. currentChangeHandle(val) {
  540. this.pageIndex = val
  541. this.getDataList()
  542. },
  543. // 多选
  544. selectionChangeHandle(val) {
  545. this.dataListSelections = val
  546. },
  547. // 导出
  548. fields() {
  549. let json = "{"
  550. this.columnList.forEach((item, index) => {
  551. if (index == this.columnList.length - 1) {
  552. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  553. } else {
  554. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  555. }
  556. })
  557. json += "}"
  558. let s = eval("(" + json + ")")
  559. return s
  560. },
  561. createExportData() {
  562. // 点击导出按钮之后,开始导出数据之前的执行函数,返回值为需要下载的数据
  563. return this.dataList;
  564. },
  565. startDownload() {
  566. },
  567. finishDownload() {
  568. }
  569. },
  570. created() {
  571. this.getTableUserColumn()
  572. this.getFunctionButtonList()
  573. this.favoriteIsOk()
  574. }
  575. }
  576. </script>
  577. <style scoped>
  578. .wrapper {
  579. height: calc(100% - 40px);
  580. }
  581. .sl-svg {
  582. overflow: hidden;
  583. float: right;
  584. }
  585. </style>