[update] 复制

This commit is contained in:
zhaomeijing
2022-05-31 14:58:32 +08:00
parent 38e86f5e46
commit 9f7389a862
@@ -52,7 +52,7 @@
:rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
@change='handleTableChange'>
<span slot='click' slot-scope='text, record'>
<a class='action-edit' @click='editArea(record.id)' v-has="'area:edit'">{{ text }}</a>
<a class='action-edit' @click='editArea(record)' v-has="'area:edit'">{{ text }}</a>
</span>
</a-table>
<div class="page" style='display: flex;justify-content: flex-end;'>
@@ -169,10 +169,22 @@ export default {
methods: {
// 清单列表传出数据
listVisibleRow(val) {
this.listVisibleRowDate = val
this.selectedRowKeys = []
let newAreaTable=JSON.parse(JSON.stringify(this.areaTable))
newAreaTable.forEach((item, index) => {
if( item.id == this.listVisibleRowDate.id ) {
let _obj = {...item}
_obj.paramsTemplateId = val[0].id
_obj.paramsTemplateName = val[0].paramsTemplateName
this.areaTable.splice(index, 1,_obj)
}
})
console.log(this.areaTable,'this.areaTable')
this.listVisible = false
},
editArea() {
editArea(val) {
this.listVisibleRowDate = val
console.log(val)
this.listVisible = true
},
pageOnChange(page, pageSize) {
@@ -255,61 +267,40 @@ export default {
if (valid) {
this.flag = true
this.spinLoading = true
// 新增編輯之前 判断 标题唯一
getAction(`params/manifest/verifyTitle?projectId=${this.$route.query.id}
&title=${this.formData.title}`, {})
.then(res => {
if (res.result) {
let postDate = {
title: this.formData.title,
paramsTemplateId: this.paramsTemplateId || this.selectedRowKeys[0],
paramsTemplatePublishVersion: this.version,
projectId: this.projectId
}
if (this.formData.id) {
//编辑
postDate = {
id : this.formData.id,
...postDate
}
postAction(`params/manifest/edit`, postDate).then(res => {
if (res.success) {
this.newVisible = false
this.$emit('areaVisible', false)
this.$message.success(this.$t('OperationSuccessful'))
} else {
this.$message.warning(res.message)
}
}
).finally(() => {
this.flag = false
this.spinLoading = false
this.newVisible = false
})
} else {
//新增
postAction(`params/manifest/add`, postDate).then(res => {
if (res.success) {
this.newVisible = false
this.$emit('areaVisible', false)
this.$message.success(this.$t('OperationSuccessful'))
} else {
this.$message.warning(res.message)
}
}
).finally(() => {
this.flag = false
this.spinLoading = false
this.newVisible = false
})
}
} else {
this.$message.warning(this.$t('changeTheTitle'))
this.spinLoading = false
let _tt = {
paramsTemplateId: this.selectedRowKeysDate[0].paramsTemplateId,
projectId: this.selectedRowKeysDate[0].projectId,
title: this.selectedRowKeysDate[0].title,
// paramsTemplatePublishVersion:
sourceManifestId: this.selectedRowKeysDate[0].id,
}
console.log(this.selectedRowKeysDate,'this.selectedRowKeysDate')
axios({
url: `/jero-boot/params/manifest/copy`,
method: 'post',
data: _tt,
transformRequest: [function (data) {
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
}).finally(() => {
this.loading = false
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':_this.token
}
})
.then( (res) =>{
if (res.data.success) {
_this.$message.success(res.data.result)
}else{
_this.$message.warning(res.data.result)
}
})
.catch( (error) =>{
console.log(error);
});
} else {
return false
}