Ver código fonte

前后:黑名单修改

dubch 4 anos atrás
pai
commit
9a85d6dd6e

+ 38 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/blacklist.go

@@ -118,6 +118,44 @@ func (this *BlackListController) AddBlackList() {
 	}
 }
 
+// @Title 修改
+// @Description 修改
+// @Success	200	{object}
+// @router /update/:id [post]
+func (this *BlackListController) UpdateBlackList() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model BlackList.BlackList
+	var jsonBlob = this.Ctx.Input.RequestBody
+	svc := BlackList.GetBlackListService(utils.DBE)
+	json.Unmarshal(jsonBlob, &model)
+
+	var err error
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	_, err = svc.UpdateEntityById (id, &model)
+	if err == nil {
+		errinfo.Message = "修改成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "修改失败"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
 // @Title 删除单条信息
 // @Description
 // @Success 200 {object} ErrorInfo

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/blacklist.js

@@ -19,6 +19,13 @@ export default {
       data: params
     })
   },
+  updateEntity (id, params, myAxios) {
+    return myAxios({
+      url: '/blacklist/update/' + id,
+      method: 'post',
+      data: params
+    })
+  },
   deleteEntity (entityId, myAxios) {
     return myAxios({
       url: '/blacklist/deleteBlackList/' + entityId,

+ 78 - 35
src/dashoo.cn/frontend_web/src/pages/oilsupplier/blacklist/index.vue

@@ -61,35 +61,40 @@
         <!--内框表格剩余栏显示-->
         <el-table-column label="操作"
                          align="center"
-                         width="150px">
+                         width="180px">
           <template slot-scope="scope">
             <el-button type="primary"
                        plain
                        title="删除"
                        size="mini"
                        @click="deleterow(scope.row.Id)">删除</el-button>
+            <el-button type="primary"
+                       plain
+                       title="编辑"
+                       size="mini"
+                       @click="updateRow(scope.row.Id,scope.row.SupplierName,scope.row.CommercialNo,scope.row.Remark)">编辑</el-button>
+          </template>
+        </el-table-column>
+        <el-table-column label="创建时间"
+                         prop="CreateOn"
+                         align="center"
+                         width="100px">
+          <template slot-scope="scope">
+            {{ jstimehandle(scope.row.CreateOn+'') }}
           </template>
         </el-table-column>
         <el-table-column label="企业名称"
                          prop="SupplierName"
                          align="center"
-                         width="260px"></el-table-column>
+                         min-width="260px"></el-table-column>
         <el-table-column label="工商注册号"
                          prop="CommercialNo"
                          align="center"
-                         width="260px"></el-table-column>
+                         min-width="260px"></el-table-column>
         <el-table-column label="备注"
                          prop="Remark"
                          align="center"
-                         width="260px"></el-table-column>
-        <el-table-column label="创建时间"
-                         prop="CreateOn"
-                         align="center"
-                         width="100px">
-          <template slot-scope="scope">
-            {{ jstimehandle(scope.row.CreateOn+'') }}
-          </template>
-        </el-table-column>
+                         min-width="260px"></el-table-column>
       </el-table>
 
       <!-- 分页 -->
@@ -102,7 +107,7 @@
                      :total="currentItemCount"></el-pagination>
     </el-card>
 
-    <el-dialog title="黑名单添加" :visible.sync="addShow" width="400px">
+    <el-dialog title="黑名单信息" :visible.sync="addShow" width="400px">
       <el-form label-width="100px" ref="EntityForm" :rules="rules" :model="saveForm">
         <el-row>
           <el-col :span="24">
@@ -161,6 +166,7 @@ export default {
       tableLoading: false,
       addLoading: false,
       addShow: false,
+      status: false,
       // 定义列表数据
       entityList: [],
       // 分页参数
@@ -174,6 +180,7 @@ export default {
         CommercialNo: ''
       },
       saveForm: {
+        Id:0,
         SupplierName: '',
         CommercialNo: '',
         Remark: ''
@@ -192,7 +199,19 @@ export default {
 
   methods: {
     add () {
+      this.saveForm.SupplierName = ""
+      this.saveForm.CommercialNo = ""
+      this.saveForm.Remark = ""
+      this.saveForm.Id = 0
+      this.addShow = true
+    },
+    updateRow (id, name, no, remark) {
+      this.saveForm.SupplierName = name
+      this.saveForm.CommercialNo = no
+      this.saveForm.Remark = remark
+      this.saveForm.Id = id
       this.addShow = true
+      this.status = true
     },
     deleterow (id) {
       this.$confirm('确定删除?', '提示', {
@@ -227,27 +246,51 @@ export default {
       this.$refs['EntityForm'].validate((valid) => {
         if (valid) {
           this.addLoading = true
-          api.addEntity(this.saveForm, this.$axios)
-            .then(res => {
-              if (res.data.code === 0) {
-                // 刷新列表
-                this.initDatas()
-                this.$message({
-                  type: 'success',
-                  message: res.data.message
-                })
-              } else {
-                this.$message({
-                  type: 'warning',
-                  message: res.data.message
-                })
-              }
-              this.addLoading = false
-              this.addShow = false
-            })
-            .catch(err => {
-              console.error(err)
-            })
+          if (this.status) {
+            api.updateEntity(this.saveForm.Id, this.saveForm, this.$axios)
+              .then(res => {
+                if (res.data.code === 0) {
+                  // 刷新列表
+                  this.initDatas()
+                  this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                } else {
+                  this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+                this.addLoading = false
+                this.addShow = false
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          } else {
+            api.addEntity(this.saveForm, this.$axios)
+              .then(res => {
+                if (res.data.code === 0) {
+                  // 刷新列表
+                  this.initDatas()
+                  this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                } else {
+                  this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+                this.addLoading = false
+                this.addShow = false
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
         } else {
           return false
         }
@@ -257,7 +300,6 @@ export default {
     initCompany () {
       api.getSupList(this.$axios)
         .then(res => {
-          this.dataList = res.data.items
         })
         .catch(err => {
           console.error(err)
@@ -290,6 +332,7 @@ export default {
           this.entityList = res.data.items
           this.currentItemCount = res.data.currentItemCount
           this.tableLoading = false
+          this.dataList = res.data.items
         })
         .catch(err => {
           console.error(err)