Bladeren bron

入库完善

wengyuwen 4 jaren geleden
bovenliggende
commit
318a99184e
4 gewijzigde bestanden met toevoegingen van 533 en 168 verwijderingen
  1. 28 6
      src/api/warehouse/inStock.js
  2. 26 9
      src/combination/MainForm.vue
  3. 9 2
      src/combination/listComponent.vue
  4. 470 151
      src/views/warehouse/inStock/index.vue

+ 28 - 6
src/api/warehouse/inStock.js

@@ -25,7 +25,7 @@ export function addSave(data) {
     data: data
   })
 }
-// 新增仓库主(出入库提交)
+// 获取项目名称
 export function getEntry(data) {
   return request({
     url: '/anpin/project/projectName',
@@ -79,6 +79,20 @@ export function canBedelet(data) {
     data: data
   })
 }
+// 判断主表是否可以删除
+export function deletMain(fIds) {
+  return request({
+    url: '/anpin/stockControl/' + fIds,
+    method: 'delete',
+  })
+}
+//删除主表
+export function delFee(fIds) {
+  return request({
+    url: '/anpin/stockControl/remove/' + fIds,
+    method: 'delete',
+  })
+}
 // 修改仓库主(出入库)
 export function updateWarehousebills(data) {
   return request({
@@ -96,12 +110,20 @@ export function delRows(fIds) {
   })
 }
 
-// 导出仓库主(出入库)
-export function exportWarehousebills(query) {
+// 入库确认
+export function addWarehous(data) {
   return request({
-    url: '/warehouseBusiness/inStock/export',
-    method: 'get',
-    params: query
+    url: '/anpin/stockControl/anPinSubmit',
+    method: 'post',
+    data: data
+  })
+}
+// 复制新增
+export function copyNew(data) {
+  return request({
+    url: '/anpin/stockControl/generateReceipts',
+    method: 'post',
+    data: data
   })
 }
 // 状态为6撤销(请核)

+ 26 - 9
src/combination/MainForm.vue

@@ -4,16 +4,16 @@
       <el-row>
         <el-col v-for="(item,index) in searchdata" :span="item.span" :key="index">
           <el-form-item :label="item.name" :label-width="item.labelSize + 'px'" :rules="[item.rules]" :prop="item.label">
-            <el-select v-if="item.form == 1" clearable v-model="form[item.label]" :style="{ width: item.width + 'px' }">
+            <el-select v-if="item.form == 1" filterable @change="changeWarehouse" :disabled="item.disabled" clearable v-model="form[item.label]" :style="{ width: item.width + 'px' }">
               <el-option v-for="(item,index) in item.data"
               :key="index"
               :label="item.label"
               :value="item.value"/>
             </el-select>
-            <el-input v-if="item.form == 2" v-model="form[item.label]" :style="{ width: item.width + 'px' }"></el-input>
-            <el-input v-if="item.form == 4" type="textarea" v-model="form[item.label]" :style="{ width: item.width + 'px' }"></el-input>
-            <el-date-picker v-if="item.form == 3" v-model="form[item.label]" :style="{ width: item.width + 'px' }" type="date" placeholder="选择日期" format="yyyy - MM - dd" value-format="yyyy-MM-dd"></el-date-picker>
-            <span v-if="item.form == 5" v-model="form[item.label]" :style="{ width: item.width + 'px' }"><el-input style="width:50%" v-model="form.first"></el-input><el-input v-model="form.last" style="width:50%"></el-input></span>
+            <el-input v-if="item.form == 2" :disabled="item.disabled" v-model="form[item.label]" :style="{ width: item.width + 'px' }"></el-input>
+            <el-input v-if="item.form == 4":disabled="item.disabled" type="textarea" v-model="form[item.label]" :style="{ width: item.width + 'px' }"></el-input>
+            <el-date-picker v-if="item.form == 3" :disabled="item.disabled" v-model="form[item.label]" :style="{ width: item.width + 'px' }" type="date" placeholder="选择日期" format="yyyy - MM - dd" value-format="yyyy-MM-dd"></el-date-picker>
+            <span v-if="item.form == 5"  v-model="form[item.label]" :style="{ width: item.width + 'px' }"><el-input clearable style="width: 95px;margin-right: 10px" v-model="form.first " oninput='this.value=this.value.replace(/[^\-?\d.]/g,"").replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")'></el-input> <el-input v-model="form.last" clearable oninput='this.value=this.value.replace(/[^\-?\d.]/g,"").replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")' style="width:95px" @change="changeMoney"></el-input></span>
           </el-form-item>
         </el-col>
       </el-row>
@@ -52,15 +52,32 @@ export default {
     console.log(this.searchdata)
   },
   methods:{
-    // hide() {
-    //   this.$emit('handleClick')
-    // },
+    changeWarehouse(){
+      this.$emit('changeWarehouse')
+    },
+    hide() {
+      if(this.form.first && this.form.last){
+        this.form.moneys = [this.form.first,this.form.last]
+      }
+    },
     rules(){
       console.log(this.form)
       this.$refs["form"].validate((valid) => {
         this.$emit('verificationRules',valid)
       })
-    }
+    },
+    saveRules(){
+      this.$refs["form"].validate((valid) => {
+        this.$emit('backSave',valid)
+        console.log("333")
+      })
+    },
+    changeMoney(){
+      if(parseInt(this.form.last) < parseInt(this.form.first)){
+        this.$message.error("第二个金额不能小于第一个金额,请重新输入")
+        this.form.last = ''
+      }
+    },
   }
 }
 </script>

+ 9 - 2
src/combination/listComponent.vue

@@ -84,7 +84,7 @@
             </span>
           </span>
           <span v-else-if="item.changeable && listData">
-            <el-select v-if="item.changeable == 1" filterable :disabled="item.disabled" v-model="scope.row[item.label]" slot="prepend" placeholder="请选择">
+            <el-select v-if="item.changeable == 1" :disabled="item.disabled" v-model="scope.row[item.label]" slot="prepend" placeholder="请选择">
               <el-option
                 v-for="(item,index) in listData[item.label]"
                 :key="index"
@@ -92,11 +92,12 @@
                 :value="item.value"
               ></el-option>
             </el-select>
-            <el-input v-if="item.changeable == 2" :disabled="item.disabled" v-model="scope.row[item.label]" placeholder="请输入内容" :onkeyup="item.onabort"></el-input>
+            <el-input v-if="item.changeable == 2" @input="totalAmount" :disabled="item.disabled" v-model="scope.row[item.label]" placeholder="请输入内容" :onkeyup="item.onabort"></el-input>
             <el-date-picker
               v-if="item.changeable == 3"
               v-model="scope.row[item.label]"
               type="date"
+              :disabled="item.disabled"
               style="width: 100%"
               placeholder="选择日期"
             >
@@ -182,6 +183,9 @@ export default {
       console.log(newValue,oldValue)
       this.queryList.columnList = newValue.columnList
     },
+    listData: function (newValue,oldValue) {
+      console.log(newValue,oldValue)
+    },
   },
   created() {
     console.log(this.listStyle)
@@ -189,6 +193,9 @@ export default {
     console.log(this.queryList.columnList.length)
   },
   methods: {
+    totalAmount(){
+      this.$emit('totalAmount')
+    },
     listTotal(param) {
       const { columns, data } = param
       const sums = []

+ 470 - 151
src/views/warehouse/inStock/index.vue

@@ -4,30 +4,30 @@
       <MainForm
         ref="MainForm"
         :searchdata="formOption"
-        :hidedata="hidedata"
         :display="display"
         :form="queryParms"
         :show="show"
+        :hidedata="hidedata"
         @handleClick="handleClick"
       />
-<!--      <div style="width:40%;margin-left:60%;margin-bottom: -10%">-->
-<!--        <el-button-->
-<!--          type="cyan"-->
-<!--          icon="el-icon-search"-->
-<!--          size="mini"-->
-<!--          @click="handleQuery"-->
-<!--        >搜索</el-button-->
-<!--        >-->
-<!--        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"-->
-<!--        >重置</el-button-->
-<!--        >-->
-<!--        <el-button-->
-<!--          @click="handleClick"-->
-<!--          :icon="arrow"-->
-<!--          size="mini"-->
-<!--        >展开</el-button-->
-<!--        >-->
-<!--      </div>-->
+      <div style="width:40%;margin-left:60%;margin-bottom: -10%">
+        <el-button
+          type="cyan"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+        >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+        >重置</el-button
+        >
+        <el-button
+          @click="handleClick"
+          :icon="arrow"
+          size="mini"
+        >展开</el-button
+        >
+      </div>
       <listComponent
         style="clear:both"
         v-if="waitFor"
@@ -39,6 +39,7 @@
         @buttonList="buttonList"
         @showSearch="showSearch"
         @getList="getList"
+        @feedback="feedback"
         :customButton="customButton"
         :arrow="arrow"
         :seachButton="seachButton"
@@ -56,12 +57,13 @@
       <MainForm
         ref="detailForm"
         :searchdata="detailOption"
-        :hidedata="hideDetail"
         :display="display"
         :form="detailForm"
         :show="show = true"
+        @backRules="backRules"
         @handleClick="handleClick"
         @verificationRules="verificationRules"
+        @changeWarehouse="changeWarehouse"
       />
       <list-component
         v-if="waitFor"
@@ -73,13 +75,15 @@
         @buttonList="buttonList"
         @showSearch="showSearch"
         @getList="getList"
-        @listTotal="listTotal"
         @deletRows="deletRows"
+        @feedback="feedback"
+        @totalAmount="totalAmount"
         :seachButton="confirmButton"
         :customButton="detailButton"
         :listStyle="mainStyle"
         :setRowList="detailStyle"
         :tatolLabel="tatolLabel"
+        :listData="listData"
         :queryList="detailList"/>
     </div>
   </div>
@@ -90,14 +94,26 @@ import { select } from '@/api/system/set'
 import MainForm from '@/combination/MainForm'
 import { listInStock, addSave, getSave, getArea,
   getustomer,getEntry, getwarehouse, getGoodName,
-  canBedelet, delRows, getWarehousekeeper} from '@/api/warehouse/inStock'
+  canBedelet, delRows, getWarehousekeeper, addWarehous,
+  deletMain, delFee, copyNew} from '@/api/warehouse/inStock'
 import Cookies from 'js-cookie'
 export default {
   name: 'inStock',
   data(){
     return{
+      ids:[],
+      listData:{
+        fFeeid:[],
+        fFeeunitid:[],
+        fStltypeid:[],
+        fWarehouseid:[]
+      },
+      selection:[],
+      // 非单个禁用
+      single: true,
       // 总条数
       total: 0,
+      inDex:4,
       tatolLabel:['单价','数量','金额'],
       MainTable:false,
       show: false,
@@ -130,7 +146,7 @@ export default {
           form:2,
           width:200,
           labelSize:'80',
-          rules:''
+          rules: { required:false }
         },
         {
           span:6,
@@ -139,7 +155,7 @@ export default {
           form:1,
           width:200,
           labelSize:'80',
-          rules:'',
+          rules: { required:false },
           data:[]
         },
         {
@@ -149,7 +165,7 @@ export default {
           form:1,
           width:200,
           labelSize:'80',
-          rules:'',
+          rules: { required:false },
           data:[]
         },
         {
@@ -159,8 +175,35 @@ export default {
           form:5,
           width:200,
           labelSize:'80',
-          rules:''
+          rules: { required:false }
         },
+        // {
+        //   span:6,
+        //   label: 'cLoadDate',
+        //   name:"申请日期",
+        //   form:3,
+        //   width:200,
+        //   labelSize:'80',
+        //   rules:''
+        // },
+        // {
+        //   span:6,
+        //   label: 'createBy',
+        //   name:"申请人",
+        //   form:2,
+        //   width:200,
+        //   labelSize:'80',
+        //   rules:''
+        // },
+        // {
+        //   span:6,
+        //   label: 'remark',
+        //   name:"备注",
+        //   form:2,
+        //   width:200,
+        //   labelSize:'80',
+        //   rules:''
+        // },
 
       ],
       //隐藏表单数据
@@ -172,7 +215,7 @@ export default {
           form:3,
           width:200,
           labelSize:'80',
-          rules:''
+          rules: { required:false }
         },
         {
           span:6,
@@ -181,7 +224,7 @@ export default {
           form:2,
           width:200,
           labelSize:'80',
-          rules:''
+          rules: { required:false }
         },
         {
           span:6,
@@ -190,7 +233,7 @@ export default {
           form:2,
           width:200,
           labelSize:'80',
-          rules:''
+          rules: { required:false }
         },
       ],
       //表名称
@@ -230,14 +273,14 @@ export default {
           operation:1
         },{
           surface: "5",
-          label: "fMaterial2",
+          label: "fMoney",
           name: "金额",
           checked: 0,
           width: 200,
           operation:1
         },{
           surface: "6",
-          label: "cLoadDate",
+          label: "createTime",
           name: "申请日期",
           checked: 0,
           width: 200,
@@ -251,7 +294,7 @@ export default {
           operation:1
         },{
           surface: "8",
-          label: "fBillstatus",
+          label: "fBillstatusName",
           name: "状态",
           checked: 0,
           width: 200,
@@ -262,7 +305,7 @@ export default {
           name: "审核日期",
           checked: 0,
           width: 200,
-          operation:1
+          operation:1,
         },{
           surface: "10",
           label: "remark",
@@ -281,10 +324,11 @@ export default {
 
       ],
       //从表数据
+
       detailStyle: [
         {
           surface: "1",
-          label: "fLineNumber",
+          label: "serialNumber",
           name: "序号",
           checked: 0,
           width: 100,
@@ -296,7 +340,7 @@ export default {
           checked: 0,
           width: 200,
           changeable:1,
-          data:[]
+          data:[],
         },{
           surface: "3",
           label: "fUnitprice",
@@ -305,6 +349,8 @@ export default {
           width: 200,
           operation:2,
           changeable:2,
+          disabled:false,
+          onabort:'this.value=this.value.replace(/[^\\d^\\.]+/g,\'\')'
         },{
           surface: "4",
           label: "fQty",
@@ -313,6 +359,8 @@ export default {
           width: 200,
           operation:2,
           changeable:2,
+          disabled:false,
+          onabort:'this.value=this.value.replace(/[^\\d^\\.]+/g,\'\')'
         },{
           surface: "5",
           label: "fFeeunitid",
@@ -321,7 +369,8 @@ export default {
           width: 200,
           changeable:1,
           operation:2,
-          data:[]
+          data:[],
+          disabled:false
         },{
           surface: "6",
           label: "fWarehouseid",
@@ -330,40 +379,47 @@ export default {
           width: 200,
           operation:2,
           changeable:1,
-          data:[]
+          data:[],
+          disabled:false
         },{
           surface: "7",
           label: "fAmount",
           name: "金额",
           checked: 0,
           width: 200,
-          operation:1,
-          changeable: 2
+          operation:2,
+          changeable: 2,
+          disabled: true,
+          doNot:'1'
         },{
           surface: "8",
           label: "fStltypeid",
           name: "付费方式",
           checked: 0,
           width: 200,
-          operation:1,
+          operation:2,
           changeable: 1,
-          data:[]
+          data:[],
+          disabled:false
         },{
           surface: "9",
           label: "remark",
           name: "备注",
           checked: 0,
           width: 200,
-          operation:1,
-          changeable: 2
+          operation:2,
+          changeable: 2,
+          disabled:false
         },{
           surface: "10",
           label: "fReviewDate",
           name: "审核日期",
           checked: 0,
           width: 200,
-          operation:1,
-          changeable: 3
+          operation:2,
+          changeable: 3,
+          disabled:true,
+          doNot:'1'
         },
         {
           surface: "11",
@@ -372,14 +428,17 @@ export default {
           checked: 0,
           width: 200,
           operation:2,
-          changeable: 2
+          changeable: 2,
+          disabled:true,
+          doNot:'1'
         },{
           surface: "12",
           label: "fMaterial10",
           name: "操作",
           checked: 0,
           width: 200,
-          operation:2
+          operation:2,
+          disabled:false
         }
 
       ],
@@ -392,7 +451,9 @@ export default {
           form:2,
           width:200,
           labelSize:'80',
-          rules:''
+          rules:'',
+          disabled:true,
+          doNot:'1'
         },
         {
           span:6,
@@ -402,7 +463,8 @@ export default {
           width:200,
           labelSize:'80',
           rules:{required: false},
-          data:[]
+          data:[],
+          disabled:false
         },
         {
           span:6,
@@ -411,8 +473,9 @@ export default {
           form:1,
           width:200,
           labelSize:'80',
-          rules:'',
-          data:[]
+          rules: {required: false},
+          data:[],
+          disabled:false
         },
         {
           span:6,
@@ -421,8 +484,9 @@ export default {
           form:1,
           width:200,
           labelSize:'80',
-          rules:{ required: true, message: ' 1asdad', trigger: 'blur' },
-          data:[]
+          rules:{ required: true, message: ' ', trigger: 'blur' },
+          data:[],
+          disabled:false
         },
         {
           span:6,
@@ -431,7 +495,8 @@ export default {
           form:3,
           width:200,
           labelSize:'80',
-          rules:''
+          rules:'',
+          disabled:false
         },
         {
           span:6,
@@ -441,7 +506,8 @@ export default {
           width:200,
           labelSize:'80',
           rules:{required: false},
-          data:[]
+          data:[],
+          disabled:false
         },
         {
           span:6,
@@ -450,7 +516,8 @@ export default {
           form:4,
           width:200,
           labelSize:'80',
-          rules:''
+          rules:'',
+          disabled:false
         },
       ],
       //详情主表隐藏
@@ -500,17 +567,11 @@ export default {
           name:'修改',
           disabled:true
         },{
-          type:'danger',
-          size:'mini',
-          icon:'el-icon-delete',
-          name:'删除',
-          disabled:true
-        },{
           type:'info',
           size:'mini',
           icon:'el-icon-plus',
           name:'复制新增',
-          disabled:false
+          disabled:true
         },
       ],
       seachButton:[
@@ -550,9 +611,38 @@ export default {
         },{
           type:'success',
           size:'mini',
-          icon:'el-icon-edit',
+          icon:'el-icon-check',
           name:'保存',
           disabled:false
+        },{
+          type:'info',
+          size:'mini',
+          icon:'el-icon-edit',
+          name:'修改',
+          disabled:false,
+          res:1
+        },{
+          type:'info',
+          size:'mini',
+          icon:'el-icon-edit',
+          name:'打印',
+          disabled:false,
+          res:1
+        },{
+          type:'info',
+          size:'mini',
+          icon:'el-icon-edit',
+          name:'入库确认',
+          disabled:false,
+          res:1
+        },
+        {
+          type:'warning',
+          size:'mini',
+          icon:'el-icon-refresh',
+          name:'刷新',
+          disabled:false,
+          res:1
         }
       ],
       confirmButton:[
@@ -578,6 +668,45 @@ export default {
     this.selectMethods()
   },
   methods:{
+    //更换仓库
+    changeWarehouse(){
+      if(this.detailData.length != 0){
+        for(let li in this.detailData){
+          this.detailData[li].fWarehouseid = ''
+        }
+      }
+      getArea(this.detailForm.fWarehouseid).then(res=>{
+        this.listData.fWarehouseid = []
+        for(let item in res.data){
+          this.listData.fWarehouseid.push({
+            label:res.data[item].fWarehouseInformation,
+            value:res.data[item].id
+          })
+        }
+      })
+    },
+    //自动合计金额
+    totalAmount(){
+      for(let li in this.detailData){
+        if(this.detailData[li].fUnitprice && this.detailData[li].fQty){
+          this.detailData[li].fAmount = (this.detailData[li].fUnitprice * this.detailData[li].fQty).toFixed(2)
+        }
+      }
+    },
+    //搜索、重置、展开
+    feedback(res){
+      if (res == '展开'){
+        if (this.inDex == 4){
+          this.inDex = this.formOption.length
+        }else {
+          this.inDex = 4
+        }
+      }else if (res == '搜索'){
+        this.$refs.avatar.submitForm()
+      }else if (res == '重置'){
+        this.$refs.avatar.form = {}
+      }
+    },
     selectMethods(){
       this.mainMethods()
       this.detailMethods()
@@ -598,7 +727,6 @@ export default {
         }else if(this.formOption[li].name == '客户名称'){
           let queryParams = { pageNum: 1, fTypeid: 1}
           getustomer(queryParams).then(res => {
-            console.log(res)
             for(let item in res.data){
               this.formOption[li].data.push({
                 label:res.data[item].fName,
@@ -659,41 +787,37 @@ export default {
         }
       }
       //获取计量单位字典表
-      for(let li in this.detailStyle) {
-        if (this.detailStyle[li].name == '计量单位') {
-          this.getDicts('data_unitfees').then((response) => {
-            if (response.data) {
-              for (let item in response.data) {
-                this.detailStyle[li].data.push({
-                  label: response.data[item].dictLabel,
-                  value: response.data[item].dictValue
-                })
-              }
-            }
-          })
-        } else if (this.detailStyle[li].name == '付费方式') {
-          this.getDicts('f_paymode').then((response) => {
-            if (response.data) {
-              for (let item in response.data) {
-                this.detailStyle[li].data.push({
-                  label: response.data[item].dictLabel,
-                  value: response.data[item].dictValue
-                })
-              }
-            }
-          })
-        }else if(this.detailStyle[li].name == '品名'){
-          let queryParams = { pageNum: 1 }
-          getGoodName(queryParams).then(res=>{
-            for(let item in res.rows){
-              this.detailStyle[li].data.push({
-                label:res.rows[item].fName,
-                value:res.rows[item].fId
-              })
-            }
+      this.getDicts('data_unitfees').then((response) => {
+        if (response.data) {
+          for (let item in response.data) {
+            this.listData.fFeeunitid.push({
+              label: response.data[item].dictLabel,
+              value: response.data[item].dictValue
+            })
+          }
+        }
+      })
+      //获取品名
+      let queryParams = { pageNum: 1 }
+      getGoodName(queryParams).then(res=>{
+        for(let item in res.rows){
+          this.listData.fFeeid.push({
+            label:res.rows[item].fName,
+            value:res.rows[item].fId
           })
         }
-      }
+      })
+      //付费方式
+      this.getDicts('f_paymode').then((response) => {
+        if (response.data) {
+          for (let item in response.data) {
+            this.listData.fStltypeid.push({
+              label: response.data[item].dictLabel,
+              value: response.data[item].dictValue
+            })
+          }
+        }
+      })
     },
     handleClick(){
       this.show = !this.show
@@ -704,10 +828,14 @@ export default {
       }
     },
     handleQuery(){
-
+      this.$refs.MainForm.hide()
+      this.getList();
     },
     resetQuery(){
+      this.queryParms = {
 
+      }
+      this.handleQuery()
     },
     //查询列数据
     getRow() {
@@ -739,7 +867,14 @@ export default {
     },
     //选择框
     selectionbox(selection){
-      console.log(selection)
+      this.selection = selection
+      this.ids = selection.map((item) => item.fId)
+      this.single = selection.length !== 1
+      for(let li in this.customButton){
+        if(this.customButton[li].name == '修改' || this.customButton[li].name == '复制新增'){
+          this.customButton[li].disabled = this.single
+        }
+      }
     },
     //查看
     viewMethod(scope){
@@ -748,6 +883,7 @@ export default {
       getSave(scope.row.fId).then(res=>{
         if(res.data.warehouseBills){
           this.detailForm = res.data.warehouseBills
+            this.$set(this.detailForm,'fStorekeeper',JSON.parse(this.detailForm.fStorekeeper))
         }
         if(res.data.tWarehousebillsfees){
           this.detailData = res.data.tWarehousebillsfees
@@ -756,6 +892,41 @@ export default {
             this.$set(this.detailData[li],'fStltypeid',JSON.stringify(this.detailData[li].fStltypeid))
           }
         }
+        for(let li in this.detailStyle){
+          this.detailStyle[li].disabled = true
+        }
+        for(let item in this.detailOption){
+          this.detailOption[item].disabled = true
+        }
+        for(let li in this.detailButton){
+          if(this.detailForm.fBillstatus == '6'){
+            if(this.detailButton[li].name == '返回列表'){
+              this.detailButton[li].disabled = false
+            }else if(this.detailButton[li].name == '录入' || this.detailButton[li].name == '保存'
+              || this.detailButton[li].name == '打印' || this.detailButton[li].name == '入库确认'
+              || this.detailButton[li].name == '刷新'){
+              this.detailButton[li].disabled = true
+            }
+          }else if(this.detailButton[li].name == '录入' || this.detailButton[li].name == '保存'
+          || this.detailButton[li].name == '打印' || this.detailButton[li].name == '入库确认'
+          || this.detailButton[li].name == '刷新'){
+            this.detailButton[li].disabled = true
+          }
+        }
+        getArea(this.detailForm.fWarehouseid).then(res=>{
+          this.listData.fWarehouseid = []
+          for(let item in res.data){
+            this.listData.fWarehouseid.push({
+              label:res.data[item].fWarehouseInformation,
+              value:res.data[item].id
+            })
+          }
+        })
+          for(let li in this.detailStyle){
+            if(this.detailStyle[li].name == '库区'){
+
+            }
+          }
         this.MainTable = true
       })
     },
@@ -766,13 +937,47 @@ export default {
     //删除
     deletion(scope){
       console.log(scope)
+      const fIds = scope.row.fId || this.ids;
+      let tips = "";
+      deletMain(fIds).then(res=>{
+        switch (res.msg) {
+          case "0": {
+            this.$message.error("当前数据已被其他操作员操作,请刷新页面");
+            break;
+          }
+          case "1": {
+            tips = "当前主表有数据,确认是否删除?";
+            this.delete_s(fIds, tips);
+            break;
+          }
+          case "2": {
+            tips = "当前主表有数据,从表有数据,确认是否删除?";
+            this.delete_s(fIds, tips);
+            break;
+          }
+          default: {
+            return this.$message.error("未知错误,无状态");
+          }
+        }
+      })
+
+    },
+    delete_s(fIds, tips) {
+      this.$confirm(tips, "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(function () {
+            return delFee(fIds);
+        })
+        .then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        });
     },
     //删除从表行
     deletRows(index,rows){
-      console.log(this.detailForm.fId)
-      console.log(this.detailData)
-      console.log(index)
-      console.log(rows[index].fId)
         if(rows[index].fId){
           let formData = {
               fId:this.detailForm.fId,
@@ -782,6 +987,19 @@ export default {
             return delRows(rows[index].fId)
           })
             .then(()=>{
+              getSave(this.detailForm.fId).then(res=>{
+                if(res.data.warehouseBills){
+                  this.detailForm = res.data.warehouseBills
+                  this.$set(this.detailForm,'fStorekeeper',JSON.parse(this.detailForm.fStorekeeper))
+                }
+                if(res.data.tWarehousebillsfees){
+                  this.detailData = res.data.tWarehousebillsfees
+                  for(let li in this.detailData){
+                    this.$set(this.detailData[li],'fFeeunitid',JSON.stringify(this.detailData[li].fFeeunitid))
+                    this.$set(this.detailData[li],'fStltypeid',JSON.stringify(this.detailData[li].fStltypeid))
+                  }
+                }
+              })
               this.msgSuccess("删除成功");
             })
           .catch(res=>{
@@ -791,6 +1009,7 @@ export default {
           rows.splice(index, 1)
         }
     },
+    //必填项
     verificationRules(valid){
       console.log(valid)
       if(valid){
@@ -799,26 +1018,60 @@ export default {
           fFeeid:null,
           fUnitprice:null,
           fQty:null,
-          fFeeunitid:null,
+          fFeeunitid:'1',
           fWarehouseid:null,
           fAmount:null,
-          fStltypeid:null,
+          fStltypeid:'1',
           remark:null,
           fReviewDate:null,
           createBy:null,
         })
-        for(let li in this.detailStyle){
-          if(this.detailStyle[li].name == '库区'){
-            getArea(this.detailForm.fWarehouseid).then(res=>{
-              for(let item in res.data){
-                this.detailStyle[li].data.push({
-                  label:res.data[item].fWarehouseInformation,
-                  value:res.data[item].id
-                })
-              }
-            })
+      }
+    },
+    //返回列表是否保存
+    backRules(){
+        for(let li in this.detailOption) {
+          if(this.detailOption[li].name == '供应商'){
+            if(this.detailOption[li].disabled == true){
+              this.show = false
+              // row.icon = 'el-icon-arrow-up'
+              this.MainTable = false
+            } else {
+              this.$confirm("返回列表,是否保存?", "提示", {
+                confirmButtonText: "保存",
+                cancelButtonText: "取消",
+                type: "warning",
+              }).then(() => {
+                this.$refs.detailForm.saveRules()
+                }).catch(() => {
+                  this.show = false
+                  // row.icon = 'el-icon-arrow-up'
+                  this.MainTable = false
+                  this.getList();
+                });
+            }
+          }
+        }
+    },
+    backSave(valid){
+      if(valid){
+        this.detailForm.fMoney = 0
+        for(let li in this.detailData){
+          if(this.detailData[li]){
+            this.detailForm.fMoney += Number(this.detailData[li].fAmount)
           }
         }
+        let formData = new window.FormData();
+        formData.append('tWarehousebills', JSON.stringify(this.detailForm))
+        formData.append('tWarehousebillsfees', JSON.stringify(this.detailData))
+        formData.append('fBilltype', 'RK')
+        addSave(formData).then(res=>{
+          this.$message.success("操作成功")
+          this.MainTable = false
+          this.getList();
+          this.show = false
+          row.icon = 'el-icon-arrow-up'
+        })
       }
     },
     //所以按钮
@@ -829,13 +1082,25 @@ export default {
         this.detailList.columnList = this.detailStyle
         this.detailForm = {}
         this.detailData = []
+          //从表修改按钮
+          for(let li in this.detailStyle){
+            if(!this.detailStyle[li].doNot){
+              this.detailStyle[li].disabled = false
+            }
+          }
+          for(let item in this.detailOption){
+            if(!this.detailOption[item].doNot){
+              this.detailOption[item].disabled = false
+            }
+          }
+          for(let li in this.detailButton){
+            this.detailButton[li].disabled = false
+          }
         this.MainTable = true
       }else if(row.name == '录入'){
         this.$refs.detailForm.rules()
       }else if(row.name == '返回列表'){
-        this.show = false
-        row.icon = 'el-icon-arrow-up'
-        this.MainTable = false
+        this.backRules()
       }else if(row.name == '展开'){
         this.show = !this.show
         if(this.show){
@@ -843,17 +1108,99 @@ export default {
         }else{
           row.icon = 'el-icon-arrow-up'
         }
+        this.getList()
       }else if(row.name == '保存'){
-        console.log(this.detailForm)
-        console.log(this.detailData)
+        this.detailForm.fMoney = 0
+        for(let li in this.detailData){
+          if(this.detailData[li]){
+            this.detailForm.fMoney += Number(this.detailData[li].fAmount)
+          }
+        }
         let formData = new window.FormData();
         formData.append('tWarehousebills', JSON.stringify(this.detailForm))
         formData.append('tWarehousebillsfees', JSON.stringify(this.detailData))
         formData.append('fBilltype', 'RK')
         addSave(formData).then(res=>{
-          this.$message.error("操作成功")
+          this.$message.success("操作成功")
+        })
+      }else if(row.name == '入库确认'){
+        this.detailForm.fMoney = 0
+        for(let li in this.detailData){
+          if(this.detailData[li]){
+            this.detailForm.fMoney += Number(this.detailData[li].fAmount)
+          }
+        }
+        let formData = new window.FormData();
+        formData.append('tWarehousebills', JSON.stringify(this.detailForm))
+        formData.append('tWarehousebillsfees', JSON.stringify(this.detailData))
+        formData.append('fBilltype', 'RK')
+        addWarehous(formData).then(res=>{
+          if(res.data.warehouseBills){
+            this.detailForm = res.data.warehouseBills
+            this.$set(this.detailForm,'fStorekeeper',JSON.parse(this.detailForm.fStorekeeper))
+          }
+          if(res.data.tWarehousebillsCntrs){
+            this.detailData = res.data.tWarehousebillsCntrs
+            for(let li in this.detailData){
+            this.$set(this.detailData[li],'fFeeunitid',JSON.stringify(this.detailData[li].fFeeunitid))
+            this.$set(this.detailData[li],'fStltypeid',JSON.stringify(this.detailData[li].fStltypeid))
+          }
+          }
+          this.$message.success("操作成功")
+          for(let li in this.detailStyle){
+            this.detailStyle[li].disabled = true
+          }
+          for(let item in this.detailOption){
+            this.detailOption[item].disabled = true
+          }
+          for(let li in this.detailButton) {
+            if (this.detailButton[li].name == '返回列表') {
+              this.detailButton[li].disabled = false
+            }
+          }
+        })
+      }else if(row.name == '刷新'){
+        getSave(this.detailForm.fId).then(res=>{
+          if(res.data.warehouseBills){
+            this.detailForm = res.data.warehouseBills
+            this.$set(this.detailForm,'fStorekeeper',JSON.parse(this.detailForm.fStorekeeper))
+          }
+          if(res.data.tWarehousebillsfees){
+            this.detailData = res.data.tWarehousebillsfees
+            for(let li in this.detailData){
+              this.$set(this.detailData[li],'fFeeunitid',JSON.stringify(this.detailData[li].fFeeunitid))
+              this.$set(this.detailData[li],'fStltypeid',JSON.stringify(this.detailData[li].fStltypeid))
+            }
+          }
+        })
+      }else if(row.name == '复制新增'){
+        console.log(this.selection[0].fId)
+        let formData = {
+          fBilltype:'RK',
+          fId:this.selection[0].fId
+        }
+        copyNew(formData).then(res=>{
+          this.$message.success("操作成功")
+          this.getList()
         })
       }
+      if(row.res === 1){
+        //从表修改按钮
+        for(let li in this.detailStyle){
+          if(!this.detailStyle[li].doNot){
+            this.detailStyle[li].disabled = false
+          }
+        }
+        for(let item in this.detailOption){
+          if(!this.detailOption[item].doNot){
+            this.detailOption[item].disabled = false
+          }
+        }
+        for(let li in this.detailButton){
+          this.detailButton[li].disabled = false
+        }
+      }
+
     },
     // 显示搜索条件、点击后会调用此方法
     showSearch(){
@@ -861,40 +1208,12 @@ export default {
     },
     //点击刷新会调用此方法
     getList(){
-      console.log('到我了2')
+      this.queryParms.fBilltype = 'RK'
       listInStock(this.queryParms).then(res=>{
-        console.log(res)
         this.tableData = res.rows
         this.total = res.total
       })
     },
-    listTotal(param) {
-      // const { columns, data } = param
-      // const sums = []
-      // console.log(this.detailData)
-      // for(let item in this.detailData){
-        // columns.forEach((column, index) => {
-        //   console.log(index)
-          // if (index === 0) {
-          //   sums[index] = '合计'
-          // } else if (column.label == '单价' || column.label == '数量') {
-          //   const values = data.map((item) => Number(item[column.property]))
-          //   if (!values.every((value) => isNaN(value))) {
-          //     sums[index] = values.reduce((prev, curr) => {
-          //       const value = Number(curr)
-          //       if (!isNaN(value)) {
-          //         return prev + curr
-          //       } else {
-          //         return prev
-          //       }
-          //     }, 0)
-          //   }
-          // }
-      //   })
-      // }
-
-      return sums
-    },
   }
 }
 </script>