浏览代码

营销填报代码优化;

001295 1 年之前
父节点
当前提交
8fe234556d

+ 35 - 0
src/api/business/spd/fillin/dailysale_quantity_assess_item.js

@@ -0,0 +1,35 @@
+import request from '@/utils/request'
+
+// 查询明细
+export function listItem(query) {
+  return request({
+    url: '/mk/fillin/dailySaleQuantityAssessItem/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 批量修改明细
+export function saveItems(data) {
+  return request({
+    url: '/mk/fillin/dailySaleQuantityAssessItem',
+    method: 'put',
+    data: data
+  })
+}
+
+//删除明细
+export function delItems(id) {
+  return request({
+    url: '/mk/fillin/dailySaleQuantityAssessItem/' + id,
+    method: 'delete'
+  })
+}
+
+//全选销售物料
+export function selectAllSaleMat(id) {
+  return request({
+    url: '/mk/fillin/dailySaleQuantityAssessItem/selectAll/' + id,
+    method: 'post',
+  })
+}

+ 37 - 20
src/views/business/spd/fillin/dailysale_quantity_assess/addmaterial.vue

@@ -31,7 +31,7 @@
                     </el-col>
                 </el-row>
             </el-form>
-            <el-table :data="tableData" size="mini" @row-dblclick="useDoubleClick" @selection-change="useSelectChange" height="450px">
+            <el-table :data="tableData" size="mini" @row-dblclick="useDoubleClick" @selection-change="useSelectChange" v-loading="loading" height="450px">
                 <el-table-column type="selection" width="55"> </el-table-column>
                 <el-table-column show-overflow-tooltip label="编码" align="center" width="150" prop="code"/>
                 <el-table-column show-overflow-tooltip label="名称" align="center" width="200" prop="name"/>
@@ -62,11 +62,13 @@
 
 <script>
 import materialApi from "@/api/material/basic";
-
+import { saveItems } from "@/api/business/spd/fillin/dailysale_quantity_assess_item";
 export default {
   name: "dailysaleQuantityAssessDetailAddmaterial",
+  props: ["form"],
   data() {
     return {
+      loading: false,
       //是否打开弹窗
       open:false,
       //搜索框参数
@@ -86,9 +88,6 @@ export default {
       selectionData:[],
     };
   },
-  watch: {},
-  created() {
-  },
   methods: {
     //打开弹窗
     openDialog(){
@@ -97,16 +96,16 @@ export default {
     },
     //关闭弹窗
     useClose(done){
-        this.selectionData = [];
-        this.queryParams = {
-            code: null,
-            name: null,
-        }
-        this.page = {
-            pageNum:1,
-            pageSize:10,
-        }
-        done();
+      this.selectionData = [];
+      this.queryParams = {
+          code: null,
+          name: null,
+      }
+      this.page = {
+          pageNum:1,
+          pageSize:10,
+      }
+      done();
     },
     //获取列表数据
     async getList() {
@@ -130,7 +129,7 @@ export default {
         this.selectionData = selection;
     },
     //确认多选
-    useConfirm(){
+    async useConfirm(){
       if(this.selectionData.length < 1){
         this.$modal.msgError("未选择数据!");
         return;
@@ -138,28 +137,46 @@ export default {
       const arr = [];
       for(let i in this.selectionData){
           arr.push({
+              dailysaleQuantityAssessId:this.form.id,
               oneClassName:this.selectionData[i].oneClass,
               twoClassName:this.selectionData[i].twoClass,
+              material:this.selectionData[i].id,
               materialCode:this.selectionData[i].code,
               materialName:this.selectionData[i].name,
               unitName:this.selectionData[i].unitIdName,
+              price:this.selectionData[i].price,
           });
       }
-      this.$emit("addRow",arr);
-      this.open = false;
+      let res = await saveItems(arr);
+      if(res.code == '200'){
+        this.$modal.msgSuccess("添加成功");
+        this.$emit("useReset");
+        this.open = false;
+      }else{
+        this.$modal.msgError("保存失败,请联系管理员!");
+      }
     },
     //双击选择
     async useDoubleClick(row){
         const arr = [];
         arr.push({
+            dailysaleQuantityAssessId:this.form.id,
             oneClassName:row.oneClass,
             twoClassName:row.twoClass,
+            material:row.id,
             materialCode:row.code,
             materialName:row.name,
             unitName:row.unitIdName,
+            price:row.price,
         });
-        this.$emit("addRow",arr);
-        this.open = false;
+        let res = await saveItems(arr);
+        if(res.code == '200'){
+          this.$modal.msgSuccess("添加成功");
+          this.$emit("useReset");
+          this.open = false;
+        }else{
+          this.$modal.msgError("保存失败,请联系管理员!");
+        }
     },
     //搜索
     useSearch(){

+ 60 - 27
src/views/business/spd/fillin/dailysale_quantity_assess/choosematerial.vue

@@ -31,7 +31,7 @@
                     </el-col>
                 </el-row>
             </el-form>
-            <el-table :data="tableData" size="mini" @row-dblclick="useDoubleClick" @selection-change="useSelectChange" height="450px">
+            <el-table :data="tableData" size="mini" @row-dblclick="useDoubleClick" @selection-change="useSelectChange" v-loading="loading" height="450px">
                 <el-table-column type="selection" width="55"> </el-table-column>
                 <el-table-column show-overflow-tooltip label="编码" align="center" width="150" prop="code"/>
                 <el-table-column show-overflow-tooltip label="名称" align="center" width="200" prop="name"/>
@@ -51,24 +51,28 @@
                 :total=total>
             </el-pagination>
             <el-card>
-            <div class="btn_group">
-                <el-col :span="1.5" style="margin: 0 10px;">
-                    <el-button type="primary" size="mini" plain @click="useConfirm">确认</el-button>
-                </el-col>
-            </div>
-        </el-card>
+              <div class="btn_group">
+                  <el-col :span="1.5" style="margin: 0 10px;">
+                      <el-button type="primary" size="mini" plain @click="selectAll">全选</el-button>
+                  </el-col>
+                  <el-col :span="1.5" style="margin: 0 10px;">
+                      <el-button type="primary" size="mini" plain @click="useConfirm">确认</el-button>
+                  </el-col>
+              </div>
+          </el-card>
         </el-dialog>
     </div>
 </template>
 
 <script>
 import {getSaleMaterialList} from "@/api/business/spd/fillin/dailysale_quantity_assess";
-
+import { saveItems,selectAllSaleMat } from "@/api/business/spd/fillin/dailysale_quantity_assess_item";
 export default {
   name: "dailysaleQuantityAssessDetailChoosematerial",
   props: ["form"],
   data() {
     return {
+      loading: false,
       //是否打开弹窗
       open:false,
       //搜索框参数
@@ -87,9 +91,6 @@ export default {
       selectionData:[],
     };
   },
-  watch: {},
-  created() {
-  },
   methods: {
     //打开弹窗
     openDialog(){
@@ -102,15 +103,15 @@ export default {
     },
     //关闭弹窗
     useClose(done){
-        this.selectionData = [];
-        this.queryParams = {
-            customer: null,
-            materialCode: null,
-            materialName: null,
-            pageNum:1,
-            pageSize:10,
-        }
-        done();
+      this.selectionData = [];
+      this.queryParams = {
+        customer: null,
+        materialCode: null,
+        materialName: null,
+        pageNum:1,
+        pageSize:10,
+      }
+      done();
     },
     //获取列表数据
     async getList() {
@@ -134,8 +135,22 @@ export default {
     useSelectChange(selection){
         this.selectionData = selection;
     },
+    //全选
+    selectAll(){
+      this.$modal.confirm('您确定要全选销售给当前客户的所有物料吗').then(() => {
+        selectAllSaleMat(this.form.id).then(res => {
+          if(res.code == '200'){
+            this.$modal.msgSuccess("全选成功");
+            this.$emit("useReset");
+            this.open = false;
+          }else{
+            this.$modal.msgError("全选失败,请联系管理员!");
+          }
+        })
+      }).catch(() => {})
+    },
     //确认多选
-    useConfirm(){
+    async useConfirm(){
       if(this.selectionData.length < 1){
         this.$modal.msgError("未选择数据!");
         return;
@@ -143,28 +158,46 @@ export default {
       const arr = [];
       for(let i in this.selectionData){
           arr.push({
+              dailysaleQuantityAssessId:this.form.id,
               oneClassName:this.selectionData[i].oneClass,
               twoClassName:this.selectionData[i].twoClass,
+              material:this.selectionData[i].id,
               materialCode:this.selectionData[i].code,
               materialName:this.selectionData[i].name,
               unitName:this.selectionData[i].unitIdName,
+              price:this.selectionData[i].price,
           });
       }
-      this.$emit("addRow",arr);
-      this.open = false;
+      let res = await saveItems(arr);
+      if(res.code == '200'){
+        this.$modal.msgSuccess("添加成功");
+        this.$emit("useReset");
+        this.open = false;
+      }else{
+        this.$modal.msgError("保存失败,请联系管理员!");
+      }
     },
     //双击选择
     async useDoubleClick(row){
         const arr = [];
         arr.push({
+            dailysaleQuantityAssessId:this.form.id,
             oneClassName:row.oneClass,
             twoClassName:row.twoClass,
+            material:row.id,
             materialCode:row.code,
             materialName:row.name,
             unitName:row.unitIdName,
+            price:row.price,
         });
-        this.$emit("addRow",arr);
-        this.open = false;
+        let res = await saveItems(arr);
+        if(res.code == '200'){
+          this.$modal.msgSuccess("添加成功");
+          this.$emit("useReset");
+          this.open = false;
+        }else{
+          this.$modal.msgError("保存失败,请联系管理员!");
+        }
     },
     //搜索
     useSearch(){
@@ -183,12 +216,12 @@ export default {
     },
     //改变一页显示条数
     useChangePageSize(val){
-      this.page.pageSize = val
+      this.queryParams.pageSize = val
       this.getList()
     },
     //翻页
     useCurrentChange(val){
-      this.page.pageNum = val
+      this.queryParams.pageNum = val
       this.getList()
     },
   },

+ 110 - 161
src/views/business/spd/fillin/dailysale_quantity_assess/detail.vue

@@ -7,8 +7,6 @@
       <el-form
         size="mini"
         :model="form"
-        :rules="rules"
-        ref="form"
         label-width="auto"
       >
         <el-row :gutter="10">
@@ -37,19 +35,13 @@
           </el-col>
           <el-col :span="1.5">
             <el-form-item label="客户" prop="customer">
-              <dr-popover-select
-                :readonly="this.openMode == 'edit' || this.openMode == 'see'"
-                size="mini"
+              <el-input
+                placeholder="自动生成"
+                readonly
                 v-model="form.customerName"
-                title="客户选择"
-                type="CUSTOMER_PARAM_ZT"
-                :dataMapping="{
-                  customer: 'id',
-                  customerName: 'name',
-                }"
-                :source.sync="form"
-              >
-              </dr-popover-select>
+                style="width: 200px"
+                clearable
+              />
             </el-form-item>
           </el-col>
           <el-col :span="1.5">
@@ -85,11 +77,11 @@
         </el-row>
       </el-form>
     </el-card>
-    <el-card style="height: 800px">
+    <el-card style="height: 750px">
       <div style="position: relative">
         <el-tabs v-model="activeName" @tab-click="useSwitchTab">
           <el-tab-pane label="明细" name="item">
-            <el-table :data="items" height="700px" size="size">
+            <el-table :data="items" height="600px" size="size" v-loading="loading">
               <el-table-column
                 label="序号"
                 type="index"
@@ -129,26 +121,16 @@
                 show-overflow-tooltip
                 label="单位"
                 align="center"
-                width="150"
+                width="100"
                 prop="unitName"
               />
               <el-table-column
                 show-overflow-tooltip
                 label="价格(元)"
                 align="center"
-                width="150"
+                width="100"
                 prop="price"
-              >
-                <template slot-scope="scope">
-                  <el-input-number
-                    size="mini"
-                    style="width: 130px"
-                    v-model="scope.row.price"
-                    :controls="false"
-                  >
-                  </el-input-number>
-                </template>
-              </el-table-column>
+              />
               <el-table-column
                 show-overflow-tooltip
                 label="日 销 售 数 据 填 报"
@@ -679,7 +661,7 @@
                   <el-button
                     type="text"
                     size="mini"
-                    @click="useRowRemove(scope.$index, scope.row)"
+                    @click="useRowRemove(scope.row)"
                     >删行</el-button
                   >
                 </template>
@@ -687,9 +669,19 @@
             </el-table>
           </el-tab-pane>
         </el-tabs>
+        <el-pagination
+            background
+            @size-change="useChangePageSize"
+            @current-change="useCurrentChange"
+            :current-page="queryParams.pageNum"
+            :page-sizes="[10, 15, 20]"
+            :page-size="100"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total=total>
+        </el-pagination>
         <div style="position: absolute; right: 10px; top: 5px; display: flex">
-          <Choosematerial @addRow="addRow" :form="form"></Choosematerial>
-          <Addmaterial @addRow="addRow"></Addmaterial>
+          <Choosematerial @useReset="useReset" :form="form"></Choosematerial>
+          <Addmaterial @useReset="useReset" :form="form"></Addmaterial>
         </div>
       </div>
     </el-card>
@@ -709,11 +701,8 @@
 </template>
 
 <script>
-import {
-  addAssess,
-  updateAssess,
-  getAssess,
-} from "@/api/business/spd/fillin/dailysale_quantity_assess";
+import { getAssess } from "@/api/business/spd/fillin/dailysale_quantity_assess";
+import { listItem,saveItems,delItems } from "@/api/business/spd/fillin/dailysale_quantity_assess_item";
 import Addmaterial from "./addmaterial";
 import Choosematerial from "./choosematerial";
 export default {
@@ -722,93 +711,56 @@ export default {
   props: ["openMode", "row"],
   data() {
     return {
-      form: {
-        month: null,
-        customer: null,
-        customerName: null,
-        items: [],
-        //所选月份天数
-        numDay:31,
-      },
-      //表单校验
-      rules: {
-        month: [{ required: true, message: "月份不能为空", trigger: "blur" }],
-        customer: [
-          { required: true, message: "客户不能为空", trigger: "blur" },
-        ],
+      loading: false,
+      //主表
+      form: {},
+      //所选月份天数
+      numDay:31,
+      //明细
+      items:[],
+      //明细查询条件
+      queryParams:{
+        dailysaleQuantityAssessId: null,
+        pageNum:1,
+        pageSize:10,
       },
+      //总条数
+      total: 0,
       activeName: "item",
     };
   },
-  watch: {
-    'form.month': {
-      handler(newVal) {
-          let arr = newVal.split('-');
-          this.numDay = this.getDays(arr[0],arr[1]);
-      },
-      immediate:true,
-    }
-  },
-  computed: {
-    items() {
-      return this.form.items.filter(({ delFlag }) => delFlag !== "2");
-    },
-  },
   async created() {
     switch (this.openMode) {
-      case "add":
-        this.form.createTime = this.getCurrentTime();
-        this.form.month = this.getCurrentMonth();
-        this.form.createByName = this.$store.state.user.nickName;
-        this.form.dept = this.$store.state.user.deptId;
-        this.form.deptName = this.$store.state.user.deptName;
-        break;
       case "edit":
         await this.fetchAssess(this.row.id);
-        this.total();
-        console.log('this.form.items',this.form.items);
+        await this.fetchItem(this.row.id);
         break;
       case "see":
         await this.fetchAssess(this.row.id);
-        this.total();
+        await this.fetchItem(this.row.id);
         break;
     }
+    let arr = this.form.month.split('-');
+    this.numDay = this.getDays(arr[0],arr[1]);
   },
   methods: {
     //保存
     async useSave() {
-      this.$refs["form"].validate(async (valid) => {
-        if (valid) {
-          try {
-            let checkRes = this.checkBeforeSave(this.form);
-            if (!checkRes) {
-              return;
-            }
-            this.loading = true;
-            let res = null;
-            if (this.openMode === "add") {
-              res = await addAssess(this.form);
-            }
-            if (this.openMode === "edit") {
-              res = await updateAssess(this.form);
-            }
-            if (res.code === 200) {
-              this.$modal.msgSuccess("保存成功");
-              this.useBack();
-            }
-          } catch (err) {
-            console.error(err);
-          } finally {
-            this.loading = false;
-          }
-        } else {
-          return false;
+      this.loading = true;
+      try {
+        let res = null;
+        if (this.openMode === "edit") {
+          res = await saveItems(this.items);
         }
-      });
-    },
-    //保存前校验
-    checkBeforeSave(form) {
-      return true;
+        if (res.code === 200) {
+          this.$modal.msgSuccess("保存成功");
+          this.useBack();
+        }
+      } catch (err) {
+        console.error(err);
+      } finally {
+        this.loading = false;
+      };
     },
     //查询详情
     async fetchAssess(id) {
@@ -830,28 +782,27 @@ export default {
         this.loading = false;
       }
     },
-    //增行
-    addRow(rows) {
-      console.log("rows", rows);
-      for (let i in rows) {
-        this.form.items.push({
-          delFlag: "0",
-          $index: new Date().getTime(),
-          ...rows[i],
-        });
-      }
+    //查询明细
+    async fetchItem(pid){
+      this.loading = true;
+      this.queryParams.dailysaleQuantityAssessId = pid;
+      await listItem(this.queryParams).then(res => {
+        if (res.code === 200) {
+          this.items = res.rows
+          this.total = res.total
+          this.aggregate();
+        }
+        this.loading = false;
+      })
     },
     //删行
-    async useRowRemove(index, row) {
-      if (row.id) {
-        this.form.items.forEach((e) => {
-          if (e.id == row.id) {
-            e.delFlag = "2";
-          }
-        });
-      } else {
-        this.form.items.splice(index, 1);
-      }
+    async useRowRemove(row) {
+      let arr = [row.id];
+      delItems(arr).then(res => {
+        if (res.code === 200) {
+           this.fetchItem(this.form.id);
+        }
+      })
     },
     //切换多页签
     useSwitchTab() {},
@@ -860,51 +811,45 @@ export default {
       this.$parent.useOpenDetail();
       this.$parent.useSearch();
     },
-    //获取当月
-    getCurrentMonth () {
-      const date = new Date()
-      let year = date.getFullYear()
-      let month = date.getMonth() + 1
-      month = month > 9 ? month : '0' + month
-      return `${year}-${month}`
-    },
+    //获取当前月份天数
     getDays(year, month){
       return new Date(year, month, 0).getDate()
     },
-    getCurrentTime() {
-      var date = new Date();//当前时间
-      var year = date.getFullYear() //年
-      var month = this.repair(date.getMonth() + 1);//月
-      var day = this.repair(date.getDate());//日
-      var hour = this.repair(date.getHours());//时
-      var minute = this.repair(date.getMinutes());//分
-      var second = this.repair(date.getSeconds());//秒
-      //当前时间 
-      var curTime = year + "-" + month + "-" + day
-              + " " + hour + ":" + minute + ":" + second;
-      return curTime;
-    },
-    repair(i){
-      if (i >= 0 && i <= 9) {
-          return "0" + i;
-      } else {
-          return i;
-      }
-    },
     //计算合计
-    total(){
+    aggregate(){
       let num = ["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth"
 				,"twentyFirst","seventeenth","eighteenth","nineteenth","twentieth","twentyFirst","twentySecond","twentyThird","twentyFourth","twentyFifth","twentySixth","twentySeventh","twentyEighth","twentyNinth","thirtieth","thirtyFirst"];
-      for(let i in this.form.items){
+      for(let i in this.items){
         let c = 0;
         for(let j in num){
-          c = (this.form.items[i][num[j]] || 0) - 0 + c;
+          c = (this.items[i][num[j]] || 0) - 0 + c;
         }
-        console.log('c',c);
-        this.form.items[i].amount = c;
-        this.form.items[i].money = c * (this.form.items[i].price || 0);
+        this.items[i].amount = c;
+        this.items[i].money = c * (this.items[i].price || 0);
       }
-    }
+      console.log('this.items222',this.items);
+    },
+    //改变一页显示条数
+    async useChangePageSize(val){
+      this.queryParams.pageSize = val
+      await saveItems(this.items);
+      await this.fetchItem(this.form.id);
+    },
+    //翻页
+    async useCurrentChange(val){
+      this.queryParams.pageNum = val
+      await saveItems(this.items);
+      await this.fetchItem(this.form.id);
+    },
+    //重置
+    useReset(){
+      this.queryParams = {
+        pageNum: 1,
+        pageSize: 10,
+      }
+      this.fetchItem(this.form.id);
+      this.aggregate();
+    },
   },
 };
 </script>
@@ -916,4 +861,8 @@ export default {
   display: flex;
   justify-content: right;
 }
+.el-pagination {
+  margin-top: 10px;
+  text-align: right;
+}
 </style>

+ 185 - 6
src/views/business/spd/fillin/dailysale_quantity_assess/index.vue

@@ -56,6 +56,7 @@
         <el-table
           :data="tableList"
           @row-dblclick="useDoubleClick"
+          v-loading="loading"
           height="600px"
         >
           <el-table-column label="序号" type="index" width="50" align="center" fixed/>
@@ -69,7 +70,7 @@
           <el-table-column show-overflow-tooltip label="修改时间" align="center" width="200" prop="updateTime" />
           <el-table-column fixed="right" label="操作" align="center" width="150">
             <template slot-scope="scope">
-              <el-button type="text" size="mini" @click="useEdit(scope.row)">编辑</el-button>
+              <el-button type="text" size="mini" @click="useEdit(scope.row)">填报</el-button>
               <el-button type="text" size="mini" @click="useDel(scope.row)">删除</el-button>
             </template>
           </el-table-column>
@@ -88,18 +89,127 @@
       </el-card>
     </div>
     <Detail v-if="openDetail" :openMode="openMode" :row="row"/>
+
+    <!-- 新增填报对话框 -->
+    <el-dialog
+      title="新增"
+      :visible.sync="open"
+      width="1000px"
+      append-to-body
+    >
+      <el-form
+        size="mini"
+        :model="form"
+        :rules="rules"
+        ref="form"
+        label-width="auto"
+      >
+        <el-row :gutter="10">
+          <el-col :span="1.5">
+            <el-form-item label="编码" prop="code">
+              <el-input
+                placeholder="自动生成"
+                readonly
+                v-model="form.code"
+                style="width: 200px"
+                clearable
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="1.5">
+            <el-form-item label="月份" prop="month">
+              <el-date-picker
+                :readonly="this.openMode == 'edit' || this.openMode == 'see'"
+                v-model="form.month"
+                value-format="yyyy-MM"
+                type="month"
+                clearable
+              >
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="1.5">
+            <el-form-item label="客户" prop="customer">
+              <dr-popover-select
+                :readonly="this.openMode == 'edit' || this.openMode == 'see'"
+                size="mini"
+                v-model="form.customerName"
+                title="客户选择"
+                type="CUSTOMER_PARAM_ZT"
+                :dataMapping="{
+                  customer: 'id',
+                  customerName: 'name',
+                }"
+                :source.sync="form"
+              >
+              </dr-popover-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="1.5">
+            <el-form-item label="创建日期" prop="createTime">
+              <el-input
+                v-model="form.createTime"
+                style="width: 200px"
+                clearable
+                readonly
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="1.5">
+            <el-form-item label="创建人" prop="createByName">
+              <el-input
+                v-model="form.createByName"
+                style="width: 200px"
+                clearable
+                readonly
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="1.5">
+            <el-form-item label="部门" prop="deptName">
+              <el-input
+                v-model="form.deptName"
+                style="width: 200px"
+                clearable
+                readonly
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import Detail from './detail.vue'
-import { listAssess,delAssess, } from "@/api/business/spd/fillin/dailysale_quantity_assess";
+import { addAssess,listAssess,delAssess, } from "@/api/business/spd/fillin/dailysale_quantity_assess";
 
 export default {
   name: "dailysaleQuantityAssess",
   components: {Detail},
   data() {
     return {
+      loading: false,
+      // 是否显示弹出层
+      open: false,
+      //新增表单
+      form: {
+        month: "",
+        customer: "",
+        customerName: "",
+      },
+      //表单校验
+      rules: {
+        month: [{ required: true, message: "月份不能为空", trigger: "blur" }],
+        customer: [
+          { required: true, message: "客户不能为空", trigger: "blur" },
+        ],
+      },
       // 搜索框参数
       queryParams: {
         customerName:null,
@@ -131,8 +241,13 @@ export default {
     },
     //新增
     useAdd(){
-      this.openMode = 'add';
-      this.openDetail = true;
+      this.reset();
+      this.form.createTime = this.getCurrentTime();
+      this.form.month = this.getCurrentMonth();
+      this.form.createByName = this.$store.state.user.nickName;
+      this.form.dept = this.$store.state.user.deptId;
+      this.form.deptName = this.$store.state.user.deptName;
+      this.open = true;
     },
     //编辑
     async useEdit(row){
@@ -146,19 +261,20 @@ export default {
         delAssess(row.id).then(res => {
           if (res.code === 200) {
             this.$modal.msgSuccess("删除成功");
-            this.getList(this.queryParams)
+            this.getList(this.queryParams);
           }
         })
       }).catch(() => {})
     },
     //查询列表
     getList(params){
-      console.log('params',params);
+      this.loading = true;
       listAssess(params).then(res => {
         if (res.code === 200) {
           this.tableList = res.rows
           this.total = res.total
         }
+        this.loading = false;
       })
     },
     //双击
@@ -194,6 +310,69 @@ export default {
       }
       this.getList(this.queryParams);
     },
+    //重置表单
+    reset(){
+      this.form = {
+        month: "",
+        customer: "",
+        customerName: "",
+      }
+    },
+    // 确认
+    async submitForm() {
+      this.$refs["form"].validate(async (valid) => {
+        if (valid) {
+          this.loading = true;
+          try {
+            let res = await addAssess(this.form);
+            if (res.code === 200) {
+              this.$modal.msgSuccess("保存成功");
+              this.cancel();
+              this.getList(this.queryParams);
+            }
+          } catch (err) {
+            console.error(err);
+          } finally {
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    getCurrentTime() {
+      var date = new Date();//当前时间
+      var year = date.getFullYear() //年
+      var month = this.repair(date.getMonth() + 1);//月
+      var day = this.repair(date.getDate());//日
+      var hour = this.repair(date.getHours());//时
+      var minute = this.repair(date.getMinutes());//分
+      var second = this.repair(date.getSeconds());//秒
+      //当前时间 
+      var curTime = year + "-" + month + "-" + day
+              + " " + hour + ":" + minute + ":" + second;
+      return curTime;
+    },
+    repair(i){
+      if (i >= 0 && i <= 9) {
+          return "0" + i;
+      } else {
+          return i;
+      }
+    },
+     //获取当月
+    getCurrentMonth(){
+      const date = new Date()
+      let year = date.getFullYear()
+      let month = date.getMonth() + 1
+      month = month > 9 ? month : '0' + month
+      return `${year}-${month}`
+    },
   },
 };
 </script>

+ 12 - 0
src/views/business/spd/fillin/test/index.vue

@@ -0,0 +1,12 @@
+
+<template>
+  <div>
+    测试
+  </div>
+</template>
+
+<script>
+export default {
+  
+};
+</script>