[update] 市场法规清单

This commit is contained in:
lideqin
2024-07-05 18:22:16 +08:00
parent 3c2b4f9010
commit 60e39606a3
6 changed files with 380 additions and 715 deletions
@@ -112,14 +112,15 @@
import InternalDetailPage from '../../../components/InternalDetailPage'
import FileEcho from '../../../components/FileEcho'
import HistoryVersionModal from './modules/HistoryVersionModal'
import { getMarketRegulationListById, marketRegulationDetailListById } from '../../../api/standardRegulationLibraryApi'
import { getMarketRegulationListById } from '../../../api/standardRegulationLibraryApi'
import JTable from '../../../components/jero/JTable'
import { StandardSource } from '../../../enums/commonEnums'
import { mapGetters } from 'vuex'
import { JeroListMixin } from '@/mixins/JeroListMixin'
export default {
name: 'MarketRegulationsDetailPage',
components: { InternalDetailPage, FileEcho, JTable, HistoryVersionModal },
mixins: [JeroListMixin],
computed: {
...mapGetters(['defaultHeight']),
...mapGetters(['userInfo']),
@@ -143,7 +144,7 @@ export default {
data () {
return {
loading: false,
model: { manifest: {}, lists: [] },
model: {},
columns: [
{ // 序号
title: this.$t('serialNumber'),
@@ -290,22 +291,11 @@ export default {
}
],
dataSource: [],
dataList: [], // 用于查询的数据,保证查询后数据不变
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
ids: [],
url: {
list: '/laws/marketStandardDetail/page'
},
queryParam: {},
filters: {},
ids: []
disableMixinCreated: true
}
},
beforeRouteUpdate (to, from, next) {
@@ -314,6 +304,7 @@ export default {
this.filters.manifestVersion = to.query.manifestVersion
}
this.ids = to.query.ids.split(',')
this.filters.manifestId = to.query.ids
this.initData(to.query.ids)
next()
} else {
@@ -325,80 +316,29 @@ export default {
this.filters.manifestVersion = this.$route.query.manifestVersion
}
this.ids = this.$route.query.ids.split(',')
this.filters.manifestId = this.$route.query.ids
this.initData(this.$route.query.ids)
this.loadData()
},
methods: {
initData (ids) {
// 只有一条数据,需要获取基础信息
if (this.ids.length > 1) {
return
}
this.loading = true
const param = Object.assign({}, this.filters)
param.manifestId = ids
if (this.ids.length <= 1) {
// 只有一条数据,需要获取基础信息和列表
getMarketRegulationListById(param).then(res => {
if (res.success) {
this.model = Object.assign({}, res.result)
if (!this.model.manifest) {
this.model.manifest = {}
}
marketRegulationDetailListById(param).then(res => {
if (res.success) {
this.model.lists = res.result
this.dataSource = JSON.parse(JSON.stringify(this.model.lists))
this.dataList = JSON.parse(JSON.stringify(this.model.lists))
}
}).finally(() => {
this.loading = false
})
}
})
} else {
// 有多条数据只需要调用获取列表的接口
marketRegulationDetailListById(param).then(res => {
if (res.success) {
this.model.lists = res.result
this.dataSource = JSON.parse(JSON.stringify(this.model.lists))
this.dataList = JSON.parse(JSON.stringify(this.model.lists))
}
}).finally(() => {
this.loading = false
})
}
},
// 查询
searchQuery () {
if (this.queryParam.standardNumber && this.queryParam.standardName) {
this.dataSource = this.dataList.filter(item => {
return item.standardNumber.indexOf(this.queryParam.standardNumber) !== -1 && item.standardName.indexOf(this.queryParam.standardName) !== -1
})
} else if (this.queryParam.standardNumber) {
this.dataSource = this.dataList.filter(item => {
return item.standardNumber.indexOf(this.queryParam.standardNumber) !== -1
})
} else if (this.queryParam.standardName) {
this.dataSource = this.dataList.filter(item => {
return item.standardName.indexOf(this.queryParam.standardName) !== -1
})
} else {
this.dataSource = JSON.parse(JSON.stringify(this.dataList))
}
},
// 重置
searchReset () {
this.queryParam = {}
this.dataSource = JSON.parse(JSON.stringify(this.dataList))
},
handleTableChange (pagination, filters, sorter) {
// 分页、排序、筛选变化时触发
this.ipagination = pagination
getMarketRegulationListById(param).then(res => {
if (res.success) {
this.model = Object.assign({}, res.result)
}
}).finally(() => {
this.loading = false
})
},
toDetail (record) {
let path = ''
// 需要先判断是哪种标准
if (record.source === StandardSource.FOREIGN.value) {
path = '/standardRegulationLibrary/foreignStandardDetailPage'
} else if (record.source === StandardSource.ENTERPRISE.value) {
path = '/enterpriseStandardLibrary/enterpriseStandardDetail'
}
const path = '/standardRegulationLibrary/foreignStandardDetailPage'
this.$openPageNewSheet({
path: path,
query: {
@@ -1,7 +1,7 @@
<template>
<internal-detail-page :title="$route.query.title" :content-padding="0" :loading="loading">
<internal-detail-page :title="$route.query.title" :content-padding="0" :loading="pageLoading">
<!-- 标题右侧按钮 只允许法规管理员和超级管理员查看历史版本 -->
<template v-if="model.manifest.id && isCanLookHistory" v-slot:titleRightCustom>
<template v-if="model.id && isCanLookHistory" v-slot:titleRightCustom>
<!-- 历史版本 -->
<a-button type="primary" ghost @click="clickHistoryVersion">{{ $t('standardRegulationLibrary.marketRegulationsList.historicalVersion') }}</a-button>
</template>
@@ -23,7 +23,7 @@
</a-form-item>
</a-col>
<!-- 清单编号 -->
<a-col :span="12" v-if="model.manifest.id">
<a-col :span="12" v-if="model.id">
<a-form-item :label="$t('standardRegulationLibrary.marketRegulationsList.listNumber')"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
@@ -88,10 +88,10 @@
<div class="center-operate-box">
<!-- 下一步 -->
<a-button type="primary" ghost :loading="loading" @click="handleNext">{{ $t('next') }}</a-button>
<a-button class="next-btn" type="primary" ghost :loading="pageLoading" @click="handleNext">{{ model.id || showList ? $t('submit') : $t('next') }}</a-button>
</div>
<template v-if="showList || model.manifest.id">
<template v-if="showList || model.id">
<!-- 市场法规清单 -->
<div class="process-part-title">{{ $t('marketRegulationsList') }}</div>
@@ -136,7 +136,7 @@
<!-- 批量删除 -->
<a-button icon="delete" type="primary" ghost @click="batchDel">{{ $t('batchDelete') }}</a-button>
<!-- 导入 -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" :data="importData" @change="handleImportExcel">
<a-button icon="download" type="primary" ghost>{{ $t('import') }}</a-button>
</a-upload>
<!-- 模板下载 -->
@@ -152,7 +152,7 @@
:can-drag="true"
:scroll="{x: '100%', y: yScrollHeight}"
ref="table"
rowKey="uid"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="false"
@@ -171,7 +171,7 @@
<template v-slot:action="{text, record}">
<a @click="handleEdit(record)">{{ $t('edit') }}</a>
<a-divider type="vertical" />
<a @click="handleDelete(record.uid)" class="table-ope-btn">{{ $t('delete') }}</a>
<a @click="handleDelete(record.id)" class="table-ope-btn">{{ $t('delete') }}</a>
</template>
</j-table>
@@ -180,13 +180,6 @@
</template>
</div>
<div class="bottom-operate-box">
<!-- 取消 -->
<a-button type="primary" ghost :loading="loading" @click="handleCancel">{{ $t('cancel') }}</a-button>
<!-- 提交 -->
<a-button type="primary" :loading="loading" @click="handleSubmit">{{ $t('submit') }}</a-button>
</div>
<!-- 新增、编辑弹框 -->
<market-regulations-modal ref="marketRegulationsModal" @ok="modalFormOk"/>
<!-- 调取弹框 -->
@@ -210,27 +203,17 @@ import StandardSelectionModal from '../../../components/selection/StandardSelect
import MarketRegulationsListSelectionModal from '../../../components/selection/MarketRegulationsListSelectionModal'
import {
getForeignStandardDocumentInfo,
getMarketRegulationListById,
marketRegulationDetailListById,
getMarketRegulationListById, marketRegulationDetailAdd, marketRegulationDetailCopy,
marketRegulationDetailTransfer,
marketRegulationListAdd,
marketRegulationListEdit
} from '../../../api/standardRegulationLibraryApi'
import pick from 'lodash.pick'
import { StandardSource } from '../../../enums/commonEnums'
import { mapGetters } from 'vuex'
import Vue from 'vue'
import { ACCESS_TOKEN, TENANT_ID } from '../../../store/mutation-types'
import { downloadFile } from '../../../api/manage'
import HistoryVersionModal from './modules/HistoryVersionModal'
import store from '@/store'
import { getFormDictTreeList } from '../../../api/api'
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
// 导入的加载提示
let importModalLoading
import { JeroListMixin } from '@/mixins/JeroListMixin'
export default {
name: 'MarketRegulationsFormPage',
@@ -243,6 +226,7 @@ export default {
HistoryVersionModal,
STreeSelect
},
mixins: [JeroListMixin],
computed: {
...mapGetters(['defaultHeight']),
...mapGetters(['userInfo']),
@@ -255,18 +239,6 @@ export default {
*/
return `calc(100vh - ${this.defaultHeight['user-info-height']} - ${this.defaultHeight['breadcrumb-height']} - ${this.defaultHeight.oneLineSearchHeight} - ${this.defaultHeight.oneLineOperationHeight} - 48px - 48px - 54px - ${this.isBackTitle ? '56px' : '0px'})`
},
// token header
tokenHeader () {
const head = { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) }
const tenantid = Vue.ls.get(TENANT_ID)
if (tenantid) {
head['tenant-id'] = tenantid
}
return head
},
importExcelUrl: function () {
return `${window._CONFIG.domianURL}/${this.url.importExcelUrl}`
},
// 是否可以查看历史版本,当前用户是否是法规管理员或超级管理员
isCanLookHistory () {
const superAdminRoleCode = window._CONFIG.superAdminRoleCode
@@ -278,7 +250,7 @@ export default {
data () {
return {
StandardSource,
loading: false,
pageLoading: false,
form: this.$form.createForm(this),
model: { manifest: {}, lists: [] },
queryParam: {},
@@ -478,26 +450,16 @@ export default {
}
],
dataSource: [],
dataList: [], // 用于查询的数据,保证查询后数据不变
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
selectedRowKeys: [],
selectionRows: [],
showList: false, // 是否展示清单
url: {
list: '/laws/marketStandardDetail/page',
importExcelUrl: '/laws/marketStandardDetail/importExcel',
downTemplateUrl: '/laws/marketStandardDetail/downloadTemplate'
}
downTemplateUrl: '/laws/marketStandardDetail/downloadTemplate',
deleteBatch: '/laws/marketStandardDetail/deleteBatch',
delete: '/laws/marketStandardDetail/delete'
},
disableMixinCreated: true,
importData: {}
}
},
mounted () {
@@ -505,8 +467,12 @@ export default {
if (this.$route.query.id) {
this.initData(this.$route.query.id)
}
this.filters.manifestId = this.$route.query.id
this.importData.manifestId = this.$route.query.id
this.loadData()
},
methods: {
// 获取国家/地区下拉数据
getCountryOption () {
getFormDictTreeList({ dictId: '1801130851452059649' }).then(res => {
if (res.success) {
@@ -514,314 +480,140 @@ export default {
}
})
},
// 获取基础信息
initData (id) {
this.loading = true
this.pageLoading = true
const param = {}
param.manifestId = id
// 获取基础信息和历史版本
getMarketRegulationListById(param).then(res => {
if (res.success) {
this.model = Object.assign({}, res.result)
if (this.model.manifest.country) {
this.model.manifest.country = this.model.manifest.country.split(',').map(item => {
this.model = Object.assign({}, res.result.manifest)
if (this.model.country) {
this.model.country = this.model.country.split(',').map(item => {
return { value: item }
})
}
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model.manifest, 'country', 'manifestNo', 'customColumnName', 'drivePosition', 'securityLevel', 'manifestDesc', 'file'))
})
marketRegulationDetailListById(param).then(res => {
if (res.success) {
this.model.lists = res.result
for (const item of this.model.lists) {
const uid = uidGenerator()
this.dataSource.push({ ...item, uid })
this.dataList.push({ ...item, uid })
}
}
}).finally(() => {
this.loading = false
this.form.setFieldsValue(pick(this.model, 'country', 'manifestNo', 'customColumnName', 'drivePosition', 'securityLevel', 'manifestDesc', 'file'))
})
}
}).finally(() => {
this.pageLoading = false
})
},
// 点击历史版本
clickHistoryVersion () {
this.$refs.historyVersionModal.open(this.model)
},
// 查询
searchQuery () {
if (this.queryParam.standardNumber && this.queryParam.standardName) {
this.dataSource = this.dataList.filter(item => {
return item.standardNumber.indexOf(this.queryParam.standardNumber) !== -1 && item.standardName.indexOf(this.queryParam.standardName) !== -1
})
} else if (this.queryParam.standardNumber) {
this.dataSource = this.dataList.filter(item => {
return item.standardNumber.indexOf(this.queryParam.standardNumber) !== -1
})
} else if (this.queryParam.standardName) {
this.dataSource = this.dataList.filter(item => {
return item.standardName.indexOf(this.queryParam.standardName) !== -1
})
} else {
this.dataSource = JSON.parse(JSON.stringify(this.dataList))
}
this.selectedRowKeys = []
this.selectionRows = []
},
// 重置
searchReset () {
this.queryParam = {}
this.dataSource = JSON.parse(JSON.stringify(this.dataList))
this.selectedRowKeys = []
this.selectionRows = []
},
onSelectChange (selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
this.selectionRows = selectionRows
},
handleTableChange (pagination, filters, sorter) {
// 分页、排序、筛选变化时触发
this.ipagination = pagination
},
batchDel () {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning(this.$t('selectARecord'))
} else {
this.$confirm({
title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'),
onOk: () => {
this.loading = true
this.dataList = this.dataList.filter(item => !this.selectedRowKeys.includes(item.uid))
this.dataSource = this.dataSource.filter(item => !this.selectedRowKeys.includes(item.uid))
this.onClearSelected()
console.log(this.dataList)
this.loading = false
}
})
}
},
/* 导入 */
handleImportExcel (info) {
// 限制导入大于500MB
if (info.file.size > 1024 * 1024 * 500) {
this.$message.error('导入文件最大500MB')
info.fileList.pop()
return
}
// 加一个大的提示
if (!this.loading) {
importModalLoading = this.$info({
title: '提示',
content: <span>正在导入,请稍候 <a-spin size="small" /></span>,
keyboard: false
})
}
this.loading = true
// 把知道了这个按钮去掉
this.$nextTick(() => {
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
})
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList)
}
if (info.file.status === 'done') {
// 销毁这个提示
importModalLoading && importModalLoading.destroy()
this.loading = false
if (info.file.response.success) {
// this.$message.success(`${info.file.name} 文件上传成功`);
if (info.file.response.code === 201) {
const { message, result: { msg, fileUrl, fileName } } = info.file.response
const href = window._CONFIG.domianURL + fileUrl
this.$warning({
title: message,
content: (<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
})
} else {
this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`)
}
const uid = uidGenerator()
// 推入表格中
this.dataSource = info.file.response.result.map(item => {
return { uid, ...item }
})
this.dataList = info.file.response.result.map(item => {
return { uid, ...item }
})
} else {
if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) {
this.messageLineFeed(this.$t('fileImportError'), info.file.response.result)
} else if (/<br>|<\/br>|<br\/>/.test(info.file.response.message)) {
this.messageLineFeedByBr(this.$t('fileImportError'), info.file.response.message)
} else {
this.$message.warning(`${info.file.name} ${info.file.response.message}`)
}
}
} else if (info.file.status === 'error') {
// 销毁这个提示
importModalLoading && importModalLoading.destroy()
this.loading = false
if (info.file.response.status === 500) {
const data = info.file.response
const token = Vue.ls.get(ACCESS_TOKEN)
if (token && data.message.includes('Token失效')) {
this.error({
title: '登录已过期',
content: '很抱歉,登录已过期,请重新登录',
okText: '重新登录',
mask: false,
onOk: () => {
store.dispatch('Logout').then(() => {
Vue.ls.remove(ACCESS_TOKEN)
window.location.reload()
})
}
})
}
} else {
this.$message.warning(`文件上传失败: ${info.file.msg} `)
}
}
},
// 下载导入模板
downTemplate (fileName, fileSuffix = '.xls') {
if (!fileName || typeof fileName !== 'string') {
fileName = '模板文件'
}
downloadFile(this.url.downTemplateUrl, fileName + fileSuffix)
},
onClearSelected () {
this.selectedRowKeys = []
this.selectionRows = []
},
// 下一步
// 下一步或提交, 提交基础信息
handleNext () {
this.showList = true
console.log(this.pageLoading)
if (this.pageLoading) return
this.form.validateFields((err, values) => {
if (!err) {
this.pageLoading = true
const param = {}
param.manifest = Object.assign({}, values)
// 国家/地区是树选择,需要处理格式
param.manifest.country = param.manifest.country.map(item => item.value).join(',')
let func
if (this.model && this.model.id) {
param.manifest.id = this.model.id
func = marketRegulationListEdit
} else {
func = marketRegulationListAdd
}
func(param).then(res => {
if (res.success) {
this.$message.success(this.$t('operationSuccessful'))
if (!this.model.id) {
// 没有id,是新增会返回id,用于下方表格处理
this.model.id = res.message
}
this.showList = true
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.pageLoading = false
})
}
})
},
// 新增
handleAdd () {
this.$refs.marketRegulationsModal.title = this.$t('newlyAdded')
this.$refs.marketRegulationsModal.add()
this.$refs.marketRegulationsModal.add(this.model.id)
},
// 调取
handleTransfer () {
this.$refs.transferModal.open()
},
// 调取完成
async transferOk (list) {
if (this.loading) {
return
}
this.loading = true
for (const item of list) {
await getForeignStandardDocumentInfo({ id: item.id, type: '2' }).then(res => {
if (res.success) {
const result = res.result
const form = {}
form.manifestId = this.model.id
form.standardId = result.id
form.standardNumber = result.standard_number // 标准编号
form.standardName = result.standard_name // 标准名称
form.standardEnglishName = result.standard_english_name // 标准英文名称
form.type = result.type // 标准类型
form.newProductImplDate = result.new_product_impl_date // 新生产车实施日期
form.newAuthImplDate = result.new_auth_impl_date // 新认证车实施日期
form.registrationDate = result.registration_date // 注册日期
form.country = result.applicable_market // 适用国家/地区
form.mainDept = result.main_dept // 主控部门
form.mainDeptProfMode = result.main_dept_prof_mode || undefined // 主控部门专业模块
form.associateDept = result.associate_dept // 关联部门
form.associateDeptProfMode = result.associate_dept_prof_mode || undefined // 关联部门专业模块
form.applicableVehicle = result.applicable_vehicle // 适用车型
form.dynamicType = result.dynamic_type // 动力类型
marketRegulationDetailAdd(form).then(res => {
if (res.success) {
this.$message.success(res.message)
this.loadData()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
}
},
// 复制
handleCopy () {
this.$refs.copyModal.open()
},
// 新增完成
modalFormOk (value) {
if (!value.uid) {
// 是新增完成
if (!this.dataList.find(i => i.standardNumber === value.standardNumber)) {
const uid = uidGenerator()
// 列表中还没有该标准
this.dataSource.unshift({ ...value, uid })
this.dataList.unshift({ ...value, uid })
} else {
// 提示标准已存在
this.$message.warning(this.$t('standardRegulationLibrary.marketRegulationsList.standardExist'))
}
} else {
// 是编辑完成
const index = this.dataSource.findIndex(item => item.uid === value.uid)
this.dataSource.splice(index, 1, value)
const listIndex = this.dataList.findIndex(item => item.uid === value.uid)
this.dataList.splice(listIndex, 1, value)
}
},
// 调取完成
async transferOk (list) {
this.loading = true
let repeatNum = 0
console.log('---list', list, this.dataList)
// 已经有的标准去掉,调取不重复的
for (const item of list) {
if (!this.dataList.find(i => i.standardNumber === item.standardNumber)) {
// 列表中还没有该标准,获取标准数据到表格中
await getForeignStandardDocumentInfo({ id: item.id, type: '2' }).then(res => {
if (res.success) {
const result = res.result
const form = {}
form.standardId = result.id
form.standardNumber = result.standard_number // 标准编号
form.standardName = result.standard_name // 标准名称
form.standardEnglishName = result.standard_english_name // 标准英文名称
form.type = result.type // 标准类型
form.type_dictText = result.type_dictText // 标准类型
form.newProductImplDate = result.new_product_impl_date // 新生产车实施日期
form.newAuthImplDate = result.new_auth_impl_date // 新认证车实施日期
form.registrationDate = result.registration_date // 注册日期
form.country = result.applicable_market // 适用国家/地区
form.country_dictText = result.applicable_market_dictText // 适用国家/地区
form.mainDept = result.main_dept // 主控部门
form.mainDept_dictText = result.main_dept_dictText // 主控部门
form.mainDeptProfMode = result.main_dept_prof_mode || undefined // 主控部门专业模块
form.mainDeptProfMode_dictText = result.main_dept_prof_mode_dictText // 主控部门专业模块
form.associateDept = result.associate_dept // 关联部门
form.associateDept_dictText = result.associate_dept_dictText // 关联部门
form.associateDeptProfMode = result.associate_dept_prof_mode || undefined // 关联部门专业模块
form.associateDeptProfMode_dictText = result.associate_dept_prof_mode_dictText // 关联部门专业模块
form.applicableVehicle = result.applicable_vehicle // 适用车型
form.applicableVehicle_dictText = result.applicable_vehicle_dictText // 适用车型
form.dynamicType = result.dynamic_type // 动力类型
form.dynamicType_dictText = result.dynamic_type_dictText // 动力类型
const uid = uidGenerator()
this.dataSource.unshift({
...form,
uid
})
this.dataList.unshift({
...form,
uid
})
}
})
} else {
repeatNum++
}
}
if (repeatNum > 0) {
// 提示部分标准已存在
this.$message.warning(this.$t('standardRegulationLibrary.marketRegulationsList.haveStandardExist'))
}
this.loading = false
},
// 复制完成
async copyOk (ids) {
if (this.loading) {
return
}
this.loading = true
// 根据选中的清单,获取清单列表,并且表格中不存在的添加到表格中
const idArr = ids.split(',')
let repeatNum = 0
for (const id of idArr) {
await marketRegulationDetailListById({ manifestId: id }).then(res => {
if (res.success) {
for (const item of res.result) {
if (!this.dataList.find(i => i.standardNumber === item.standardNumber)) {
const uid = uidGenerator()
// 列表中还没有该标准
this.dataSource.unshift({ ...item, uid, id: undefined })
this.dataList.unshift({ ...item, uid, id: undefined })
} else {
repeatNum++
}
}
}
})
}
if (repeatNum > 0) {
// 提示部分标准已存在
this.$message.warning(this.$t('standardRegulationLibrary.marketRegulationsList.haveStandardExist'))
}
this.loading = false
const param = {}
param.oldId = ids
param.newId = this.model.id
marketRegulationDetailCopy(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.loadData()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
toDetail (record) {
const path = '/standardRegulationLibrary/foreignStandardDetailPage'
@@ -835,97 +627,7 @@ export default {
// 编辑
handleEdit (record) {
this.$refs.marketRegulationsModal.title = this.$t('edit')
this.$refs.marketRegulationsModal.edit(record)
},
// 删除
handleDelete (uid) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
this.dataList = this.dataList.filter(item => item.uid !== uid)
this.dataSource = this.dataSource.filter(item => item.uid !== uid)
}
})
},
// 取消
handleCancel () {
this.close()
},
// 提交
handleSubmit () {
if (this.loading) return
this.form.validateFields((err, values) => {
if (err) {
return
}
let tableErr = false
// 校验表格是否至少有一条数据
if (this.dataList.length <= 0) {
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
tableErr = true
return
}
// 校验表格必填项是否都填写了
const requiredField = [
'standardNumber', // 标准编号
'standardName', // 标准名称
'newProductImplDate', // 新生产车实施日期
'newAuthImplDate', // 新认证车实施日期
'registrationDate', // 注册日期
'country', // 适用国家/地区
'authenticationObject', // 认证对象
'mainDept', // 主控部门
'mainDeptProfMode', // 主控部门专业模块
'applicableVehicle', // 适用车型
'dynamicType' // 动力类型
]
for (const item of this.dataList) {
for (const filed of requiredField) {
if (!item[filed]) {
this.$message.warning(this.$t('pleaseCompleteTableInfo'))
tableErr = true
return
}
}
}
if (!err && !tableErr) {
this.loading = true
const param = {}
param.manifest = Object.assign({}, values)
// 国家/地区是树选择,需要处理格式
param.manifest.country = param.manifest.country.map(item => item.value).join(',')
let func
if (this.model && this.model.manifest.id) {
param.manifest.id = this.model.manifest.id
func = marketRegulationListEdit
} else {
func = marketRegulationListAdd
}
param.lists = this.dataList
func(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
},
close () {
this.model = {}
this.dataSource = []
this.dataList = []
let timer = setTimeout(() => {
clearTimeout(timer)
timer = null
this.$router.go(-1)
}, 700)
this.$refs.marketRegulationsModal.edit(this.model.id, record)
}
}
}
@@ -952,5 +654,8 @@ export default {
.center-operate-box {
float: right;
.next-btn {
z-index: 999;
}
}
</style>
@@ -65,15 +65,12 @@
:tree-data="countryOptions"
tree-checkable
treeCheckStrictly
@change="countryChange"
:placeholder="$t('pleaseSelect')+$t('standardRegulationLibrary.marketListField.applicableCountryRegion')" />
</a-form-item>
<!-- 认证对象 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.authenticationObject')">
<j-dict-select-tag ref="authenticationObject"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.authenticationObject')"
<j-dict-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.authenticationObject')"
dict-code="authentication_object"
@change="authenticationObjectChange"
v-decorator.trim="[ 'authenticationObject', validatorRules.authenticationObject ]" />
</a-form-item>
<!-- 认证交付物 -->
@@ -86,70 +83,54 @@
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.mainControlDepartment')">
<j-select-depart :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.mainControlDepartment')"
:backDepart="true"
@back="mainDeptBack"
v-decorator.trim="[ 'mainDept', validatorRules.mainDept ]" />
</a-form-item>
<!-- 主控部门专业模块 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.masterControlDepartmentProfessionalModule')">
<j-multi-select-tag ref="mainDeptProfMode"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.masterControlDepartmentProfessionalModule')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.masterControlDepartmentProfessionalModule')"
dict-code="professional_module"
@change="mainDeptProfModeChange"
v-decorator.trim="[ 'mainDeptProfMode', validatorRules.mainDeptProfMode ]" />
</a-form-item>
<!-- 关联部门 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.relatedDepartment')">
<j-select-depart :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.relatedDepartment')"
:backDepart="true"
@back="associateDeptBack"
v-decorator.trim="[ 'associateDept', validatorRules.associateDept ]" />
</a-form-item>
<!-- 关联部门专业模块 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.associateDepartmentSpecializedModules')">
<j-multi-select-tag ref="associateDeptProfMode"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.associateDepartmentSpecializedModules')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.associateDepartmentSpecializedModules')"
dict-code="professional_module"
@change="associateDeptProfModeChange"
v-decorator.trim="[ 'associateDeptProfMode', validatorRules.associateDeptProfMode ]" />
</a-form-item>
<!-- 适用车型 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.applicableVehicleType')">
<j-multi-select-tag ref="applicableVehicle"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.applicableVehicleType')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.applicableVehicleType')"
dict-code="applicable_vehicle_type"
@change="applicableVehicleChange"
v-decorator.trim="[ 'applicableVehicle', validatorRules.applicableVehicle ]" />
</a-form-item>
<!-- 动力类型 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.dynamicType')">
<j-multi-select-tag ref="dynamicType"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.dynamicType')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.dynamicType')"
dict-code="dynamic_type"
@change="dynamicTypeChange"
v-decorator.trim="[ 'dynamicType', validatorRules.dynamicType ]" />
</a-form-item>
<!-- 批量限制 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.batchRestriction')">
<j-multi-select-tag ref="batchLimit"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.batchRestriction')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.batchRestriction')"
dict-code="batch_restriction"
@change="batchLimitChange"
v-decorator.trim="[ 'batchLimit', validatorRules.batchLimit ]" />
</a-form-item>
<!-- 自动驾驶等级 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.automaticDrivingLevel')">
<j-multi-select-tag ref="autopilotLevel"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.automaticDrivingLevel')"
<j-multi-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.automaticDrivingLevel')"
dict-code="automatic_driving_level"
@change="autopilotLevelChange"
v-decorator.trim="[ 'autopilotLevel', validatorRules.autopilotLevel ]" />
</a-form-item>
<!-- 要求类型 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.marketListField.requirementType')">
<j-dict-select-tag ref="requireType"
:placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.requirementType')"
<j-dict-select-tag :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.marketListField.requirementType')"
dict-code="requirement_type"
@change="requireTypeChange"
v-decorator.trim="[ 'requireType', validatorRules.requireType ]" />
</a-form-item>
</a-form>
@@ -170,7 +151,11 @@ import StandardSelection from '@/components/selection/StandardSelection'
import JMultipleDatePicker from '../../../../components/JMultipleDatePicker'
import STreeSelect from '@/components/STreeSelect'
import pick from 'lodash.pick'
import { getForeignStandardDocumentInfo } from '../../../../api/standardRegulationLibraryApi'
import {
getForeignStandardDocumentInfo,
marketRegulationDetailEdit,
marketRegulationDetailAdd
} from '../../../../api/standardRegulationLibraryApi'
import { getFormDictTreeList } from '../../../../api/api'
export default {
@@ -282,19 +267,21 @@ export default {
}],
validateTrigger: 'change'
}
}
},
manifestId: '' // 基础信息清单id
}
},
mounted () {
this.getCountryOption()
},
methods: {
add () {
this.edit({})
add (manifestId) {
this.edit(manifestId, {})
},
edit (record) {
edit (manifestId, record) {
this.form.resetFields()
this.visible = true
this.manifestId = manifestId
this.model = Object.assign({}, record)
// 处理适用国家/地区格式
if (this.model.country) {
@@ -330,26 +317,18 @@ export default {
form.standardName = result.standard_name // 标准名称
form.standardEnglishName = result.standard_english_name // 标准英文名称
form.type = result.type // 标准类型
form.type_dictText = result.type_dictText // 标准类型
form.newProductImplDate = result.new_product_impl_date // 新生产车实施日期
form.newAuthImplDate = result.new_auth_impl_date // 新认证车实施日期
form.registrationDate = result.registration_date // 注册日期
form.country = result.applicable_market ? (result.applicable_market.split(',').map(item => {
return { value: item }
})) : [] // 适用国家/地区
form.country_dictText = result.applicable_market_dictText // 适用国家/地区
form.mainDept = result.main_dept // 主控部门
form.mainDept_dictText = result.main_dept_dictText // 主控部门
form.mainDeptProfMode = result.main_dept_prof_mode || undefined // 主控部门专业模块
form.mainDeptProfMode_dictText = result.main_dept_prof_mode_dictText // 主控部门专业模块
form.associateDept = result.associate_dept // 关联部门
form.associateDept_dictText = result.associate_dept_dictText // 关联部门
form.associateDeptProfMode = result.associate_dept_prof_mode || undefined // 关联部门专业模块
form.associateDeptProfMode_dictText = result.associate_dept_prof_mode_dictText // 关联部门专业模块
form.applicableVehicle = result.applicable_vehicle // 适用车型
form.applicableVehicle_dictText = result.applicable_vehicle_dictText // 适用车型
form.dynamicType = result.dynamic_type // 动力类型
form.dynamicType_dictText = result.dynamic_type_dictText // 动力类型
this.model = Object.assign({}, form)
this.$nextTick(() => {
this.form.setFieldsValue(pick(form, 'standardName', 'standardEnglishName',
@@ -361,72 +340,6 @@ export default {
this.confirmLoading = false
})
},
// 主控部门回调
mainDeptBack (value) {
if (value && value.length > 0) {
this.model.mainDept_dictText = value.map(item => item.text).join(',')
} else {
this.model.mainDept_dictText = ''
}
},
// 关联部门回调
associateDeptBack (value) {
if (value && value.length > 0) {
this.model.associateDept_dictText = value.map(item => item.text).join(',')
} else {
this.model.associateDept_dictText = ''
}
},
// 主控部门专业模块改变
mainDeptProfModeChange (value) {
const valueArr = value.split(this.$refs.mainDeptProfMode.spliter)
const arr = this.$refs.mainDeptProfMode.dictOptions.filter(item => valueArr.includes(item.value))
this.model.mainDeptProfMode_dictText = arr.map(item => item.title).join(',')
},
// 关联部门专业模块改变
associateDeptProfModeChange (value) {
const valueArr = value.split(this.$refs.associateDeptProfMode.spliter)
const arr = this.$refs.associateDeptProfMode.dictOptions.filter(item => valueArr.includes(item.value))
this.model.associateDeptProfMode_dictText = arr.map(item => item.title).join(',')
},
// 适用车型改变
applicableVehicleChange (value) {
const valueArr = value.split(this.$refs.applicableVehicle.spliter)
const arr = this.$refs.applicableVehicle.dictOptions.filter(item => valueArr.includes(item.value))
this.model.applicableVehicle_dictText = arr.map(item => item.title).join(',')
},
// 动力类型改变
dynamicTypeChange (value) {
const valueArr = value.split(this.$refs.dynamicType.spliter)
const arr = this.$refs.dynamicType.dictOptions.filter(item => valueArr.includes(item.value))
this.model.dynamicType_dictText = arr.map(item => item.title).join(',')
},
// 适用国家/地区改变
countryChange (value) {
this.model.country_dictText = value.map(item => item.label).join(',')
},
// 认证对象改变
authenticationObjectChange (value) {
const obj = this.$refs.authenticationObject.dictOptions.find(item => item.value === value)
this.model.authenticationObject_dictText = obj.title
},
// 批量限制改变
batchLimitChange (value) {
const valueArr = value.split(this.$refs.batchLimit.spliter)
const arr = this.$refs.batchLimit.dictOptions.filter(item => valueArr.includes(item.value))
this.model.batchLimit_dictText = arr.map(item => item.title).join(',')
},
// 自动驾驶等级改变
autopilotLevelChange (value) {
const valueArr = value.split(this.$refs.autopilotLevel.spliter)
const arr = this.$refs.autopilotLevel.dictOptions.filter(item => valueArr.includes(item.value))
this.model.autopilotLevel_dictText = arr.map(item => item.title).join(',')
},
// 要求类型改变
requireTypeChange (value) {
const obj = this.$refs.requireType.dictOptions.find(item => item.value === value)
this.model.requireType_dictText = obj.title
},
handleOk () {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
@@ -435,8 +348,28 @@ export default {
const param = Object.assign({}, values)
// 处理适用国家/地区格式
param.country = param.country.map(item => item.value).join(',')
this.$emit('ok', { ...this.model, ...param })
this.close()
// 基础信息id
param.manifestId = this.manifestId
// 标准id
param.standardId = this.model.standardId
let func
if (this.model.id) {
func = marketRegulationDetailEdit
param.id = this.model.id
} else {
func = marketRegulationDetailAdd
}
func(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
this.confirmLoading = false
}
})