|
|
@@ -217,7 +217,6 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import emitter from '@/plugins/element-ui/src/mixins/emitter'
|
|
|
-import { valueEquals } from '@/plugins/element-ui/src/utils/util'
|
|
|
import { nestedFieldTypes } from '@/business/platform/form/constants/fieldTypes'
|
|
|
import FormOptions from '../../constants/formOptions'
|
|
|
import ActionUtils from '@/utils/action'
|
|
|
@@ -232,6 +231,7 @@ import FormrenderDialog from '@/business/platform/form/formrender/dialog'
|
|
|
import ImportTable from './components/import-table'
|
|
|
import IbpsExport from '@/plugins/export'
|
|
|
import IbpsImport from '@/plugins/import'
|
|
|
+import sortableJs from '@/mixins/sortable'
|
|
|
|
|
|
const JForm = window.JForm
|
|
|
// 获取子表展示数据
|
|
|
@@ -246,7 +246,7 @@ export default {
|
|
|
CustomDialog,
|
|
|
ImportTable
|
|
|
},
|
|
|
- mixins: [emitter],
|
|
|
+ mixins: [emitter, sortableJs],
|
|
|
props: {
|
|
|
value: [Array, Object, String], // 值
|
|
|
formData: [Array, Object], // 表单数据
|
|
|
@@ -315,6 +315,7 @@ export default {
|
|
|
|
|
|
formEditVisible: false,
|
|
|
formDialogVisible: false,
|
|
|
+ subDefaultFormData: {},
|
|
|
dialogFormDef: {},
|
|
|
dialogFormData: {},
|
|
|
dialogFormIndex: -1,
|
|
|
@@ -326,7 +327,8 @@ export default {
|
|
|
oldList: [], // 子表旧数据
|
|
|
importList: [],
|
|
|
importValue: null,
|
|
|
- actionButton: null
|
|
|
+ actionButton: null,
|
|
|
+ sortFlag: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -421,6 +423,9 @@ export default {
|
|
|
tableReadonly () {
|
|
|
return this.readonlyRights ? true : this.tableRights === FormOptions.t.PERMISSIONS.READ
|
|
|
},
|
|
|
+ canSortable () {
|
|
|
+ return !this.tableReadonly && this.fieldOptions.sortable === 'Y'
|
|
|
+ },
|
|
|
tableHidden () {
|
|
|
return this.tableRights === FormOptions.t.PERMISSIONS.HIDE
|
|
|
},
|
|
|
@@ -535,8 +540,22 @@ export default {
|
|
|
},
|
|
|
mounted () {
|
|
|
this.handleRefreshTable()
|
|
|
+ this.canSortable && this.initSortable()
|
|
|
},
|
|
|
methods: {
|
|
|
+ sortableEnd (evt) {
|
|
|
+ const { oldIndex, newIndex } = evt
|
|
|
+ // 处理数据交换
|
|
|
+ const tem = JSON.parse(JSON.stringify(this.copDataModel))
|
|
|
+ const currRow = tem.splice(oldIndex, 1)[0]
|
|
|
+ const num = new Date().getTime()
|
|
|
+ tem.splice(newIndex, 0, currRow)
|
|
|
+ tem.forEach((t, index) => {
|
|
|
+ t.tenantId = num + index
|
|
|
+ })
|
|
|
+ this.sortFlag = true
|
|
|
+ this.$emit('update:value', tem)
|
|
|
+ },
|
|
|
handleRefreshTable () {
|
|
|
this.$nextTick(() => {
|
|
|
if (this.$refs.elTable) {
|
|
|
@@ -556,23 +575,53 @@ export default {
|
|
|
this.$emit('change-data', key, val)
|
|
|
},
|
|
|
handlePagination (val) {
|
|
|
- this.totalCount = val.length
|
|
|
+ // this.totalCount = val.length
|
|
|
// 限制最小页数为1
|
|
|
- const pageCount = Math.ceil(this.totalCount / this.pageSize) || 1
|
|
|
+ // const pageCount = Math.ceil(this.totalCount / this.pageSize) || 1
|
|
|
// 逻辑:删除后当前页大于总页数,替换为总页数,否则留在当前页
|
|
|
- if (this.editFromType === 'add') {
|
|
|
+ // if (this.editFromType === 'add') {
|
|
|
// 新增按钮逻辑:前往最后一页
|
|
|
- this.currentPage = pageCount
|
|
|
- } else if (this.editFromType === 'import') {
|
|
|
+ // this.currentPage = pageCount
|
|
|
+ // } else if (this.editFromType === 'import') {
|
|
|
// 导入定位到第一页
|
|
|
- this.currentPage = 1
|
|
|
- } else {
|
|
|
+ // this.currentPage = 1
|
|
|
+ // } else {
|
|
|
// 其余逻辑(编辑、删除、整表赋值):操作后当前页大于总页数,替换为总页数,否则留在当前页
|
|
|
- this.currentPage = this.currentPage > pageCount ? pageCount : this.currentPage
|
|
|
+ // this.currentPage = this.currentPage > pageCount ? pageCount : this.currentPage
|
|
|
+ // }
|
|
|
+ // this.copDataModel = this.getShowData(val, this.currentPage, this.pageSize)
|
|
|
+ // this.editFromType = ''
|
|
|
+ // this.$emit('update:value', val)
|
|
|
+ if (this.canSortable && this.sortFlag) {
|
|
|
+ this.copDataModel = []
|
|
|
+ this.sortFlag = false
|
|
|
}
|
|
|
- this.copDataModel = this.getShowData(val, this.currentPage, this.pageSize)
|
|
|
- this.editFromType = ''
|
|
|
- this.$emit('update:value', val)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.totalCount = val.length
|
|
|
+ // 限制最小页数为1
|
|
|
+ const pageCount = Math.ceil(this.totalCount / this.pageSize) || 1
|
|
|
+ // 逻辑:删除后当前页大于总页数,替换为总页数,否则留在当前页
|
|
|
+ if (this.editFromType === 'add') {
|
|
|
+ // 新增按钮逻辑:前往最后一页
|
|
|
+ this.currentPage = pageCount
|
|
|
+ } else if (this.editFromType === 'import') {
|
|
|
+ // 导入定位到第一页
|
|
|
+ this.currentPage = 1
|
|
|
+ } else {
|
|
|
+ // 其余逻辑(编辑、删除、整表赋值):操作后当前页大于总页数,替换为总页数,否则留在当前页
|
|
|
+ this.currentPage =
|
|
|
+ this.currentPage > pageCount ? pageCount : this.currentPage
|
|
|
+ }
|
|
|
+
|
|
|
+ this.copDataModel = this.getShowData(
|
|
|
+ val,
|
|
|
+ this.currentPage,
|
|
|
+ this.pageSize
|
|
|
+ )
|
|
|
+ this.editFromType = ''
|
|
|
+ })
|
|
|
+
|
|
|
+ // this.$emit('update:value', val)
|
|
|
},
|
|
|
// 处理切换分页
|
|
|
handleCurrentChange (val) {
|
|
|
@@ -1086,7 +1135,8 @@ export default {
|
|
|
},
|
|
|
// =====================对话框模式数据处理 金源信通改=====================
|
|
|
handleDialogMode (index) {
|
|
|
- const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
|
|
|
+ // const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
|
|
|
+ const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : this.subDefaultFormData
|
|
|
this.dialogFormData = {
|
|
|
responses: JSON.parse(JSON.stringify(data)),
|
|
|
// 表单字段权限
|
|
|
@@ -1246,6 +1296,9 @@ export default {
|
|
|
},
|
|
|
// 后置脚本
|
|
|
afterScript (action, position, params, callback) {
|
|
|
+ // 刷新拖拽表格排序实例
|
|
|
+ this.canSortable && this.refreshSortable()
|
|
|
+ this.$emit('update:value', this.dataModel)
|
|
|
if (!this.hasScript()) {
|
|
|
if (callback) {
|
|
|
const flag = true
|