Bläddra i källkod

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/MainT.vue
zzy90 2 månader sedan
förälder
incheckning
dd21b73705
2 ändrade filer med 24 tillägg och 13 borttagningar
  1. 13 12
      src/components/RulesTable.vue
  2. 11 1
      src/http/api.js

+ 13 - 12
src/components/RulesTable.vue

@@ -11,7 +11,7 @@ import {
   Upload
 } from "@element-plus/icons-vue";
 import {ElMessage, ElMessageBox} from "element-plus";
-import {addRuleInfo, searchRules} from "@/http/api";
+import {addRuleInfo, deleteRule, searchRules} from "@/http/api";
 
 export default {
   name: "RulesTable",
@@ -57,12 +57,7 @@ export default {
         duration_minutes: '',
         interval_minutes: ''
       },
-      tableData: [{
-        name: '煤炭采购规则',
-        rounds: '2',
-        duration_minutes: '2',
-        interval_minutes: '1'
-      }],
+      tableData: [],
       addForm: {
         name: '',
         rounds: '',
@@ -79,6 +74,7 @@ export default {
       this.searchForm.rounds = '';
       this.searchForm.duration = '';
       this.searchForm.interval = '';
+      this.tableData=[];
     },
     handleClose(done) {
       ElMessageBox.confirm('您确定关闭此对话框吗?')
@@ -92,15 +88,18 @@ export default {
     addRule() {
       addRuleInfo(this.addForm);
       this.dialogVisible = false;
+      this.searchRules();
     },
     searchRules() {
       searchRules(this.searchForm).then(
           res => {
-            console.log(res.data);
             this.tableData = res.data;
-            ElMessage.success("搜索成功");
           }
       )
+    },
+    deleteRule(row){
+      deleteRule(row);
+      this.searchRules();
     }
   }
 }
@@ -165,9 +164,11 @@ export default {
         <el-table-column
             prop="operation"
             label="操作">
-          <el-link type="primary" :icon="Edit">设置提示语</el-link>&nbsp;
-          <el-link type="primary" :icon="Edit">修改</el-link>&nbsp;
-          <el-link type="primary" :icon="Delete">删除</el-link>
+          <template v-slot="scope">
+            <el-link type="primary" :icon="Edit">设置提示语</el-link>&nbsp;
+            <el-link type="primary" :icon="Edit">修改</el-link>&nbsp;
+            <el-link type="primary" :icon="Delete" @click="deleteRule(scope.row)">删除</el-link>
+          </template>
         </el-table-column>
       </el-table>
     </el-row>

+ 11 - 1
src/http/api.js

@@ -116,7 +116,7 @@ export function updateSuppliersAddress(params){
 //规则
 //新增规则
 export function addRuleInfo(params){
-  console.log('rule:'+params);
+  //console.log('rule:'+params);
   let new_params = {
     url: '/Rules/addRule',
     method: "post",
@@ -133,6 +133,16 @@ export function searchRules(params){
   }
   return request(new_params);
 }
+//删除规则
+export function deleteRule(params){
+  console.log('row:'+params)
+  let new_params = {
+    url: '/Rules/deleteRule',
+    method: "post",
+    data:params
+  }
+  return request(new_params);
+}
 //其实,也不一定就是params,也可以是 query 还有 data 的呀!
 //params是添加到url的请求字符串中的,用于get请求。(后面这句不对)会将参数加到 url后面。所以,传递的都是字符串。无法传递参数中含有json格式的数据
 //而data是添加到请求体(body)中的, 用于post请求。添加到请求体(body)中,json 格式也是可以的。