Files
laws_weilai/jero-web/src/views/parameter/parameterlist/index.vue
T
2022-07-04 15:45:28 +08:00

503 lines
14 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('NiONumber')">
<span>{{$t('NiONumber')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('PleaseEnter')+$t('NiONumber')"
v-model="queryParam.nioNumber"></a-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('ParameterName')">
<span>{{$t('ParameterName')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('PleaseEnter')+$t('ParameterName')"
v-model="queryParam.paramsName"></a-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('areaOfResponsibility')">
<span>{{$t('areaOfResponsibility')}}</span>
</div>
<j-dict-select-tag class="box-input" v-model="queryParam.dutyTerritory"
:placeholder="$t('PleaseSelect')+$t('areaOfResponsibility')"
:type="'select'"
:triggerChange="false" :dictCode="'duty_territory'"/>
</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" v-has="'params:paramsInfo:add'">
<a-icon type="plus"/>
{{$t('newlyAdded')}}
</div>
<div @click="handleExport" class="operator-text" v-has="'params:paramsInfo:import'">
<a-icon type="export" :rotate="-90"/>
{{$t('dataExport')}}
</div>
<div @click="handleModule" class="operator-text" v-has="'params:paramsInfo:template'">
<a-icon type="download"/>
{{$t('templateDownload')}}
</div>
<div class="operator-text" v-has="'params:paramsInfo:import'">
<ImportFileOnlyList :url="url" :isTrue="false" :accept="'.zip'" :paramsTemplateId='this.$route.query.id' @getList='getList'/>
</div>
<div @click="releaseVersion" class="operator-text" v-has="'params:paramsInfo:publish'">
<a-icon type="rocket"/>
{{$t('releaseVersion')}}
</div>
<div @click="handleDel" class="operator-text" v-has="'params:paramsInfo:deleteBatch'">
<a-icon type="delete"/>
{{$t('BatchDelete')}}
</div>
</div>
<div>
<a-table
ref="table"
size="middle"
:loading="loading"
:pagination="false"
:scroll="{x: '100%'}"
rowKey="id"
:data-source="dataSource"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:columns="columns"
@customHeaderRow='customHeaderRow'
@change='handleTableChange'
>
<span slot="titleName" slot-scope="text,record" :title="text">
{{ text && text.length > 10 ? text.slice(0, 9) + '...' : text }}
</span>
<span slot="operation" slot-scope="text,record">
<a class="text-operation" v-has="'params:paramsInfo:edit'" @click="edit(record)">{{$t('edit')}}</a>
<a class="text-operation" v-has="'params:paramsInfo: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>
<addModel :url="url" ref="addModelRef" @addModelList="addModelList" :certCategoryParamsInfoEOListItem='certCategoryParamsInfoEOList'/>
</a-card>
</template>
<script>
import { getAction, postAction, downloadFile, deleteAction, downFilePost } from '@/api/manage'
import addModel from './components/addModel'
import axios from 'axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import ImportFileOnlyList from '@/components/ImportFileOnlyList/index'
import Vue from 'vue'
export default {
name: 'index',
components: {
addModel,
ImportFileOnlyList
},
data() {
return {
certCategoryParamsInfoEOList: [],
orderBy: '1',
selectedRowKeysArray: '',
token:Vue.ls.get(ACCESS_TOKEN),
loading: false,
toggleSearchStatus: false,
selectedRowKeys: [],
formInline: {},
rules: {},
visible: false,
dataSource: [],
confirmLoading: false,
url: {
queryById: 'params/paramsInfo/queryById', // 编辑 通过id进行查询
list: 'params/paramsInfo/page', // 查询列表
add: 'params/paramsInfo/add', // 添加 -- 提交
edit: 'params/paramsInfo/edit', // 编辑 -- 提交
deleteBatch: 'params/paramsInfo/delete', // 单个删除
deleteAll: 'params/paramsInfo/deleteBatch', // 批量删除
importZipUrl: 'params/paramsInfo/importParamsInfo', // 导入
checkNIOnumber: 'params/paramsInfo/verifyNioNumber', // 校验nio编号
},
total: 0,
pageSize: 10,
pageNo: 1,
title: '新增',
/* 排序参数 */
isorter:{
column: 'nioNumber',
order: 'desc',
},
columns: [
{
title: this.$t('NiONumber'),
align: 'center',
width: 100,
dataIndex: 'nioNumber',
sorter: true
},
{
title: this.$t('ParameterName'),
align: 'center',
dataIndex: 'paramsName',
width: 160,
},
{
title: this.$t('ParameterDescription'),
align: 'center',
dataIndex: 'description',
// scopedSlots: { customRender: 'titleName' }
},
{
title: this.$t('areaOfResponsibility'),
align: 'center',
dataIndex: 'dutyTerritory_dictText',
width: 150,
},
{
title: this.$t('createTime'),
align: 'center',
dataIndex: 'createTime',
width: 110,
},
{
title: this.$t('operation'),
align: 'center',
fixed: 'right',
width: 100,
scopedSlots: { customRender: 'operation' }
}
],
queryParam: {}
}
},
mounted() {
this.getList()
},
methods: {
customHeaderRow(val,kk) {
console.log(val,kk)
},
handleTableChange(pagination, filters, sorter) {
let _i = sorter.order === 'descend' ? 'asc': 'desc'
let _tt = {
orderByField: 'nioNumber',
orderBy: _i
}
this.queryParam = {
...this.queryParam, ..._tt
}
// this.queryParam.orderByField = 'nioNumber'
// this.queryParam.orderBy = (sorter.order === 'descend' ? 'asc': 'desc')
this.getList()
},
onClick(val,kk) {
console.log(val,kk)
},
//导出
handleExport() {
let _tt = {
paramsTemplateId: this.$route.query.id,
...this.queryParam,
ids: this.selectedRowKeys.join(','),
}
let _xx = JSON.stringify(_tt)
let _yy = { paramsInfoVO : _xx, exportName: '参数项列表' }
downloadFile('params/paramsInfo/exportParamsInfoZip', this.$t('parameterDataExport') + '.zip', { paramsInfoVO : _xx, exportName: '参数项列表' } , this.Deselect)
},
// 发布版本
releaseVersion() {
getAction('params/paramsInfo/publish', { paramsTemplateId: this.$route.query.id }).then((res) => {
if (res.success) {
this.$message.success(res.result)
} else {
this.$message.warning(res.message)
}
})
},
//下载模板
handleModule() {
// let lang = localStorage.getItem('language') || 'zh-cn';
// if (lang == 'en-us') {
downloadFile('params/paramsInfo/exportTemplate', this.$t('parameterTemplateExportName') + '.xlsx', {})
// } else if (langCn == 'zh-cn') {
// downloadFile('params/paramsInfo/exportTemplate', 'Parameter list.xlsx', {})
// }
},
handleToggleSearch() {
this.toggleSearchStatus = !this.toggleSearchStatus
},
onSelectChange(value) {
this.selectedRowKeys = value
this.selectedRowKeysArray = this.selectedRowKeys.join(',')
},
//添加
handleAdd() {
this.$refs.addModelRef.addModel()
},
//批量删除
handleDel() {
let param={
ids: this.selectedRowKeysArray
}
if (this.selectedRowKeys.length > 0) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmBatchDeletion'),
onOk() {
axios({
url: '/jero-boot/params/paramsInfo/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'))
}
},
//编辑
edit(item) {
let _this = this
getAction(_this.url.queryById, { id: item.id }).then((res) => {
if (res.success) {
this.certCategoryParamsInfoEOList = res.result.certCategoryParamsInfoEOList
this.$refs.addModelRef.editModel(JSON.parse(JSON.stringify(res.result)))
} else {
this.$message.warning(res.message)
}
})
},
//删除
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) {
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
delete this.queryParam.orderBy
delete this.queryParam.orderByField
this.getList()
},
PersonnelSelectionChange(value, id) {
this.queryParam[value] = id
this.queryParam = { ...this.queryParam }
},
getList() {
let query = {
pageNo: this.pageNo,
pageSize: this.pageSize,
paramsTemplateId: this.$route.query.id,
...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 = res.result.current - 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;
}
.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;
width: 100%;
z-index:100;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
</style>