Skip to content

Commit 54e05a9

Browse files
authored
Merge pull request #316 from WeBankPartners/dev
Dev
2 parents 5a7acc8 + e13d272 commit 54e05a9

File tree

6 files changed

+278
-47
lines changed

6 files changed

+278
-47
lines changed

artifacts-ui/src/api/server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const getCiTypeAttr = id => req.get(`/ci-types/${id}/attributes`)
4545
export const getSpecialConnector = () => req.get('/static-data/special-connector')
4646
export const getVariableRootCiTypeId = () => req.get('/getVariableRootCiTypeId')
4747
export const getEntitiesByCiType = (packageName, ci, data) => req.post(`/platform/v1/packages/${packageName}/entities/${ci}/retrieve`, data)
48+
// 获取cmdb中差异化变量
49+
export const getDiffVariable = (citype, data) => req.post(`/cidata/${citype}/query`, data)
50+
4851
export const queryArtifactsList = (guid, data) => req.post(`/unit-designs/${guid}/packages/queryNexusDirectiry`, data)
4952
export const uploadArtifact = (guid, url, baselinePackage, packageType) => req.post(`/unit-designs/${guid}/packages/uploadNexusPackage?downloadUrl=${url}&baseline_package=${encodeURIComponent(baselinePackage)}&package_type=${encodeURIComponent(packageType)}`)
5053

artifacts-ui/src/components/pkg-diff-variable.vue

Lines changed: 169 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,26 @@
6060
<div class="drawer-footer">
6161
<Button @click="openDrawer = false" type="primary">{{ $t('art_close') }}</Button>
6262
</div>
63-
<Modal :mask-closable="false" v-model="isShowConfigKeyModal" :title="$t('artifacts_property_value_fill_rule')" @on-ok="setConfigRowValue" @on-cancel="closeConfigSelectModal">
64-
<div style="display: flex">
65-
<Input type="text" :placeholder="$t('artifacts_unselected')" v-model="customSearch"> </Input>
66-
<Button type="primary" @click="remoteConfigSearch" :loading="remoteLoading">{{ $t('search') }}</Button>
63+
<Modal :mask-closable="false" v-model="isShowConfigKeyModal" :fullscreen="fullscreen" width="900">
64+
<p slot="header">
65+
<span>{{ $t('art_copy_exist') }}</span>
66+
<Icon v-if="!fullscreen" @click="zoomModalMax" class="header-icon" type="ios-expand" />
67+
<Icon v-else @click="zoomModalMin" class="header-icon" type="ios-contract" />
68+
</p>
69+
<div slot="footer">
70+
<Button type="text" @click="closeConfigSelectModal()">{{ $t('artifacts_cancel') }} </Button>
71+
<Button type="primary" @click="setConfigRowValue()">{{ $t('art_ok') }} </Button>
72+
</div>
73+
<div style="display: flex;gap: 8px;margin-bottom: 8px;">
74+
<Select style="width: 200px;" @on-change="remoteConfigSearch()" :placeholder="$t('artifacts_uploaded_by')" v-model="tempCopyParams.variable_type">
75+
<Option v-for="item in ['GLOBAL', 'PRIVATE', 'ENCRYPTED', 'FILE']" :value="item" :key="item">{{ item }}</Option>
76+
</Select>
77+
<Input style="width: 200px;" v-model="tempCopyParams.variable_name" @on-change="remoteConfigSearch()" :placeholder="$t('art_variable_name')" clearable />
78+
<Select style="width: 200px;" clearable filterable @on-change="remoteConfigSearch()" @on-clear="tempCopyParams.create_user = ''" :placeholder="$t('artifacts_uploaded_by')" v-model="tempCopyParams.create_user">
79+
<Option v-for="user in userList" :value="user.username" :key="user.id">{{ user.username }}</Option>
80+
</Select>
6781
</div>
68-
<Select ref="ddrop" :disabled="!allDiffConfigs || allDiffConfigs.length === 0" filterable clearable v-model="currentConfigId" style="margin-top: 10px">
69-
<Option v-for="conf in allDiffConfigs.filter(conf => conf.variable_value && conf.code !== currentConfigRow.key)" :value="conf.id" :key="conf.key_name">{{ conf.key_name }}</Option>
70-
</Select>
82+
<RuleTable :data="tempCopyTableData" ref="tempCopyTableRef" :columns="tempCopyColomns" :page="page" @reloadTableData="remoteConfigSearch" :maxHeight="fileContentHeight" :loading="remoteLoading"></RuleTable>
7183
</Modal>
7284
<Modal :mask-closable="false" v-model="isShowBatchBindModal" :width="800" :title="$t('multi_bind_config')">
7385
<Card>
@@ -103,10 +115,12 @@
103115
</template>
104116

105117
<script>
106-
import { sysConfig, getSpecialConnector, getAllCITypesWithAttr, getPackageCiTypeId, getSystemDesignVersions, updateEntity, getPackageDetail, updatePackage, getVariableRootCiTypeId, getEntitiesByCiType } from '@/api/server.js'
118+
import { getUserList, sysConfig, getSpecialConnector, getAllCITypesWithAttr, getPackageCiTypeId, getSystemDesignVersions, updateEntity, getPackageDetail, updatePackage, getVariableRootCiTypeId, getEntitiesByCiType, getDiffVariable } from '@/api/server.js'
107119
import { setCookie, getCookie } from '../util/cookie.js'
108120
import axios from 'axios'
109121
import { decode } from 'js-base64'
122+
import RuleTable from './rule-table.vue'
123+
import { debounce } from 'lodash'
110124
// 业务运行实例ciTypeId
111125
const defaultAppRootCiTypeId = 'app_instance'
112126
const defaultDBRootCiTypeId = 'rdb_instance'
@@ -155,7 +169,6 @@ export default {
155169
packageId: '',
156170
157171
customInputs: [],
158-
customSearch: '',
159172
// -------------------
160173
// 差异化变量数据
161174
// -------------------
@@ -186,7 +199,6 @@ export default {
186199
isShowConfigKeyModal: false,
187200
isShowCiConfigModal: false,
188201
currentConfigRow: {},
189-
allDiffConfigs: [],
190202
allCIConfigs: [],
191203
attrsTableColomnOptions: [
192204
{
@@ -315,7 +327,60 @@ export default {
315327
],
316328
prefixType: 'variable_prefix_default', // 前缀
317329
tempTableData: [], // 通过类型、文件、前缀过滤后的展示数据
318-
currentFileIndex: -1 // 缓存单签文件顺序
330+
currentFileIndex: -1, // 缓存单签文件顺序
331+
tempCopySelectRow: {
332+
guid: ''
333+
},
334+
// 选择已有模版-开始
335+
tempCopyColomns: [
336+
{
337+
title: '',
338+
align: 'center',
339+
width: 30,
340+
render: (h, params) => {
341+
return (
342+
<Radio
343+
value={params.row.guid === this.tempCopySelectRow.guid}
344+
onInput={value => {
345+
this.selectTemp(params.row)
346+
}}
347+
></Radio>
348+
)
349+
}
350+
},
351+
{
352+
title: this.$t('art_variable_name'),
353+
width: 200,
354+
key: 'variable_name'
355+
},
356+
{
357+
title: this.$t('art_value_rule'),
358+
key: 'variable_value',
359+
render: (h, params) => {
360+
return <ArtifactsAutoFill style="margin-top:5px;" allCiTypes={this.ciTypes} specialDelimiters={this.specialDelimiters} rootCiTypeId="" isReadOnly={true} v-model={params.row.variable_value} cmdbPackageName={cmdbPackageName} />
361+
}
362+
},
363+
{
364+
title: this.$t('art_creator'),
365+
width: 120,
366+
key: 'create_user'
367+
}
368+
],
369+
tempCopyTableData: [],
370+
page: {
371+
currentPage: 1,
372+
pageSize: 10,
373+
total: 0
374+
},
375+
tempCopyParams: {
376+
variable_name: '',
377+
create_user: '',
378+
variable_type: 'GLOBAL'
379+
},
380+
userList: [],
381+
// 选择已有模版-结束
382+
fullscreen: false,
383+
fileContentHeight: window.screen.availHeight * 0.4 + 100
319384
}
320385
},
321386
computed: {},
@@ -698,12 +763,6 @@ export default {
698763
renderConfigButton (params) {
699764
let row = params.row
700765
return [
701-
// <Tooltip placement="top" max-width="200" content={this.$t('variable_select_key_tooltip')}>
702-
// <Button disabled={!!row.conf_variable.fixedDate} size="small" type="primary" style="margin-right:5px;margin-bottom:5px;" onClick={async () => this.showConfigKeyModal(row)}>
703-
// {this.$t('select_key')}
704-
// </Button>
705-
// </Tooltip>,
706-
// disable no dirty data or row is confirmed
707766
<Button disabled={!!(row.conf_variable.diffExpr === row.conf_variable.originDiffExpr || row.conf_variable.fixedDate)} size="small" type="info" style="margin-right:5px;margin-bottom:5px;" onClick={() => this.saveConfigVariableValue(row)}>
708767
{this.$t('artifacts_save')}
709768
</Button>
@@ -742,23 +801,81 @@ export default {
742801
cancelBatchBindOperation () {
743802
this.isShowBatchBindModal = false
744803
},
804+
selectTemp (val) {
805+
this.tempCopySelectRow = val
806+
},
745807
async showConfigKeyModal (row) {
808+
this.tempCopyParams = {
809+
variable_name: '',
810+
create_user: '',
811+
variable_type: 'GLOBAL'
812+
}
813+
this.getUserList()
814+
await this.remoteConfigSearch()
815+
this.tempCopySelectRow = {
816+
guid: ''
817+
}
818+
this.fullscreen = false
746819
this.isShowConfigKeyModal = true
747820
this.currentConfigRow = row
748-
// }
749-
},
750-
async remoteConfigSearch () {
751-
const query = this.customSearch
752-
if (typeof query === 'string' && query.trim().length > 0) {
753-
this.remoteLoading = true
754-
const diffConfigs = await getEntitiesByCiType(cmdbPackageName, DIFF_CONFIGURATION, { criteria: {}, additionalFilters: [{ attrName: 'code', op: 'like', condition: query.trim() }] })
755-
if (diffConfigs) {
756-
this.allDiffConfigs = diffConfigs.data
757-
this.$nextTick(() => {
758-
this.$refs['ddrop'].toggleMenu(null, true)
759-
})
760-
}
761-
this.remoteLoading = false
821+
},
822+
remoteConfigSearch: debounce(async function (
823+
pageable = {
824+
pageSize: 10,
825+
currentPage: 1
826+
}
827+
) {
828+
this.remoteLoading = true
829+
let params = {
830+
dialect: {
831+
queryMode: 'new'
832+
},
833+
filters: [],
834+
pageable: {},
835+
sorting: {
836+
asc: false,
837+
field: 'update_time'
838+
},
839+
paging: true
840+
}
841+
params.pageable.pageSize = pageable.pageSize
842+
params.pageable.startIndex = (pageable.currentPage - 1) * this.page.pageSize
843+
844+
if (this.tempCopyParams.variable_name !== '') {
845+
params.filters.push({
846+
name: 'variable_name',
847+
operator: 'contains',
848+
value: this.tempCopyParams.variable_name
849+
})
850+
}
851+
if (this.tempCopyParams.create_user) {
852+
params.filters.push({
853+
name: 'create_user',
854+
operator: 'eq',
855+
value: this.tempCopyParams.create_user
856+
})
857+
}
858+
if (this.tempCopyParams.variable_type) {
859+
params.filters.push({
860+
name: 'variable_type',
861+
operator: 'eq',
862+
value: this.tempCopyParams.variable_type
863+
})
864+
}
865+
866+
const diffConfigs = await getDiffVariable(DIFF_CONFIGURATION, params)
867+
if (diffConfigs) {
868+
this.tempCopyTableData = diffConfigs.data.contents
869+
this.page.total = diffConfigs.data.pageInfo.totalRows
870+
this.page.currentPage = pageable.currentPage
871+
this.$refs.tempCopyTableRef.setPage(this.page)
872+
}
873+
this.remoteLoading = false
874+
}, 300),
875+
async getUserList () {
876+
let { status, data } = await getUserList()
877+
if (status === 'OK') {
878+
this.userList = data || []
762879
}
763880
},
764881
handleCIConfigChange (code) {
@@ -805,18 +922,14 @@ export default {
805922
}
806923
},
807924
setConfigRowValue () {
808-
if (this.currentConfigId) {
809-
const tmp = this.currentDiffConfigTab === this.constPackageOptions.db ? 'db_diff_conf_file' : 'diff_conf_file'
810-
this.packageDetail[tmp].forEach(elFile => {
811-
elFile.configKeyInfos.forEach(elFileVar => {
812-
if (this.currentConfigRow.key.toLowerCase() === elFileVar.key.toLowerCase()) {
813-
const tmp = this.allDiffConfigs.find(item => item.id === this.currentConfigId)
814-
elFileVar.conf_variable.diffExpr = tmp.variable_value
815-
}
816-
})
925+
const tmp = this.currentDiffConfigTab === this.constPackageOptions.db ? 'db_diff_conf_file' : 'diff_conf_file'
926+
this.packageDetail[tmp].forEach(elFile => {
927+
elFile.configKeyInfos.forEach(elFileVar => {
928+
if (this.currentConfigRow.key.toLowerCase() === elFileVar.key.toLowerCase()) {
929+
elFileVar.conf_variable.diffExpr = this.tempCopySelectRow.variable_value
930+
}
817931
})
818-
// this.$set(this.packageDetail.diff_conf_variable[this.currentConfigRow._index], 'diffExpr', this.currentConfigValue)
819-
}
932+
})
820933
this.closeConfigSelectModal()
821934
},
822935
setCIConfigRowValue () {
@@ -841,8 +954,7 @@ export default {
841954
this.currentConfigValue = ''
842955
this.isShowConfigKeyModal = false
843956
this.currentConfigRow = {}
844-
this.customSearch = ''
845-
this.allDiffConfigs = []
957+
this.tempCopyTableData = []
846958
},
847959
closeCIConfigSelectModal () {
848960
this.currentConfigValue = ''
@@ -902,13 +1014,25 @@ export default {
9021014
},
9031015
handleResize () {
9041016
this.maxHeight = window.innerHeight - 290
1017+
},
1018+
1019+
// #endregion
1020+
zoomModalMax () {
1021+
this.fileContentHeight = window.screen.availHeight - 410
1022+
this.fullscreen = true
1023+
},
1024+
zoomModalMin () {
1025+
this.fileContentHeight = window.screen.availHeight * 0.4 + 100
1026+
this.fullscreen = false
9051027
}
9061028
},
9071029
created () {
9081030
this.fetchData()
9091031
this.getSpecialConnector()
9101032
},
911-
components: {}
1033+
components: {
1034+
RuleTable
1035+
}
9121036
}
9131037
</script>
9141038

0 commit comments

Comments
 (0)