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

176 lines
6.5 KiB

2 years ago
2 years ago
  1. <template>
  2. <div class="format-main">
  3. <div class="format-main-left">
  4. <div class="head-container">
  5. <el-button v-permission="permission.add" size="mini" icon="el-icon-plus" :disabled="table.left.selections.length == 0" @click="toAdd(table.left.selections)">
  6. 插入
  7. </el-button>
  8. </div>
  9. <!--表格渲染-->
  10. <el-table ref="leftTable" v-loading="table.left.loading" :data="table.left.data" style="width: 400px;" height="calc(100vh - 302px)" @selection-change="(val)=>selectionChangeHandler(val,'left')" @row-click="(row,column,e)=>clickRowHandler(row,column,e,'leftTable')">
  11. <el-table-column type="selection" width="55" align="center" />
  12. <el-table-column type="index" label="序号" width="55" align="center" />
  13. <el-table-column prop="fieldCnName" label="字段名称" align="center" />
  14. </el-table>
  15. <!--表单渲染-->
  16. <eForm />
  17. </div>
  18. <div class="format-main-right">
  19. <div class="head-container">
  20. <!-- type="danger" -->
  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. <el-button v-permission="permission.sort" icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="table.right.data <= 1" @click="toSort">排序</el-button>
  28. </div>
  29. <!--表格渲染-->
  30. <el-table ref="rightTable" v-loading="table.right.loading" :data="table.right.data" style="min-width: 100%;" height="calc(100vh - 302px)" @selection-change="(val)=>selectionChangeHandler(val,'right')" @row-click="(row,column,e)=>clickRowHandler(row,column,e,'rightTable')">
  31. <el-table-column type="selection" width="55" align="center" />
  32. <el-table-column type="index" label="序号" width="55" align="center" />
  33. <el-table-column prop="fieldCnName" label="组成字段" align="center" />
  34. <el-table-column prop="connector" label="组成符号" align="center" />
  35. </el-table>
  36. <!--表单渲染-->
  37. <eForm ref="cuform" @refresh="initData" />
  38. </div>
  39. <!--排序对话框组件-->
  40. <sortDialog ref="sort" @refresh="initData" />
  41. <!--删除对话框组件-->
  42. <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="deleteVisible">
  43. <div class="setting-dialog">
  44. <div class="tip-content">
  45. <p class="tipMsg">此操作将移除当前所选字段</p>
  46. <span>你是否还要继续?</span>
  47. </div>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="text" @click="deleteVisible = false">取消</el-button>
  50. <el-button type="primary" @click.native="handleDelConfirm">确定</el-button>
  51. </div>
  52. </div>
  53. </el-dialog>
  54. </div>
  55. </template>
  56. <script>
  57. import { FetchInitCategoryField } from '@/api/system/category/category'
  58. import { getNoFormatField, del } from '@/api/system/category/fileNoFormat'
  59. import eForm from './module/form'
  60. import sortDialog from './module/sortDialog'
  61. import Vue from 'vue'
  62. export default {
  63. components: { eForm, sortDialog },
  64. props: {
  65. selectedCategory: {
  66. type: Object,
  67. default: function() {
  68. return {}
  69. }
  70. }
  71. },
  72. data() {
  73. return {
  74. permission: {
  75. add: ['admin', 'fileNoFormat:add'],
  76. edit: ['admin', 'fileNoFormat:edit'],
  77. del: ['admin', 'fileNoFormat:delete'],
  78. sort: ['admin', 'fileNoFormat:sort']
  79. },
  80. deleteVisible: false,
  81. sortLoading: false,
  82. delAllLoading: false,
  83. table: {
  84. left: {
  85. data: [],
  86. Loading: false,
  87. selections: []
  88. },
  89. right: {
  90. data: [],
  91. Loading: false,
  92. selections: []
  93. }
  94. }
  95. }
  96. },
  97. watch: {
  98. selectedCategory: function(newValue, oldValue) {
  99. this.initData()
  100. }
  101. },
  102. created() {
  103. this.initData()
  104. },
  105. methods: {
  106. initData() {
  107. FetchInitCategoryField({ categoryId: this.selectedCategory.id, isType: 2 }).then((res) => {
  108. this.table.left.data.splice(0, this.table.left.data.length)
  109. res.forEach((item) => {
  110. if (!item.isDisplayformat && item.isInput && !item.isAutomatic) {
  111. this.table.left.data.push(item)
  112. }
  113. })
  114. })
  115. getNoFormatField({ categoryId: this.selectedCategory.id }).then((res) => {
  116. this.table.right.data.splice(0, this.table.right.data.length)
  117. res.forEach((item) => {
  118. this.table.right.data.push(item)
  119. })
  120. })
  121. },
  122. clickRowHandler(row, column, e, tableName) {
  123. this.$refs[tableName].toggleRowSelection(row)
  124. },
  125. selectionChangeHandler(val, tableName) {
  126. this.table[tableName].selections = val
  127. },
  128. toAdd() {
  129. this.table.left.selections.forEach((item) => {
  130. Vue.set(item, 'connector', '-')
  131. Vue.set(item, 'categoryId', this.selectedCategory.id)
  132. })
  133. this.$refs.cuform.title = '新增档号规则'
  134. Vue.set(this.$refs.cuform.formData, 'fields', JSON.parse(JSON.stringify(this.table.left.selections)))
  135. this.$refs.cuform.cuDialogVisible = true
  136. },
  137. toEdit() {
  138. this.$refs.cuform.title = '编辑档号规则'
  139. Vue.set(this.$refs.cuform.formData, 'fields', JSON.parse(JSON.stringify(this.table.right.selections)))
  140. this.$refs.cuform.cuDialogVisible = true
  141. },
  142. toDelete() {
  143. this.deleteVisible = true
  144. },
  145. handleDelConfirm() {
  146. this.deleteVisible = false
  147. this.delAllLoading = true
  148. const deleteData = this.table.right.selections
  149. del(deleteData).then((res) => {
  150. this.delAllLoading = false
  151. this.$message({
  152. message: '删除成功',
  153. type: 'success',
  154. duration: 2500
  155. })
  156. this.initData()
  157. })
  158. },
  159. toSort() {
  160. this.$refs.sort.sortTableData = JSON.parse(JSON.stringify(this.table.right.data))
  161. this.$refs.sort.sortVisible = true
  162. }
  163. }
  164. }
  165. </script>
  166. <style rel="stylesheet/scss" lang="scss" scoped>
  167. // ::v-deep div.el-dialog__footer {
  168. // text-align: center;
  169. // }
  170. // ::v-deep .el-table tr .el-table__cell {
  171. // height: 40px;
  172. // }
  173. </style>