ソースを参照

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

quwangxin 3 年 前
コミット
0f4b57493c

+ 37 - 1
src/api/codeManagement/index.js

@@ -1,9 +1,45 @@
 import request from '@/utils/request';
 
+// 保存/修改编码信息
 export async function saveNew(data) {
     const res = await request.post('/main/codemanage/saveNew', data);
     if (res.data.code == 0) {
         return res.data;
     }
     return Promise.reject(new Error(res.data.message));
-}
+}
+
+// 获取编码列表
+export async function getCodeList(data) {
+    let par = new URLSearchParams(data)
+    const res = await request.post(`/main/codemanage/page?`+par, {});
+    if (res.data.code == 0) {
+        return {
+          list: res.data.data.records,
+          count: res.data.data.total
+        }
+    }
+    return Promise.reject(new Error(res.data.message));
+}
+
+
+/**
+ * 删除编码
+ */
+export async function removeCodeInfo(params) {
+  const res = await request.post('/main/codemanage/delete' , params );
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
+// 获取编码详情
+export async function getCodeDetail(id) {
+    const res = await request.get(`/main/codemanage/getById/`+id, {});
+    if (res.data.code == 0) {
+       return res.data
+    }
+    return Promise.reject(new Error(res.data.message));
+}

+ 13 - 16
src/views/codeManagement/components/addDialog.vue

@@ -65,7 +65,7 @@
 </template>
 
 <script>
-import { saveNew } from '@/api/codeManagement/index';
+import { saveNew , getCodeDetail } from '@/api/codeManagement/index';
 import myTable from './myTable.vue'
 export default {
   components:{
@@ -104,6 +104,8 @@ export default {
       this.addRoleDialog = false;
     },
     restForm() {
+      this.$refs.myTable.handleReset();  //清空表格校验
+      this.$refs.addForm.resetFields();
       this.addForm = {
         name: '',
         code: '',
@@ -111,20 +113,6 @@ export default {
       };
     },
     submitAdd() {
-      // this.$refs.addForm.validate((valid) => {
-      //   if (!valid) {
-      //     return false;
-      //   }
-      //   let par = {
-      //     code: this.addForm.code,
-      //     name: this.addForm.name,
-      //     remark: this.addForm.remark
-      //   };
-      //   saveNew(par).then((res) => {
-      //     console.log(res);
-      //   });
-      // });
-
           const a1 = new Promise((resolve, reject) => {
             this.$refs.addForm.validate((valid) => {
               if (valid) resolve()
@@ -136,7 +124,16 @@ export default {
             })
           })
           Promise.all([a1, a2]).then(() => {
-              console.log('1111')
+              const codeConfigurationList  = this.$refs.myTable.getTableValue()
+              let par = {
+                code: this.addForm.code,
+                name: this.addForm.name,
+                remark: this.addForm.remark,
+                codeConfigurationList:codeConfigurationList
+              };
+              saveNew(par).then((res) => {
+                console.log(res);
+              });
           })
 
     },

+ 7 - 21
src/views/codeManagement/components/code-list.vue

@@ -55,7 +55,7 @@
 <script>
   import CodeSearch from './code-search.vue';
   import addDialog from './addDialog.vue'
-  import { getUserPage , removePersonnel } from '@/api/system/organization';
+  import { getCodeList , removeCodeInfo } from '@/api/codeManagement/index';
 
   export default {
     components: { CodeSearch , addDialog },
@@ -118,12 +118,12 @@
     methods: {
       /* 表格数据源 */
       datasource({ page, limit, where, order }) {
-        return getUserPage({
+        return getCodeList({
           ...where,
           ...order,
           pageNum:page,
           size:limit,
-          groupId: this.organizationId
+          // groupId: 1
         });
       },
       /* 刷新表格 */
@@ -141,7 +141,7 @@
       /* 删除 */
       remove(row) {
         const loading = this.$loading({ lock: true });
-        removePersonnel([row.id])
+        removeCodeInfo([row.id])
           .then((msg) => {
             loading.close();
             this.$message.success(msg);
@@ -151,27 +151,13 @@
             loading.close();
             this.$message.error(e.message);
           });
-      },
-      /* 更改状态 */
-      editStatus(row) {
-        const loading = this.$loading({ lock: true });
-        updateUserStatus(row.userId, row.status)
-          .then((msg) => {
-            loading.close();
-            this.$message.success(msg);
-          })
-          .catch((e) => {
-            loading.close();
-            row.status = !row.status ? 1 : 0;
-            this.$message.error(e.message);
-          });
       }
     },
     watch: {
       // 监听机构id变化
-      organizationId() {
-        this.reload();
-      }
+      // organizationId() {
+      //   this.reload();
+      // }
     }
   };
 </script>

+ 91 - 57
src/views/codeManagement/components/myTable.vue

@@ -46,71 +46,93 @@
               </el-select>
             </el-form-item>
           </template>
-          <!--          <template slot-scope="{ row }">
-            <el-select
-              @change="settype(row, $event)"
-              v-model="row.type.code"
-              placeholder="请选择"
-            >
-              <el-option
-                v-for="item in options.type"
-                :key="item.value"
-                :label="item.label"
-                :value="item.value"
-              >
-              </el-option>
-            </el-select>
-          </template> -->
         </el-table-column>
         <el-table-column prop="content" label="内容" width="180">
-          <template slot-scope="{ row }">
-            <!-- 固定值 -->
-            <el-input
-              v-if="row.type.code == 3"
-              v-model="row.content"
-              placeholder="请输入内容"
-            ></el-input>
-            <!-- 日期 -->
-            <el-select
-              v-if="row.type.code == 1"
-              v-model="row.content"
-              placeholder="请选择"
-            >
-              <el-option
-                v-for="item in options.date"
-                :key="item.value"
-                :label="item.label"
-                :value="item.value"
-              >
-              </el-option>
-            </el-select>
-          </template>
+           <template slot-scope="scope">
+             <el-form-item
+               :prop="'tableData.' + scope.$index + '.content'"
+               :rules="{
+                 required: true,
+                 message: '',
+                 trigger: 'blur'
+               }"
+              v-if="scope.row.type.code!=2"
+             >
+               <!-- 固定值 -->
+               <el-input
+                 v-if="scope.row.type.code == 3"
+                 v-model="scope.row.content"
+                 placeholder="请输入内容"
+               ></el-input>
+               <!-- 日期 -->
+               <el-select
+                 v-if="scope.row.type.code == 1"
+                 v-model="scope.row.content"
+                 placeholder="请选择"
+               >
+                 <el-option
+                   v-for="item in options.date"
+                   :key="item.value"
+                   :label="item.label"
+                   :value="item.value"
+                 >
+                 </el-option>
+               </el-select>
+             </el-form-item>
+           </template>
         </el-table-column>
         <el-table-column prop="length" label="长度">
-          <template slot-scope="{ row }">
-            <el-input
-              v-if="row.type.code == 2"
-              v-model="row.length"
-              placeholder="请输入"
-            ></el-input>
+          <template slot-scope="scope">
+            <el-form-item
+              :prop="'tableData.' + scope.$index + '.length'"
+              :rules="{
+                required: true,
+                message: '',
+                trigger: 'blur'
+              }"
+              v-if="scope.row.type.code == 2"
+            >
+              <el-input
+                v-model="scope.row.length"
+                placeholder="请输入"
+              ></el-input>
+            </el-form-item>
           </template>
         </el-table-column>
         <el-table-column prop="currentId" label="当前流水">
-          <template slot-scope="{ row }">
-            <el-input
-              v-if="row.type.code == 2"
-              v-model="row.currentId"
-              placeholder="请输入"
-            ></el-input>
+          <template slot-scope="scope">
+            <el-form-item
+              :prop="'tableData.' + scope.$index + '.currentId'"
+              :rules="{
+                required: true,
+                message: '',
+                trigger: 'blur'
+              }"
+              v-if="scope.row.type.code == 2"
+            >
+              <el-input
+                v-model="scope.row.currentId"
+                placeholder="请输入"
+              ></el-input>
+            </el-form-item>
           </template>
         </el-table-column>
         <el-table-column prop="step" label="步长">
-          <template slot-scope="{ row }">
-            <el-input
-              v-if="row.type.code == 2"
-              v-model="row.step"
-              placeholder="请输入"
-            ></el-input>
+          <template slot-scope="scope">
+            <el-form-item
+              :prop="'tableData.' + scope.$index + '.step'"
+              :rules="{
+                required: true,
+                message: '',
+                trigger: 'blur'
+              }"
+              v-if="scope.row.type.code == 2"
+            >
+              <el-input
+                v-model="scope.row.step"
+                placeholder="请输入"
+              ></el-input>
+            </el-form-item>
           </template>
         </el-table-column>
         <el-table-column prop="address" label="说明">
@@ -196,11 +218,11 @@
       _delete () {
         let selection = this.getSelection();
         if (selection.length > 0) {
-          let itemIndex = this.tableData.findIndex((n) => {
+          let itemIndex = this.form.tableData.findIndex((n) => {
             return n.sort == selection[0].sort;
           });
           if (itemIndex !== -1) {
-            this.tableData.splice(itemIndex, 1);
+            this.form.tableData.splice(itemIndex, 1);
             this.againSort();
           }
         }
@@ -251,7 +273,19 @@
         this.$refs.tableForm.validate((valid) => {
           callback(valid);
         });
+      },
+
+      // 清空表单校验
+      handleReset() {
+          this.$refs["tableForm"].resetFields();
+          this.form.tableData = []
+      },
+
+      // 返回列表数据
+      getTableValue(){
+         return this.form.tableData
       }
+
     }
   };
 </script>

+ 5 - 4
src/views/codeManagement/index.vue

@@ -1,13 +1,12 @@
 <template>
   <div class="ele-body">
-    <el-card shadow="never" v-loading="loading">
+<!--    <el-card shadow="never" v-loading="loading">
       <ele-split-layout
         width="266px"
         allow-collapse
         :right-style="{ overflow: 'hidden' }"
       >
         <div>
-          <!-- 操作按钮 -->
           <ele-toolbar class="ele-toolbar-actions">
             <div style="margin: 5px 0">
               <el-input size="small" suffix-icon="el-icon-search" placeholder="请输入功能名称" v-model="filterText"> </el-input>
@@ -34,7 +33,9 @@
           />
         </template>
       </ele-split-layout>
-    </el-card>
+    </el-card> -->
+    <code-list
+    />
   </div>
 </template>
 
@@ -66,7 +67,7 @@
       };
     },
     created() {
-      this.query();
+      // this.query();
     },
     methods: {
       /* 查询 */

+ 31 - 6
src/views/system/dictionary/components/dict-edit.vue

@@ -325,7 +325,8 @@
         // 提交状态
         loading: false,
         // 是否是修改
-        isUpdate: false
+        isUpdate: false,
+        delectId: 1
       };
     },
     created() {},
@@ -336,8 +337,10 @@
           code: '',
           enable: 1,
           name: '',
-          sort: ''
+          sort: '',
+          delectId: this.delectId
         });
+        this.delectId = this.delectId + 1;
         this.filterArr();
       },
       //
@@ -346,14 +349,30 @@
       },
       removeArr(row) {
         console.log(row);
-        let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
-        if (falg) {
-          this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
+        if (row.row.id) {
+          this.form.dictStaticSubmitPOList.forEach((item) => {
+            if (item.id === row.row.id) {
+              item.deleted = 1;
+            }
+          });
           this.filterArr();
         } else {
-          this.form.dictStaticSubmitPOList.splice(row.$index, 1);
+          let index = this.form.dictStaticSubmitPOList.findIndex(
+            (item) => item.delectId === row.row.delectId
+          );
+          console.log(index);
+          this.form.dictStaticSubmitPOList.splice(index, 1); // 在数组的指定位置移除对应的元素。 返回移除的
           this.filterArr();
         }
+
+        // let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
+        // if (falg) {
+        //   this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
+        //   this.filterArr();
+        // } else {
+        //   this.form.dictStaticSubmitPOList.splice(row.$index, 1);
+        //   this.filterArr();
+        // }
       },
       handleSelectionChange() {},
       /* 保存编辑 */
@@ -372,6 +391,12 @@
             });
             return;
           }
+          this.form.dictStaticSubmitPOList.forEach((item, index) => {
+            if (item.delectId) {
+              delete item.delectId;
+            }
+          });
+
           this.loading = true;
           const saveOrUpdate = this.isUpdate ? updateDictionary : addDictionary;
           saveOrUpdate(this.form)