Commit bff8e6c5 authored by ztf's avatar ztf

科研计划中的自定义组件

parent c8eb54f9
<template>
<div>
<dee-as-com
:lay-config="{
typeName: 'ExtDistributeRecord',
layKey: 'DistributeRecordLists'
}"
/>
</div>
</template>
<script >
export default {
name: 'DistributeRecord',
componentName: '分发记录'
}
</script>
<style lang="scss" scoped>
</style>
<template>
<span>
<el-button v-show="showAdd" type="text" @click.stop="btnClick">添加文件</el-button>
<el-dropdown>
<span class="el-dropdown-link">
<el-button v-show="files.length" type="text">{{ `查看(${files.length})` }}</el-button>
</span>
<el-dropdown-menu slot="dropdown" class="ExtReviewDocComLink-updateflie">
<el-dropdown-item v-for="(file,index) in files" :key="index">
<div class="file-row">
<span class="file-name" :title="file.originalFileName" @click="downloadFile(file)">
{{ file.originalFileName }}
</span>
</div></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</template>
<script>
import _get from 'lodash.get'
import { downFileByFileCode, downFileByFileId } from '@/api/file'
export default {
name: 'MuxDownloadFiles',
componentName: '多文件下载',
props: {
scope: {
type: Object,
default: null
},
filterKey: {
type: String,
default: () => ''
},
showAdd: {
type: Boolean,
default: false
}
},
data() {
return {}
},
computed: {
files() {
if (!this.scope || !this.scope.row || !this.scope.column) {
return []
}
let objFileLinks = _get(this.scope.row, this.scope.column.property)
if (!objFileLinks) {
return []
}
if (this.filterKey) {
objFileLinks = objFileLinks.filter(link => this.filterKey.includes(link.contentType))
}
return objFileLinks.map(link => link.target)
}
},
watch: {},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {},
methods: {
removeFile(row) {
this.$emit('clickRowFun', this.scope, { btnvalue: 'removeFile', row: row })
},
btnClick() {
this.$emit('clickRowFun', this.scope, { btnvalue: 'addFiles' })
},
downloadFile(file) {
if (!file.fileCode && !file.resourceId) {
this.$utils.showMessageWarning('没有权限下载该文件!')
return
}
if (file.fileCode) {
downFileByFileCode(file.fileCode).then(res => {
this.downLoadFileUrl(res)
})
return
}
if (file.resourceId) {
downFileByFileId(file.resourceId).then(res => {
this.downLoadFileUrl(res)
})
}
},
downLoadFileUrl(res) {
if (res.headers['content-disposition']) {
const fileName = decodeURI(res.headers['content-disposition'].substring(res.headers['content-disposition'].indexOf('=') + 1, res.headers['content-disposition'].length))
const url = window.URL.createObjectURL(new Blob([res.data], { type: res.headers['content-type'] }))
this.$utils.downLoadFileUrl(url, decodeURI(fileName))
} else {
if (res.data instanceof Blob) {
var reader = new FileReader()
reader.addEventListener('loadend', () => {
const message = reader.result && JSON.parse(reader.result)
this.$utils.showMessageWarning(message ? message.message : '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
})
reader.readAsText(res.data, 'utf-8')
} else {
const message = res.data && res.data.message
this.$utils.showMessageWarning(message || '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
}
}
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
</style>
export function updateTableData(obj, table = 'tableData', type = 'input') {
obj[table].forEach(row => {
if (row.$row) {
delete row.$row
}
if (typeof row.permissions !== undefined) {
delete row.permissions
}
})
obj.$emit(type, obj[table].map(r => { return { ...r } }))
}
export function initTableData(obj, table = 'tableData', value = 'value') {
obj[table] = obj[value].map(r => { return { ...r } })
}
import { post } from '@/utils/http'
// 查询所有用户列表
export function getAllUsers(params) {
return post('/User/search', params)
}
<template>
<div class="dee-model">
<el-select
v-if="informativeUser"
v-model="cloneValue"
:disabled="disabled"
:read-only="readOnly"
:size="size"
:multiple="multiple"
placeholder="请选择"
>
<el-option
v-for="item in userListOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<DxUserSelect
v-else
:user="user"
:value="value"
:disabled="disabled"
:read-only="readOnly"
:is-remote="isRemote"
:size="size"
:input-attr="inputAttr"
:async-attr="asyncAttr"
:form="form"
:multiple="multiple"
@input="(val)=>{update(val)}"
/>
</div>
</template>
<script>
import { getAllUsers } from '@/api/user'
export default {
name: 'DistributeReceiveUser',
componentName: '人员选择',
props: {
user: {
type: [Number, String, Object],
default: ''
},
value: {
type: [Number, String, Object, Array],
default: ''
},
disabled: {
type: Boolean,
default: false
},
readOnly: {
type: Boolean,
default: false
},
isRemote: {
type: Boolean,
default: true
},
size: {
type: String,
default: () => ''
},
inputAttr: {
type: String,
default: () => ''
},
// eslint-disable-next-line vue/require-default-prop
asyncAttr: {
type: Object,
defalut: () => {}
},
// eslint-disable-next-line vue/require-default-prop
form: {
type: Object,
defalut: () => {}
},
multiple: {
type: Boolean,
default: false
},
basicData: {
type: Object,
default: () => {}
}
},
data() {
return {
userListOptions: [],
cloneValue: ''
}
},
computed: {
informativeUser() {
return this.form && this.form.informativeUser
}
},
watch: {
cloneValue() {
this.update(this.cloneValue)
},
informativeUser: {
immediate: true,
deep: true,
handler: function(val) {
val && this.initOptions()
}
}
},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {
console.log('basicData', this.basicData)
this.cloneValue = this.value
},
methods: {
initOptions() {
this.getAllUsers()
},
getAllUsers() {
const params = {
'pageFrom': 1,
'searchItems': {
'items': [
{
'fieldName': 'id',
'operator': 'IN',
'value': this.informativeUser
}
],
'operator': 'AND'
},
'pageSize': 9999
}
getAllUsers(params).then(res => {
if (res.items && res.items.content) {
this.userListOptions = res.items.content.map(n => {
return {
label: `${n.userName}(${n.userAccount})`,
value: n.id,
data: n
}
})
} else {
this.userListOptions = []
}
})
},
update(val) {
this.$emit('input', val)
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
</style>
<template>
<div class="dee-model foreign-unit-mode">
<div v-show="editState||value"><span>{{ value }}</span>
<el-button type="text" @click="showDialogFlag=true">{{ editState?'设置':'查看' }}</el-button>
</div>
<dee-dialog
:dialog-visible="showDialogFlag"
:title="editState?'外单位选择':'外单位查看'"
width="800px"
class="foreign-unit-dialog"
:dialog-bttons="editState?dialogBttons:[]"
@on-submit="submit"
@on-cancel="showDialogFlag=false"
@handleClose="showDialogFlag=false"
>
<div v-for="(units,index) in unitLists" :key="index" class="rows">
<div class="sub-title">
{{ units.title }}
</div>
<div class="checkbox">
<el-checkbox
v-for="(unit) in units.children"
:key="unit.key"
:checked="unit.checked"
:disabled="unit.disabled"
@change="(val)=>{unit.checked = val}"
>{{ unit.title }}</el-checkbox>
</div>
</div>
</dee-dialog>
</div>
</template>
<script>
export default {
name: 'InternalUnit',
componentName: '外单位选择或查看',
props: {
disabled: {
type: Boolean,
default: false
},
readOnly: {
type: Boolean,
default: false
},
value: {
type: [String, Object],
default: () => ''
}
},
data() {
return {
dictOptions: [],
dialogBttons: [{
type: 'submit',
text: '提交',
component: {
type: 'primary'
}
}, {
type: 'cancel',
text: '取消',
component: {}
}],
showDialogFlag: false,
checkedValue: []
}
},
computed: {
editState() {
return !this.disabled && !this.readOnly
},
serviceApi() {
return this.$getService('DictData', { versionControl: false }).baseQuery().orderByDesc('modifyTime')
},
unitLists() {
if (!this.dictOptions || this.dictOptions.length === 0) { return [] }
return this.setChecked(this.dictOptions, this.value)
}
},
watch: {},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {
this.init()
},
methods: {
init() {
this.serviceApi
.page(1, 1000)
.search({
data: {
items: [{
fieldName: 'dictCode',
operator: 'EQ',
value: 'ExternalParties'
}, {
fieldName: 'dictState',
operator: 'EQ',
value: 'ENABLE'
}],
operator: 'AND'
}
}).then(res => {
this.dictOptions = res.content
})
},
submit() {
const checked = []
this.unitLists.forEach(items => {
if (items.children && items.children.length) {
items.children.forEach(unit => {
if (unit.checked) {
checked.push(unit.title)
}
})
}
})
this.$emit('input', checked.join())
this.showDialogFlag = false
},
setChecked(options, checkedStr) {
const checked = checkedStr ? checkedStr.split(',') : []
// 数据洗澡
const list = options.map(r => {
return {
title: r.dictValue,
key: r.dictKey,
parentKey: r.parentKey,
disabled: !this.editState,
checked: checked.includes(r.dictValue)
}
})
// 分类
const parent = list.filter(r => !r.parentKey)
parent.forEach(item => {
item.children = list.filter(r => r.parentKey === item.key)
})
return parent
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
.foreign-unit-dialog{
.rows{
margin-bottom: 20px;
}
.title-bar{
margin-bottom: 6px;
font-weight: 700;
&:before{
content: "";
width: 4px;
height: 13px;
-ms-flex-item-align: center;
align-self: center;
margin-right: 12px;
}
}
}
</style>
<template>
<div class="project-list">
项目列表
<dee-tools :tools="BtnTools" mode="normal" :collapse="false" :permissions="permissions" :perm-enable="true" />
<el-table
:data="tableData"
style="width: 100%; margin-bottom: 20px"
row-key="id"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="perIndex" label="序号" sortable />
<el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">
编辑
</el-button>
<img class="self-btn-icon" src="/icons/c-edit.png">
<el-button
size="small"
type="danger"
@click="handleStatusDLG(scope.$index, scope.row)"
>
改状态
</el-button>
</template>
</el-table-column>
<el-table-column prop="date" label="项目名称" show-overflow-tooltip />
<el-table-column prop="name" label="项目分类" show-overflow-tooltip />
<el-table-column prop="address" label="项目代号" show-overflow-tooltip />
<el-table-column prop="address" label="项目类型" show-overflow-tooltip />
<el-table-column prop="address" label="状态" />
<el-table-column prop="address" label="密级" />
</el-table>
<dee-dialog title="修改状态" :dialog-visible="dialogVisible" width="55%" @handleClose="dialogClose" />
</div>
</template>
<script>
export default {
name: 'ProjectList',
componentName: '项目列表',
data() {
const that = this
return {
BtnTools: [
{
name: '新增',
icon: '/icons/c-add.png',
key: 'add',
handler: {
click: () => {
// this.dialogTitle = '新增资源属性'
// this.dialogVisible = true
}
}
},
{
name: '移除',
icon: '/icons/c-remove.png',
key: 'remove',
handler: {
click: () => {
// this.dialogTitle = '新增资源属性'
// this.dialogVisible = true
this.remove()
}
}
}
],
tableData: [],
tableColums: [
{
title: '操作',
key: 'operate',
show: true,
name: 'EditTableRow',
props: {
btns: [
{
operation: '改状态',
handleClick: (row, index) => {
},
icon: '/icons/c-edit.png',
showFun: (row) => {
}
},
{
operation: '编辑',
handleClick: (row, index) => {
},
icon: '/icons/c-edit.png',
showFun: (row) => {
}
}
]
}
},
{
title: '项目名称',
key: 'name',
component: {
render: function(h, data) {
return <span class='link' v-on:click={() => {
that.jump(data)
}}>{data.name}</span>
}
}
},
{
title: '项目分类',
key: ''
},
{
title: '项目代号',
key: ''
},
{
title: '项目类型',
key: ''
},
{
title: '状态',
key: ''
},
{
title: '密级',
key: ''
}
],
optionsTree: {
fit: true,
// defaultExpandAll: true,
highlightCurrentRow: true,
rowKey: 'id'
},
selectedData: []
}
},
methods: {
jump(data) {
this.$router.push({
path: `/page/${data.pageNumber}/${data.id}/?id=${data.id}&title=${data.name}`,
query: { title: data.name + '详情', id: data.id }
})
},
handleSelectionChange(val) {
this.selectedData = val
},
remove() {
if (this.sectionData.length === 0) {
this.$message.error('请至少选择一条数据')
} else {
this.$confirm('确定要删除选中的数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// const caRecordLinks = []
// this.sectionData.forEach(v => {
// caRecordLinks.push({
// operator: 'REMOVE',
// id: v.id,
// target: {
// id: v.target.id,
// operator: 'REMOVE'
// }
// })
// })
// const params = {
// id: this.basicData.businessObject.id,
// operator: 'NO_CHANGE',
// caRecordLinks: caRecordLinks
// }
// batchCAData(params).then(del => {
// this.tableData = this.tableData.filter(t => {
// return !caRecordLinks.some(s => {
// return t.id === s.id
// })
// })
// const pageSize = this.pagination.pageSize
// this.pagination.total = this.tableData.length
// let maxPage = parseInt(this.pagination.total / pageSize)
// const mode = this.pagination.total % pageSize
// if (mode) {
// maxPage++
// }
// if (maxPage < this.pagination.currentPage) {
// this.pagination.currentPage = maxPage
// }
// this.$message.success('删除成功')
// }).catch(() => {
// this.$message.error('删除失败')
// })
}
).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
}
}
}
</script>
<style lang="scss" scoped>
.link{
color: #2A75CE;
cursor: pointer;
}
</style>
<template>
<div class="project-list">
项目列表
<dee-table
ref="projectTable"
:data="tableData"
:columns="tableColums"
:options="optionsTree"
selection-row
@selection-change="selectionChange"
>
<dee-tools slot="header" :tools="BtnTools" mode="normal" :collapse="false" :permissions="permissions" :perm-enable="true" />
</dee-table>
<dee-dialog title="修改状态" :dialog-visible="dialogVisible" width="55%" @handleClose="dialogClose" />
</div>
</template>
<script>
export default {
name: 'ProjectList',
componentName: '项目列表',
data() {
const that = this
return {
BtnTools: [
{
name: '新增',
icon: '/icons/c-add.png',
key: 'add',
handler: {
click: () => {
// this.dialogTitle = '新增资源属性'
// this.dialogVisible = true
}
}
},
{
name: '移除',
icon: '/icons/c-remove.png',
key: 'remove',
handler: {
click: () => {
// this.dialogTitle = '新增资源属性'
// this.dialogVisible = true
this.remove()
}
}
}
],
tableData: [],
tableColums: [
{
title: '序号',
key: 'perIndex'
},
{
title: '操作',
key: 'operate',
show: true,
name: 'EditTableRow',
props: {
btns: [
{
operation: '改状态',
handleClick: (row, index) => {
},
icon: '/icons/c-edit.png',
showFun: (row) => {
}
},
{
operation: '编辑',
handleClick: (row, index) => {
},
icon: '/icons/c-edit.png',
showFun: (row) => {
}
}
]
}
},
{
title: '项目名称',
key: 'name',
component: {
render: function(h, data) {
return <span class='link' v-on:click={() => {
that.jump(data)
}}>{data.name}</span>
}
}
},
{
title: '项目分类',
key: ''
},
{
title: '项目代号',
key: ''
},
{
title: '项目类型',
key: ''
},
{
title: '状态',
key: ''
},
{
title: '密级',
key: ''
}
],
optionsTree: {
fit: true,
// defaultExpandAll: true,
highlightCurrentRow: true,
rowKey: 'id'
},
selectedData: []
}
},
methods: {
jump(data) {
this.$router.push({
path: `/page/${data.pageNumber}/${data.id}/?id=${data.id}&title=${data.name}`,
query: { title: data.name + '详情', id: data.id }
})
},
selectionChange(val) {
this.selectedData = val
},
remove() {
if (this.sectionData.length === 0) {
this.$message.error('请至少选择一条数据')
} else {
this.$confirm('确定要删除选中的数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// const caRecordLinks = []
// this.sectionData.forEach(v => {
// caRecordLinks.push({
// operator: 'REMOVE',
// id: v.id,
// target: {
// id: v.target.id,
// operator: 'REMOVE'
// }
// })
// })
// const params = {
// id: this.basicData.businessObject.id,
// operator: 'NO_CHANGE',
// caRecordLinks: caRecordLinks
// }
// batchCAData(params).then(del => {
// this.tableData = this.tableData.filter(t => {
// return !caRecordLinks.some(s => {
// return t.id === s.id
// })
// })
// const pageSize = this.pagination.pageSize
// this.pagination.total = this.tableData.length
// let maxPage = parseInt(this.pagination.total / pageSize)
// const mode = this.pagination.total % pageSize
// if (mode) {
// maxPage++
// }
// if (maxPage < this.pagination.currentPage) {
// this.pagination.currentPage = maxPage
// }
// this.$message.success('删除成功')
// }).catch(() => {
// this.$message.error('删除失败')
// })
}
).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
}
}
}
</script>
<style lang="scss" scoped>
.link{
color: #2A75CE;
cursor: pointer;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment