[add] 历史版本

This commit is contained in:
zhaomeijing
2022-05-18 18:14:01 +08:00
parent a7746bac73
commit c6904eb63b
2 changed files with 40 additions and 149 deletions
@@ -81,7 +81,7 @@
<configure ref="configureRef" :url='url' :itemId='itemId'/>
<!-- 历史版本-->
<a-modal v-model="historicalVisible" :title="$t('historicalVersion')" width='750px' :footer="null">
<historical-version v-if='historicalVisible' ></historical-version>
<historical-version v-if='historicalVisible' :historicalRow='historicalRow'></historical-version>
</a-modal>
</a-card>
</template>
@@ -174,7 +174,8 @@
rowId: '',
version: 0,
itemId: '',
historicalVisible: false
historicalVisible: false,
historicalRow: {}, // 历史版本得数据
}
},
mounted() {
@@ -208,10 +209,11 @@
handleTableChange() {
},
//
historicalVersion() {
// 历史版本
historicalVersion(historicalRow) {
console.log(historicalRow)
this.historicalVisible = true
console.log('历史版本。。。。')
this.historicalRow = historicalRow
},
// 配置
configure(item) {
@@ -9,30 +9,27 @@
:dataSource='areaTable'
:pagination='false'
:loading='loading'
:scroll='{x: 600}'
@change='handleTableChange'>
:scroll='{x: 600}'>
<a slot='name' slot-scope='text'>{{ text }}</a>
<span slot='action' slot-scope='text, record'>
<a class='action-edit' @click='editArea(record.id)' v-has="'area:edit'">{{ $t('edit') }}</a>
<a style='color:red' href='javascript:;' @click=' deleteArea(record.id)'
v-has="'area:delete'">{{ $t('delete') }}</a>
</span>
</a-table>
<div class='drawer-bootom-button'>
<a-button style='margin-right: .8rem' @click='handleCancel'>{{ $t('cancel') }}</a-button>
<a-button @click='handleSubmit' type='primary' :loading='confirmLoading'>{{ $t('submit') }}</a-button>
</div>
</div>
</template>
<script>
import { putAction, postAction, getAction, deleteAction } from '@/api/manage'
import axios from 'axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import Vue from 'vue'
export default {
name: 'diolagArea',
components: {},
data() {
return {
token:Vue.ls.get(ACCESS_TOKEN),
title: this.$t('add'),
total: 0,
selectedRowKeysDate: {},
@@ -63,143 +60,44 @@ export default {
}
},
props: {
historicalRow: {
type: Object,
default: {},
require: true
}
},
mounted() {
this.loadData()
},
methods: {
loadData() {
this.loading = true
let params = {
...this.form
}
getAction(`params/manifest/getParamsTemplateList`, params).then(res => {
if (res.success) {
this.areaTable = [...res.result]
this.total = res.result.total
let _this = this
axios({
url: `/jero-boot/params/collectManifestHistory/getConfigById?id=${this.historicalRow.id}`,
method: 'get',
transformRequest: [function (data) {
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':_this.token
}
}).finally(() => {
this.loading = false
})
},
searchQuery() {
this.loadData()
},
searchReset() {
this.form = {}
this.loadData()
},
handleCancel() {
this.$emit('areaVisible', false)
},
onSelectChange(selectedRowKeys, selectedRowKeysDate) {
this.selectedRowKeysDate = selectedRowKeysDate
this.selectedRowKeys = selectedRowKeys
},
handleTableChange(val) {
},
showModal() {
this.title = this.$t('add')
this.newVisible = true
this.form = {}
},
//新增
handleSubmit() {
if (this.selectedRowKeys.length == 0) {
this.$message.warning(this.$t('pleaseSelectData'))
} else if (this.selectedRowKeys.length > 1) {
this.$message.warning(this.$t('OnlyOneSelected'))
} else {
this.$refs.ruleForm.validate(valid => {
if (valid) {
this.flag = true
this.spinLoading = true
// 新增編輯之前 判断 标题唯一
getAction(`params/manifest/verifyTitle?projectId=${this.$route.query.id}
&title=${this.templatetitle}`, {})
.then(res => {
if (res.success) {
let postDate = {
title: this.templatetitle,
paramsTemplateId: this.rowId || this.selectedRowKeysDate[0].id,
paramsTemplatePublishVersion: this.version || this.selectedRowKeysDate[0].version,
projectId: this.projectId
}
if (this.rowId) {
//编辑
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(res.message)
}
}).finally(() => {
this.loading = false
})
} else {
return false
.then( (res) =>{
console.log(res)
if (res.data.success) {
console.log(res,'lll')
}else{
_this.$message.warning(res.data.result)
}
})
}
},
cancelModel() {
this.newVisible = false
this.$refs.ruleForm.resetFields()
},
//删除按钮
deleteArea(val) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: '',
onOk:
async () => {
getAction(`tag/onlCgformArea/delete`, { id: val }).then((res) => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
if (this.areaTable.length == 1 && this.queryParams.pageNo != 1) {
this.queryParams.pageNo = this.queryParams.pageNo - 1
}
this.loadData()
} else {
// this.$message.warning(res.message)
if (res.message == '该展示区域有关联数据无法删除') {
this.$message.warning(this.$t('noDelete'))
} else {
this.$message.warning(this.$t('operationFailed'))
}
}
})
}
})
.catch( (error) =>{
console.log(error);
});
},
//编辑按钮
editArea(val) {
@@ -217,15 +115,6 @@ export default {
})
}
},
watch: {
templateTitle(val) {
this.templatetitle = val
},
selectedRowKeyS(val) {
this.selectedRowKeys = val
}
}
}
</script>