Переглянути джерело

【新增】工程信息单

莫绍宝 3 роки тому
батько
коміт
1932207de6

+ 54 - 0
src/api/supply/engin.js

@@ -52,4 +52,58 @@ export function getRetailProductList(params) {
     method: 'get',
     params
   })
+}
+
+// 新增
+export function addEngin(params) {
+  return request({
+    url: '/engin-info-order/add',
+    method: 'post',
+    data: params
+  })
+}
+
+// 编辑
+export function editEngin(params) {
+  return request({
+    url: '/engin-info-order/edit',
+    method: 'post',
+    data: params
+  })
+}
+
+// 提交审核
+export function submitEngin(params) {
+  return request({
+    url: '/engin-info-order/submit',
+    method: 'post',
+    data: params
+  })
+}
+
+// 申请
+export function applyEngin(params) {
+  return request({
+    url: '/engin-info-order/apply',
+    method: 'post',
+    params
+  })
+}
+
+// 撤回
+export function withdrawEngin(params) {
+  return request({
+    url: '/engin-info-order/revoke',
+    method: 'post',
+    params
+  })
+}
+
+// 删除
+export function deleteEngin(params) {
+  return request({
+    url: '/engin-info-order/del',
+    method: 'post',
+    params
+  })
 }

+ 140 - 14
src/views/supply/engin/components/engin_form.vue

@@ -6,11 +6,11 @@
       <div class="title">工程信息单</div>
     </div>
 
-    <el-form ref="mainForm" :model="mainForm" label-width="100px" size="small" label-position="left">
+    <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="100px" size="small" label-position="left">
       <el-row :gutter="20">
         <el-col :xs="24" :sm="12" :lg="8">
           <el-form-item label="工程信息单" prop="orderNum">
-            <el-input v-model="mainForm.orderNum" placeholder="请输入工程信息单"></el-input>
+            <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" readonly></el-input>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
@@ -33,7 +33,7 @@
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
           <el-form-item label="经销商编码" prop="jxsNum">
-            <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码"></el-input>
+            <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" readonly></el-input>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
@@ -48,7 +48,7 @@
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
           <el-form-item label="经销商名称" prop="jxsName">
-            <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称"></el-input>
+            <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" readonly></el-input>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
@@ -83,12 +83,12 @@
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
           <el-form-item label="业务员" prop="salesMan">
-            <el-input v-model="mainForm.salesMan" placeholder="请输入业务员"></el-input>
+            <el-input v-model="mainForm.salesMan" placeholder="请输入业务员" readonly></el-input>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
           <el-form-item label="制单人" prop="createMan">
-            <el-input v-model="mainForm.createMan" placeholder="请输入制单人"></el-input>
+            <el-input v-model="mainForm.createMan" placeholder="请输入制单人" readonly></el-input>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
@@ -96,6 +96,7 @@
             <el-date-picker
               v-model="mainForm.createDate"
               type="date"
+              readonly
               value-format="yyyy-MM-dd"
               style="width: 100%;"
               placeholder="选择日期">
@@ -182,8 +183,8 @@
     
     <div class="page-footer">
       <div class="footer" :class="classObj">
-        <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
-        <el-button type="primary" @click="clickSubmitForm">提交审核</el-button>
+        <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
+        <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
         <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
           <el-button slot="reference">关 闭</el-button>
         </el-popconfirm>
@@ -194,7 +195,7 @@
 </template>
 
 <script>
-import { getEnginDetail, getRetailProductList } from "@/api/supply/engin";
+import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from "@/api/supply/engin";
 import { getDictList, getTypeList } from '@/api/common'
 
 export default {
@@ -203,10 +204,33 @@ export default {
   props: ['listItem'],
   data() {
     return {
-      detailData: {},
       goodsList: [],
       mainForm: {
-
+        orderNum: '',
+        orderDate: '',
+        mainId: '102',
+        jxsNum: '',
+        enginName: '',
+        orderType: '',
+        jxsName: '',
+        company: '',
+        address: '',
+        enginNum: '',
+        factoryNum: '',
+        loginType: '',
+        remark: '',
+        salesMan: '',
+        createMan: '',
+        createDate: '',
+        contractDate: '',
+      },
+      mainFormRules: {
+        orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
+        jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
+        enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
+        jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
+        company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
+        address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
       },
 
       typeList: [],
@@ -225,15 +249,21 @@ export default {
         openSidebar: this.sidebar.opened
       }
     },
+    
   },
 
   created() {
+    this.getDictList();
     this.getTypeList();
     this.getRetailProductList();
     if(this.listItem) {
       this.getDetail();
     }else {
-
+      this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerId;
+      this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
+      this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
+      this.mainForm.createDate = this.getDate(0);
+      this.mainForm.contractDate = this.getDate(1);
     }
   },
 
@@ -243,14 +273,49 @@ export default {
       this.$emit('backListFormDetail');
     },
 
+    getDate(addYear) {
+      var date = new Date();
+      var seperator1 = "-";
+      var year = date.getFullYear() + addYear;
+      var month = date.getMonth() + 1;
+      var strDate = date.getDate();
+      if (month >= 1 && month <= 9) {
+          month = "0" + month;
+      }
+      if (strDate >= 0 && strDate <= 9) {
+          strDate = "0" + strDate;
+      }
+      var currentdate = year + seperator1 + month + seperator1 + strDate;
+      return currentdate;
+    },
+
     // 获取详情
     getDetail() {
       getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
-        this.detailData = res.data;
+        let data = res.data;
+        this.mainForm.orderNum = data.enginInfoNo;
+        this.mainForm.orderDate = data.orderDate;
+        this.mainForm.mainId = data.productCategoryId;
+        this.mainForm.jxsNum = data.customerId;
+        this.mainForm.enginName = data.projectName;
+        this.mainForm.orderType = data.orderType;
+        this.mainForm.jxsName = data.customerName;
+        this.mainForm.company = data.useUnit;
+        this.mainForm.address = data.installAddress;
+        this.mainForm.enginNum = data.projectNo;
+        this.mainForm.factoryNum = data.enginFactoryNo;
+        this.mainForm.loginType = data.enginSignType;
+        this.mainForm.remark = data.remark;
+        this.mainForm.salesMan = data.serviceId;
+        this.mainForm.createMan = data.createName;
+        this.mainForm.createDate = data.createTime;
+        this.mainForm.contractDate = data.contractExpireDate;
+
         this.goodsList = data.items;
       })
     },
 
+    // 获取产品大类列表
     getDictList() {
       getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
         this.typeList = res.data;
@@ -310,8 +375,69 @@ export default {
       this.goodsList.splice(index, 1);
     },
 
-    clickSubmitForm() {
+    clickSubmitForm(type) {
+      this.$refs.mainForm.validate((valid) => {
+        if (valid) {
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(!this.goodsList[i].saleTypeId) {
+              this.$errorMsg('请选择销售类型');
+              return;
+            }
+          }
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(!this.goodsList[i].materialNumber) {
+              this.$errorMsg('请选择产品');
+              return;
+            }
+          }
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(!this.goodsList[i].qty) {
+              this.$errorMsg('请输入数量');
+              return;
+            }
+          }
 
+          let params = {
+            orderDate: this.mainForm.orderDate + ' 00:00:00',
+            productCategoryId: this.mainForm.mainId,
+            projectName: this.mainForm.enginName,
+            orderType: this.mainForm.orderType,
+            useUnit: this.mainForm.company,
+            installAddress: this.mainForm.address,
+            projectNo: this.mainForm.enginNum,
+            enginFactoryNo: this.mainForm.factoryNum,
+            enginSignType: this.mainForm.loginType,
+            remark: this.mainForm.remark,
+            contractExpireDate: this.mainForm.contractDate,
+            items: this.goodsList
+          }
+          if(type === 1) {
+            if(this.listItem) {
+              params.enginInfoId = this.listItem.enginInfoId;
+              editEngin(params).then(res => {
+                this.$successMsg('编辑成功');
+                this.goBack();
+                this.$parent.getList();
+              })
+            }else {
+              addEngin(params).then(res => {
+                this.$successMsg('保存成功');
+                this.goBack();
+                this.$parent.getList();
+              })
+            }
+          }else {
+            if(this.listItem) {
+              params.enginInfoId = this.listItem.enginInfoId;
+            }
+            submitEngin(params).then(res => {
+              this.$successMsg('提交审核成功');
+              this.goBack();
+              this.$parent.getList();
+            })
+          }
+        }
+      })
     },
   }
 }

+ 32 - 6
src/views/supply/engin/engin_list.vue

@@ -89,7 +89,7 @@
         <div class="table">
           <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
             <el-table-column align="center" label="工程信息单" prop="enginInfoNo" min-width="200" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="单据日期" prop="createTime" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="单据日期" prop="orderDate" min-width="160" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="经销商编码" prop="customerId" min-width="120" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="工程名称" prop="projectName" min-width="160" show-overflow-tooltip></el-table-column>
@@ -108,12 +108,18 @@
                 {{scope.row.examineStatus | statusFilter}}
               </template>
             </el-table-column>
-            <el-table-column align="center" label="操作" width="160" fixed="right">
+            <el-table-column align="center" label="操作" width="180" fixed="right">
               <template slot-scope="scope">
+                <el-popconfirm style="margin-right: 10px;" title="确定申请吗?" @onConfirm="handleSubmit(scope.row.enginInfoId)" v-if="scope.row.examineStatus === 'SAVE'" >
+                  <el-button slot="reference" type="text">申请</el-button>
+                </el-popconfirm>
+                <el-popconfirm style="margin-right: 10px;" title="确定撤回吗?" @onConfirm="handleWithdraw(scope.row.enginInfoId)" v-if="scope.row.examineStatus === 'WAIT'" >
+                  <el-button slot="reference" type="text">撤回</el-button>
+                </el-popconfirm>
                 <el-button type="text" @click="toForm(scope.row)" v-if="scope.row.examineStatus === 'SAVE'">编辑</el-button>
-                <el-button type="text" @click="toExamine(scope.row)" v-if="scope.row.examineStatus === 'SAVE'">审批</el-button>
+                <el-button type="text" @click="toExamine(scope.row)" v-if="scope.row.examineStatus === 'WAIT'">审批</el-button>
                 <el-button type="text" @click="toDetail(scope.row)">详情</el-button>
-                <el-popconfirm v-if="scope.row.status" style="margin-left: 10px;" title="确定删除吗?" @onConfirm="handleDelete(scope.row.id)" >
+                <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="handleDelete(scope.row.enginInfoId)" >
                   <el-button slot="reference" type="text">删除</el-button>
                 </el-popconfirm>
               </template>
@@ -144,7 +150,7 @@
 </template>
 
 <script>
-import { getEnginList } from "@/api/supply/engin";
+import { getEnginList, applyEngin, withdrawEngin, deleteEngin } from "@/api/supply/engin";
 import EnginDetail from "@/views/supply/engin/components/engin_detail";
 import EnginForm from "@/views/supply/engin/components/engin_form";
 import EnginExamine from "@/views/supply/engin/components/engin_examine";
@@ -309,8 +315,28 @@ export default {
       this.isShowExamine = false;
     },
 
-    handleDelete(id) {
+    // 申请
+    handleSubmit(id) {
+      applyEngin({id}).then(res => {
+        this.$successMsg();
+        this.getList();
+      })
+    },
 
+    // 撤回
+    handleWithdraw(id) {
+      withdrawEngin({id}).then(res => {
+        this.$successMsg();
+        this.getList();
+      })
+    },
+
+    // 删除
+    handleDelete(id) {
+      deleteEngin({id}).then(res => {
+        this.$successMsg();
+        this.getList();
+      })
     }
   }
 }