huang_an 1 год назад
Родитель
Сommit
e2ba88d27a

+ 54 - 44
src/views/rulesManagement/meteringManagement/baseDialog.vue

@@ -6,9 +6,9 @@
     width="60%"
   >
     <el-form label-width="100px" :model="formData" class="zw-criterion">
-      <div class="el-form-item checkbox">
+      <!-- <div class="el-form-item checkbox">
         <el-checkbox v-model="formData.checked">基准计量单位</el-checkbox>
-      </div>
+      </div> -->
       <el-form-item label="编码" required>
         <el-input
           v-model="formData.code"
@@ -21,12 +21,12 @@
       </el-form-item>
       <el-form-item label="所属组别" required>
         <el-input
-          v-model="formData.name"
+          v-model="formData.parentName"
           placeholder="请输入内容"
           disabled
         ></el-input>
       </el-form-item>
-      <el-form-item label="换算类型">
+      <!-- <el-form-item label="换算类型">
         <el-select
           v-model="formData.type"
           :placeholder="`请选择${formData.type}`"
@@ -40,15 +40,15 @@
           >
           </el-option>
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="精度" required>
         <el-input-number
-          v-model="formData.precision"
+          v-model="formData.precisions"
           :min="0"
           :max="5"
         ></el-input-number>
       </el-form-item>
-      <el-form-item label="舍入类型" required>
+      <!-- <el-form-item label="舍入类型" required>
         <template>
           <el-select v-model="formData.type" placeholder="请选择">
             <el-option
@@ -73,7 +73,7 @@
             </el-option>
           </el-select>
         </template>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item class="w100" label="换算关系">
         <div class="top">
           <div class="">换算分母</div>
@@ -87,24 +87,26 @@
         <div class="bottom">
           <div
             ><el-input-number
-              v-model="num1"
-              :precision="formData.precision"
+              v-model="formData.measureNum"
+              :precision="formData.precisions"
             ></el-input-number
           ></div>
           <div class="unit">*</div>
           <div>
-            <DictSelection dictName="计量单位" v-model="formData.unit1" />
+            <DictSelection dictName="计量单位" v-model="formData.measureUnit" />
           </div>
           <div class="unit">=</div>
           <div
             ><el-input-number
-              v-model="num2"
-              :precision="formData.precision"
+              v-model="formData.conversionNum"
+              :precision="formData.precisions"
             ></el-input-number
           ></div>
           <div class="unit">*</div>
           <div
-            ><DictSelection dictName="计量单位" v-model="formData.unit2"
+            ><DictSelection
+              dictName="计量单位"
+              v-model="formData.conversionUnit"
           /></div>
         </div>
       </el-form-item>
@@ -125,20 +127,24 @@
 </template>
 
 <script>
-  import { getImageUrl } from '@/utils/file';
+  import { getCode } from '@/api/codeManagement';
   import {
-    saveInfo,
-    updateInfo,
-    getDetails
-  } from '@/api/system/unifiedPortal/index.js';
+    saveCategorymeasure,
+    updateCategorymeasure,
+    getCategorymeasureDetails
+  } from '@/api/ruleManagement/meteringManagement.js';
   export default {
     data() {
       return {
         precision: 2,
         formData: {
-          type: 1,
-          precision: 2,
-          dataType: 1
+          code: '',
+          name: '',
+          measureNum: '',
+          measureUnit: '',
+          conversionNum: '',
+          conversionUnit: '',
+          precisions: 2
         },
         num1: '',
         num2: '',
@@ -170,46 +176,50 @@
         ],
         dialogVisible: false,
         file: null,
-        type: '新增'
+        type: '新增',
+        parentId: ''
       };
     },
     methods: {
       handleClose() {
         this.dialogVisible = false;
       },
-      async open(type, id) {
+      async open(type, parentObj, id) {
         this.type = type;
         if (type == '新增') {
-          this.form = {};
-          this.imageUrl = '';
-          this.file = null;
+          this.formData = {
+            code: await getCode('metrological_code'),
+            name: '',
+            measureNum: '',
+            parentName: parentObj.name,
+            parentId: parentObj.id,
+            measureUnit: '',
+            conversionNum: '',
+            conversionUnit: '',
+            precisions: 2
+          };
         } else {
-          this.file = null;
-          this.form = await getDetails(id);
-          this.imageUrl = getImageUrl(this.form.iconPath);
+          this.formData = await getCategorymeasureDetails(id);
         }
+        console.log('this.formData------------', this.formData);
         this.dialogVisible = true;
       },
       async config() {
-        if (!this.form.name) {
+        if (!this.formData.name) {
           return this.$message.error('请输入名称');
         }
-        if (this.form.sort < 0) {
-          return this.$message.error('请输入排序');
-        }
-        if (!this.form.linkUrl) {
-          return this.$message.error('请输入链接');
-        }
-        if (this.form.linkType < 0) {
-          return this.$message.error('请选择链接类型');
-        }
-        if (this.form.architType < 0) {
-          return this.$message.error('请选择架构类型');
+        if (
+          !(this.formData.measureNum > 0) &&
+          !(this.formData.conversionNum > 0) &&
+          !this.formData.measureUnit &&
+          !this.formData.conversionUnit
+        ) {
+          return this.$message.error('请输入正确换算关系数据');
         }
         if (this.type == '新增') {
           // 保存数据
           try {
-            await saveInfo(this.form);
+            await saveCategorymeasure(this.formData);
             this.$message.success('新增成功');
             this.dialogVisible = false;
             this.$emit('reload');
@@ -220,7 +230,7 @@
         } else {
           // 修改
           try {
-            await updateInfo(this.form);
+            await updateCategorymeasure(this.formData);
             this.$message.success('修改成功');
             this.dialogVisible = false;
             this.$emit('reload');

+ 65 - 16
src/views/rulesManagement/meteringManagement/index.vue

@@ -6,12 +6,16 @@
           <el-button icon="el-icon-plus" type="primary" @click="addType('新增')"
             >新增</el-button
           >
-          <el-button icon="el-icon-edit" type="success" @click="addType('修改')"
+          <el-button
+            v-if="currentObj.id"
+            icon="el-icon-edit"
+            type="success"
+            @click="addType('修改')"
             >修改</el-button
           >
-          <el-button icon="el-icon-delete" type="danger" @click="deleted()"
+          <!-- <el-button icon="el-icon-delete" type="danger" @click="deleted()"
             >删除</el-button
-          >
+          > -->
         </div>
         <el-tree
           class="tree"
@@ -29,10 +33,13 @@
         <div class="search_bar">
           <el-input
             placeholder="请输入关键词"
-            v-model="keyWord"
+            v-model="name"
+            clearable
             class="input-with-select"
           >
-            <el-button slot="append" icon="el-icon-search">搜索</el-button>
+            <el-button slot="append" icon="el-icon-search" @click="search"
+              >搜索</el-button
+            >
           </el-input>
         </div>
         <div class="table_box">
@@ -46,6 +53,7 @@
             <!-- 表头工具栏 -->
             <template v-slot:toolbar>
               <el-button
+                v-if="currentObj.id"
                 size="small"
                 type="primary"
                 icon="el-icon-plus"
@@ -55,6 +63,16 @@
                 新增
               </el-button>
             </template>
+            <template v-slot:action="{ row }">
+              <el-link
+                type="primary"
+                :underline="false"
+                icon="el-icon-edit"
+                @click="openEdit('修改', row)"
+              >
+                修改
+              </el-link>
+            </template>
           </ele-pro-table>
         </div>
       </div>
@@ -72,7 +90,10 @@
     components: { baseDialog, typeDialog },
     data() {
       return {
-        currentId: '',
+        currentObj: {
+          id: '',
+          name: ''
+        },
         // 表格列配置
         columns: [
           {
@@ -92,9 +113,24 @@
             prop: 'name',
             label: '名称',
             showOverflowTooltip: true
+          },
+          {
+            prop: 'parentName',
+            label: '分组',
+            showOverflowTooltip: true
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 200,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
           }
         ],
-        keyWord: '',
+
+        name: '',
         tableData: [
           {
             name: '包',
@@ -121,24 +157,32 @@
         ],
         defaultProps: {
           children: 'children',
-          label: 'label'
+          label: 'name'
         }
       };
     },
-    async created() {
+    async mounted() {
       this.getTypeList(); // 获取侧边栏分类列表
-      this.getPages(); // 获取表格数据列表
     },
     methods: {
+      search() {
+        this.getPages({
+          name: this.name,
+          parentId: this.currentObj.id ? this.currentObj.id : ''
+        });
+      },
       async getTypeList() {
         this.typeList = await getCategorymeasureList({ parentId: 0 });
         this.getPages();
       },
       addType(type) {
+        if (!this.currentObj.id) {
+          return this.$message.warning('请选择分类');
+        }
         if (type == '新增') {
           this.$refs.typeDialogRef.open(type);
         } else {
-          this.$refs.typeDialogRef.open(type, this.currentId);
+          this.$refs.typeDialogRef.open(type, this.currentObj.id);
         }
       },
       deleted() {
@@ -156,20 +200,25 @@
           .catch(() => {});
       },
       getPages(where) {
-        this.$refs.table.reload(where);
+        this.$refs.table.reload({ where });
       },
       datasource({ page, limit, where, order }) {
+        console.log('where', where);
         return getCategorymeasureList({
           ...where
         });
       },
       handleNodeClick(data) {
-        this.currentId = data.id;
+        this.currentObj = data;
+        this.getPages({ parentId: data.id });
         console.log(data);
       },
-      openEdit() {
-        this.type = '新增';
-        this.$refs.baseDialogRef.open(this.type);
+      openEdit(type, row) {
+        if (type == '新增') {
+          this.$refs.baseDialogRef.open(type, this.currentObj);
+        } else {
+          this.$refs.baseDialogRef.open(type, this.currentObj, row.id);
+        }
       }
     }
   };

+ 4 - 1
src/views/rulesManagement/meteringManagement/typeDialog.vue

@@ -45,7 +45,10 @@
       },
       async open(type, id) {
         if (type == '新增') {
-          this.formData.code = await getCode('metrological_code');
+          this.formData = {
+            name: '',
+            code: await getCode('metrological_code')
+          };
         } else {
           this.formData = await getCategorymeasureDetails(id);
         }