阅行客电子档案
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.

228 lines
9.0 KiB

  1. <template>
  2. <div>
  3. <div class="format-main">
  4. <div class="format-main-left">
  5. <div class="head-container">
  6. <el-button v-permission="permission.add" size="mini" icon="el-icon-plus" :disabled="table.left.selections.length == 0" @click="toAdd(table.left.selections)">
  7. 插入
  8. </el-button>
  9. </div>
  10. <!--表格渲染-->
  11. <el-table ref="leftTable" v-loading="table.left.loading" :data="table.left.data" style="width: 400px;" height="calc(100vh - 602px)" @selection-change="(val)=>selectionChangeHandler(val,'left')" @row-click="(row,column,e)=>clickRowHandler(row,column,e,'leftTable')">
  12. <el-table-column type="selection" width="55" align="center" />
  13. <el-table-column type="index" label="序号" width="55" align="center" />
  14. <el-table-column prop="fieldCnName" label="字段名称" align="center" />
  15. </el-table>
  16. <!--表单渲染-->
  17. <eForm />
  18. </div>
  19. <div class="format-main-right">
  20. <div class="head-container">
  21. <el-button v-permission="permission.del" icon="el-icon-delete" size="mini" :loading="delAllLoading" :disabled="table.right.selections.length === 0" @click="toDelete(table.right.selections)">
  22. 移除
  23. </el-button>
  24. <el-button v-permission="permission.edit" size="mini" icon="el-icon-edit" :disabled="table.right.selections.length === 0" @click="toEdit(table.right.selections)">
  25. 编辑
  26. </el-button>
  27. <!-- type="danger" -->
  28. <el-button v-permission="permission.sort" icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="table.right.data <= 1" @click="toSort">排序</el-button>
  29. </div>
  30. <!--表格渲染-->
  31. <el-table ref="rightTable" v-loading="table.right.loading" :data="table.right.data" height="calc(100vh - 602px)" @selection-change="(val)=>selectionChangeHandler(val,'right')" @row-click="(row,column,e)=>clickRowHandler(row,column,e,'rightTable')">
  32. <el-table-column type="selection" width="55" align="center" />
  33. <el-table-column type="index" label="序号" width="55" align="center" />
  34. <el-table-column prop="fieldCnName" label="字段名称" align="center" />
  35. <el-table-column prop="displayLength" label="显示长度" align="center" />
  36. <el-table-column label="显示格式">
  37. <template slot-scope="scope">
  38. <span v-if="scope.row.displayformatType === 'center'">居中</span>
  39. <span v-if="scope.row.displayformatType === 'left'">靠左</span>
  40. <span v-if="scope.row.displayformatType === 'right'">靠右</span>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. </div>
  45. <!--表单渲染-->
  46. <eForm ref="cuform" @refresh="initData" />
  47. <!--排序对话框组件-->
  48. <sortDialog ref="sort" @refresh="initData" />
  49. <!--删除对话框组件-->
  50. <el-dialog class="tip-dialog" title="提示" :visible.sync="deleteVisible" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body>
  51. <div class="setting-dialog">
  52. <div class="tip-content">
  53. <p class="tipMsg">此操作将移除当前所选字段</p>
  54. <span>你是否还要继续?</span>
  55. </div>
  56. <div slot="footer" class="dialog-footer">
  57. <el-button type="text" @click="deleteVisible = false">取消</el-button>
  58. <el-button type="primary" @click.native="handleDelConfirm">确定</el-button>
  59. </div>
  60. </div>
  61. </el-dialog>
  62. </div>
  63. <!-- @selection-change="selectionChangeHandler" -->
  64. <el-table ref="table" :key="tableKey" v-loading="table.bottom.loading" :data="table.bottom.data" style="min-width: 100%;" height="300" class="nowrap-tab">
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column type="index" label="序号" width="55" align="center" />
  67. <el-table-column v-for="field in table.right.data" :key="field.id" :label="field.fieldCnName" :align="field.displayformatType" :width="field.displayLength" show-overflow-tooltip>
  68. <template slot-scope="scope">
  69. {{ scope.row[field.fieldName] }}
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. </div>
  74. </template>
  75. <script>
  76. import { FetchDocumentFieldManage } from '@/api/system/fileLibrary/fileLibrary'
  77. import { FetchInitArchivesView } from '@/api/archivesManage/archivesList'
  78. import { add } from '@/api/system/fileLibrary/listBrowsing'
  79. import eForm from './module/form'
  80. import sortDialog from './module/sortDialog'
  81. import Vue from 'vue'
  82. export default {
  83. components: { eForm, sortDialog },
  84. props: {
  85. selectedCategory: {
  86. type: Object,
  87. default: function() {
  88. return {}
  89. }
  90. }
  91. },
  92. data() {
  93. return {
  94. permission: {
  95. add: ['admin', 'listBrowsing:add'],
  96. edit: ['admin', 'listBrowsing:edit'],
  97. del: ['admin', 'listBrowsing:delete'],
  98. sort: ['admin', 'listBrowsing:sort']
  99. },
  100. deleteVisible: false,
  101. sortLoading: false,
  102. delAllLoading: false,
  103. tableKey: false, // 刷新下面预览表格用的:key
  104. table: {
  105. left: {
  106. data: [],
  107. Loading: false,
  108. selections: []
  109. },
  110. right: {
  111. data: [],
  112. Loading: false,
  113. selections: []
  114. },
  115. bottom: {
  116. data: [],
  117. Loading: false,
  118. selections: []
  119. }
  120. }
  121. }
  122. },
  123. watch: {
  124. selectedCategory: function(newValue, oldValue) {
  125. this.initData()
  126. }
  127. },
  128. mounted() {
  129. this.initData()
  130. },
  131. methods: {
  132. initData() {
  133. this.getDisplayFieldData()
  134. this.getBottomTableData()
  135. },
  136. getDisplayFieldData() {
  137. FetchDocumentFieldManage({ documentId: this.selectedCategory.id, isType: 2 }).then((res) => {
  138. this.table.right.data.splice(0, this.table.right.data.length)
  139. this.table.left.data.splice(0, this.table.left.data.length)
  140. res.sort((item1, item2) => { return item1.displayOrder - item2.displayOrder }).forEach((item) => {
  141. if (item.isInput) {
  142. if (item.isDisplay) {
  143. this.table.right.data.push(item)
  144. } else {
  145. this.table.left.data.push(item)
  146. }
  147. }
  148. })
  149. this.tableKey = !this.tableKey
  150. })
  151. },
  152. getBottomTableData() {
  153. FetchInitArchivesView({ documentId: this.selectedCategory.id, isdel: false, page: 0, size: 10 }).then((res) => {
  154. this.table.bottom.data.splice(0, this.table.bottom.data.length)
  155. if (res && res.list) {
  156. res.list.content.forEach((item) => {
  157. this.table.bottom.data.push(item)
  158. })
  159. }
  160. })
  161. },
  162. clickRowHandler(row, column, e, tableName) {
  163. this.$refs[tableName].toggleRowSelection(row)
  164. },
  165. selectionChangeHandler(val, tableName) {
  166. this.table[tableName].selections = val
  167. },
  168. toAdd() {
  169. const maxDisplayOrder = this.table.right.data.reduce((prev, cur) => { return { displayOrder: Math.max(prev.displayOrder, cur.displayOrder) } }, { displayOrder: 0 }).displayOrder + 1
  170. this.table.left.selections.forEach((item, index) => {
  171. Vue.set(item, 'displayLength', 100)
  172. Vue.set(item, 'displayformatType', 'center')
  173. Vue.set(item, 'displayOrder', maxDisplayOrder + index)
  174. item.isDisplay = true
  175. })
  176. this.$refs.cuform.title = '新增列表显示列'
  177. Vue.set(this.$refs.cuform.formData, 'fields', JSON.parse(JSON.stringify(this.table.left.selections)))
  178. this.$refs.cuform.cuDialogVisible = true
  179. },
  180. toEdit() {
  181. this.$refs.cuform.title = '编辑列表显示列'
  182. Vue.set(this.$refs.cuform.formData, 'fields', JSON.parse(JSON.stringify(this.table.right.selections)))
  183. this.$refs.cuform.cuDialogVisible = true
  184. },
  185. toDelete() {
  186. this.deleteVisible = true
  187. },
  188. handleDelConfirm() {
  189. this.deleteVisible = false
  190. this.delAllLoading = true
  191. const deleteData = this.table.right.selections.map((item) => {
  192. item.isDisplay = false
  193. item.displayformatType = null
  194. item.displayLength = null
  195. item.displayOrder = null
  196. return item
  197. })
  198. add(deleteData).then((res) => {
  199. this.delAllLoading = false
  200. this.$message({
  201. message: '删除成功',
  202. type: 'success',
  203. duration: 2500
  204. })
  205. this.getDisplayFieldData()
  206. })
  207. },
  208. toSort() {
  209. this.$refs.sort.sortTableData = JSON.parse(JSON.stringify(this.table.right.data))
  210. this.$refs.sort.sortVisible = true
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. // ::v-deep div.el-dialog__footer {
  217. // text-align: center;
  218. // }
  219. // ::v-deep .el-table tr .el-table__cell {
  220. // height: 40px;
  221. // }
  222. // ::v-deep .nowrap-tab .el-table__header .cell {
  223. // text-overflow: unset !important;
  224. // white-space: nowrap !important;
  225. // }
  226. </style>