Files
foton-laws-system-front/src/components/CustomFormComponents/InputForPolicy.vue
T
2021-06-25 17:57:33 +08:00

378 lines
11 KiB
Vue

<template>
<!-- <div>-->
<el-col :span="span">
<el-form-item
:label="config.attrName"
:prop="config.attrField"
:label-width="labelWidth"
class="add-form-item"
:class="{'form-item-disabled': disabled}"
>
<el-input
:value="value"
:maxlength="maxlength"
:placeholder="placeholder"
:disabled="disabled"
type="textarea"
resize="none"
clearable
:autosize="true"
@input="handleChange"
></el-input>
<el-button
type="primary"
class="common-button-primary"
size="mini"
style="position:absolute;top: 10px;right: 0;"
@click="selectLaws"
v-if="(processModel && !disabled) || !processModel"
>{{config.attrField === 'releventLaws' ? '选择政策' :'手动查找'}}</el-button>
</el-form-item>
<el-dialog
:title="config.attrName"
:visible.sync="replaceLawsNumModel"
width="875px"
:close-on-click-modal="false"
@close="replaceLawsNumModelCancel"
:append-to-body="true"
>
<div class="search-area">
<div class="left">
<el-form :modal="replaceLawsNumForm" :inline="true" class="label-input-form" @keyup.enter.native="getReplaceLawsNumRowFirst">
<el-form-item label="编号/名称" class="search-item">
<el-input v-model="replaceLawsNumForm.numberName" placeholder="根据编号/名称查找" clearable :maxlength="1000"></el-input>
</el-form-item>
<el-form-item class="search-item btn-box">
<el-button
icon="el-icon-search"
type="primary"
class="common-button-primary"
round
@click="getReplaceLawsNumRowFirst">
</el-button>
</el-form-item>
<el-form-item class="search-item btn-box">
<el-button
class="common-button-default"
icon="el-icon-refresh-left"
round
type="default"
@click="getResetLawsNumRow"></el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-table
ref="selections"
:data="replaceLawsNumRow"
tooltip-effect="dark"
style="width: 100%;overflow-y: auto;overflow-x: hidden;"
border
:height="300"
:header-cell-style="{background: '#e8e8e8', color: '#333333', fontSize: '16px',
fontWeight: 'bold', height: '48px'}"
@selection-change="selectReplaceStandNumRowChange">
<el-table-column
type="selection"
width="55"
align="center">
</el-table-column>
<el-table-column
label="政策编号"
width="130">
<template slot-scope="scope">
<a class="table-jump" @click="handlePreview(scope.row)">{{ scope.row.lawsNumber }}</a>
<!--<a v-if="scope.row.standYear" @click="handlePreview(scope.row)">{{ scope.row.standSort }} {{ scope.row.standNumber }}-{{ scope.row.standYear }}</a>-->
<!--<a v-else @click="handlePreview(scope.row)">{{ scope.row.standSort }} {{ scope.row.standNumber }}</a>-->
</template>
</el-table-column>
<el-table-column
prop="lawsName"
label="中文名称">
<template slot-scope="scope">
<a class="table-jump" @click="handlePreview(scope.row)">{{ scope.row.lawsName }}</a>
</template>
</el-table-column>
<el-table-column
prop="issueTime"
label="发布日期"
width="130">
</el-table-column>
<el-table-column
show-overflow-tooltip
prop="XCXSSRQ"
label="新车型实施日期">
<template slot-scope="scope">
<span v-if="scope.row.attrInfoMap.XCXSSRQ !== 'N/A' && scope.row.attrInfoMap.XCXSSRQ !== 'TBD'">{{ scope.row.attrInfoMap.XCXSSRQ || '' }}</span>
<span v-else>{{ scope.row.attrInfoMap.XCXSSRQ }}</span>
</template>
</el-table-column>
<el-table-column
prop="stateName"
label="文本状态">
</el-table-column>
</el-table>
<loading :loading="replaceLoading">{{$t('m.dataAcquisition')}}</loading>
<!--分页-->
<pagination
style="position: relative;"
:page="replacePage"
:total="replaceTotal"
@pageChange="pageChangeReplace"
@pageSizeChange="pageSizeChangeReplace"></pagination>
<div slot="footer" class="demo-drawer-footer">
<el-button class="common-button-default" icon="el-icon-close" @click="replaceLawsNumModelCancel">取消</el-button>
<el-button type="primary" round class="common-button-primary" icon="el-icon-check" @click="replaceLawsNumModelBt">提交</el-button>
</div>
</el-dialog>
</el-col>
<!-- </div>-->
</template>
<script>
export default {
name: 'CustomInput',
props: {
config: {
type: Object,
required: true
},
value: {
required: true
},
maxlength: {
type: Number,
required: true,
},
disabled: {
type: Boolean,
default: false
},
// 栅格比例
span: {
type: Number,
default: 24
},
// 是否为流程中使用
processModel: {
type: Boolean,
default: false
},
// label宽度
labelWidth: {
type: String,
default: '150px'
}
},
data() {
return {
replaceLawsNumModel: false,
sarBussionessLawsEO: {
replaceLawsNum: ''
},
// 代替标准号
replaceLawsNumForm: {
numberName: '', // 政策编号
page: 1,
pageSize: this.$store.getters.userInfo.configContent,
total: 0,
lawsType: 'FOREIGN',
quoteIdList: '',
menuId: ''
},
replaceLawsNumRow: [], // 代替政策号 数组内容
replaceTotal: 0,
selectedListRep: [],
replaceLoading: true,
replacePage: 1,
}
},
computed: {
placeholder () {
return `请输入${this.config.attrName}`
},
showMessage () {
return `${this.config.attrName}不能为空`
},
isRequired () {
return !!this.config.isMust
}
},
methods: {
handleChange (event) {
// const value = event.target.value
const value = event
this.$emit('input', value)
if (value.length==1000){
return this.$message({
message: '相关政策不能输入超过1000个字符',
type: 'warning'
});
}
},
selectLaws () {
// if (this.standNumFlag === 1) {
// this.$refs.selections.selectAll(false)
// }
// this.sarBussionessLawsEO.replaceLawsNum = ''
this.replaceLawsNumModel = true
this.getReplaceLawsNumRow()
},
// 代替政策号 请求数据
getReplaceLawsNumRowFirst () {
if (this.sarBussionessLawsEO.replaceLawsNum !== null && this.sarBussionessLawsEO.replaceLawsNum !== '') {
this.replaceLawsNumForm.quoteIdList = this.quoteIdList1.toString() === '' ? '' : this.quoteIdList1
} else {
this.quoteIdList1 = []
this.replaceLawsNumForm.quoteIdList = ''
}
this.replaceLawsNumForm.page = 1
this.replacePage = 1
this.$http.get('lawss/sarLawsInfo/page', this.replaceLawsNumForm, {
_this: this,
loading: 'replaceLoading'
}, res => {
this.replaceLawsNumRow = res.data.list
this.replaceTotal = res.data.count
if (this.selectedListRep.length !== 0) {
this.selectedListRep.map((list) => {
this.replaceLawsNumRow.map((item) => {
if (list.id === item.id) {
item._checked = true
}
})
})
}
}, e => {
})
},
// 代替政策号 请求数据
getReplaceLawsNumRow () {
if (this.sarBussionessLawsEO.replaceLawsNum !== null && this.sarBussionessLawsEO.replaceLawsNum !== '') {
this.replaceLawsNumForm.quoteIdList = this.quoteIdList1.toString() === '' ? '' : this.quoteIdList1
} else {
this.quoteIdList1 = []
this.replaceLawsNumForm.quoteIdList = ''
}
this.$http.get('lawss/sarLawsInfo/page', this.replaceLawsNumForm, {
_this: this,
loading: 'replaceLoading'
}, res => {
this.replaceLawsNumRow = res.data.list
this.replaceTotal = res.data.count
if (this.selectedListRep.length !== 0) {
this.selectedListRep.map((list) => {
this.replaceLawsNumRow.map((item) => {
if (list.id === item.id) {
item._checked = true
}
})
})
}
}, e => {
})
},
// 代替政策编号-取消
replaceLawsNumModelCancel () {
this.replaceLawsNumModel = false
this.replaceLawsNumForm.numberName = ''
this.$refs.selections.clearSelection()
},
// 代替政策号 table选择事件
selectReplaceStandNumRowChange (row) {
this.selectedListRep = row
},
// 代替政策分页
pageChangeReplace (page) {
this.replacePage = page
this.replaceLawsNumForm.page = page
this.getReplaceLawsNumRow()
},
pageSizeChangeReplace (pageSize) {
// this.replaceRows = pageSize
this.replaceLawsNumForm.pageSize = pageSize
this.getReplaceLawsNumRow()
},
// 代替政策编号确定
replaceLawsNumModelBt () {
let textArr = []
if (typeof this.value === 'string') {
if (this.value) {
textArr = this.value.split(',')
}
}
if (this.selectedListRep.length === 0) {
return this.$message({
message: '请先选择数据',
type: 'warning'
})
}
if (this.selectedListRep.length + textArr.length > 20) {
return this.$message({
message: '政策最多选择20项',
type: 'warning'
})
}
this.selectedListRep.map((item) => {
let texts = item.lawsNumber
// if (item.standYear != null && item.standYear !== '') {
// texts = item.standSort !== null ? item.standSort + ' ' + item.standNumber + '-' + item.standYear : item.standNumber + '-' + item.standYear
// } else {
// texts = item.standSort !== null ? item.standSort + ' ' + item.standNumber : item.standNumber
// }
textArr.push(texts)
textArr = [...new Set(textArr)]
this.replaceLawsNumModel = false
})
// this.SarLawsInfoEO.replaceLawsNum = textArr.join(',')
this.$emit('input', textArr.join(','))
this.$refs.selections.clearSelection()
},
// 点击查看
handlePreview (item) {
if (this.$hasPermission('A2HDHMEA6W')) {
let routeUrl = this.$router.resolve({
name: 'OtherLawsDetails',
params: {
id: item.id,
pageType: 'FOREIGN_LAWS'
}
})
window.open(routeUrl.href, '_blank')
} else {
this.$message.warning('无权访问')
}
},
getResetLawsNumRow() {
this.replaceLawsNumForm = {
numberName: '', // 政策编号
page: 1,
pageSize: this.$store.getters.userInfo.configContent,
total: 0,
lawsType: 'FOREIGN',
quoteIdList: '',
menuId: ''
// validFlag: '0'
}
this.getReplaceLawsNumRow()
}
}
}
</script>
<style scoped lang="less">
.add-form-item{
/deep/.el-form-item__content{
.el-textarea{
width: calc(~'100% - 90px');
}
}
}
</style>