|
|
@@ -306,7 +306,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'
|
|
|
@@ -324,6 +323,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
|
|
|
// 获取子表展示数据
|
|
|
@@ -340,7 +340,7 @@ export default {
|
|
|
CustomDialog,
|
|
|
ImportTable
|
|
|
},
|
|
|
- mixins: [emitter],
|
|
|
+ mixins: [emitter, sortableJs],
|
|
|
props: {
|
|
|
value: [Array, Object, String], // 值
|
|
|
formData: [Array, Object], // 表单数据
|
|
|
@@ -406,22 +406,19 @@ export default {
|
|
|
actionPosition: 'toolbar',
|
|
|
handleCout: '',
|
|
|
dynamicShow: true,
|
|
|
-
|
|
|
customDialogVisible: false,
|
|
|
customDialogKey: '',
|
|
|
customDialogDynamicParams: {},
|
|
|
customDialogCustom: {},
|
|
|
-
|
|
|
formEditVisible: false,
|
|
|
formDialogVisible: false,
|
|
|
+ subDefaultFormData: {},
|
|
|
dialogFormDef: {},
|
|
|
dialogFormData: {},
|
|
|
dialogFormIndex: -1,
|
|
|
-
|
|
|
importTableDialogVisible: false,
|
|
|
dialogTemplate: null,
|
|
|
dialogTemplateAtts: {},
|
|
|
-
|
|
|
oldList: [], // 子表旧数据
|
|
|
importList: [],
|
|
|
importValue: null,
|
|
|
@@ -525,6 +522,9 @@ export default {
|
|
|
? true
|
|
|
: this.tableRights === FormOptions.t.PERMISSIONS.READ
|
|
|
},
|
|
|
+ canSortable() {
|
|
|
+ return !this.tableReadonly && this.fieldOptions.sortable === 'Y'
|
|
|
+ },
|
|
|
tableHidden() {
|
|
|
return this.tableRights === FormOptions.t.PERMISSIONS.HIDE
|
|
|
},
|
|
|
@@ -565,6 +565,7 @@ export default {
|
|
|
this.dataModel = []
|
|
|
return
|
|
|
}
|
|
|
+ // this.dataModel = []
|
|
|
this.dataModel = val
|
|
|
// if (!valueEquals(val, oldVal)) {
|
|
|
// this.dispatch('ElFormItem', 'el.form.change', val)
|
|
|
@@ -644,8 +645,17 @@ 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]
|
|
|
+ tem.splice(newIndex, 0, currRow)
|
|
|
+ this.$emit('update:value', tem)
|
|
|
+ },
|
|
|
handleRefreshTable() {
|
|
|
this.$nextTick(() => {
|
|
|
if (this.$refs.elTable) {
|
|
|
@@ -665,24 +675,33 @@ export default {
|
|
|
this.$emit('change-data', key, val)
|
|
|
},
|
|
|
handlePagination(val) {
|
|
|
- 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)
|
|
|
+ this.copDataModel = []
|
|
|
+ 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) {
|
|
|
@@ -1253,7 +1272,10 @@ export default {
|
|
|
},
|
|
|
// =====================对话框模式数据处理 金源信通改=====================
|
|
|
handleDialogMode(index) {
|
|
|
- const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
|
|
|
+ const data = this.$utils.isNotEmpty(index)
|
|
|
+ ? this.dataModel[index]
|
|
|
+ : // : this.subDefaultFormData
|
|
|
+ this.subDefaultFormData
|
|
|
this.dialogFormData = {
|
|
|
responses: JSON.parse(JSON.stringify(data)),
|
|
|
// 表单字段权限
|
|
|
@@ -1444,6 +1466,8 @@ export default {
|
|
|
},
|
|
|
// 后置脚本
|
|
|
afterScript(action, position, params, callback) {
|
|
|
+ // 刷新拖拽表格排序实例
|
|
|
+ this.canSortable && this.refreshSortable()
|
|
|
if (!this.hasScript()) {
|
|
|
if (callback) {
|
|
|
const flag = true
|