chris 3 лет назад
Родитель
Сommit
71afbd2176

+ 7 - 9
src/views/modules/sale/add-material.vue

@@ -5,7 +5,7 @@
       width="50%"
       :close-on-click-modal="false"
       :visible.sync="visible">
-      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
+      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="100px">
         <el-form-item label="物品名称" prop="name">
           <el-input v-model="dataForm.name" :disabled="display" placeholder="物品名称"></el-input>
         </el-form-item>
@@ -13,24 +13,23 @@
           <el-input v-model="dataForm.specification" :disabled="display" placeholder="型号及规格"></el-input>
         </el-form-item>
         <el-form-item label="数量" prop="cnt">
-          <el-input-number v-model="dataForm.cnt" :disabled="display" :min="1" style="width: 140px;"/>
+          <el-input-number v-model="dataForm.cnt" :disabled="display" :min="1"/>
         </el-form-item>
         <el-form-item label="单位" prop="unitName">
           <el-input v-model="dataForm.unitName" :disabled="display" placeholder="单位"></el-input>
         </el-form-item>
         <el-form-item label="不含税单价" prop="price">
-          <el-input-number v-model="dataForm.price" :disabled="display" :precision="2" :step="0.1" :min="0" style="width: 140px;"/>
+          <el-input-number v-model="dataForm.price" :disabled="display" :precision="2" :step="1" :min="0"/>
         </el-form-item>
         <el-form-item label="含税单价" prop="taxPrice">
-          <el-input-number v-model="dataForm.taxPrice" :disabled="display" :precision="2" :step="0.1" :min="0" style="width: 140px;"/>
+          <el-input-number v-model="dataForm.taxPrice" :disabled="display" :precision="2" :step="1" :min="0"/>
         </el-form-item>
         <el-form-item label="含税总价" prop="taxAmount">
           <span>{{ (dataForm.cnt*dataForm.taxPrice).toFixed(2) }}</span>
         </el-form-item>
         <el-form-item label="税率" prop="taxRateVal">
-          <el-input style="width: 140px" type="number" :step="1" :min="0" v-model="dataForm.taxRateVal" :disabled="display">
-            <template slot="append">%</template>
-          </el-input>
+          <el-input-number :step="1" :min="0" v-model="dataForm.taxRateVal" :disabled="display"/>
+          %
         </el-form-item>
         <el-form-item label="备注" prop="notes">
           <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注"></el-input>
@@ -55,6 +54,7 @@
         transferData: {},
         dataForm: {},
         id: 0,
+        taxRateVal: 0,
         dataRule: {
           name: [{ required: true, message: '物品名称不能为空', trigger: 'blur' }],
           specification: [{ required: true, message: '型号及规格不能为空', trigger: 'blur' }],
@@ -64,8 +64,6 @@
     },
     methods: {
       async init (id, display, transferData) {
-        console.log('id = ' + id)
-        console.log('transferData = ' + JSON.stringify(transferData))
         this.dataForm = {
           cnt: 1,
           price: 0,

+ 33 - 6
src/views/modules/sale/purchase-add-or-update.vue

@@ -45,9 +45,9 @@
               <el-select v-else
                 v-model="dataForm.applierId"
                 remote
-                         filterable
-                         :remote-method="remoteApplier"
-                         @change="onApplierChanged"
+                filterable
+                :remote-method="remoteApplier"
+                @change="onApplierChanged"
                 placeholder="请选择">
                 <el-option
                   v-for="item in optionsApplier"
@@ -157,6 +157,9 @@
             </el-table-column>
           </el-table>
         </el-row>
+        <el-row>
+          <span>合计(含税): {{totalAmount}}</span>
+        </el-row>
         <el-row v-if="!display" style="text-align: center; margin-top: 10px;">
           <el-button type="primary" icon="el-icon-plus" @click="addMaterial"></el-button>
         </el-row>
@@ -192,6 +195,7 @@
         optionsApplier: [],
         materialDetails: [],
         addMaterialVisible: false,
+        totalAmount: 0,
         dataRule: {
           purchaseType: [{ required: true, message: '请选择采购类别', trigger: 'change' }],
           applierId: [{ required: true, message: '请选择申请人', trigger: 'change' }]
@@ -227,6 +231,17 @@
             if (data.data.details) {
               this.materialDetails = []
               this.materialDetails = data.data.details
+              this.calTotal()
+            }
+            // 获取申请人
+            if (data.data.applierId) {
+              this.optionsApplier = []
+              this.optionsApplier.push({
+                code: data.data.applierId,
+                value: data.data.applierName,
+                orgId: data.data.orgId,
+                orgName: data.data.deptName
+              })
             }
           }
         })
@@ -238,10 +253,12 @@
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
+            // 添加采购物品明细
+            this.dataForm.details = this.materialDetails
             this.$http({
-              url: this.$http.adornUrl(`/biz-service/purchase/save`),
+              url: !this.id ? this.$http.adornUrl(`/biz-service/purchase/save`) : this.$http.adornUrl(`/biz-service/purchase/update`),
               method: 'post',
-              data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
+              data: this.$http.adornData(this.dataForm)
             }).then(({data}) => {
               if (data && data.code === '200') {
                 this.$message({
@@ -294,6 +311,7 @@
       },
       deleteMaterialHandle (id) {
         this.materialDetails.splice(this.materialDetails.findIndex((item) => item.id === id))
+        this.calTotal()
       },
       addMaterialCallback (data) {
         if (!data) return
@@ -303,11 +321,20 @@
           this.materialDetails.splice(i)
         }
         this.materialDetails.push(data)
+        this.calTotal()
+      },
+      calTotal () {
+        let total = 0
+        if (this.materialDetails) {
+          this.materialDetails.forEach((item) => {
+            total += item.taxAmount ? Number(item.taxAmount) : 0
+          })
+        }
+        this.totalAmount = total
       },
       // 百分比
       formatPercent (row) {
         if (!row.taxRate) return ''
-        console.log('taxRate: ' + row.taxRate)
         let str = (Number(row.taxRate * 100)).toFixed(0)
         str += '%'
         return str

+ 21 - 4
src/views/modules/sale/purchase.vue

@@ -2,6 +2,9 @@
 <template>
   <div class="purchase">
     <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
+      <el-form-item label="采购编码">
+        <el-input v-model="dataForm.purchaseCode" placeholder="采购编码" clearable/>
+      </el-form-item>
       <el-form-item label="说明">
         <el-input v-model="dataForm.notes" placeholder="说明" clearable/>
       </el-form-item>
@@ -40,7 +43,7 @@
       </el-form-item>
       <el-form-item>
         <el-button @click="search()">查询</el-button>
-        <el-button type="primary" @click="addOrUpdateHandle(0, false)">创建新产品</el-button>
+        <el-button type="primary" @click="addOrUpdateHandle(0, false)">新建采购申请</el-button>
       </el-form-item>
     </el-form>
     <el-table
@@ -158,14 +161,27 @@
         dataListLoading: false,
         dataListSelections: [],
         optionsType: [],
+        // 审批状态:0 待提交 1 待审批 2 审批中 3 审批完成 4 审批不通过
         optionsState: [
           {
             code: '0',
-            value: '未审批'
+            value: '待提交'
           },
           {
             code: '1',
-            value: '审批通过'
+            value: '待审批'
+          },
+          {
+            code: '2',
+            value: '审批中'
+          },
+          {
+            code: '3',
+            value: '审批完成'
+          },
+          {
+            code: '4',
+            value: '审批不通过'
           }
         ]
       }
@@ -198,7 +214,8 @@
           'applyDate': this.dataForm.applyDate ? this.dataForm.applyDate : null,
           'notes': this.dataForm.notes ? this.dataForm.notes : null,
           'purchaseState': this.dataForm.purchaseState ? this.dataForm.purchaseState : null,
-          'purchaseType': this.dataForm.purchaseType ? this.dataForm.purchaseType : null
+          'purchaseType': this.dataForm.purchaseType ? this.dataForm.purchaseType : null,
+          'purchaseCode': this.dataForm.purchaseCode ? this.dataForm.purchaseCode : null
         }
         getPurchaseList(params).then(({data}) => {
           if (data && data.code === '200') {