From ba77fdc6a30c9ad0941e40319f8c4f6fe6fdf9f1 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期四, 07 八月 2025 10:30:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/mdc/base/modules/DeviceParamThresholdManagement/ParamThresholdModal.vue |  252 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 252 insertions(+), 0 deletions(-)

diff --git a/src/views/mdc/base/modules/DeviceParamThresholdManagement/ParamThresholdModal.vue b/src/views/mdc/base/modules/DeviceParamThresholdManagement/ParamThresholdModal.vue
new file mode 100644
index 0000000..73e9c7c
--- /dev/null
+++ b/src/views/mdc/base/modules/DeviceParamThresholdManagement/ParamThresholdModal.vue
@@ -0,0 +1,252 @@
+<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>
\ No newline at end of file

--
Gitblit v1.9.3