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

1.修改itemdetail表无itemcode问题
2.信息发布页下拉状态从字典读取

zangkai пре 5 година
родитељ
комит
949c18e10f

+ 25 - 0
backend/src/dashoo.cn/modi_webapi/app/api/system/itemdetail/itemdetail.go

@@ -163,3 +163,28 @@ func (c *ItemDetailController) GetPageList(r *ghttp.Request) {
 	}
 
 }
+
+// GetDetailByItemCode 根据itemcode获取字典项
+func (c *ItemDetailController) GetDetailByItemCode(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	// 字典id
+	ItemCode := r.GetString("ItemCode")
+	glog.Info(ItemCode)
+	rsp, err := ItemDetailService.GetListByItemCode(context.TODO(), &protoItemDetail.CodeReq{
+		Tenant: tenant,
+		Code:   ItemCode,
+	})
+
+	if err != nil {
+		response.Json(r, -1, err.Error())
+	} else {
+		commonmsg := rsp.CommonMsg
+		if commonmsg.Code == 0 {
+			response.Json(r, 0, "", rsp.List)
+		} else {
+			response.Json(r, -1, commonmsg.Msg)
+		}
+	}
+
+}

+ 9 - 1
frontend_web/src/api/sysadmin/itemdetail.js

@@ -33,12 +33,20 @@ export default {
       params: params
     })
   },
-  // 删除学生
+  // 删除字典项
   delete (params) {
     return request({
       url: process.env.VUE_APP_API + 'itemdetail/deletebyid',
       method: 'get',
       params: params
     })
+  },
+  // 根据ItemCode获取字典项
+  getItemDetailByItemCode (params) {
+    return request({
+      url: process.env.VUE_APP_API + 'itemdetail/getdetailbyitemcode',
+      method: 'get',
+      params: params
+    })
   }
 }

+ 18 - 23
frontend_web/src/views/information/index.vue

@@ -23,9 +23,9 @@
           <el-select v-model="search.status"
                      style="width: 140px;">
             <el-option v-for="item in status"
-                       :key="item.key"
-                       :label="item.key"
-                       :value="item.value">
+                       :key="item.ItemName"
+                       :label="item.ItemName"
+                       :value="parseInt(item.ItemValue)">
             </el-option>
           </el-select>
         </el-form-item>
@@ -129,6 +129,7 @@
 
 import InformationApi from '@/api/information'
 import informationInfoDialog from './components/informationInfoDialog'
+import itemDetailApi from '@/api/sysadmin/itemdetail'
 export default {
   name: 'informationIndex',
   components: {
@@ -150,19 +151,7 @@ export default {
           size: 10
         }
       },
-      status: [{
-        key: '全部',
-        value: -1
-      },
-      {
-        key: '草稿',
-        value: 0
-      },
-      {
-        key: '已发布',
-        value: 1
-      }
-      ],
+      status: [],
       // 列表排序
       Column: {
         Order: '',
@@ -171,13 +160,20 @@ export default {
     }
   },
   mounted () {
-    this.initDatas()
+    itemDetailApi.getItemDetailByItemCode({ ItemCode: 'InformationStatusOptions' })
+      .then(res => {
+        this.status = res
+        this.initDatas()
+      })
+      .catch(err => {
+        console.error(err)
+      })
   },
   methods: {
     formatStatus (row, column) {
       for (var i = 0; i < this.status.length; i++) {
-        if (this.status[i].value == row.status) {
-          return this.status[i].key;
+        if (parseInt(this.status[i].ItemValue) === row.status) {
+          return this.status[i].ItemName
         }
       }
     },
@@ -185,10 +181,10 @@ export default {
       this.search = {
         Title: '',
         Status: -1,
-        Content: '',
+        Content: ''
       }
     },
-    //初始化分页分页对象
+    // 初始化分页分页对象
     initPageInfo () {
       this.search.page = {
         total: 0,
@@ -211,7 +207,7 @@ export default {
       this.$refs.informationDialog.dialogvisible = false
       this.initPageInfo()
       this.initDatas()
-      console.log("handleClose informationId" + this.informationId)
+      console.log('handleClose informationId' + this.informationId)
     },
     publish (information) {
       information.status = 1
@@ -235,7 +231,6 @@ export default {
       this.initDatas()
     },
 
-
     deleteinformation (val) {
       let _this = this
       let params = {

+ 2 - 1
frontend_web/src/views/sysadmin/item/components/command.vue

@@ -46,7 +46,8 @@ export default Vue.extend({
     handleDetail () {
       let Id = parseInt(this.params.data['Id'])
       let name = this.params.data['FullName']
-      this.$router.push({ path: '/sysadmin/itemdetail', query: { Id: Id, name: name } })
+      let ItemCode = this.params.data['Code']
+      this.$router.push({ path: '/sysadmin/itemdetail', query: { Id: Id, name: name, ItemCode: ItemCode } })
     }
   }
 })

+ 37 - 31
frontend_web/src/views/sysadmin/item/editForm.vue

@@ -3,36 +3,41 @@
              :visible.sync="dialogVisible"
              @opened="dialogOpen"
              @closed="dialogClose"
-              width="40%"
-             >
+             width="40%">
     <el-form ref="form"
              :model="formdata"
              label-width="110px"
              :rules="rules"
              size="small">
-      <el-form-item label="分类名称" prop="FullName">
+      <el-form-item label="分类名称"
+                    prop="FullName">
         <el-input v-model="formdata.FullName"></el-input>
       </el-form-item>
-      <el-form-item label="分类编码" prop="Code">
+      <el-form-item label="分类编码"
+                    prop="Code">
         <el-input v-model="formdata.Code"></el-input>
       </el-form-item>
       <el-form-item label="关联表">
         <el-input v-model="formdata.TargetTable"></el-input>
       </el-form-item>
       <el-form-item label="使用分类名">
-        <el-switch style="width:100%;text-align:left" v-model="formdata.UseItemName"></el-switch>
+        <el-switch style="width:100%;text-align:left"
+                   v-model="formdata.UseItemName"></el-switch>
       </el-form-item>
       <el-form-item label="使用分类编码">
-        <el-switch style="width:100%;text-align:left" v-model="formdata.UseItemCode"></el-switch>
+        <el-switch style="width:100%;text-align:left"
+                   v-model="formdata.UseItemCode"></el-switch>
       </el-form-item>
       <el-form-item label="树结构">
-        <el-switch style="width:100%;text-align:left" v-model="formdata.IsTree"></el-switch>
+        <el-switch style="width:100%;text-align:left"
+                   v-model="formdata.IsTree"></el-switch>
       </el-form-item>
       <el-form-item label="排序">
         <el-input v-model="formdata.SortCode"></el-input>
       </el-form-item>
       <el-form-item label="备注">
-        <el-input type="textarea" v-model="formdata.Description"></el-input>
+        <el-input type="textarea"
+                  v-model="formdata.Description"></el-input>
       </el-form-item>
     </el-form>
     <div slot="footer"
@@ -62,6 +67,7 @@ export default {
       subjectList: [],
       selectSubject: [],
       formdata: {
+        ParentId: 0,
         Id: 0,
         FullName: '',
         Code: '',
@@ -188,27 +194,27 @@ export default {
 </script>
 
 <style>
-  .avatar-uploader .el-upload {
-    border: 1px dashed #d9d9d9;
-    border-radius: 6px;
-    cursor: pointer;
-    position: relative;
-    overflow: hidden;
-  }
-  .avatar-uploader .el-upload:hover {
-    border-color: #409EFF;
-  }
-  .avatar-uploader-icon {
-    font-size: 28px;
-    color: #8c939d;
-    width: 80px;
-    height: 80px;
-    line-height: 80px;
-    text-align: center;
-  }
-  .avatar {
-    width: 80px;
-    height: 80px;
-    display: block;
-  }
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409eff;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 80px;
+  height: 80px;
+  line-height: 80px;
+  text-align: center;
+}
+.avatar {
+  width: 80px;
+  height: 80px;
+  display: block;
+}
 </style>

+ 36 - 31
frontend_web/src/views/sysadmin/item_detail/editForm.vue

@@ -3,24 +3,26 @@
              :visible.sync="dialogVisible"
              @opened="dialogOpen"
              @closed="dialogClose"
-              width="40%"
-             >
+             width="40%">
     <el-form ref="form"
              :model="formdata"
              label-width="110px"
              :rules="rules"
              size="small">
-      <el-form-item label="字典名称" prop="ItemName">
+      <el-form-item label="字典名称"
+                    prop="ItemName">
         <el-input v-model="formdata.ItemName"></el-input>
       </el-form-item>
-      <el-form-item label="字典编码" prop="ItemValue">
+      <el-form-item label="字典编码"
+                    prop="ItemValue">
         <el-input v-model="formdata.ItemValue"></el-input>
       </el-form-item>
       <el-form-item label="排序">
         <el-input v-model="formdata.SortCode"></el-input>
       </el-form-item>
       <el-form-item label="备注">
-        <el-input type="textarea" v-model="formdata.Description"></el-input>
+        <el-input type="textarea"
+                  v-model="formdata.Description"></el-input>
       </el-form-item>
     </el-form>
     <div slot="footer"
@@ -41,7 +43,8 @@ export default {
   props: {
     id: Number,
     parentId: Number,
-    value: Boolean
+    value: Boolean,
+    itemCode: String
   },
   data () {
     return {
@@ -56,7 +59,8 @@ export default {
         ItemName: '',
         ItemValue: '',
         SortCode: '',
-        Description: ''
+        Description: '',
+        ItemCode: ''
       },
       imageUrl: '',
       rules: {
@@ -91,7 +95,6 @@ export default {
     },
     initData () {
       let _this = this
-      console.log(_this.parentId)
       if (_this.id > 0) {
         _this.formdata = {}
         const params = {
@@ -104,6 +107,7 @@ export default {
               _this.formdata = {
                 Id: res.Id,
                 ParentId: _this.parentId,
+                ItemCode: _this.itemCode,
                 ItemName: res.ItemName,
                 ItemValue: res.ItemValue,
                 SortCode: res.SortCode,
@@ -118,6 +122,7 @@ export default {
       } else {
         _this.formdata.Id = 0
         _this.formdata.ParentId = _this.parentId
+        _this.formdata.ItemCode = _this.itemCode
         _this.formdata.ItemName = ''
         _this.formdata.ItemValue = ''
         _this.formdata.SortCode = ''
@@ -166,27 +171,27 @@ export default {
 </script>
 
 <style>
-  .avatar-uploader .el-upload {
-    border: 1px dashed #d9d9d9;
-    border-radius: 6px;
-    cursor: pointer;
-    position: relative;
-    overflow: hidden;
-  }
-  .avatar-uploader .el-upload:hover {
-    border-color: #409EFF;
-  }
-  .avatar-uploader-icon {
-    font-size: 28px;
-    color: #8c939d;
-    width: 80px;
-    height: 80px;
-    line-height: 80px;
-    text-align: center;
-  }
-  .avatar {
-    width: 80px;
-    height: 80px;
-    display: block;
-  }
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409eff;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 80px;
+  height: 80px;
+  line-height: 80px;
+  text-align: center;
+}
+.avatar {
+  width: 80px;
+  height: 80px;
+  display: block;
+}
 </style>

+ 15 - 14
frontend_web/src/views/sysadmin/item_detail/index.vue

@@ -6,13 +6,13 @@
                ref="searchForm"
                size="mini"
                style="height: 25px; margin-top: -7px;text-align:right;">
-        <span class="item-name">所属分类: {{parentName}}</span>
+        <span class="item-name">所属分类: {{itemCode}}_{{parentName}}</span>
         <el-form-item label="字典名称"
                       prop="name">
           <el-input v-model="searchForm.name"
                     placeholder="字典名称"
                     style="width: 140px;"
-                    clearable/>
+                    clearable />
         </el-form-item>
         <el-form-item>
           <el-button type="primary"
@@ -47,13 +47,12 @@
     </template>
     <ag-grid-vue class="table ag-theme-balham ag-title-center"
                  style="width: 100%; height: 100%;"
-      id="myGrid"
-      :gridOptions="gridOptions"
-      @gridReady="onGridReady"
-      :rowData="rowData"
-      :columnDefs="columnDefs"
-      rowSelection="multiple"
-      >
+                 id="myGrid"
+                 :gridOptions="gridOptions"
+                 @gridReady="onGridReady"
+                 :rowData="rowData"
+                 :columnDefs="columnDefs"
+                 rowSelection="multiple">
     </ag-grid-vue>
     <template slot="footer">
       <el-pagination style="margin: -10px;"
@@ -66,7 +65,9 @@
                      layout="total, sizes, prev, pager, next, jumper">
       </el-pagination>
     </template>
-    <edit-form :id="id" :parentId="parentId"
+    <edit-form :id="id"
+               :parentId="parseInt(parentId)"
+               :itemCode="itemCode"
                v-model="editFormVisible"
                @submit="doRefresh" />
   </d2-container>
@@ -103,11 +104,11 @@ export default {
 
       parentId: null, // 字典分类id
       parentName: null, // 字典分类
+      itemCode: null,
       id: -1,
       rowdata: {},
       searchForm: {
         name: ''
-        // code: ''
       },
       loading: false,
       multipleSelection: [],
@@ -160,6 +161,7 @@ export default {
     _this.gridApi = _this.gridOptions.api
     _this.gridColumnApi = _this.gridOptions.columnApi
     _this.parentId = _this.$route.query.Id
+    _this.itemCode = _this.$route.query.ItemCode
     _this.parentName = _this.$route.query.name
     this.doRefresh()
   },
@@ -297,7 +299,6 @@ export default {
 </script>
 
 <style lang="scss">
-
 .el-pagination {
   margin: 1rem 0 2rem;
   text-align: right;
@@ -312,8 +313,8 @@ export default {
   margin-left: 1px;
   padding: 5px 10px 0 0;
 }
-.ag-header-cell-text{
-  text-align: center ;
+.ag-header-cell-text {
+  text-align: center;
   width: 100%;
 }
 .item-name {