فهرست منبع

成本模板对接完成

谢杰标 2 سال پیش
والد
کامیت
808199f56e
3فایلهای تغییر یافته به همراه76 افزوده شده و 51 حذف شده
  1. 14 7
      src/api/financed/index.js
  2. 28 29
      src/views/financed/cost/dislogSet.vue
  3. 34 15
      src/views/financed/cost/index.vue

+ 14 - 7
src/api/financed/index.js

@@ -32,6 +32,14 @@ export function editDefaultStatus(data) {
     data,
   });
 }
+// 批量删除
+export function batchCost(data) {
+  return request({
+    url: "/financial/tp/deleteBatch",
+    method: "post",
+    data,
+  });
+}
 // 修改模板
 export function editCost(data) {
   return request({
@@ -41,10 +49,9 @@ export function editCost(data) {
   });
 }
 // 查询模板
-export function costDetal(query) {
-    return request({
-      url: "/financial/tp/list",
-      method: "get",
-      params: query,
-    });
-  }
+export function costDetail(id) {
+  return request({
+    url: "/financial/tp/" + id,
+    method: "get",
+  });
+}

+ 28 - 29
src/views/financed/cost/dislogSet.vue

@@ -3,7 +3,7 @@
     <BaseDialog
       width="1400px"
       :isShow.sync="isShow"
-      :title="['新增', '修改', '复制'][type]"
+      :title="title"
       @close="close"
       @submit="submitForm"
     >
@@ -67,8 +67,8 @@
             :rules="rules['itemCategory']"
           >
             <el-select v-model="item.itemCategory" placeholder="请选择成本类型">
-              <el-option label="业务类型" value="1"></el-option>
-              <el-option label="非分成" value="2"></el-option>
+              <el-option label="业务类型" :value="1"></el-option>
+              <el-option label="非分成" :value="2"></el-option>
             </el-select>
           </el-form-item>
           <template v-if="item.itemCategory == 1">
@@ -118,8 +118,8 @@
             :rules="rules['itemType']"
           >
             <el-select v-model="item.itemType" placeholder="请选择成本类型">
-              <el-option label="百分比成本" value="1"></el-option>
-              <el-option label="固定成本" value="2"></el-option>
+              <el-option label="百分比成本" :value="1"></el-option>
+              <el-option label="固定成本" :value="2"></el-option>
             </el-select>
           </el-form-item>
           <el-form-item
@@ -179,7 +179,7 @@
 </template>
 
 <script>
-import { eduList, addCost, costDetal } from "@/api/financed/index";
+import { eduList, addCost, costDetail, editCost } from "@/api/financed/index";
 export default {
   name: "DislogSet",
   props: {
@@ -187,7 +187,7 @@ export default {
       type: Boolean,
       default: false,
     },
-    // 1 新增  2修改  3复制
+    // 0 新增  1修改  2复制
     type: {
       type: [String, Number],
       default: 0,
@@ -229,31 +229,23 @@ export default {
           { required: true, message: "请输入百分比成本", trigger: "blur" },
         ],
       },
-      eduTypeOptions: [],
-      newCourTypeOptions: [],
       companyList: [],
       eduList: [],
-      courType: 0,
     };
   },
-
-  mounted() {
-    console.log(8798465465);
-  },
-
   methods: {
     init() {
       this.resetForm();
-      if (this.tpId) {
-        this.getCostDetal();
-        console.log(this.tpId, 666);
-      }
+      this.tpId && this.getCostDetail();
       this.getCompanyList();
       this.getEduList();
     },
-    getCostDetal() {
-      costDetal({ tpId: this.tpId }).then((res) => {
-        console.log(res.rows, 89);
+    getCostDetail() {
+      costDetail(this.tpId).then((res) => {
+        if (this.type == 2) delete res.data["tpId"];
+        Object.keys(this.form).map((key) => {
+          this.form[key] = res.data[key];
+        });
       });
     },
     getEduList() {
@@ -313,21 +305,25 @@ export default {
             maxValue: undefined,
           },
         ],
+        tpId: undefined,
         tpName: 123,
         defaultStatus: 0,
         tenantId: "1",
       };
     },
+    cb() {
+      this.$message.success(this.title + "成功");
+      this.isShow = false;
+      this.$emit("search");
+    },
     submitForm() {
-      console.log(1232132);
       this.$refs["form"].validate((valid) => {
         if (valid) {
-          console.log(13213);
-          addCost(this.form).then((res) => {
-            console.log(res, 666);
-            this.isShow = false;
-            this.$emit("search");
-          });
+          if (this.type !== 1) {
+            addCost(this.form).then(this.cb);
+          } else {
+            editCost(this.form).then(this.cb);
+          }
         } else {
           return false;
         }
@@ -346,6 +342,9 @@ export default {
         this.$emit("update:dialogVisible", false);
       },
     },
+    title() {
+      return ["新增", "修改", "复制"][this.type];
+    },
   },
 };
 </script>

+ 34 - 15
src/views/financed/cost/index.vue

@@ -61,7 +61,12 @@ import dislogSet from "./dislogSet.vue";
 import searchBoxNew from "@/components/searchBoxNew";
 import tableList from "@/components/tableList";
 import pagination from "@/components/pagination";
-import { costList, editDefaultStatus, editCost } from "@/api/financed/index";
+import {
+  costList,
+  editDefaultStatus,
+  editCost,
+  batchCost,
+} from "@/api/financed/index";
 export default {
   name: "cost",
   components: { searchBoxNew, tableList, pagination, dislogSet },
@@ -112,10 +117,10 @@ export default {
           soltName: "status",
         },
       ],
-      tableData: [], //表单数据
-      total: 0, //一共多少条
+      tableData: [],
+      total: 0,
       dialogVisible: false,
-      id: "",
+      tpId: "1",
       type: 0,
     };
   },
@@ -139,19 +144,33 @@ export default {
       if (!len) {
         return this.$message.warning("请先勾选模板");
       }
-      const ids = this.$refs.tableList.allCheckData.map((item) => item.id);
+      const ids = this.$refs.tableList.allCheckData.map((item) => item.tpId);
+      this.handelDel(ids, 1);
     },
-    handelDel(tpId) {
-      this.$confirm("此操作将删除该模板, 是否继续?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
+    handelDel(tpId, type = 0) {
+      this.$confirm(
+        `此操作将删除${type ? "批量" : "该"}模板, 是否继续?`,
+        "提示",
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      )
         .then(() => {
-          editCost({ tpId, status: -1 }).then((res) => {
-            this.$message.success("删除成功");
-            this.search();
-          });
+          if (type) {
+            batchCost({ ids: tpId }).then((res) => {
+              this.$message.success("删除成功");
+              this.$refs.tableList.clearMoreActive();
+              this.search();
+            });
+          } else {
+            editCost({ tpId, status: -1 }).then((res) => {
+              this.$message.success("删除成功");
+              this.$refs.tableList.clearMoreActive();
+              this.search();
+            });
+          }
         })
         .catch(() => {
           this.$message({