Browse Source

bug修复

master
xuhuajiao 3 months ago
parent
commit
21a96cb08e
  1. 84
      src/utils/dialog/drag.js
  2. 12
      src/utils/dialog/index.js
  3. 3
      src/views/archivesManage/managementLibrary/mixins/index.js
  4. 3
      src/views/collectReorganizi/collectionLibrary/mixins/index.js
  5. 5
      src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
  6. 15
      src/views/system/archivesCategory/fileNoFormat/index.vue
  7. 2
      src/views/system/archivesCategory/fileNoFormat/module/form.vue
  8. 16
      src/views/system/archivesCategory/listBrowsing/module/form.vue

84
src/utils/dialog/drag.js

@ -0,0 +1,84 @@
export default {
bind(el, binding, vnode) {
const dialogHeaderEl = el.querySelector('.el-dialog__header')
const dragDom = el.querySelector('.el-dialog')
dialogHeaderEl.style.cssText += ';cursor:move;'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const getStyle = (function() {
if (window.document.currentStyle) {
return (dom, attr) => dom.currentStyle[attr]
} else {
return (dom, attr) => getComputedStyle(dom, false)[attr]
}
})()
// 获取初始位置
let initLeft = getStyle(dragDom, 'left')
let initTop = getStyle(dragDom, 'top')
if (initLeft.includes('%')) {
initLeft = +document.body.clientWidth * (+initLeft.replace(/%/g, '') / 100)
} else {
initLeft = +initLeft.replace(/\px/g, '')
}
if (initTop.includes('%')) {
initTop = +document.body.clientHeight * (+initTop.replace(/%/g, '') / 100)
} else {
initTop = +initTop.replace(/\px/g, '')
}
// 考虑 transform 的影响
const transform = getStyle(dragDom, 'transform')
const match = transform.match(/translate\((-?\d+(\.\d+)?%)?, (-?\d+(\.\d+)?%)?\)/)
let translateX = 0
let translateY = 0
if (match) {
translateX = +document.body.clientWidth * (+match[1].replace(/%/g, '') / 100)
translateY = +document.body.clientHeight * (+match[3].replace(/%/g, '') / 100)
}
dialogHeaderEl.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = e.clientX - dialogHeaderEl.offsetLeft
const disY = e.clientY - dialogHeaderEl.offsetTop
const dragDomWidth = dragDom.offsetWidth
const dragDomHeight = dragDom.offsetHeight
const screenWidth = document.body.clientWidth
const screenHeight = document.body.clientHeight
// 计算边界
const minDragDomLeft = -initLeft - translateX
const maxDragDomLeft = screenWidth - initLeft - dragDomWidth - translateX
const minDragDomTop = -initTop - translateY
const maxDragDomTop = screenHeight - initTop - dragDomHeight - translateY
document.onmousemove = function(e) {
// 通过事件委托,计算移动的距离
let left = e.clientX - disX
let top = e.clientY - disY
// 边界处理
if (left < minDragDomLeft) {
left = minDragDomLeft
} else if (left > maxDragDomLeft) {
left = maxDragDomLeft
}
if (top < minDragDomTop) {
top = minDragDomTop
} else if (top > maxDragDomTop) {
top = maxDragDomTop
}
// 移动当前元素
dragDom.style.cssText += `;left:${left + initLeft + translateX}px;top:${top + initTop + translateY}px;`
// emit onDrag event
vnode.child.$emit('dragDialog')
}
document.onmouseup = function() {
document.onmousemove = null
document.onmouseup = null
}
}
}
}

12
src/utils/dialog/index.js

@ -0,0 +1,12 @@
import Vue from 'vue'
import drag from './drag'
const install = function(Vue) {
Vue.directive('el-drag-dialog', drag)
}
if (window.Vue) {
window['el-drag-dialog'] = drag
Vue.use(install)
}
drag.install = install
export default drag

3
src/views/archivesManage/managementLibrary/mixins/index.js

@ -135,7 +135,8 @@ export const manageLibraryCrud = {
'categoryId': this.selectedCategory.id,
'categoryLevel': categoryLevel,
'ignore': false,
'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
// 'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
'isdel': this.parentsData.isdel === true ? this.parentsData.isdel : false,
'checkTypes': this.selectStatus && this.selectStatus.length !== 0 ? this.selectStatus.join(',') : null,
'search': this.query.search,
'retention': this.smartQuery.retention,

3
src/views/collectReorganizi/collectionLibrary/mixins/index.js

@ -133,7 +133,8 @@ export const collectionLibraryCrud = {
'categoryId': this.selectedCategory.id,
'categoryLevel': categoryLevel,
'ignore': false,
'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
// 'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
'isdel': this.parentsData.isdel === true ? this.parentsData.isdel : false,
'search': this.query.search,
'retention': this.smartQuery.retention,
'security_class': this.smartQuery.security_class,

5
src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue

@ -138,6 +138,7 @@
</div>
<!--新增 / 编辑 表单组件-->
<!-- v-el-drag-dialog -->
<el-dialog :class="isAiAutoCategory ? 'preview-dialog ai-preview-dialog' :'preview-dialog'" :modal-append-to-body="false" :close-on-click-modal="false" append-to-body :before-close="handleClose" :visible="formVisible" :title="formTitle">
<span class="dialog-right-top" />
<span class="dialog-left-bottom" />
@ -355,9 +356,13 @@ import ArchivesFilling from './archivesFilling/index'
import qs from 'qs'
import { downloadFile, exportFile } from '@/utils/index'
import { mapGetters } from 'vuex'
import elDragDialog from '@/utils/dialog'
export default {
name: 'CollectHeader',
directives: {
elDragDialog
},
components: { Treeselect, PreviewForm, UploadOriginal, BigUpload, BlukImport, BlukEditing, FileSeqAdjustment, CombineFile, InsertFile, CollectMoveFile, Print, FourTest, QuickPaper, PackingBox, ArchivesFilling },
mixins: [collectionLibraryCrud, crud()],
props: {

15
src/views/system/archivesCategory/fileNoFormat/index.vue

@ -57,6 +57,7 @@
<script>
import { FetchCategoryFieldManage } from '@/api/system/category/category'
import { getNoFormatField, del } from '@/api/system/category/fileNoFormat'
import { order } from '@/api/system/category/fileNoFormat'
import eForm from './module/form'
import sortDialog from './module/sortDialog'
import Vue from 'vue'
@ -105,7 +106,7 @@ export default {
this.initData()
},
methods: {
initData() {
initData(type) {
FetchCategoryFieldManage({ categoryId: this.selectedCategory.id, isType: 2 }).then((res) => {
this.table.left.data.splice(0, this.table.left.data.length)
res.forEach((item) => {
@ -119,6 +120,18 @@ export default {
res.forEach((item) => {
this.table.right.data.push(item)
})
if (type === 'add') {
this.handleSort(this.table.right.data)
}
})
},
handleSort(sortTableData) {
sortTableData.forEach((item, index) => {
item.sequence = index + 1
})
order(sortTableData).then(() => {
this.$message({ message: '保存成功', type: 'success', offset: 8 })
this.$emit('refresh')
})
},
clickRowHandler(row, column, e, tableName) {

2
src/views/system/archivesCategory/fileNoFormat/module/form.vue

@ -51,7 +51,7 @@ export default {
this.$message({ message: '保存成功', type: 'success', offset: 8 })
this.cuDialogVisible = false
this.loading = false
this.$emit('refresh')
this.$emit('refresh', 'add')
})
} else {
edit(this.formData.fields).then((res) => {

16
src/views/system/archivesCategory/listBrowsing/module/form.vue

@ -31,7 +31,7 @@
</template>
<script>
import { add, edit } from '@/api/system/category/listBrowsing'
import { add, edit, order } from '@/api/system/category/listBrowsing'
export default {
data() {
return {
@ -57,15 +57,17 @@ export default {
},
methods: {
save() {
console.log('this.formData.fields', this.formData.fields)
this.$refs['formData'].validate((valid) => {
if (valid) {
this.loading = true
if (this.title === '新增字段') {
if (this.title === '新增列表显示列') {
add(this.formData.fields).then((res) => {
this.$message({ message: '保存成功', type: 'success', offset: 8 })
// this.$message({ message: '', type: 'success', offset: 8 })
this.cuDialogVisible = false
this.loading = false
this.$emit('refresh')
// this.$emit('refresh')
this.handleSort(this.formData.fields)
})
} else {
edit(this.formData.fields).then((res) => {
@ -79,6 +81,12 @@ export default {
return false
}
})
},
handleSort(sortTableData) {
order(sortTableData).then(() => {
this.$message({ message: '保存成功', type: 'success', offset: 8 })
this.$emit('refresh')
})
}
}
}

Loading…
Cancel
Save