Files
laws_weilai/jero-web/src/views/parameter/ParameterTemplate/index.vue
T

746 lines
23 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">
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('parameterTemplate')">
<span>{{$t('parameterTemplate')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('PleaseEnter')+$t('parameterTemplate')"
v-model="queryParam.paramsTemplateName"></a-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('zoneOfApplication')">
<span>{{$t('zoneOfApplication')}}</span>
</div>
<j-dict-select-tag class="box-input" v-model="queryParam.region"
:placeholder="$t('PleaseSelect')+$t('zoneOfApplication')"
:type="'select'"
:triggerChange="false" :dictCode="'region'"/>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('updated')">
<span>{{$t('updated')}}</span>
</div>
<a-range-picker class="box-input" v-model="updateTime"
@change="onChangeUpdateTime"></a-range-picker>
</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" @click="searchReset">{{$t('reset')}}</a-button>
<a-button class="box-button" style="margin-left: 8px" type="primary" @click="searchQuery">{{$t('query')}}</a-button>
</a-col>
</span>
</a-row>
</a-form>
</div>
<div class="table-operator">
<div @click="syncToListClick" class="operator-text" v-has="'params:template:syncToList'">
<a-icon type="plus"/>
{{$t('syncToList')}}
</div>
<div @click="handleAdd" class="operator-text" v-has="'params:template:add'">
<a-icon type="plus"/>
{{$t('newlyAdded')}}
</div>
<div @click="handlecody" class="operator-text" v-has="'params:template:copy'">
<a-icon type="copy"/>
{{$t('copy')}}
</div>
<div @click="handleDel" class="operator-text" v-has="'params:template:delete'">
<a-icon type="delete"/>
{{$t('BatchDelete')}}
</div>
</div>
<div>
<a-table
ref="table"
size="middle"
:loading="loading"
:pagination="false"
:components="drag(columns,'columns')"
:scroll="{x: '100%',y:'calc(100vh - 130px)'}"
rowKey="id"
:data-source="dataSource"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
@change="tableOnChange"
:columns="columns"
>
<span slot="projectName" slot-scope="text,record" :title="text">
<a @click="entryNameClick(record)">
{{ text }}
</a>
</span>
<span slot="titleName" slot-scope="text,record" :title="text">
{{ text && text.length > 50 ? text.slice(0, 49) + '...' : text }}
</span>
<span slot="operation" slot-scope="text,record">
<a class="text-operation" v-has="'params:template:setupMaintainer'"
@click="setupMaintainerClick(record)">{{$t('setupMaintainer')}}</a>
<a class="text-operation"
v-has="'params:template:subscribe'"
:disabled="record.authorityFlag == '1'? true : false"
@click="subscribeClick(record)">
{{!record.readFlag || record.readFlag == 0 ? $t('subscribe') : $t('CancelSubscribe')}}
</a>
<a class="text-operation"
:disabled="record.status == '1' || record.authorityFlag == '1'? true : false"
v-has="'params:template:edit'"
@click="edit(record)">{{$t('edit')}}</a>
<a class="text-operation"
v-has="'params:template:publish'"
:disabled="record.authorityFlag == '1'? true : false"
@click="withdrawOrRelease(record)">
{{record.status && record.status == '1'? $t('withdraw') : $t('release')}}
</a>
<a class="text-operation"
:disabled="record.status == '1' || record.authorityFlag == '1'? true : false"
v-has="'params:template:maintenanceTemplate'"
@click="maintenanceTemplateClick(record)">{{$t('maintenanceTemplate')}}</a>
<a class="text-operation"
:disabled="record.status == '1' || record.authorityFlag == '1'? true : false"
v-has="'params:template:delete'" @click="deleteLib(record)">{{$t('deleteLib')}}</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"
:current="pageNo"
@change="pageOnChange"
@showSizeChange="SizeChange"
/>
</div>
<JLoading :loading="JLoading">{{ $t('pleaseWaitWhileRunning') }}</JLoading>
<addModel :url="url" ref="addModelRef" @addModelList="addModelList"/>
<setupMaintainerModel ref="setupMaintainerModelRef" @setupMaintainerModelForm="setupMaintainerModelForm"/>
<syncToList ref="syncToListRef" @syncToListForm="syncToListForm"/>
<a-modal class="show-copy" v-model="areaVisible" :title="$t('templateCopy')" :footer="null" @cancel="hideModal">
<a-form-model :model="formInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24">
<a-col :span="24">
<div class="box-title-text">
<div class="title-text add-text-text">
<span class="Required">*</span>
<span class="title-text-text"
:title="$t('templateName')">{{$t('templateName')}}</span>
</div>
<a-form-model-item class="itemModel" prop="paramsTemplateName">
<a-input class="box-input add-input"
v-model="formInline.paramsTemplateName"
:placeholder="$t('PleaseEnter')+$t('templateName')"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
<div class="drawer-bootom-button">
<a-button style="margin-right: 8px" @click="handleCancel">{{$t('cancel')}}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
</div>
</a-modal>
</a-card>
</template>
<script>
import { getAction, postAction, downloadFile, deleteAction } from '@/api/manage'
import addModel from './components/addModel'
import syncToList from './components/syncToList'
import setupMaintainerModel from './components/setupMaintainerModel'
import axios from 'axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import eventBUs from '../../../common/event'
import Vue from 'vue'
import { ResizeHeader, ResizeColumnProvide } from '@/mixins/header'
import { mapGetters } from 'vuex'
export default {
name: 'index',
components: {
addModel,
setupMaintainerModel,
syncToList
},
mixins: [ResizeHeader, ResizeColumnProvide],
data() {
return {
token: Vue.ls.get(ACCESS_TOKEN),
loading: false,
toggleSearchStatus: false,
JLoading: false,
selectedRowKeys: [],
selectedRowKeysArray: '',
orderBy: '1',
orderByField: '',
formInline: {},
rules: {
paramsTemplateName: [
{ required: true, message: this.$t('PleaseEnter') + this.$t('templateName'), trigger: 'change' },
{ min: 1, max: 50, message: this.$t('cantExeed') + '50' + this.$t('characters'), trigger: 'blur' }
]
},
visible: false,
dataSource: [],
confirmLoading: false,
url: {
list: 'params/template/page',
add: 'params/template/add',
edit: 'params/template/edit',
deleteBatch: 'params/template/delete',
deleteAll: 'params/template/deleteBatch',
copy: 'params/template/copyById'
},
total: 0,
pageSize: 10,
pageNo: 1,
title: '新增',
columns: [
{
title: this.$t('zoneOfApplication'),
align: 'left',
width: 125,
ellipsis: true,
sorter: true,
dataIndex: 'region_dictText'
},
{
title: this.$t('parameterTemplate'),
align: 'left',
width: 200,
ellipsis: true,
sorter: true,
dataIndex: 'paramsTemplateName',
scopedSlots: { customRender: 'projectName' }
},
{
title: this.$t('contentDescription'),
align: 'left',
ellipsis: true,
dataIndex: 'description',
// scopedSlots: { customRender: 'titleName' }
width: 300
},
// {
// title: this.$t('zoneOfApplication'),
// align: 'center',
// width: 160,
// ellipsis: true,
// dataIndex: 'region_dictText',
// },
{
title: this.$t('VersionNumber'),
align: 'left',
width: 120,
ellipsis: true,
dataIndex: 'version'
},
{
title: this.$t('creater'),
align: 'left',
width: 120,
ellipsis: true,
dataIndex: 'createBy'
},
{
title: this.$t('maintainer'),
align: 'left',
width: 120,
ellipsis: true,
dataIndex: 'maintainerName'
},
// {
// title: this.$t('created'),
// align: 'left',
// dataIndex: 'createTime',
// width: 200,
// sorter: true,
// ellipsis: true
// },
{
title: this.$t('updated'),
align: 'left',
width: 200,
ellipsis: true,
sorter: true,
dataIndex: 'updateTime'
},
{
title: this.$t('operation'),
align: 'left',
fixed: 'right',
width: 360,
scopedSlots: { customRender: 'operation' }
}
],
queryParam: {},
updateTime: [],
areaVisible: false,
paramsTemplateName: ''
}
},
mounted() {
this.getList()
},
methods: {
...mapGetters(['userInfo']),
onChangeUpdateTime(values) {
let StartTime = values[0].format('YYYY-MM-DD')
let EndTime = values[1].format('YYYY-MM-DD')
this.queryParam.updateTimeStart = StartTime
this.queryParam.updateTimeEnd = EndTime
},
subscribeClick(val) {
let _this = this
this.$confirm({
content: val.readFlag == 0 || !val.readFlag ? _this.$t('ConfirmSubscribe') : _this.$t('cancelConfirmSubscribe'),
onOk() {
let url = ''
let action
let query = {}
if (val.readFlag == 0 || !val.readFlag) {
url = 'template/paramsTemplateSubscribeEO/add'
action = postAction
query = {
paramsTemplateId: val.id,
userId: _this.userInfo().id
}
} else {
url = 'template/paramsTemplateSubscribeEO/cancelSubscribe'
action = getAction
query = {
id: val.id
}
}
action(url, query).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getList()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
},
handleCancel() {
this.areaVisible = false
this.$refs['ruleForm'].resetFields()
},
handleSubmit() {
if (this.formInline.paramsTemplateName !== undefined) {
this.formInline.paramsTemplateName = this.formInline.paramsTemplateName.trim()
}
this.$refs.ruleForm.validate(valid => {
if (valid) {
getAction(this.url.copy + `?id=${this.selectedRowKeys[0]}&paramsTemplateName=${this.formInline.paramsTemplateName}`, {}).then((res) => {
if (res.success) {
this.areaVisible = false
this.$message.success(res.message)
this.selectedRowKeys = []
this.getList()
} else {
this.$message.warning(res.message)
}
})
}
})
},
handleToggleSearch() {
this.toggleSearchStatus = !this.toggleSearchStatus
},
onSelectChange(value) {
this.selectedRowKeys = value
this.selectedRowKeysArray = this.selectedRowKeys.join(',')
},
syncToListForm() {
this.selectedRowKeys = []
this.getList()
},
syncToListClick() {
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
if (this.selectedRowKeys.length == 1) {
let dataList = []
this.selectedRowKeys.forEach(res => {
this.dataSource.forEach(val => {
if (res == val.id) {
dataList.push(val)
}
})
})
if (dataList && dataList.length > 0) {
if (dataList[0].status == 1) {
this.$refs.syncToListRef.getData(dataList[0])
} else {
this.$message.warning(this.$t('pleaseSelectPublishedData'))
}
}
} else {
this.$message.warning(this.$t('OnlyOneSelected'))
}
} else {
this.$message.warning(this.$t('PleaseSelectData'))
}
},
//添加
handleAdd() {
this.$refs.addModelRef.addModel()
},
// 复制
handlecody() {
if (this.selectedRowKeys.length > 1) {
this.$message.warning(this.$t('OnlyOneSelected'))
} else if (this.selectedRowKeys.length == 0) {
this.$message.warning(this.$t('pleaseSelectData'))
} else {
this.areaVisible = true
this.formInline = {}
}
},
hideModal() {
this.visible = false
this.$refs['ruleForm'].resetFields()
},
withdrawOrRelease(item) {
let _this = this
this.$confirm({
content: item.status && item.status == '1' ? _this.$t('confirmWithdraw') : _this.$t('confirmRelease'),
onOk() {
_this.JLoading = true
if (item.status && item.status == '1') {
getAction('params/paramsInfo/withdraw', { paramsTemplateId: item.id }).then((res) => {
if (res.success) {
_this.$message.success(res.result)
_this.getList()
_this.JLoading = false
} else {
_this.$message.warning(res.message)
_this.JLoading = false
}
})
} else {
getAction('params/paramsInfo/publish', { paramsTemplateId: item.id }).then((res) => {
if (res.success) {
_this.$message.success(res.result)
_this.getList()
_this.JLoading = false
} else {
_this.$message.warning(res.message)
_this.JLoading = false
}
})
}
}
})
},
maintenanceTemplateClick(item) {
item.titleNameDesgin = 'maintenance'
this.$router.push({
path: '/ParameterTemplateList',
query: item
})
},
//批量删除
handleDel() {
let param = {
ids: this.selectedRowKeysArray
}
if (this.selectedRowKeys.length > 0) {
let _this = this
let dataSource = []
for (let i = 0; i < this.dataSource.length; i++) {
for (let j = 0; j < this.selectedRowKeys.length; j++) {
if (this.dataSource[i].id == this.selectedRowKeys[j]) {
dataSource.push(this.dataSource[i])
}
}
}
for (let i = 0; i < dataSource.length; i++) {
if (dataSource[i].authorityFlag == '1') {
this.$message.warning(this.$t('doNotHavePermissionDeleteData'))
return
}
}
this.$confirm({
content: _this.$t('ConfirmBatchDeletion'),
onOk() {
axios({
url: '/jero-boot/params/template/deleteBatch',
method: 'post',
data: param,
transformRequest: [function(data) {
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': _this.token
}
})
.then((res) => {
if (res.data.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.selectedRowKeys = []
_this.getList()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
.catch((error) => {
console.log(error)
})
}
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
setupMaintainerModelForm() {
this.getList()
},
setupMaintainerClick(item) {
this.$refs.setupMaintainerModelRef.editModel(item)
},
//编辑
edit(item) {
this.$refs.addModelRef.editModel(JSON.parse(JSON.stringify(item)))
},
//删除
deleteLib(val) {
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'))
}
})
}
})
},
//虚拟清单名称事件
entryNameClick(item) {
item.titleNameDesgin = 'view'
this.$router.push({
path: '/ParameterTemplateList',
query: item
})
},
searchQuery() {
this.pageNo = 1
this.getList()
},
searchReset() {
this.pageNo = 1
this.queryParam = {}
this.getList()
},
pageOnChange(page, pageSize) {
this.pageNo = page
this.getList()
},
SizeChange(page, pageSize) {
this.pageNo = 1
this.pageSize = pageSize
this.getList()
},
addModelList() {
this.pageNo = 1
this.getList()
},
PersonnelSelectionChange(value, id) {
this.queryParam[value] = id
this.queryParam = { ...this.queryParam }
},
tableOnChange(pagination, filters, sorter) {
this.orderBy = sorter.order == 'ascend' ? '1' : '2'
if (sorter.columnKey == 'region_dictText') {
this.orderByField = 'region'
} else if (sorter.columnKey == 'paramsTemplateName') {
this.orderByField = 'params_template_name'
} else if (sorter.columnKey == 'createTime') {
this.orderByField = 'create_time'
} else if (sorter.columnKey == 'updateTime') {
this.orderByField = 'update_time'
} else {
this.orderByField = sorter.columnKey
}
this.getList()
},
getList() {
let query = {
pageNo: this.pageNo,
pageSize: this.pageSize,
orderBy: this.orderBy,
orderByField: this.orderByField,
...this.queryParam
}
this.loading = true
getAction(this.url.list, query).then((res) => {
if (res.success) {
if (res.result.current > 1 && res.result.records.length == 0) {
this.pageNo = 1
this.getList()
return
}
this.dataSource = res.result.records || []
this.total = res.result.total
this.loading = false
} else {
this.loading = false
}
})
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.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;
}
.add-input {
width: 82%;
}
.box-button {
height: 38px;
/*margin-top: 2px;*/
}
.text-operation {
margin-right: 8px;
}
.page {
text-align: right;
margin-top: 20px;
}
.box-title-text-add {
line-height: 1.4;
display: flex;
}
.title-text-add {
width: 114px;
text-align: right;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 42px;
line-height: 42px;
margin-top: 3px;
}
.box-input-add {
display: inline-block;
height: 38px;
width: 100%;
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
margin-top: 2px;
}
.Required {
color: red;
margin-right: 4px;
}
.title-text-text {
margin-top: 9px;
}
.formAdd {
margin-bottom: 40px;
}
.drawer-bootom-button {
position: absolute;
bottom: 0;
z-index: 100;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
.add-text-text {
margin-top: -14px;
}
::v-deep .ant-table-row:first-child {
background: #fff !important;
opacity: 0.9;
}
::v-deep .ant-table-body {
background: transparent !important;
}
::v-deep .ant-table-placeholder {
margin-top: 8px !important;
}
</style>