@@ -54,6 +54,7 @@ import {
5454} from '@vicons/antd'
5555import { IDefinitionData } from '../types'
5656import styles from '../index.module.scss'
57+ import { queryProjectPreferenceByProjectCode } from '@/service/modules/projects-preference'
5758
5859const props = {
5960 row : {
@@ -172,6 +173,75 @@ export default defineComponent({
172173 ]
173174 }
174175
176+ const projectPreferences = ref ( { } as any )
177+
178+ const initProjectPreferences = async ( projectCode : number ) => {
179+ if ( projectCode ) {
180+ await queryProjectPreferenceByProjectCode ( projectCode ) . then (
181+ ( result : any ) => {
182+ if ( result ?. preferences && result . state === 1 ) {
183+ projectPreferences . value = JSON . parse ( result . preferences )
184+ }
185+ }
186+ )
187+ }
188+ }
189+
190+ const containValueInOptions = (
191+ options : Array < any > ,
192+ findingValue : string
193+ ) : boolean => {
194+ for ( let { value } of options ) {
195+ if ( findingValue === value ) {
196+ return true
197+ }
198+ }
199+ return false
200+ }
201+
202+ const restructureForm = async ( form : any ) => {
203+ await initProjectPreferences ( props . row . projectCode )
204+ if ( projectPreferences . value ?. taskPriority ) {
205+ form . processInstancePriority = projectPreferences . value . taskPriority
206+ }
207+ if ( projectPreferences . value ?. warningType ) {
208+ form . warningType = projectPreferences . value . warningType
209+ }
210+ if ( projectPreferences . value ?. workerGroup ) {
211+ if (
212+ containValueInOptions (
213+ variables . workerGroups ,
214+ projectPreferences . value . workerGroup
215+ )
216+ ) {
217+ form . workerGroup = projectPreferences . value . workerGroup
218+ }
219+ }
220+ if ( projectPreferences . value ?. tenant ) {
221+ if (
222+ containValueInOptions (
223+ variables . tenantList ,
224+ projectPreferences . value . tenant
225+ )
226+ ) {
227+ form . tenantCode = projectPreferences . value . tenant
228+ }
229+ }
230+ if (
231+ projectPreferences . value ?. environmentCode &&
232+ variables ?. environmentList
233+ ) {
234+ if (
235+ containValueInOptions (
236+ variables . environmentList ,
237+ projectPreferences . value . environmentCode
238+ )
239+ ) {
240+ form . environmentCode = projectPreferences . value . environmentCode
241+ }
242+ }
243+ }
244+
175245 const updateWorkerGroup = ( ) => {
176246 startState . startForm . environmentCode = null
177247 }
@@ -206,6 +276,7 @@ export default defineComponent({
206276 ( ) => {
207277 if ( props . show ) {
208278 getStartParamsList ( props . row . code )
279+ restructureForm ( startState . startForm )
209280 if ( props . taskCode )
210281 startState . startForm . startNodeList = props . taskCode
211282 }
@@ -438,8 +509,8 @@ export default defineComponent({
438509 </ NFormItem >
439510 ) }
440511 < NFormItem
441- label = { t ( 'project.workflow.order_of_execution' ) }
442- path = 'executionOrder'
512+ label = { t ( 'project.workflow.order_of_execution' ) }
513+ path = 'executionOrder'
443514 >
444515 < NRadioGroup v-model :value = { this . startForm . executionOrder } >
445516 < NSpace >
0 commit comments