Files
laws_weilai/jero-web/src/views/projectManagement/components/TaskParameterCollection.vue
T
2022-06-27 14:13:29 +08:00

500 lines
15 KiB
Java

<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery" >
<a-row :gutter="24" class='add-padding'>
<a-col :md="7" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('title')">
<span>{{$t('title')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('PleaseEnter')+$t('title')"
v-model="queryParam.title"></a-input>
</div>
</a-col>
<span style="float: right;overflow: hidden;margin-right: 11px" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button class="box-button" type="primary" @click="searchQuery">{{$t('query')}}</a-button>
<a-button class="box-button" style="margin-left: 8px" @click="searchReset">{{$t('reset')}}</a-button>
</a-col>
</span>
</a-row>
</a-form>
</div>
<div class="table-operator">
<div @click="handleAdd" class="operator-text">
<a-icon type="plus"/>
{{$t('add')}}{{ $t('detailedList') }}
</div>
<div @click="handleModule" class="operator-text">
<a-icon type="bulb"/>
{{$t('changeExtension')}}
</div>
<div @click="handleCody" class="operator-text">
<a-icon type="copy"/>
{{$t('copy')}}{{$t('parameter')}}{{ $t('detailedList') }}
</div>
<div @click="handleDel" class="operator-text" v-has="'document:deleteBatch'">
<a-icon type="delete"/>
{{$t('BatchDelete')}}
</div>
</div>
<div style="width: 100%">
<a-table
class='table-area'
ref='table'
size='middle'
rowKey='id'
:columns='columns'
:dataSource='dataSource'
:pagination='false'
:loading='loading'
:scroll='{x: 600}'
:rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
@change='handleTableChange'>
<span slot="paramsManifestClick" slot-scope="text,record">
<a @click="paramsManifestClick(record)">{{text}}</a>
</span>
<span slot="operation" slot-scope="text,record">
<a class="text-operation" @click="configure(record)">{{$t('configure')}}</a>
<a class="text-operation" @click="edit(record)">{{$t('edit')}}</a>
<a class="text-operation" @click="deleteLib(record)">{{$t('deleteLib')}}</a>
<a class="text-operation" @click="historicalVersion(record)">{{$t('historicalVersion')}}</a>
</span>
</a-table>
</div>
<div class="page">
<a-pagination
:show-total="total => $t('total')+` ${total} `+$t('strip')"
show-quick-jumper
show-size-changer
:page-size.sync="pageSize"
:total="total"
@change="pageOnChange"
@showSizeChange="SizeChange"
/>
</div>
<!-- 参数模板-->
<a-modal v-model="areaVisible" :title="$t('parameterTemplate')" width='750px' :footer="null">
<parameter-template-add :url='url' ref='templateRef' v-if='areaVisible' @areaVisible='handleCancel' :version='version'
:projectId='this.$route.query.id'></parameter-template-add>
</a-modal>
<!-- 配置-->
<configure ref="configureRef" :url='url' :itemId='itemId' :itemRow='itemRow'/>
<!-- 历史版本-->
<a-modal v-model="historicalVisible" :title="$t('historicalVersion')" width='750px' :footer="null">
<historical-version v-if='historicalVisible' :historicalRow='historicalRow'></historical-version>
</a-modal>
<!-- 复制参数模板-->
<a-modal class="show-drawer" :title="$t('Copyparameterlist')" width="700px" v-model="drawerVisible" :footer="null">
<project-collection-parameters v-if='drawerVisible' @areaVisible='drawerhandleCancel' :templateTitle='templatetitle' @copysubmit='copysubmit'
:selectedRowKeyS='selectedRowKeys' :rowId='rowId' :version='version' :url='url'
:projectId='this.$route.query.id'></project-collection-parameters>
</a-modal>
</a-card>
</template>
<script>
import ImportFile from '@/components/ImportFile/index'
import ParameterTemplateAdd from '../dialog/ParameterTemplateAdd'
import ProjectCollectionParameters from '../dialog/ProjectCollectionParameters'
import HistoricalVersion from '../dialog/historicalVersion'
import { getAction, postAction } from '../../../api/manage'
import Configure from '../dialog/configure'
import axios from 'axios'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
name: 'TaskParameterCollection',
components: {
ImportFile,
ParameterTemplateAdd,
Configure,
HistoricalVersion,
ProjectCollectionParameters
},
data() {
return {
columns: [
{
title: this.$t('title'),
align: 'center',
dataIndex: 'title',
scopedSlots: { customRender: 'paramsManifestClick' }
},
{
title: this.$t('status'),
align: 'center',
dataIndex: 'state'
},
{
title: this.$t('parameterTemplateName'),
align: 'center',
dataIndex: 'paramsTemplateName'
},
{
title: this.$t('collectionCompletionTime'),
align: 'center',
dataIndex: 'finishTime'
},
{
title: this.$t('Version'),
align: 'center',
dataIndex: 'version'
},
{
title: this.$t('creator'),
align: 'center',
dataIndex: 'createBy'
},
{
title: this.$t('createTime'),
align: 'center',
dataIndex: 'createTime'
},
{
title: this.$t('operation'),
align: 'center',
fixed: 'right',
width: 310,
scopedSlots: { customRender: 'operation' }
}
],
token: Vue.ls.get(ACCESS_TOKEN),
selectedRowKeys: [],
queryParam: {},
url: {
list: 'params/manifest/page',
add: 'params/manifest/add',
edit: 'params/manifest/edit',
queryById: 'params/manifest/queryById',
deleteBatch: 'params/manifest/delete',
deleteAll: 'params/manifest/deleteBatch',
conAdd: 'params/config/addBatch',
conList: 'params/config/list',
changeExtension:'params/manifest/changeExtension'
},
loading: false,
dataSource: [],
areaVisible: false, // 弹框的控制
configureareaVisible: false, // 配置的彈框
pageNo: 1,
pageSize: 10,
total: 0,
selectedRowKeysArray: '',
templatetitle: '',
templatetitleId: '',
rowId: '',
version: 0,
itemId: '', // 配置id
itemRow: {}, // 配置一行数据
historicalVisible: false,
historicalRow: {}, // 历史版本得数据
drawerVisible: false,
drawerVisibleitem: false,
titleTag: '',
selectedRowKeysvalArray: [],
}
},
mounted() {
this.getlist()
},
methods: {
paramsManifestClick(item) {
localStorage.setItem('paramsManifest', JSON.stringify(item))
let newUrl = this.$router.resolve({
path: '/ParameterItemCollection',
query: item,
})
window.open(newUrl.href, '_blank')
},
deleteLib(val) {
if(val.state === '已完成' || val.state === 'Finished' ) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmDelete'),
onOk() {
getAction(_this.url.deleteBatch, { id: val.id }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getlist()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
} else {
this.$message.warning(this.$t('thisbuttonCompleted'))
}
},
handleTableChange() {
},
// 历史版本
historicalVersion(historicalRow) {
this.historicalVisible = true
this.historicalRow = historicalRow
},
// 配置
configure(item) {
this.itemId = item.id
this.itemRow = item
this.$refs.configureRef.addModel(item.id)
},
handleCancel(val) {
this.areaVisible = val
this.getlist()
},
// 项目收集参数
drawerhandleCancel(val) {
this.drawerVisible = val
},
copysubmit() {
this.drawerVisible = false
this.getlist()
},
searchQuery() {
this.pageNo = 1
this.getlist()
},
searchReset() {
this.queryParam = {}
this.pageNo = 1
this.getlist()
},
onSelectChange(val,valArray) {
this.selectedRowKeys = val
this.selectedRowKeysArray = val.join(',')
this.selectedRowKeysvalArray = valArray
},
edit(edit) {
this.areaVisible = true
setTimeout(() => {
this.$refs.templateRef.editData(edit)
},50)
},
handleAdd() {
this.areaVisible = true
},
// 变更扩展
handleModule() {
let _this = this
if(this.selectedRowKeys.length == 0){
this.$message.warning(_this.$t('pleaseSelectData'))
}else if(this.selectedRowKeys.length > 1){
this.$message.warning(_this.$t('OnlyOneSelected'))
} else if(this.selectedRowKeysvalArray[0].state === '已完成'|| this.selectedRowKeysvalArray[0].state ==='Finished'){
getAction(_this.url.changeExtension, { id: this.selectedRowKeys[0] }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getlist()
} else {
_this.$message.warning(res.message)
this.selectedRowKeys = []
}
})
} else {
this.$message.warning(_this.$t('thisbuttonCompleted'))
}
},
handleDel() {
// 默认为0 可全部删除
let flag = 1
this.selectedRowKeysvalArray.forEach((item) => {
if(item.state !== '已完成' && val.state !== 'Finished' ){
flag = 0
}
})
if(flag) {
let param = {
ids: this.selectedRowKeysArray
}
if (this.selectedRowKeys.length > 0) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmBatchDeletion'),
onOk() {
postAction(_this.url.deleteAll, param).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getlist()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
} else {
this.$message.warning(this.$t('thisbuttonCompleted'))
}
},
handleCody() {
this.drawerVisible = true
},
pageOnChange(page, pageSize) {
this.pageNo = page
this.getlist()
},
SizeChange(page, pageSize) {
this.pageNo = 1
this.pageSize = pageSize
this.getlist()
},
getlist() {
let query = {
projectId: this.$route.query.id,
pageSize: this.pageSize,
pageNo: this.pageNo,
...this.queryParam
}
getAction(this.url.list, query).then((res) => {
if (res.success) {
if (res.result.current > 1 && res.result.records.length == 0) {
this.pageNo = res.result.current - 1
this.getlist()
return
}
this.total = res.result.total
this.dataSource = res.result.records || []
this.loading = false
} else {
this.loading = false
}
})
}
}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.doc-detail {
background: #fff;
height: 100%;
.Virtual-detail-header {
width: 100%;
height: 68px;
line-height: 68px;
padding: 0 32px 0 32px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
border-bottom: 2px #eff1f3 solid;
background: #fff;
.Virtual-detail-title {
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
font-size: 20px;
font-weight: 400;
color: #040B29;
line-height: 68px;
}
.doc-detail-right {
width: 800px;
line-height: 68px;
display: flex;
}
}
.Virtual-detail-content {
padding: 0 38px 0 38px;
box-sizing: border-box;
font-size: 16px;
.box-title-text-add {
line-height: 1.4;
}
.title-text-add {
display: inline-block;
font-weight: 500;
margin-right: 16px;
height: 42px;
line-height: 42px;
}
}
}
.header-text {
font-size: 16px;
font-weight: 400;
height: 60px;
color: #000F16;
line-height: 40px;
}
.box-title-text {
line-height: 1.4;
display: flex;
align-items: center;
margin-bottom: 10px;
}
.title-text {
width: 20%;
min-width: 110px;
color: #000F16;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
margin-top: 3px;
text-align: right;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.box-input {
display: inline-block;
width: 70%;
height: 38px;
margin-top: 2px;
}
.box-button {
height: 38px;
}
.text-operation {
margin-right: 8px;
}
.page {
text-align: right;
margin-top: 20px;
}
.operator-text-left {
font-size: 14px;
margin-right: 20px;
background: #eff1f3;
padding: 8px 8px;
cursor: pointer;
border-radius: 4px;
}
/deep/.add-padding{
margin-left: -89px!important;
}
</style>
<style>
.box-input .ant-select-selection {
height: 38px !important;
}
.box-input .ant-select-selection__rendered {
line-height: 38px;
}
</style>