From 2ecf3363eca41ed38f4bf9f50d62cdd14d75d166 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期一, 06 十一月 2023 10:53:54 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/mes-ocea-before

---
 src/views/equipment/metering/metering-form.vue |  201 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 201 insertions(+), 0 deletions(-)

diff --git a/src/views/equipment/metering/metering-form.vue b/src/views/equipment/metering/metering-form.vue
new file mode 100644
index 0000000..1d290dd
--- /dev/null
+++ b/src/views/equipment/metering/metering-form.vue
@@ -0,0 +1,201 @@
+<template>
+    <el-dialog
+      :title="!dataForm.id ? '鏂板' : '淇敼'"
+      :close-on-click-modal="false"
+      :visible.sync="visible"
+    >
+      <el-form
+        :model="dataForm"
+        :rules="dataRule"
+        ref="dataForm"
+        label-width="80px"
+        class="l-mes"
+      >
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="缂栧彿" prop="code">
+              <el-input v-model="dataForm.code" placeholder="缂栧彿"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鍚嶇О" prop="name">
+              <el-input v-model="dataForm.name" placeholder="鍚嶇О"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="绫诲瀷" prop="type">
+              <el-select
+                v-model="dataForm.type"
+                filterable
+                placeholder="璇烽�夋嫨"
+                style="width:100%"
+              >
+                <el-option
+                  v-for="item in workshopList"
+                  :key="item.id"
+                  :label="item.label"
+                  :value="item.value"
+                >
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鍘傚" prop="supplier">
+              <el-input
+                v-model="dataForm.supplier"
+                placeholder="鍘傚"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鐘舵��" prop="state">
+              <el-select
+                v-model="dataForm.status"
+                placeholder="鐘舵��"
+                filterable
+                style="width: 100%"
+              >
+                <el-option
+                  v-for="item in equipmentState"
+                  :key="item.id"
+                  :label="item.label"
+                  :value="item.label"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="visible = false">鍙栨秷</el-button>
+        <el-button
+          type="primary"
+          :disabled="isSubmit"
+          v-thinclick="`dataFormSubmit`"
+          >纭畾</el-button
+        >
+      </span>
+    </el-dialog>
+  </template>
+  <script>
+  import { getObj, addObj, putObj } from '@/api/equipment/metering'
+  import { loadFactoryList } from '@/api/basic/factory'
+  import { remote } from '../../../api/admin/dict'
+  export default {
+    data() {
+      return {
+        // options: regionData,
+        visible: false,
+        dataForm: {
+          id: 0,
+          number: '',
+          name: '',
+          factoryId: '',
+          workshop: '',
+          position: '',
+          email: '',
+          supplier: '',
+          manufacturer: '',
+          typeSpecification: '',
+          manufactureDate: '',
+          installDate: '',
+          state: '',
+          description: '',
+          value1: '',
+          code: null,
+          type: null,
+          status: null,
+          supplier: null
+        },
+        dataRule: {
+          number: [{ required: true, message: '缂栧彿涓嶈兘涓虹┖', trigger: 'blur' }],
+          name: [{ required: true, message: '鍚嶇О涓嶈兘涓虹┖', trigger: 'blur' }]
+        },
+        factoryOptions: [],
+        equipmentState: [],
+        isSubmit: false,
+        workshopList: [{
+            label: "鍘熸潗鏂欐楠�",
+            value: '鍘熸潗鏂欐楠�'
+        },{
+            label: '杩囩▼妫�楠�',
+            value: '杩囩▼妫�楠�'
+        }]
+      }
+    },
+    methods: {
+      init(id) {
+        this.dataForm.id = id || 0
+        this.visible = true
+        this.$nextTick(() => {
+          this.$refs.dataForm.resetFields()
+          if (this.dataForm.id) {
+            getObj(this.dataForm.id).then((response) => {
+              this.dataForm = response.data.data
+            })
+          } else {
+            if (this.factoryOptions.length > 0) {
+              this.dataForm.factoryId = this.factoryOptions[0].id
+            }
+          }
+        })
+      },
+      // 琛ㄥ崟鎻愪氦
+      getEquipmentState() {
+        remote('equipment_state').then((response) => {
+          if (response.data.code === 0) {
+            this.equipmentState = response.data.data
+          }
+        })
+      },
+      dataFormSubmit() {
+        this.isSubmit = true
+        this.$refs.dataForm.validate((valid) => {
+          if (valid) {
+            if (this.dataForm.id) {
+              putObj(this.dataForm).then((data) => {
+                this.$message.success('淇敼鎴愬姛')
+                this.visible = false
+                this.isSubmit = false
+                this.$emit('refreshDataList')
+              })
+            } else {
+              addObj(this.dataForm).then((data) => {
+                this.$message.success('娣诲姞鎴愬姛')
+                this.visible = false
+                this.isSubmit = false
+                this.$emit('refreshDataList')
+              })
+            }
+          } else {
+            this.isSubmit = false
+          }
+        })
+      },
+  
+      initFactorySelect() {
+        loadFactoryList().then((res) => {
+          this.factoryOptions = res.data
+          if (this.factoryOptions.length > 0) {
+            this.dataForm.factoryId = this.factoryOptions[0].id
+          }
+        })
+      }
+    },
+  
+    created() {
+      this.initFactorySelect()
+      this.getEquipmentState()
+  
+    //   remote('work_shop').then((response) => {
+    //     if (response.data.code === 0) {
+    //       this.workshopList = response.data.data
+    //     } else {
+    //       this.workshopList = []
+    //     }
+    //   })
+    }
+  }
+  </script>
+  
\ No newline at end of file

--
Gitblit v1.9.3