¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <a-modal |
| | | :title="title" |
| | | :maskClosable="true" |
| | | :width="modalWidth" |
| | | @cancel="visible=false" |
| | | :visible="visible"> |
| | | <a-spin :spinning="confirmLoading"> |
| | | <a-form-model ref="form" :form="form" :model="model" :rules="validatorRules" :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol"> |
| | | |
| | | <a-row :gutter="24"> |
| | | <a-col :span="12"> |
| | | <a-form-model-item prop="controlSystemType" label="驱å¨ç±»å"> |
| | | <a-select v-model="model.controlSystemType" @change="handleDriveTypeChange" |
| | | placeholder="è¯·éæ©é©±å¨ç±»å"> |
| | | <a-select-option v-for="(item,index) in driveTypeList" :key="index" :value="item"> |
| | | {{item}} |
| | | </a-select-option> |
| | | </a-select> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | |
| | | <a-col :span="12"> |
| | | <a-form-model-item prop="chineseName" label="åæ°"> |
| | | <a-select v-model="model.chineseName" placeholder="è¯·éæ©åæ°"> |
| | | <a-select-option v-for="item in paramList" :key="item.value" :value="item.value"> |
| | | {{item.label}} |
| | | </a-select-option> |
| | | </a-select> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | </a-row> |
| | | |
| | | <a-row :gutter="24"> |
| | | |
| | | <a-col :span="12"> |
| | | <a-form-model-item prop="maxThreshold" label="éå¼ä¸é"> |
| | | <a-input-number v-model="model.maxThreshold" placeholder="请è¾å
¥éå¼ä¸é" style="width: 100%"></a-input-number> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | |
| | | <a-col :span="12"> |
| | | <a-form-model-item prop="minThreshold" label="éå¼ä¸é"> |
| | | <a-input-number v-model="model.minThreshold" placeholder="请è¾å
¥éå¼ä¸é" style="width: 100%"></a-input-number> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | |
| | | </a-row> |
| | | |
| | | </a-form-model> |
| | | </a-spin> |
| | | |
| | | |
| | | <template slot="footer"> |
| | | <a-popconfirm title="ç¡®å®æ¾å¼æä½ï¼" @confirm="visible=false" okText="ç¡®å®" cancelText="åæ¶"> |
| | | <a-button style="margin-right: .8rem">åæ¶</a-button> |
| | | </a-popconfirm> |
| | | <a-button @click="handleSubmit" type="primary" :loading="confirmLoading">æäº¤</a-button> |
| | | </template> |
| | | |
| | | </a-modal> |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | import pick from 'lodash.pick' |
| | | import api from '@/api/mdc' |
| | | |
| | | export default { |
| | | name: 'ParamThresholdModal', |
| | | components: {}, |
| | | props: { |
| | | driveTypeList: { |
| | | type: Array |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | modalWidth: 700, |
| | | form: this.$form.createForm(this), |
| | | validatorRules: { |
| | | controlSystemType: [ |
| | | { |
| | | required: true, message: 'è¯·éæ©é©±å¨ç±»å' |
| | | } |
| | | ], |
| | | chineseName: [ |
| | | { |
| | | required: true, message: 'è¯·éæ©åæ°' |
| | | } |
| | | ], |
| | | minThreshold: [ |
| | | { |
| | | required: true, message: '请è¾å
¥éå¼ä¸é' |
| | | }, |
| | | { |
| | | pattern: /^[0-9]+$/, |
| | | message: '请è¾å
¥é¿æä¼¯æ°å' |
| | | } |
| | | ], |
| | | maxThreshold: [ |
| | | { |
| | | required: true, message: '请è¾å
¥éå¼ä¸é' |
| | | }, |
| | | { |
| | | pattern: /^[0-9]+$/, |
| | | message: '请è¾å
¥é¿æä¼¯æ°å' |
| | | } |
| | | ] |
| | | }, |
| | | title: 'æä½', |
| | | visible: false, |
| | | model: { |
| | | controlSystemType: '', |
| | | chineseName: '', |
| | | minThreshold: '', |
| | | maxThreshold: '' |
| | | }, |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 6 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 15 } |
| | | }, |
| | | confirmLoading: false, |
| | | url: { |
| | | userId: '/sys/user/generateUserId' // å¼å
¥çææ·»å ç¨æ·æ
åµä¸çurl |
| | | }, |
| | | paramList: [] |
| | | } |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | methods: { |
| | | add() { |
| | | this.visible = true |
| | | this.model = { |
| | | controlSystemType: this.driveTypeList[0], |
| | | chineseName: '', |
| | | minThreshold: '', |
| | | maxThreshold: '' |
| | | } |
| | | console.log('driveType',this.driveTypeList) |
| | | this.handleDriveTypeChange(this.driveTypeList[0]) |
| | | this.$nextTick(() => { |
| | | this.form.setFieldsValue(pick(this.model, 'controlSystemType', 'chineseName', 'minThreshold', 'maxThreshold')) |
| | | }) |
| | | }, |
| | | |
| | | edit(record) { |
| | | this.visible = true |
| | | this.model = Object.assign({}, record) |
| | | api.getParamListByDriveTypeApi(record.controlSystemType) |
| | | .then(res => { |
| | | if (res.success) { |
| | | this.paramList = res.result |
| | | } |
| | | }) |
| | | this.model.chineseName = `${record.englishName}(${record.chineseName})` |
| | | this.$nextTick(() => { |
| | | this.form.setFieldsValue(pick(this.model, 'controlSystemType', 'chineseName', 'minThreshold', 'maxThreshold')) |
| | | }) |
| | | }, |
| | | |
| | | handleSubmit() { |
| | | const that = this |
| | | // 触å表åéªè¯ |
| | | this.$refs.form.validate(valid => { |
| | | if (valid) { |
| | | if (this.model.maxThreshold > this.model.minThreshold) { |
| | | that.confirmLoading = true |
| | | let obj |
| | | if (this.title == 'æ°å¢') { |
| | | obj = api.addParamThresholdApi(this.model) |
| | | } else { |
| | | obj = api.editParamThresholdApi(this.model) |
| | | } |
| | | obj.then((res) => { |
| | | if (res.success) { |
| | | that.$notification.success({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | that.$emit('ok') |
| | | } else { |
| | | that.$notification.warning({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false |
| | | this.visible = false |
| | | }) |
| | | } else { |
| | | this.$notification.warning({ |
| | | message: 'æ¶æ¯', |
| | | description: 'éå¼ä¸éä¸è½å°äºçäºéå¼ä¸é' |
| | | }) |
| | | } |
| | | |
| | | } else { |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * èæ³è¾å
¥æ¡çéåè½ |
| | | * @param input è¾å
¥çå
容 |
| | | * @param option é
ç½® |
| | | * @returns {boolean} 夿æ¯å¦çé |
| | | */ |
| | | filterOption(input, option) { |
| | | return ( |
| | | option.componentOptions.children[0].text.toUpperCase().indexOf(input.toUpperCase()) >= 0 |
| | | ) |
| | | }, |
| | | |
| | | /** |
| | | * 驱å¨åæ°ç±»åéä¸å渲æç¸åºçåæ°å表 |
| | | * @param value 驱å¨åæ°ç±»åéä¸é¡¹ |
| | | */ |
| | | handleDriveTypeChange(value) { |
| | | api.getParamListByDriveTypeApi(value) |
| | | .then(res => { |
| | | if (res.success) { |
| | | this.paramList = res.result |
| | | this.model.chineseName = res.result.length ? res.result[0].value : undefined |
| | | if (this.model.chineseName) this.$refs.form.clearValidate('chineseName') |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * ç¼è¾ææ¥ç详æ
æ°æ®æ¶æ¸
餿½å±è¡¨åéªè¯ |
| | | */ |
| | | removeValidate() { |
| | | if (this.$refs.form) this.$refs.form.clearValidate() |
| | | } |
| | | } |
| | | |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |