Преглед изворни кода

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

quwangxin пре 3 година
родитељ
комит
ed3148af08

+ 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));
 }

+ 5 - 5
src/api/system/dictionary/index.js

@@ -4,8 +4,8 @@ import request from '@/utils/request';
  * 查询字典列表
  * @param params 查询条件
  */
-export async function listDictionaries () {
-  const res = await request.get('/system/dict/getPage', {});
+export async function listDictionaries(params) {
+  const res = await request.get('/system/dict/getPage', { params });
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -16,7 +16,7 @@ export async function listDictionaries () {
  * 添加字典
  * @param data 字典信息
  */
-export async function addDictionary (data) {
+export async function addDictionary(data) {
   const res = await request.post('/system/dict/submit', data);
   if (res.data.code == 0) {
     return res.data.message;
@@ -28,7 +28,7 @@ export async function addDictionary (data) {
  * 修改字典
  * @param data 字典信息
  */
-export async function updateDictionary (data) {
+export async function updateDictionary(data) {
   const res = await request.post('/system/dict/update', data);
   if (res.data.code == 0) {
     return res.data.message;
@@ -40,7 +40,7 @@ export async function updateDictionary (data) {
  * 删除字典
  * @param id 字典id
  */
-export async function removeDictionary (id, f) {
+export async function removeDictionary(id, f) {
   let res;
   if (f) {
     res = await request.post('/system/dict/removeDictInfoById', id);

+ 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>

+ 49 - 6
src/views/system/dictionary/components/dict-data-search.vue

@@ -2,22 +2,46 @@
 <template>
   <el-form
     size="small"
+    label-width="77px"
     class="ele-form-search"
     @keyup.enter.native="search"
     @submit.native.prevent
   >
     <el-row :gutter="10">
-      <el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
-        <el-form-item>
+      <el-col v-bind="styleResponsive ? { md: 4 } : { span: 4 }">
+        <el-form-item label="编码">
+          <el-input
+            clearable
+            size="small"
+            v-model="where.code"
+            placeholder="请输入"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 4 } : { span: 4 }">
+        <el-form-item label="名称">
           <el-input
             clearable
             size="small"
-            v-model="where.keywords"
-            placeholder="输入关键字搜索"
+            v-model="where.name"
+            placeholder="输入"
           />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { md: 16 } : { span: 16 }">
+      <el-col v-bind="styleResponsive ? { md: 4 } : { span: 4 }">
+        <el-form-item label="应用类型">
+          <el-select v-model="where.appType" placeholder="请选择">
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 12 } : { span: 4 }">
         <el-form-item>
           <el-button
             size="small"
@@ -28,6 +52,15 @@
           >
             查询
           </el-button>
+
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh"
+            class="ele-btn-icon"
+            size="medium"
+            >重置</el-button
+          >
+
           <slot></slot>
         </el-form-item>
       </el-col>
@@ -40,9 +73,16 @@
     data() {
       // 默认表单数据
       const defaultWhere = {
-        keywords: ''
+        name: '',
+        code: '',
+        appType: ''
       };
       return {
+        options: [
+          { value: 0, label: '全部' },
+          { value: 1, label: '业务字典' },
+          { value: 2, label: '数据字典' }
+        ],
         defaultWhere,
         // 表单数据
         where: { ...defaultWhere }
@@ -57,6 +97,9 @@
     methods: {
       /* 搜索 */
       search() {
+        if (this.where.appType === 0) {
+          this.where.appType = '';
+        }
         this.$emit('search', this.where);
       },
       /*  重置 */

+ 16 - 7
src/views/system/dictionary/components/dict-data.vue

@@ -8,7 +8,7 @@
       :need-page="true"
       :toolkit="[]"
       :selection.sync="selection"
-      height="calc(100vh - 265px)"
+      height="calc(100vh - 350px)"
       full-height="calc(100vh - 116px)"
       tool-class="ele-toolbar-form"
       cache-key="systemDictDataTable"
@@ -37,6 +37,9 @@
         </dict-data-search>
       </template> -->
       <!-- 操作列 -->
+      <template v-slot:appType="{ row }">
+        {{ types[row.appType] }}
+      </template>
       <template v-slot:action="{ row }">
         <el-link
           type="primary"
@@ -97,12 +100,13 @@
           {
             prop: 'code',
             label: '字典编码',
+            align: 'center',
             showOverflowTooltip: true
           },
           {
             prop: 'name',
             label: '字典名称',
-
+            align: 'center',
             showOverflowTooltip: true
           },
           // {
@@ -114,20 +118,21 @@
           // },
           {
             prop: 'appType',
+            align: 'center',
             label: '应用类型',
-
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            slot: 'appType'
           },
           {
             prop: 'remark',
             label: '描述',
-
+            align: 'center',
             showOverflowTooltip: true
           },
           {
             prop: 'updateTime',
             label: '上次更新时间',
-
+            align: 'center',
             showOverflowTooltip: true,
             minWidth: 110,
             formatter: (_row, _column, cellValue) => {
@@ -144,6 +149,10 @@
             showOverflowTooltip: true
           }
         ],
+        types: {
+          1: '业务字典',
+          2: '数据字典'
+        },
         // 表格选中数据
         selection: [],
         // 当前编辑数据
@@ -157,7 +166,7 @@
     methods: {
       /* 表格数据源 */
       datasource({ page, limit, where, order }) {
-        return listDictionaries();
+        return listDictionaries({ pageNum: page, size: limit, ...where });
       },
       /* 刷新表格 */
       reload(where) {

+ 1 - 0
src/views/system/dictionary/components/dict-edit.vue

@@ -38,6 +38,7 @@
           <el-form-item label="字典值:" prop="code">
             <el-input
               clearable
+              :disabled="isUpdate"
               :maxlength="20"
               v-model="form.code"
               placeholder="请输入字典值"

+ 6 - 4
src/views/system/dictionary/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="ele-body">
+    <DictDataSearch @search="reload" />
     <el-card shadow="never">
       <div style="margin: 5px 0; padding-left: 262px">
         <el-button
@@ -42,7 +43,7 @@
           ref="table"
           :columns="columns"
           :datasource="datasource"
-          height="calc(100vh - 265px)"
+          height="calc(100vh - 350px)"
           :need-page="false"
           :toolkit="[]"
           :current.sync="current"
@@ -69,11 +70,12 @@
 <script>
   import DictData from './components/dict-data.vue';
   import DictEdit from './components/dict-edit.vue';
+  import DictDataSearch from './components/dict-data-search.vue';
   import { listDictionaries, removeDictionary } from '@/api/system/dictionary';
 
   export default {
     name: 'SystemDictionary',
-    components: { DictData, DictEdit },
+    components: { DictData, DictEdit, DictDataSearch },
     data() {
       return {
         // 表格列配置
@@ -113,9 +115,9 @@
         }
       },
       /* 刷新表格 */
-      reload() {
+      reload(where) {
         this.$refs.table.reload();
-        this.$refs.dictData.reload();
+        this.$refs.dictData.reload(where);
       },
       /* 显示编辑 */
       openEdit(row) {

+ 3 - 3
vue.config.js

@@ -17,9 +17,9 @@ module.exports = {
       '/api': {
         // target: 'http://192.168.3.51:18086', // 跨域请求的地址
         // target: 'http://192.168.3.35:8080', // kang杨威
-        // target: 'http://192.168.3.25:8080', // 黄峥嵘
+        target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
-        target: 'http://192.168.3.33:8080', // 谢一平
+        // target: 'http://192.168.3.33:8080', // 谢一平
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
@@ -28,7 +28,7 @@ module.exports = {
       }
     }
   },
-  chainWebpack (config) {
+  chainWebpack(config) {
     config.plugins.delete('prefetch');
     if (process.env.NODE_ENV !== 'development') {
       // gzip 压缩