[update] 修改标准选择器组件

This commit is contained in:
lideqin
2023-09-04 09:59:58 +08:00
parent 18c682e175
commit a2bf4db396
7 changed files with 201 additions and 358 deletions
+9 -145
View File
@@ -8,53 +8,16 @@
{{this.$t('standardSelect.standardSelection')}}
</a-button>
</div>
<a-drawer
:title="$t('standardSelect.standardSelection')"
:maskClosable="false"
:width="1000"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<div style="margin-bottom: 60px">
<currency-search
:flag="'1'"
:url="url"
:queryParam='queryParam'
@searchQuery="searchQuery"
@searchReset="searchReset"
/>
<a-table
:components="drag(columns,'cloumns')"
:columns="columns"
rowKey="serial_number"
:scroll="{x: 1500}"
:data-source="dataList"
:pagination="ipagination"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:loading="loading">
</a-table>
</div>
<div class="drawer-bootom-button">
<a-button @click="handleCancel" style="margin-right: 16px">{{$t('cancel')}}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
</div>
</a-drawer>
<standard-selection-modal ref="standardSelectionModal" v-bind="$attrs" @input="modalInput" @change="modalChange"></standard-selection-modal>
</div>
</template>
<script>
import CurrencySearch from './CurrencySearch'
import { ResizeHeader, ResizeColumnProvide } from '@/mixins/header'
import { postAction } from '@/api/manage'
import StandardSelectionModal from './StandardSelectionModal'
export default {
name: 'StandardSelection',
components: { CurrencySearch },
mixins: [ResizeColumnProvide, ResizeHeader],
components: { StandardSelectionModal },
props: ['query', 'value', 'standard'],
computed: {
isDisabled () {
@@ -66,121 +29,22 @@ export default {
},
data () {
return {
visible: false,
confirmLoading: false,
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: 'serial_number',
ellipsis: true,
align: 'left',
width: 480
},
{
title: this.$t('title'),
dataIndex: 'title',
ellipsis: true,
align: 'left',
width: 480
},
{
title: this.$t('textStatus'),
dataIndex: 'state',
align: 'left',
width: 480
}
],
dataList: [],
url: {
searchList: 'document/bussDocumentLibraryEO/queryCondition' // 搜索字段
}
}
},
mounted () {
this.replacePage()
},
methods: {
// 点击选择标准按钮
standardClick () {
this.visible = true
this.queryParam = {}
this.replacePage()
},
replacePage () {
const query = {
...this.queryParam,
pageNo: this.ipagination.current,
pageSize: this.ipagination.pageSize
}
this.selectedRowKeys = []
this.loading = true
postAction('document/bussDocumentLibraryEO/replacePageInfo', query).then((res) => {
this.loading = false
if (res.success) {
this.dataList = res.result.records
this.ipagination.total = res.result.total
this.selectedRowKeys = this.standard[this.query.db_field_name] ? this.standard[this.query.db_field_name].split(',') : []
} else {
this.dataList = []
}
})
},
handleCancel () {
this.visible = false
},
handleSubmit () {
const serialNumber = []
const replaceStandardId = []
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
// let content = JSON.parse(JSON.stringify(this.selectedRowList))
this.selectedRowList.forEach(res => {
serialNumber.push(res.serial_number)
replaceStandardId.push(res.id)
})
this.$emit('input', serialNumber.join(','))
this.$emit('change', this.query.dbFieldName, replaceStandardId.join(','))
// this.$emit('changecontent', this.content)
this.visible = false
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
this.$refs.standardSelectionModal.open()
},
// 输入框输入监听
indexClick (event) {
this.$emit('input', event.target.value)
},
onSelectChange (value, row) {
this.selectedRowKeys = value
this.selectedRowList = row
modalInput (value) {
this.$emit('input', value)
},
searchQuery (queryParam) {
const queryParamQuery = JSON.parse(JSON.stringify(queryParam))
Object.keys(queryParamQuery).forEach(res => {
if (queryParamQuery[res] instanceof Array) {
queryParamQuery[res] = queryParamQuery[res].join(',')
}
})
this.queryParam = queryParamQuery
this.replacePage()
},
searchReset (queryParam) {
this.queryParam = queryParam
this.replacePage()
modalChange (fieldName, value) {
this.$emit('change', fieldName, value)
}
}
}