Sfoglia il codice sorgente

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

汪钰 3 anni fa
parent
commit
b8f9c56415

+ 2 - 2
src/api/codeManagement/index.js

@@ -4,7 +4,7 @@ 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 res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
@@ -34,7 +34,7 @@ export async function removeCodeInfo (params) {
 export async function getCodeDetail (id) {
   const res = await request.get(`/main/codemanage/getById/` + id, {});
   if (res.data.code == 0) {
-    return res.data;
+    return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }

+ 28 - 5
src/views/codeManagement/components/addDialog.vue

@@ -53,7 +53,7 @@
           header="编码配置"
           body-style="padding: 22px 22px 0 22px;"
         >
-            <myTable ref="myTable"></myTable>
+            <myTable ref="myTable" :codeConfigurationList="codeConfigurationList"></myTable>
         </el-card>
       </el-form>
     </div>
@@ -71,7 +71,6 @@ export default {
   components:{
     myTable
   },
-  watch: {},
   data() {
     return {
       addRoleDialog: false,
@@ -85,6 +84,8 @@ export default {
         name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
         code: [{ required: true, message: '请输入编码', trigger: 'blur' }]
       },
+      codeConfigurationList:[],
+      openType:'add',
     };
   },
   created() {
@@ -94,10 +95,17 @@ export default {
     open(type,row) {
       if(type == 'add'){
         this.dialogTitle = '新建编码规则'
+        this.codeConfigurationList = []
       }else if(type == 'edit'){
         this.dialogTitle = '编辑编码规则'
+        getCodeDetail(row.id).then(res=>{
+          this.addForm = {...res}
+          if(this.addForm.codeConfigurationList) delete this.addForm.codeConfigurationList
+          this.codeConfigurationList = res.codeConfigurationList
+        })
       }
       this.addRoleDialog = true;
+      this.openType = type
     },
     handleClose() {
       this.restForm();
@@ -125,14 +133,29 @@ export default {
           })
           Promise.all([a1, a2]).then(() => {
               const codeConfigurationList  = this.$refs.myTable.getTableValue()
+              // codeConfigurationList.map(item=>{
+              //    item.type = item.type.code
+              // })
               let par = {
                 code: this.addForm.code,
                 name: this.addForm.name,
                 remark: this.addForm.remark,
-                codeConfigurationList:codeConfigurationList
+                codeConfigurationList:codeConfigurationList,
+                codeManageTreeId: 1
               };
-              saveNew(par).then((res) => {
-                console.log(res);
+              if(this.openType == 'edit'){
+                 par.id = this.addForm.id
+              }
+              saveNew(par).then(res => {
+                  console.log('res',res)
+                  this.loading = false;
+                  this.addRoleDialog = false
+                  this.$message.success(res);
+                  this.$emit('done');
+              })
+              .catch((e) => {
+                  this.loading = false;
+                  this.$message.error(e.message);
               });
           })
 

+ 5 - 2
src/views/codeManagement/components/code-list.vue

@@ -48,7 +48,10 @@
       </template>
     </ele-pro-table>
     <!-- 编辑弹窗 -->
-    <addDialog ref="addDialog"></addDialog>
+    <addDialog 
+      ref="addDialog"
+      @done="reload"
+    ></addDialog>
   </div>
 </template>
 
@@ -133,7 +136,7 @@
       /* 显示编辑 */
       openEdit(row) {
           if(row){
-            this.$refs.addDialog.open('edit')
+            this.$refs.addDialog.open('edit',row)
           }else{
             this.$refs.addDialog.open('add')
           }

+ 37 - 24
src/views/codeManagement/components/myTable.vue

@@ -24,7 +24,7 @@
         <el-table-column prop="type.descp" label="类型" width="130">
           <template slot-scope="scope">
             <el-form-item
-              :prop="'tableData.' + scope.$index + '.type.code'"
+              :prop="'tableData.' + scope.$index + '.type'"
               :rules="{
                 required: true,
                 message: '',
@@ -33,7 +33,7 @@
             >
               <el-select
                 @change="settype(scope.row, $event)"
-                v-model="scope.row.type.code"
+                v-model="scope.row.type"
                 placeholder="请选择"
               >
                 <el-option
@@ -56,17 +56,17 @@
                  message: '',
                  trigger: 'blur'
                }"
-              v-if="scope.row.type.code!=2"
+              v-if="scope.row.type!=2"
              >
                <!-- 固定值 -->
                <el-input
-                 v-if="scope.row.type.code == 3"
+                 v-if="scope.row.type == 3"
                  v-model="scope.row.content"
                  placeholder="请输入内容"
                ></el-input>
                <!-- 日期 -->
                <el-select
-                 v-if="scope.row.type.code == 1"
+                 v-if="scope.row.type == 1"
                  v-model="scope.row.content"
                  placeholder="请选择"
                >
@@ -90,7 +90,7 @@
                 message: '',
                 trigger: 'blur'
               }"
-              v-if="scope.row.type.code == 2"
+              v-if="scope.row.type == 2"
             >
               <el-input
                 v-model="scope.row.length"
@@ -108,7 +108,7 @@
                 message: '',
                 trigger: 'blur'
               }"
-              v-if="scope.row.type.code == 2"
+              v-if="scope.row.type == 2"
             >
               <el-input
                 v-model="scope.row.currentId"
@@ -126,7 +126,7 @@
                 message: '',
                 trigger: 'blur'
               }"
-              v-if="scope.row.type.code == 2"
+              v-if="scope.row.type == 2"
             >
               <el-input
                 v-model="scope.row.step"
@@ -146,6 +146,12 @@
 </template>
 <script>
   export default {
+    props: {
+      codeConfigurationList: {
+        type:Array,
+        default:[]
+      }
+    },
     data () {
       return {
         selectData: [],
@@ -170,29 +176,36 @@
           ],
           date: [
             {
-              value: '年月日',
-              label: '年月日'
+              value: 'yyyy',
+              label: '年'
             },
             {
-              value: '年月日时分秒',
-              label: '年月日时分秒'
+              value: 'yyyymm',
+              label: '年月'
             },
             {
-              value: '年月日时',
-              label: '年月日'
+              value: 'yyyymmdd',
+              label: '年月日'
             },
             {
-              value: '年月',
-              label: '年月'
+              value: 'yyyymmddhh',
+              label: '年月日时'
             },
             {
-              value: '',
-              label: '年'
+              value: 'yyyymmddhhmmss',
+              label: '年月日时分秒'
             }
           ]
         }
       };
     },
+    watch: {
+       codeConfigurationList(val){
+          if(val){
+            this.form.tableData = val
+          }
+       }
+    },
     methods: {
       selectionChange (selection) {
         if (selection.length > 1) {
@@ -202,7 +215,7 @@
       },
 
       settype (row, val) {
-        row.type.descp = this.options.type.find((n) => n.value == val).label;
+        // row.type.descp = this.options.type.find((n) => n.value == val).label;
         // 重选初始化数据
         row.content = '';
         row.length = '';
@@ -229,10 +242,11 @@
       },
       add () {
         this.form.tableData.push({
-          type: {
-            code: '',
-            descp: ''
-          },
+          // type: {
+          //   code: '',
+          //   descp: ''
+          // },
+          type:null,
           content: '',
           length: '', // 长度
           currentId: '', // 当前流水
@@ -285,7 +299,6 @@
       getTableValue(){
          return this.form.tableData
       }
-
     }
   };
 </script>