Files
laws_weilai/jero-web/src/views/businessSupport/problemKnowledgeBase/components/countryCardReleaseAdd.vue
T
2022-08-11 09:30:12 +08:00

361 lines
11 KiB
Java

<template>
<div>
<a-drawer
:title="title"
:maskClosable="false"
:width="1000"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<a-form-model :model="formInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24" v-if="title == $t('newlyAdded')">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text"
:title="$t('applicableMarket')">{{$t('applicableMarket')}}</span>
</div>
<a-form-model-item class="itemModel" prop="applyMarket">
<a-select :placeholder="$t('PleaseSelect')+$t('applicableMarket')"
:disabled="false"
v-model="formInline.applyMarket">
<a-select-option v-for="(item, key) in applyMarketList"
:key="key"
:value="item.value">
<span style="display: inline-block;width: 100%" :title=" item.title ">
{{ item.title}}
</span>
</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24" v-if="title == $t('edit')">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('applicableMarket')">{{$t('applicableMarket')}}</span>
</div>
<a-form-model-item class="itemModel">
<j-dict-select-tag class="box-input" v-model="formInline.applyMarket"
:disabled="true"
:placeholder="$t('PleaseSelect')+$t('applicableMarket')"
:type="'select'"
:triggerChange="false" :dictCode="'region'"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
<div style="margin-bottom: 60px">
<a-table
:columns="columns"
:scroll="{x: '100%',y:'calc(100vh - 300px)'}"
:data-source="dataList"
:pagination="false"
:loading="loading">
<span slot="content" slot-scope="text,record,index">
<a-input class="box-input"
v-if="record.lableType == 8"
v-model.trim="record.content"
:maxLength="100"
:placeholder="$t('PleaseEnter')"/>
<a-select :placeholder="$t('PleaseSelect')"
style="width: 100%"
v-else-if="record.lableType == 3"
v-model="record.content">
<a-select-option v-for="(item, key) in record.countryCardTempItemEOList"
:key="key"
:value="item.id">
<span style="display: inline-block;width: 100%" :title=" item.itemText ">
{{ item.itemText}}
</span>
</a-select-option>
</a-select>
<a-button type="primary" class="button-text"
v-else-if="record.lableType == 7"
@click="clickButtonToUpload('content',index)">
{{ (record.content === 'null' || record.content === '' ||
record.content == null) ? $t('clickUpload') : $t('viewUploadedFiles')
}}
</a-button>
</span>
</a-table>
</div>
<div class="drawer-bootom-button">
<a-button @click="handleCancel" type="danger" style="margin-right: 16px">{{$t('cancel')}}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
</div>
</a-drawer>
<uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"/>
</div>
</template>
<script>
import { getAction, postAction, deleteAction } from '@/api/manage'
import uploadFile from '@/components/uploadFile/file'
export default {
name: 'countryCardReleaseAdd',
components: {
uploadFile
},
data() {
return {
url: {
list: '/problemKnowledgeBase/countryCardTempEO/list',
deleteOne: '',
add: '/problemKnowledgeBase/countryCardManageReleaseEO/add',
edit: '/problemKnowledgeBase/countryCardManageReleaseDetailEO/editBatch'
},
title: '',
formInline: {},
rules: {
applyMarket: [
{
required: true,
message: this.$t('applicableMarket') + this.$t('cannotEmpty'),
trigger: 'change'
}
]
},
visible: false,
selectedRowKeys: [],
dataList: [],
loading: false,
confirmLoading: false,
index: '',
applyMarketList: [],
columns: [
{
title: this.$t('LabelName'),
dataIndex: 'lableName',
align: 'center',
ellipsis: true,
width: 220
},
{
title: this.$t('describe'),
dataIndex: 'description',
align: 'center',
width: 260,
ellipsis: true
},
{
title: this.$t('content'),
align: 'center',
fixed: 'right',
width: 260,
scopedSlots: { customRender: 'content' }
}
]
}
},
mounted() {
},
methods: {
add() {
this.visible = true
this.$nextTick(() => {
this.formInline = {}
this.$refs.ruleForm.clearValidate()
})
this.title = this.$t('newlyAdded')
this.replacePage()
this.getApplyMarketList()
},
edit(row) {
this.visible = true
this.$nextTick(() => {
this.formInline = row
this.formInline = { ...this.formInline }
this.$refs.ruleForm.clearValidate()
})
this.title = this.$t('edit')
this.editReplacePage(row)
},
getApplyMarketList() {
getAction('/problemKnowledgeBase/countryCardManageReleaseEO/getApplyMarketList', {}).then((res) => {
if (res.success) {
this.applyMarketList = res.result || []
} else {
this.applyMarketList = []
}
})
},
clickButtonToUpload(item, index) {
this.$refs.uploadFile.perentHandleFunc()
this.index = index
this.$refs.uploadFile.visible = true
this.uploadName = item
getAction('sys/common/getFileInfos', { id: this.dataList[this.index][this.uploadName] }).then((res) => {
if (res.success) {
this.$refs.uploadFile.perentHandleFunc(res.result)
} else {
this.$refs.uploadFile.perentHandleFunc()
}
})
},
/** 上传文件的回调 */
uploadSuccess(data) {
let attIdList = []
if (data && data.length > 0) {
data.map(item => {
attIdList.push(item.id || data.name)
})
}
/** 赋值给当前对应的表单文件 */
this.dataList[this.index][this.uploadName] = attIdList.join(',')
this.dataList = [...this.dataList]
},
handleCancel() {
this.visible = false
},
handleSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let url = ''
let content = []
if (this.title == this.$t('newlyAdded')) {
url = this.url.add
this.dataList.forEach(res => {
content.push({
countryCardTempId: res.id,
description: res.description,
content: res.content
})
})
} else {
url = this.url.edit
this.dataList.forEach(res => {
content.push({
countryCardTempId: res.countryCardTempId,
description: res.description,
content: res.content,
id: res.id
})
})
}
this.confirmLoading = true
let query = {
countryCardManageReleaseDetailEOList: content,
applyMarket: this.formInline.applyMarket
}
postAction(url, query).then((res) => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.visible = false
this.confirmLoading = false
this.$emit('countryCardReleaseAddForm')
} else {
this.confirmLoading = false
this.$message.warning(this.$t('operationFailed'))
}
})
}
})
},
replacePage() {
this.loading = true
getAction(this.url.list, {}).then((res) => {
if (res.success) {
this.dataList = res.result || []
this.loading = false
} else {
this.dataList = []
this.loading = false
}
})
},
editReplacePage(row) {
this.loading = true
getAction('/problemKnowledgeBase/countryCardManageReleaseDetailEO/list', { countryCardManageReleaseId: row.id }).then((res) => {
if (res.success) {
this.dataList = res.result || []
this.loading = false
} else {
this.dataList = []
this.loading = false
}
})
}
}
}
</script>
<style scoped>
.page {
text-align: right;
margin-top: 20px;
}
.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;
}
.button-text {
height: 38px;
width: 100%;
line-height: 38px;
background: #fff;
border: 1px #00B3BE solid;
color: #00B3BE;
}
.box-title-text {
line-height: 1.4;
display: flex;
}
.title-text {
width: 84px;
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;
}
.box-input {
display: inline-block;
height: 38px;
width: 100%;
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
margin-top: 2px;
}
.title-text-text {
margin-top: 9px;
}
.Required {
color: red;
margin-right: 4px;
}
</style>