策略运行
This commit is contained in:
@ -4,58 +4,99 @@
|
||||
custom-class="ems-dialog"
|
||||
:visible.sync="dialogFormVisible"
|
||||
width="420px"
|
||||
destroy-on-close
|
||||
lock-scroll
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
@close="cancel"
|
||||
>
|
||||
<el-form :model="form" label-width="100px">
|
||||
<el-form-item label="主策略">
|
||||
<el-select v-model="form.main" placeholder="请选择">
|
||||
<el-option label="主策略一" value="1"></el-option>
|
||||
<el-option label="主策略二" value="2"></el-option>
|
||||
<el-form ref="form" :model="form" :rules='rule' label-width="100px" v-loading="loading > 0">
|
||||
<el-form-item label="主策略" prop="mainStrategyId">
|
||||
<el-select v-model="form.mainStrategyId" placeholder="请选择">
|
||||
<el-option :label="item.strategyName" :value="item.id" v-for="(item,index) in mainStrategyList" :key="index+'mainStrategyList'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="辅助策略">
|
||||
<el-select v-model="form.assis" placeholder="请选择">
|
||||
<el-option label="辅助策略一" value="1"></el-option>
|
||||
<el-option label="辅助策略二" value="2"></el-option>
|
||||
<el-form-item label="辅助策略" prop="auxStrategyId">
|
||||
<el-select v-model="form.auxStrategyId" placeholder="请选择" clearable>
|
||||
<el-option :label="item.strategyName" :value="item.id" v-for="(item,index) in auxStrategyList" :key="index+'auxStrategyList'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible=false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="sure">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading > 0" @click="sure">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getMainStrategyList, getAuxStrategyList, configStrategy} from '@/api/ems/dzjk'
|
||||
export default {
|
||||
inject:['$home'],
|
||||
data(){
|
||||
return {
|
||||
loading:false,
|
||||
info:{},
|
||||
loading:0,
|
||||
dialogFormVisible:false,
|
||||
mainStrategyList:[],
|
||||
auxStrategyList:[],
|
||||
form:{
|
||||
main:'',
|
||||
assis:''
|
||||
mainStrategyId:'',
|
||||
auxStrategyId:''
|
||||
},
|
||||
rule:{
|
||||
mainStrategyId:[
|
||||
{ required: true, message: '请选择主策略', trigger: ['blur','change'] },
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
showSettingDialog(item){
|
||||
console.log('打开弹窗',item)
|
||||
this.dialogFormVisible = true
|
||||
this.info = item || {}
|
||||
const {auxStrategyId = '',mainStrategyId = ''} = item
|
||||
this.form.auxStrategyId=auxStrategyId
|
||||
this.form.mainStrategyId=mainStrategyId
|
||||
this.init()
|
||||
},
|
||||
init(){
|
||||
this.loading+=2
|
||||
this.mainStrategyList=[]
|
||||
this.auxStrategyList=[]
|
||||
getMainStrategyList().then(response => {
|
||||
this.mainStrategyList=response?.data || []
|
||||
}).finally(()=>{this.loading-=1})
|
||||
getAuxStrategyList().then(response => {
|
||||
this.auxStrategyList=response?.data || []
|
||||
}).finally(()=>{this.loading-=1})
|
||||
},
|
||||
cancel(){
|
||||
this.form.main='';
|
||||
this.form.assis='';
|
||||
this.$refs.form.resetFields()
|
||||
this.form={
|
||||
mainStrategyId:'',
|
||||
auxStrategyId:''
|
||||
}
|
||||
this.dialogFormVisible = false;
|
||||
},
|
||||
sure(){
|
||||
if(this.form.main===''||this.form.assis===''){
|
||||
return this.$alert('请选择正确的策略');
|
||||
}
|
||||
this.loading = true
|
||||
setTimeout(()=>{
|
||||
this.loading = false
|
||||
//如果接口调用成功 关闭弹窗
|
||||
this.dialogFormVisible = false;
|
||||
},3000)
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (!valid) return
|
||||
console.log('this.$home',this.$home)
|
||||
this.loading +=1
|
||||
const {mainStrategyId='', auxStrategyId=''} = this.form
|
||||
configStrategy({mainStrategyId,auxiliaryStrategyId:auxStrategyId,siteId:this.$home.siteId,id:this.info?.id || ''}).then(response => {
|
||||
if(response?.code === 200){
|
||||
this.$home.init()
|
||||
this.cancel()
|
||||
}
|
||||
}).finally(()=>{
|
||||
this.loading -=1
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user