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.

789 lines
22 KiB

3 years ago
1 year ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- <div>-->
  4. <!-- <span @click="favoriteFunction()">-->
  5. <!-- <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>-->
  6. <!-- </span>-->
  7. <!-- </div>-->
  8. <el-form :inline="true" :model="querySysLanguagePack" @keyup.enter.native="getDataList()">
  9. <el-form-item>
  10. <el-input filterable v-model="querySysLanguagePack.key" clearable>
  11. </el-input>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button @click="getDataList()" type="primary">{{ buttons.search }}</el-button>
  15. <el-button v-if="isAuth('sys:setting')" @click="saveColumnList()" type="primary">{{ buttons.defaultTable }}
  16. </el-button>
  17. <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>
  18. <download-excel
  19. :fields="fields()"
  20. :data="exportData"
  21. type="xls"
  22. :name="exportName"
  23. :header="exportHeader"
  24. :footer="exportFooter"
  25. :defaultValue="exportDefaultValue"
  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-item>
  35. <el-select filterable v-model="querySysLanguagePack.languageCode" clearable>
  36. <el-option :label="item.languageName" :value="item.languageCode" v-for="(item,index) in languageList "
  37. :key="index"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" @click="addLanguageFun()">{{ buttons.add }}
  42. </el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-table
  46. id="commmon"
  47. :height="height"
  48. :data="dataList"
  49. border
  50. v-loading="dataListLoading"
  51. @selection-change="selectionChangeHandle"
  52. style="width: 100%;">
  53. <el-table-column
  54. v-for="(item,index) in columnList" :key="index"
  55. :sortable="item.columnSortable"
  56. :prop="item.columnProp"
  57. :header-align="item.headerAlign"
  58. :show-overflow-tooltip="item.showOverflowTooltip"
  59. :align="item.align"
  60. :fixed="item.fixed==''?false:item.fixed"
  61. :min-width="item.columnWidth"
  62. :label="item.columnLabel">
  63. <template slot-scope="scope">
  64. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  65. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  66. style="width: 100px; height: 80px"/></span>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <el-pagination
  71. @size-change="sizeChangeHandle"
  72. @current-change="currentChangeHandle"
  73. :current-page="pageIndex"
  74. :page-sizes="[20, 50, 200, 500]"
  75. :page-size="pageSize"
  76. :total="totalPage"
  77. layout="total, sizes, prev, pager, next, jumper">
  78. </el-pagination>
  79. <!-- 动态列 -->
  80. <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
  81. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-drag
  82. :title="'设置语言一'+querySysLanguagePack.languageCode" :visible.sync="addLanguage" width="1000px">
  83. <el-form :inline="true" :model="addQuery" @keyup.enter.native="getDataList()">
  84. <el-form-item>
  85. <el-input filterable v-model="addQuery.functionId" clearable>
  86. </el-input>
  87. </el-form-item>
  88. <el-form-item>
  89. <el-button @click="getAddOrUpdateList()" type="primary">{{ buttons.search }}</el-button>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-button @click="addListLanguage()" :disabled="dataListSelections.length <= 0" type="primary">
  93. {{ buttons.addList }}
  94. </el-button>
  95. </el-form-item>
  96. </el-form>
  97. <el-table
  98. height="450"
  99. :data="languageDataList"
  100. border
  101. v-loading="dataListLoading"
  102. @selection-change="selectionChangeHandle"
  103. style="width: 100%;">
  104. <el-table-column
  105. type="selection"
  106. header-align="center"
  107. width="40"
  108. align="center">
  109. </el-table-column>
  110. <el-table-column
  111. v-for="(item,index) in languageColumnList" :key="index"
  112. :sortable="item.columnSortable"
  113. :prop="item.columnProp"
  114. :width="item.columnWidth"
  115. :label="item.columnLabel">
  116. <template slot-scope="scope">
  117. <span v-if="item.columnProp!='languageValue'"> {{ scope.row[item.columnProp] }}</span>
  118. <span v-if="item.columnProp=='languageValue'"><input
  119. class="sl-input"
  120. v-model="scope.row[item.columnProp]" type="text"
  121. clearable></input></span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. fixed="right"
  126. header-align="center"
  127. align="center"
  128. width="150"
  129. :label="buttons.cz">
  130. <template slot-scope="scope">
  131. <a type="text" size="small" @click="saveLanguageList(scope.row)">添加</a>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import column from "../common/column";
  140. import {
  141. searchSysLanguagePackList,
  142. searchSysLanguageParam,
  143. searchFunctionButtonList,
  144. saveButtonList,
  145. searchSysLanguage,
  146. searchLanguageListByLanguageCode,
  147. saveSysLanguageOne,
  148. searchPageLanguageData,
  149. removerLanguage,
  150. saveSysLanguageList
  151. } from "@/api/sysLanguage.js"
  152. import {
  153. saveTableDefaultList,
  154. getTableDefaultListLanguage,
  155. getTableUserListLanguage,
  156. removerDefault,
  157. removerUser
  158. } from "@/api/table.js"
  159. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  160. export default {
  161. components: {
  162. column
  163. },
  164. data() {
  165. return {
  166. listShow: false,
  167. // table高度
  168. height: 450,
  169. // 是否收藏
  170. favorite: false,
  171. addLanguage: false,
  172. functionId: 9001,
  173. tableId: "common1001",
  174. value1: true,
  175. visible: false,
  176. showDefault: false,
  177. // 默认table 查询参数
  178. queryTable: {
  179. functionId: 9001,
  180. tableId: "common1001",
  181. languageCode: this.$i18n.locale
  182. },
  183. // 用户table 查询参数
  184. queryTableUser: {
  185. userId: this.$store.state.user.name,
  186. functionId: 9001,
  187. tableId: "common1001",
  188. status: true,
  189. languageCode: this.$i18n.locale
  190. },
  191. // 语言词典查询参数
  192. querySysLanguageParam: {
  193. languageCode: this.$i18n.locale
  194. },
  195. // 语言词典集合
  196. sysLanguageParams: [],
  197. // 用户table 配置集合
  198. userColumnList: [],
  199. // 展示列集
  200. columnList: [
  201. {
  202. "tableId": "common1001",
  203. "tableName": "common",
  204. "columnProp": "functionId",
  205. "columnLabel": "功能编码",
  206. "columnHidden": false,
  207. "columnImage": false,
  208. "columnSortable": false,
  209. "columnWidth": null,
  210. "format": null,
  211. "functionId": "9001",
  212. "sortLv": 0,
  213. "status": true,
  214. "fixed": false,
  215. "serialNumber": null,
  216. "columnType": null,
  217. "align": null
  218. },
  219. {
  220. "tableId": "common1001",
  221. "tableName": "common",
  222. "columnProp": "objectId",
  223. "columnLabel": "序列化编码",
  224. "columnHidden": false,
  225. "columnImage": false,
  226. "columnSortable": false,
  227. "columnWidth": null,
  228. "format": null,
  229. "functionId": "9001",
  230. "sortLv": 0,
  231. "status": true,
  232. "fixed": false,
  233. "serialNumber": null,
  234. "columnType": null,
  235. "align": null
  236. },
  237. {
  238. "tableId": "common1001",
  239. "tableName": "common",
  240. "columnProp": "objectType",
  241. "columnLabel": "类型",
  242. "columnHidden": false,
  243. "columnImage": false,
  244. "columnSortable": false,
  245. "columnWidth": null,
  246. "format": null,
  247. "functionId": "9001",
  248. "sortLv": 0,
  249. "status": true,
  250. "fixed": false,
  251. "serialNumber": null,
  252. "columnType": null,
  253. "align": null
  254. },
  255. {
  256. "tableId": "common1001",
  257. "tableName": "common",
  258. "columnProp": "languageValue",
  259. "columnLabel": "语言值",
  260. "columnHidden": false,
  261. "columnImage": false,
  262. "columnSortable": false,
  263. "columnWidth": null,
  264. "format": null,
  265. "functionId": "9001",
  266. "sortLv": 0,
  267. "status": true,
  268. "fixed": false,
  269. "serialNumber": null,
  270. "columnType": null,
  271. "align": null
  272. }
  273. ],
  274. // 展示列集
  275. columnList1: [
  276. {
  277. "tableId": "common1002",
  278. "tableName": "commonLanguage",
  279. "columnProp": "functionId",
  280. "columnLabel": "功能编码",
  281. "columnHidden": false,
  282. "columnImage": false,
  283. "columnSortable": false,
  284. "columnWidth": null,
  285. "format": null,
  286. "functionId": "9001",
  287. "sortLv": 0,
  288. "status": true,
  289. "fixed": false,
  290. "serialNumber": null,
  291. "columnType": null,
  292. "align": null
  293. },
  294. {
  295. "tableId": "common1002",
  296. "tableName": "commonLanguage",
  297. "columnProp": "languageCode",
  298. "columnLabel": "语言编码",
  299. "columnHidden": false,
  300. "columnImage": false,
  301. "columnSortable": false,
  302. "columnWidth": null,
  303. "format": null,
  304. "functionId": "9001",
  305. "sortLv": 0,
  306. "status": true,
  307. "fixed": false,
  308. "serialNumber": null,
  309. "columnType": null,
  310. "align": null
  311. },
  312. {
  313. "tableId": "common1002",
  314. "tableName": "commonLanguage",
  315. "columnProp": "objectId",
  316. "columnLabel": "序列化编码",
  317. "columnHidden": false,
  318. "columnImage": false,
  319. "columnSortable": false,
  320. "columnWidth": null,
  321. "format": null,
  322. "functionId": "9001",
  323. "sortLv": 1,
  324. "status": true,
  325. "fixed": false,
  326. "serialNumber": null,
  327. "columnType": null,
  328. "align": null
  329. },
  330. {
  331. "tableId": "common1002",
  332. "tableName": "commonLanguage",
  333. "columnProp": "objectType",
  334. "columnLabel": "类型",
  335. "columnHidden": false,
  336. "columnImage": false,
  337. "columnSortable": false,
  338. "columnWidth": null,
  339. "format": null,
  340. "functionId": "9001",
  341. "sortLv": 1,
  342. "status": true,
  343. "fixed": false,
  344. "serialNumber": null,
  345. "columnType": null,
  346. "align": null
  347. },
  348. {
  349. "tableId": "common1002",
  350. "tableName": "commonLanguage",
  351. "columnProp": "languageValue",
  352. "columnLabel": "语言值",
  353. "columnHidden": false,
  354. "columnImage": false,
  355. "columnSortable": false,
  356. "columnWidth": null,
  357. "format": null,
  358. "functionId": "9001",
  359. "sortLv": 2,
  360. "status": true,
  361. "fixed": false,
  362. "serialNumber": null,
  363. "columnType": null,
  364. "align": null
  365. }
  366. ],
  367. // 数据集
  368. dataList: [],
  369. queryButton: {
  370. functionId: 9001,
  371. table_id: 'common1001',
  372. languageCode: this.$i18n.locale,
  373. objectType: 'button'
  374. },
  375. buttons: {
  376. add: '添加',
  377. edit: '编辑',
  378. delete: '删除',
  379. deleteList: '批量删除',
  380. cz: '操作',
  381. search: '查询',
  382. download: '导出',
  383. settingTable: '设置列表',
  384. defaultTable: '设置默认配置',
  385. list: "列表",
  386. addList: '批量添加'
  387. },
  388. // 导出 start
  389. exportData: [],
  390. exportName: "页面功能语言",
  391. exportHeader: ["页面功能语言"],
  392. exportFooter: [],
  393. exportDefaultValue: "这一行这一列没有数据",
  394. // 导出 end
  395. buttonList: [
  396. {
  397. functionId: "9001",
  398. languageValue: '添加',
  399. objectId: 'add',
  400. objectType: "button",
  401. tableId: "common1001"
  402. },
  403. {
  404. functionId: "9001",
  405. languageValue: '编辑',
  406. objectId: 'edit',
  407. objectType: "button",
  408. tableId: "common1001"
  409. },
  410. {
  411. functionId: "9001",
  412. languageValue: '删除',
  413. objectId: 'delete',
  414. objectType: "button",
  415. tableId: "common1001"
  416. },
  417. {
  418. functionId: "9001",
  419. languageValue: '批量删除',
  420. objectId: 'deleteList',
  421. objectType: "button",
  422. tableId: "common1001"
  423. },
  424. {
  425. functionId: "9001",
  426. languageValue: '操作',
  427. objectId: 'cz',
  428. objectType: "button",
  429. tableId: "common1001"
  430. },
  431. {
  432. functionId: "9001",
  433. languageValue: '查询',
  434. objectId: 'search',
  435. objectType: "button",
  436. tableId: "common1001"
  437. },
  438. {
  439. functionId: "9001",
  440. languageValue: '导出',
  441. objectId: 'download',
  442. objectType: "button",
  443. tableId: "common1001"
  444. },
  445. {
  446. functionId: "9001",
  447. languageValue: '设置列表',
  448. objectId: 'settingTable',
  449. objectType: "button",
  450. tableId: "common1001"
  451. },
  452. {
  453. functionId: "9001",
  454. languageValue: '设置默认配置',
  455. objectId: 'defaultTable',
  456. objectType: "button",
  457. tableId: "common1001"
  458. },
  459. {
  460. functionId: "9001",
  461. languageValue: '列表',
  462. objectId: 'list',
  463. objectType: "button",
  464. tableId: "common1001"
  465. }
  466. ],
  467. languageList: [],
  468. languageColumnList: [],
  469. languageDataList: [],
  470. queryLanguage: {},
  471. // 数据集条件
  472. querySysLanguagePack: {
  473. key: '',
  474. page: 1,
  475. limit: 1,
  476. languageValue: '',
  477. objectType: '',
  478. objectId: ''
  479. },
  480. addQuery: {
  481. functionId: '',
  482. languageCode: ''
  483. },
  484. // 批量选中对象
  485. // 分页
  486. pageIndex: 1,
  487. pageSize: 20,
  488. totalPage: 0,
  489. dataListLoading: false,
  490. dataListSelections: [],
  491. addOrUpdateVisible: false
  492. }
  493. },
  494. mounted() {
  495. this.$nextTick(() => {
  496. this.height = window.innerHeight - 175;
  497. })
  498. },
  499. activated() {
  500. this.getDataList()
  501. this.getLanguageList()
  502. },
  503. methods: {
  504. // 校验用户是否收藏
  505. favoriteIsOk() {
  506. let userFavorite = {
  507. userId: this.$store.state.user.id,
  508. languageCode: this.$i18n.locale
  509. }
  510. userFavoriteList(userFavorite).then(({data}) => {
  511. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  512. if (size > 0) {
  513. this.favorite = true
  514. } else {
  515. this.favorite = false
  516. }
  517. })
  518. },
  519. // 收藏 OR 取消收藏
  520. favoriteFunction() {
  521. let userFavorite = {
  522. userId: this.$store.state.user.id,
  523. functionId: this.$route.meta.menuId,
  524. }
  525. if (this.favorite) {
  526. // 取消收藏
  527. this.$confirm(`确定取消收藏`, '提示', {
  528. confirmButtonText: '确定',
  529. cancelButtonText: '取消',
  530. type: 'warning'
  531. }).then(() => {
  532. removeUserFavorite(userFavorite).then(({data}) => {
  533. this.$message.success(data.msg)
  534. this.favorite = false
  535. })
  536. })
  537. } else {
  538. // 收藏
  539. saveUserFavorite(userFavorite).then(({data}) => {
  540. this.$message.success(data.msg)
  541. this.favorite = true
  542. })
  543. }
  544. },
  545. // 保存语言编辑
  546. saveLanguageList(val) {
  547. saveSysLanguageOne(val).then(({data}) => {
  548. if (data.code == 0) {
  549. this.$message.success(data.msg)
  550. } else {
  551. this.$message.error(data.msg)
  552. }
  553. })
  554. },
  555. // 批量保存
  556. addListLanguage() {
  557. saveSysLanguageList(this.dataListSelections).then(({data}) => {
  558. if (data.code == 0) {
  559. this.$message.success(data.msg)
  560. } else {
  561. this.$message.error(data.msg)
  562. }
  563. })
  564. },
  565. // 查询可编辑语言列表
  566. getAddOrUpdateList() {
  567. searchLanguageListByLanguageCode(this.addQuery).then(({data}) => {
  568. this.languageDataList = data.rows
  569. })
  570. },
  571. // 编辑语言
  572. addLanguageFun() {
  573. if (this.querySysLanguagePack.languageCode) {
  574. this.addLanguage = true
  575. this.languageColumnList = []
  576. let query = {
  577. functionId: 9001,
  578. tableId: "common1002",
  579. languageCode: this.$i18n.locale
  580. }
  581. getTableDefaultListLanguage(query).then(({data}) => {
  582. if (data.rows.length > 0) {
  583. this.languageColumnList = data.rows
  584. }
  585. })
  586. this.languageColumnList = this.columnList
  587. this.addQuery.languageCode = this.querySysLanguagePack.languageCode
  588. this.getAddOrUpdateList()
  589. } else {
  590. this.$message("请选中一种语言")
  591. }
  592. },
  593. // 获取多语言列表
  594. getLanguageList() {
  595. searchSysLanguage(this.queryLanguage).then(({data}) => {
  596. this.languageList = data.rows
  597. })
  598. },
  599. // 获取页面多语言
  600. getMsgLanguage() {
  601. this.dataListLoading = true
  602. let queryLang = {
  603. functionId: 9001,
  604. table_id: 'common1001',
  605. languageCode: this.$i18n.locale
  606. }
  607. searchPageLanguageData(queryLang).then((data) => {
  608. if (data.code == 0) {
  609. this.pageLanguageData = data.data
  610. } else {
  611. }
  612. })
  613. this.dataListLoading = false
  614. },
  615. // 获取button的词典
  616. getFunctionButtonList() {
  617. searchFunctionButtonList(this.queryButton).then(({data}) => {
  618. if (data.code == 0) {
  619. this.buttons = data.data
  620. } else {
  621. // saveButtonList(this.buttonList).then(({data}) => {
  622. // })
  623. }
  624. })
  625. },
  626. // 获取语言词典
  627. getSysLanguageParamList() {
  628. searchSysLanguageParam(this.querySysLanguageParam).then(({data}) => {
  629. this.sysLanguageParams = data.rows
  630. })
  631. },
  632. // 打开页面设置
  633. userSetting() {
  634. this.visible = true;
  635. let queryTable = {
  636. userId: this.$store.state.user.name,
  637. functionId: 9001,
  638. tableId: "common1001",
  639. languageCode: this.$i18n.locale
  640. }
  641. this.$nextTick(() => {
  642. this.$refs.column.init(queryTable);
  643. });
  644. },
  645. // 获取 用户保存的 格式列
  646. getTableUserColumn() {
  647. getTableUserListLanguage(this.queryTableUser).then(({data}) => {
  648. if (data.rows.length > 0) {
  649. //this.columnList = []
  650. this.columnList = data.rows
  651. } else {
  652. this.getColumnList()
  653. }
  654. })
  655. },
  656. // 保存 默认配置 列
  657. saveColumnList() {
  658. // 删除所有的该页面下保存的数据
  659. if (this.userColumnList) {
  660. //删除 user自定义的数据
  661. removerUser(this.queryTable)
  662. }
  663. // 删除默认配置
  664. removerDefault(this.queryTable)
  665. // 删除语言
  666. removerLanguage(this.queryTable)
  667. // 保存页面 table属性
  668. let sumColumnList = this.columnList.concat(this.columnList1);
  669. saveTableDefaultList(sumColumnList).then(({data}) => {
  670. })
  671. // 保存页面 button label title 属性
  672. saveButtonList(this.buttonList).then(({data}) => {
  673. })
  674. this.getFunctionButtonList()
  675. this.getColumnList()
  676. },
  677. // 获取 tableDefault 列
  678. getColumnList() {
  679. getTableDefaultListLanguage(this.queryTable).then(({data}) => {
  680. if (!data.rows.length == 0) {
  681. // this.showDefault = false
  682. this.columnList = data.rows
  683. } else {
  684. // this.showDefault = true
  685. }
  686. })
  687. },
  688. // 获取数据列表
  689. getDataList() {
  690. this.dataListLoading = true
  691. this.querySysLanguagePack.limit = this.pageSize
  692. this.querySysLanguagePack.page = this.pageIndex
  693. searchSysLanguagePackList(this.querySysLanguagePack).then(({data}) => {
  694. if (data && data.code === 0) {
  695. this.dataList = data.page.list
  696. this.totalPage = data.page.totalCount
  697. } else {
  698. this.dataList = []
  699. this.totalPage = 0
  700. }
  701. this.dataListLoading = false
  702. })
  703. },
  704. // 每页数
  705. sizeChangeHandle(val) {
  706. this.pageSize = val
  707. this.pageIndex = 1
  708. this.getDataList()
  709. },
  710. // 当前页
  711. currentChangeHandle(val) {
  712. this.pageIndex = val
  713. this.getDataList()
  714. },
  715. // 多选
  716. selectionChangeHandle(val) {
  717. this.dataListSelections = val
  718. },
  719. // 导出
  720. fields() {
  721. let json = "{"
  722. this.columnList.forEach((item, index) => {
  723. if (index == this.columnList.length - 1) {
  724. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  725. } else {
  726. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  727. }
  728. })
  729. json += "}"
  730. let s = eval("(" + json + ")")
  731. return s
  732. },
  733. createExportData() {
  734. // 点击导出按钮之后,开始导出数据之前的执行函数,返回值为需要下载的数据
  735. return this.dataList;
  736. },
  737. startDownload() {
  738. },
  739. finishDownload() {
  740. }
  741. },
  742. created() {
  743. this.getTableUserColumn()
  744. this.getSysLanguageParamList()
  745. this.getFunctionButtonList()
  746. this.favoriteIsOk()
  747. this.getMsgLanguage()
  748. }
  749. }
  750. </script>
  751. <style scoped>
  752. .wrapper {
  753. height: calc(100% - 40px);
  754. }
  755. .sl-input {
  756. background-color: transparent;
  757. border: 0 !important;
  758. font-size: 12px !important;
  759. height: 12px !important;
  760. line-height: 14px !important;
  761. background-color: transparent !important;
  762. width: 140px;
  763. }
  764. .sl-input:focus, textarea:focus {
  765. outline: none;
  766. }
  767. .sl-svg {
  768. overflow: hidden;
  769. float: right;
  770. }
  771. </style>