234 lines
6.9 KiB
Vue
234 lines
6.9 KiB
Vue
<template>
|
|
<a-drawer
|
|
:title="$t('standardSelect.standardSelection')"
|
|
:maskClosable="false"
|
|
:width="1000"
|
|
placement="right"
|
|
:closable="true"
|
|
@close="handleCancel"
|
|
:visible="visible"
|
|
class="custom-drawer-style">
|
|
<div class="custom-drawer-style-scroll">
|
|
<div class="table-page-search-wrapper">
|
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
|
<a-row :gutter="24">
|
|
<a-col :sm="8">
|
|
<a-form-item :label="$t('standardSelect.source')" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<j-dict-select-tag style="width: 100%" v-model="queryParam.source"
|
|
:disabled="disabledSourceSearch"
|
|
:placeholder="$t('pleaseSelect')+$t('standardSelect.source')"
|
|
:triggerChange="false" dictCode="standard_source"
|
|
@change="handleTypeChange" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :sm="8">
|
|
<a-form-item :label="$t('standardSelect.standardNumOrName')" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input :placeholder="$t('pleaseEnter')+$t('standardSelect.standardNumOrName')"
|
|
v-model="queryParam.standardNumberOrName"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
<div style="float: right;overflow: hidden;margin-right: 41px;margin-bottom: 20px"
|
|
class="table-page-search-submitButtons">
|
|
<a-button class="box-button" style="margin-left: 8px" @click="searchReset">{{ $t('reset') }}</a-button>
|
|
<a-button class="box-button" style="margin-left: 8px" type="primary" @click="searchQuery">{{
|
|
$t('query')
|
|
}}
|
|
</a-button>
|
|
</div>
|
|
</a-row>
|
|
</a-form>
|
|
</div>
|
|
<a-table
|
|
:columns="columns"
|
|
rowKey="standardNumber"
|
|
:scroll="{x: 900}"
|
|
:data-source="dataList"
|
|
:pagination="ipagination"
|
|
:row-selection="{ type: type, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:loading="loading"
|
|
@change="handleTableChange">
|
|
<template slot="text" slot-scope="text">
|
|
<a-tooltip overlay-class-name="tooltip-style">
|
|
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
|
<div class="table-text">{{ text || text === 0 ? text : global.emptyLine }}</div>
|
|
</a-tooltip>
|
|
</template>
|
|
|
|
</a-table>
|
|
</div>
|
|
|
|
<div class="custom-drawer-style-bottom-btn">
|
|
<a-button @click="handleCancel">{{ $t('cancel') }}</a-button>
|
|
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{ $t('submit') }}</a-button>
|
|
</div>
|
|
</a-drawer>
|
|
</template>
|
|
|
|
<script>
|
|
import { getStandardList } from '@/api/api'
|
|
import JDictSelectTag from '../dict/JDictSelectTag'
|
|
|
|
export default {
|
|
name: 'StandardSelectionModal',
|
|
components: { JDictSelectTag },
|
|
props: {
|
|
source: {
|
|
type: [String, Number],
|
|
default: '1'
|
|
},
|
|
value: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
// 搜索条件中的来源是否不可更改
|
|
disabledSourceSearch: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
type: {
|
|
type: String,
|
|
required: false,
|
|
default: 'checkbox'
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
visible: false,
|
|
confirmLoading: false,
|
|
labelCol: {
|
|
sm: 8
|
|
},
|
|
wrapperCol: {
|
|
sm: 14
|
|
},
|
|
selectedRowKeys: [],
|
|
selectedRowList: [],
|
|
loading: false,
|
|
queryParam: {},
|
|
/* 分页参数 */
|
|
ipagination: {
|
|
current: 1,
|
|
pageSize: 10,
|
|
pageSizeOptions: ['10', '20', '30'],
|
|
showTotal: (total, range) => {
|
|
return range[0] + '-' + range[1] + ' ' + this.$t('total') + ' ' + total + ' ' + this.$t('strip')
|
|
},
|
|
showQuickJumper: true,
|
|
showSizeChanger: true,
|
|
total: 0
|
|
},
|
|
columns: [
|
|
{
|
|
title: this.$t('number'),
|
|
dataIndex: 'standardNumber',
|
|
ellipsis: true,
|
|
align: 'center',
|
|
width: 150
|
|
},
|
|
{
|
|
title: this.$t('title'),
|
|
dataIndex: 'standardName',
|
|
ellipsis: true,
|
|
align: 'center',
|
|
width: 150
|
|
},
|
|
// 发布日期
|
|
{
|
|
title: this.$t('standardSelect.releaseDate'),
|
|
dataIndex: 'releaseDate',
|
|
align: 'center',
|
|
width: 120,
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: this.$t('standardSelect.textState'),
|
|
dataIndex: 'standardState_dictText',
|
|
align: 'center',
|
|
width: 150
|
|
}
|
|
],
|
|
dataList: []
|
|
}
|
|
},
|
|
methods: {
|
|
open () {
|
|
this.visible = true
|
|
this.queryParam = {}
|
|
this.$nextTick(() => {
|
|
this.source ? this.queryParam.source = this.source : this.queryParam = {}
|
|
this.replacePage()
|
|
})
|
|
},
|
|
// 获取表格数据
|
|
replacePage () {
|
|
const query = {
|
|
...this.queryParam,
|
|
pageNo: this.ipagination.current,
|
|
pageSize: this.ipagination.pageSize
|
|
}
|
|
// this.selectedRowKeys = []
|
|
this.loading = true
|
|
getStandardList(query).then((res) => {
|
|
if (res.success) {
|
|
this.dataList = res.result.records
|
|
this.ipagination.total = res.result.total
|
|
this.selectedRowKeys = this.value.split(',')
|
|
} else {
|
|
this.dataList = []
|
|
}
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
searchQuery () {
|
|
this.replacePage()
|
|
},
|
|
searchReset () {
|
|
// 如果禁用来源,就不重置来源
|
|
if (this.disabledSourceSearch) {
|
|
this.queryParam = { source: this.source }
|
|
} else {
|
|
this.queryParam = {}
|
|
}
|
|
this.replacePage()
|
|
},
|
|
// 表格选择改变
|
|
onSelectChange (value, row) {
|
|
this.selectedRowKeys = value
|
|
this.selectedRowList = row
|
|
},
|
|
handleTableChange (pagination) {
|
|
// 分页、排序、筛选变化时触发
|
|
this.ipagination = pagination
|
|
this.replacePage()
|
|
},
|
|
handleCancel () {
|
|
this.visible = false
|
|
},
|
|
handleSubmit () {
|
|
const serialNumber = []
|
|
const serialNameArr = []
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
|
|
this.selectedRowList.forEach(res => {
|
|
serialNumber.push(res.standardNumber)
|
|
serialNameArr.push(res.standardName)
|
|
})
|
|
this.$emit('change', serialNumber.join(','))
|
|
this.$emit('nameChange', serialNameArr.join(','))
|
|
this.$emit('listChange', this.selectedRowList)
|
|
this.visible = false
|
|
} else {
|
|
this.$message.warning(this.$t('selectLeastOne'))
|
|
}
|
|
},
|
|
handleTypeChange () {
|
|
this.$forceUpdate()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|