|  | @@ -6,17 +6,25 @@
 | 
	
		
			
				|  |  |                     @click="backToList">返回列表
 | 
	
		
			
				|  |  |          </el-button>
 | 
	
		
			
				|  |  |          <div class="upper_right_button">
 | 
	
		
			
				|  |  | +          <el-button type="primary"
 | 
	
		
			
				|  |  | +                     size="small"
 | 
	
		
			
				|  |  | +                     v-if="viewDisabled"
 | 
	
		
			
				|  |  | +                     class="el-button--small-yh"
 | 
	
		
			
				|  |  | +                     :loading="buttonLoading"
 | 
	
		
			
				|  |  | +                     @click.stop="openEdit()">编辑
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  |            <el-button class="el-button--small-yh"
 | 
	
		
			
				|  |  |                       type="primary"
 | 
	
		
			
				|  |  |                       size="small"
 | 
	
		
			
				|  |  |                       :loading="buttonLoading"
 | 
	
		
			
				|  |  | -                     :disabled="!form.id"
 | 
	
		
			
				|  |  | +                     :disabled="!form.id || viewDisabled"
 | 
	
		
			
				|  |  |                       @click.stop="makeInvoice"
 | 
	
		
			
				|  |  | -          >{{viewDisabled?'撤销开票':'确认开票'}}
 | 
	
		
			
				|  |  | +          >{{cancelDisabled?'撤销开票':'确认开票'}}
 | 
	
		
			
				|  |  |            </el-button>
 | 
	
		
			
				|  |  |            <el-button class="el-button--small-yh"
 | 
	
		
			
				|  |  |                       type="primary"
 | 
	
		
			
				|  |  |                       size="small"
 | 
	
		
			
				|  |  | +                     :disabled="viewDisabled"
 | 
	
		
			
				|  |  |                       :loading="buttonLoading"
 | 
	
		
			
				|  |  |                       @click.stop="saveSettlement"
 | 
	
		
			
				|  |  |            >保存数据
 | 
	
	
		
			
				|  | @@ -30,7 +38,6 @@
 | 
	
		
			
				|  |  |        <el-tab-pane label="开票信息" name="second" :key="'second'">
 | 
	
		
			
				|  |  |        </el-tab-pane>
 | 
	
		
			
				|  |  |      </el-tabs>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      <div class="customer-main" style="margin-top: 1px" v-show="show">
 | 
	
		
			
				|  |  |        <containerTitle title="基础信息"></containerTitle>
 | 
	
		
			
				|  |  |        <basic-container>
 | 
	
	
		
			
				|  | @@ -39,7 +46,7 @@
 | 
	
		
			
				|  |  |              <crop-select
 | 
	
		
			
				|  |  |                v-model="form.corpId"
 | 
	
		
			
				|  |  |                corpType="KG"
 | 
	
		
			
				|  |  | -              :disabled="viewDisabled"
 | 
	
		
			
				|  |  | +              :disabled="cancelDisabled || viewDisabled"
 | 
	
		
			
				|  |  |                @getCorpData="returnBack"
 | 
	
		
			
				|  |  |                style="width: 100%"
 | 
	
		
			
				|  |  |              ></crop-select>
 | 
	
	
		
			
				|  | @@ -48,7 +55,7 @@
 | 
	
		
			
				|  |  |              <el-select v-model="form.accountNo"
 | 
	
		
			
				|  |  |                         placeholder="请选择"
 | 
	
		
			
				|  |  |                         @change="accountNoChange"
 | 
	
		
			
				|  |  | -                       :disabled="viewDisabled"
 | 
	
		
			
				|  |  | +                       :disabled="cancelDisabled  || viewDisabled"
 | 
	
		
			
				|  |  |                         clearable
 | 
	
		
			
				|  |  |                         filterable>
 | 
	
		
			
				|  |  |                <el-option v-for="(item,index) in form.bankList"
 | 
	
	
		
			
				|  | @@ -76,13 +83,13 @@
 | 
	
		
			
				|  |  |                         size="small"
 | 
	
		
			
				|  |  |                         :loading="buttonLoading"
 | 
	
		
			
				|  |  |                         icon="el-icon-shopping-cart-2"
 | 
	
		
			
				|  |  | -                       :disabled="viewDisabled"
 | 
	
		
			
				|  |  | +                       :disabled="cancelDisabled || viewDisabled"
 | 
	
		
			
				|  |  |                         @click="selectPurchase">选择销售合同
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
		
			
				|  |  |              <el-button type="warning"
 | 
	
		
			
				|  |  |                         size="small"
 | 
	
		
			
				|  |  |                         :loading="buttonLoading"
 | 
	
		
			
				|  |  | -                       :disabled="selectionList.length === 0 || viewDisabled"
 | 
	
		
			
				|  |  | +                       :disabled="selectionList.length === 0 || cancelDisabled || viewDisabled"
 | 
	
		
			
				|  |  |                         @click="generate">生成开票
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
		
			
				|  |  |            </template>
 | 
	
	
		
			
				|  | @@ -91,7 +98,7 @@
 | 
	
		
			
				|  |  |                type="text"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                icon="el-icon-edit"
 | 
	
		
			
				|  |  | -              :disabled="viewDisabled"
 | 
	
		
			
				|  |  | +              :disabled="cancelDisabled || viewDisabled"
 | 
	
		
			
				|  |  |                @click.stop="rowCell(scope.row,scope.index)"
 | 
	
		
			
				|  |  |              > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
	
		
			
				|  | @@ -99,7 +106,7 @@
 | 
	
		
			
				|  |  |                type="text"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                icon="el-icon-delete"
 | 
	
		
			
				|  |  | -              :disabled="viewDisabled"
 | 
	
		
			
				|  |  | +              :disabled="cancelDisabled || viewDisabled"
 | 
	
		
			
				|  |  |                @click.stop="rowDel(scope.row,scope.index)"
 | 
	
		
			
				|  |  |              >删除
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
	
		
			
				|  | @@ -119,6 +126,7 @@
 | 
	
		
			
				|  |  |                placeholder="请输入"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                @change="amountChange"
 | 
	
		
			
				|  |  | +              @input="thisAmountVerify(row)"
 | 
	
		
			
				|  |  |                oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
 | 
	
		
			
				|  |  |              ></el-input>
 | 
	
		
			
				|  |  |              <span v-else>{{ row.thisAmount }}</span>
 | 
	
	
		
			
				|  | @@ -133,6 +141,7 @@
 | 
	
		
			
				|  |  |            <template slot="remark">
 | 
	
		
			
				|  |  |              <el-input type="textarea"
 | 
	
		
			
				|  |  |                        v-model="form.remark"
 | 
	
		
			
				|  |  | +                      :disabled="viewDisabled"
 | 
	
		
			
				|  |  |                        size="small"
 | 
	
		
			
				|  |  |                        rows="2"
 | 
	
		
			
				|  |  |                        autocomplete="off"
 | 
	
	
		
			
				|  | @@ -155,6 +164,7 @@
 | 
	
		
			
				|  |  |              <el-button type="primary"
 | 
	
		
			
				|  |  |                         size="small"
 | 
	
		
			
				|  |  |                         :loading="buttonLoading"
 | 
	
		
			
				|  |  | +                       :disabled="viewDisabled"
 | 
	
		
			
				|  |  |                         icon="el-icon-plus"
 | 
	
		
			
				|  |  |                         @click="cellAdd">录入
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
	
		
			
				|  | @@ -164,6 +174,7 @@
 | 
	
		
			
				|  |  |                type="text"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                icon="el-icon-edit"
 | 
	
		
			
				|  |  | +              :disabled="viewDisabled"
 | 
	
		
			
				|  |  |                @click.stop="rowCells(scope.row,scope.index)"
 | 
	
		
			
				|  |  |              > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
	
		
			
				|  | @@ -171,10 +182,43 @@
 | 
	
		
			
				|  |  |                type="text"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                icon="el-icon-delete"
 | 
	
		
			
				|  |  | +              :disabled="viewDisabled"
 | 
	
		
			
				|  |  |                @click.stop="rowDels(scope.row,scope.index)"
 | 
	
		
			
				|  |  |              >删除
 | 
	
		
			
				|  |  |              </el-button>
 | 
	
		
			
				|  |  |            </template>
 | 
	
		
			
				|  |  | +          <template slot-scope="{row,index}" slot="serverName">
 | 
	
		
			
				|  |  | +            <span v-if="row.$cellEdit" class="required_fields">*</span>
 | 
	
		
			
				|  |  | +            <breakdown-select
 | 
	
		
			
				|  |  | +              v-if="row.$cellEdit"
 | 
	
		
			
				|  |  | +              v-model="row.serverName"
 | 
	
		
			
				|  |  | +              style="width: 90%"
 | 
	
		
			
				|  |  | +              :configuration="configuration">
 | 
	
		
			
				|  |  | +            </breakdown-select>
 | 
	
		
			
				|  |  | +            <span v-else>{{ row.serverName }}</span>
 | 
	
		
			
				|  |  | +          </template>
 | 
	
		
			
				|  |  | +          <template slot="typeno" slot-scope="{ row, index }">
 | 
	
		
			
				|  |  | +            <span v-if="row.$cellEdit" class="required_fields">*</span>
 | 
	
		
			
				|  |  | +            <el-select
 | 
	
		
			
				|  |  | +              v-if="row.$cellEdit"
 | 
	
		
			
				|  |  | +              v-model="row.typeno"
 | 
	
		
			
				|  |  | +              size="small"
 | 
	
		
			
				|  |  | +              style="width:90% !important;"
 | 
	
		
			
				|  |  | +              filterable
 | 
	
		
			
				|  |  | +              allow-create
 | 
	
		
			
				|  |  | +              default-first-option
 | 
	
		
			
				|  |  | +              clearable
 | 
	
		
			
				|  |  | +            >
 | 
	
		
			
				|  |  | +              <el-option
 | 
	
		
			
				|  |  | +                v-for="(item,index) in typenoList"
 | 
	
		
			
				|  |  | +                :key="index"
 | 
	
		
			
				|  |  | +                :label="item"
 | 
	
		
			
				|  |  | +                :value="item"
 | 
	
		
			
				|  |  | +              >
 | 
	
		
			
				|  |  | +              </el-option>
 | 
	
		
			
				|  |  | +            </el-select>
 | 
	
		
			
				|  |  | +            <span v-else>{{ row.itemType }}</span>
 | 
	
		
			
				|  |  | +          </template>
 | 
	
		
			
				|  |  |            <template slot-scope="{row,index}" slot="unit">
 | 
	
		
			
				|  |  |              <span v-if="row.$cellEdit" class="required_fields">*</span>
 | 
	
		
			
				|  |  |              <el-select  v-if="row.$cellEdit" v-model="row.unit" size="small" placeholder="请选择 单位" style="width: 90%" clearable filterable>
 | 
	
	
		
			
				|  | @@ -269,6 +313,7 @@
 | 
	
		
			
				|  |  |        return {
 | 
	
		
			
				|  |  |          show:true,
 | 
	
		
			
				|  |  |          viewDisabled:false,
 | 
	
		
			
				|  |  | +        cancelDisabled:false, //核销状态
 | 
	
		
			
				|  |  |          form: {},
 | 
	
		
			
				|  |  |          option: {
 | 
	
		
			
				|  |  |            menuBtn: false,
 | 
	
	
		
			
				|  | @@ -480,6 +525,7 @@
 | 
	
		
			
				|  |  |          dataLists:[],
 | 
	
		
			
				|  |  |          itemsForms:{},
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        typenoList:['*'],
 | 
	
		
			
				|  |  |          configuration: {
 | 
	
		
			
				|  |  |            multipleChoices: false,
 | 
	
		
			
				|  |  |            multiple: false,
 | 
	
	
		
			
				|  | @@ -528,6 +574,12 @@
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +      if(this.detailData.view){
 | 
	
		
			
				|  |  | +        this.viewDisabled = true
 | 
	
		
			
				|  |  | +        this.option.disabled = true
 | 
	
		
			
				|  |  | +        this.options.disabled = true
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        if(this.detailData.params){
 | 
	
		
			
				|  |  |          this.buttonLoading = true
 | 
	
		
			
				|  |  |          getDetails(this.detailData.params).then(res =>{
 | 
	
	
		
			
				|  | @@ -571,6 +623,13 @@
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          this.$set(this.form,"amount",thisAmountList.reduce((n,m) => n + m)) //数组内和
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  | +      //本次金额验证
 | 
	
		
			
				|  |  | +      thisAmountVerify(row){
 | 
	
		
			
				|  |  | +        if(parseFloat(row.thisAmount) > parseFloat(row.amount)){
 | 
	
		
			
				|  |  | +          this.$message.warning('本次开票金额不得大于金额!')
 | 
	
		
			
				|  |  | +          this.$set(row,'thisAmount','')
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  |        //选择卡号
 | 
	
		
			
				|  |  |        accountNoChange(value){
 | 
	
		
			
				|  |  |          this.form.bankList.forEach(item =>{
 | 
	
	
		
			
				|  | @@ -591,6 +650,7 @@
 | 
	
		
			
				|  |  |            amount:sum
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          this.$refs.cruds.rowCellAdd(params);
 | 
	
		
			
				|  |  | +        this.activeName = 'second'
 | 
	
		
			
				|  |  |          this.show = false
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        selectPurchase(){
 | 
	
	
		
			
				|  | @@ -611,10 +671,14 @@
 | 
	
		
			
				|  |  |            item.accId = item.id;
 | 
	
		
			
				|  |  |            item.srcOrderno  = item.accSysNo
 | 
	
		
			
				|  |  |            item.billNo  = item.srcBillNo
 | 
	
		
			
				|  |  | +          item.thisAmount = item.amount
 | 
	
		
			
				|  |  | +          item.$cellEdit = true
 | 
	
		
			
				|  |  |            delete item.id;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -          this.$refs.crud.rowCellAdd(item);
 | 
	
		
			
				|  |  | +          this.dataList.push(item)
 | 
	
		
			
				|  |  | +          // this.$refs.crud.rowCellAdd(item);
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | +        //合同号去重加逗号
 | 
	
		
			
				|  |  |          this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ if(item.srcOrderno){return item.srcOrderno}}))).join(','))
 | 
	
		
			
				|  |  |          this.billDetailDialog = false;
 | 
	
		
			
				|  |  |        },
 | 
	
	
		
			
				|  | @@ -622,10 +686,13 @@
 | 
	
		
			
				|  |  |          done(row);
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        cellAdd(){
 | 
	
		
			
				|  |  | -        this.$refs.cruds.rowCellAdd();
 | 
	
		
			
				|  |  | +        this.$refs.cruds.rowCellAdd({typeno : '*'});
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        rowCell(row,index){
 | 
	
		
			
				|  |  | -        this.$refs.crud.rowCell(row, index)
 | 
	
		
			
				|  |  | +        // row.$cellEdit = !row.$cellEdit
 | 
	
		
			
				|  |  | +        this.$set(row,'$cellEdit',!row.$cellEdit)
 | 
	
		
			
				|  |  | +        // this.$refs.crud.rowCell(row, index)
 | 
	
		
			
				|  |  | +        console.log(row.$cellEdit)
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        rowDel(row,index){
 | 
	
		
			
				|  |  |          this.$confirm("确定将选择数据删除?", {
 | 
	
	
		
			
				|  | @@ -656,7 +723,7 @@
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        makeInvoice(){
 | 
	
		
			
				|  |  |          if(this.verificationData()){
 | 
	
		
			
				|  |  | -          this.$confirm(this.viewDisabled?"是否撤销开票":"是否确认开票", "提示", {
 | 
	
		
			
				|  |  | +          this.$confirm(this.cancelDisabled?"是否撤销开票":"是否确认开票", "提示", {
 | 
	
		
			
				|  |  |              confirmButtonText: "确认",
 | 
	
		
			
				|  |  |              cancelButtonText: "取消",
 | 
	
		
			
				|  |  |              type: "warning",
 | 
	
	
		
			
				|  | @@ -690,7 +757,7 @@
 | 
	
		
			
				|  |  |                settlementType:2
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if(!this.viewDisabled){
 | 
	
		
			
				|  |  | +            if(!this.cancelDisabled){
 | 
	
		
			
				|  |  |                //确认开票
 | 
	
		
			
				|  |  |                putFund(params).then(res=>{
 | 
	
		
			
				|  |  |                  if(res.data.success){
 | 
	
	
		
			
				|  | @@ -759,10 +826,10 @@
 | 
	
		
			
				|  |  |          this.form = data;
 | 
	
		
			
				|  |  |          this.oldForm = Object.assign({},data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        this.viewDisabled =  data.foundStatus === "核销完成"?true:false;
 | 
	
		
			
				|  |  | +        this.cancelDisabled =  data.foundStatus === "核销完成"?true:false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          this.option.column.forEach(item=>{
 | 
	
		
			
				|  |  | -          this.$set(item,"disabled",this.viewDisabled)
 | 
	
		
			
				|  |  | +          this.$set(item,"disabled",this.cancelDisabled)
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if(data.itemsList){
 | 
	
	
		
			
				|  | @@ -774,6 +841,19 @@
 | 
	
		
			
				|  |  |            this.oldDataLists = this.deepClone(data.invoiceItemList)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  | +      async openEdit() {
 | 
	
		
			
				|  |  | +        //标签页保存key
 | 
	
		
			
				|  |  | +        this.inDetailsKey(this.$route.name,this.detailData.lockData);
 | 
	
		
			
				|  |  | +        //单据是否锁定
 | 
	
		
			
				|  |  | +        if(!await this.checkLocks(this.detailData.lockData)){
 | 
	
		
			
				|  |  | +          this.onLock(this.detailData.lockData); //上锁
 | 
	
		
			
				|  |  | +          this.viewDisabled = false
 | 
	
		
			
				|  |  | +          this.option = this.$options.data().option;
 | 
	
		
			
				|  |  | +          this.options = this.$options.data().options;
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +          this.$message.warning('此单据已被锁定,请稍后再进行操作!')
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  |        verificationData(){
 | 
	
		
			
				|  |  |          if(contrastObj(this.form,this.oldForm)
 | 
	
		
			
				|  |  |            || contrastList(this.dataList,this.oldDataList)
 | 
	
	
		
			
				|  | @@ -793,6 +873,12 @@
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        backToList() {
 | 
	
		
			
				|  |  | +        //编辑按钮存在 或者为新单  新单是没有lockData的
 | 
	
		
			
				|  |  | +        if(this.viewDisabled || !this.detailData.lockData){
 | 
	
		
			
				|  |  | +          this.$emit("goBack");
 | 
	
		
			
				|  |  | +          return
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
 | 
	
		
			
				|  |  |          ){
 | 
	
		
			
				|  |  |            this.$confirm("是否保存当前页面?", "提示", {
 | 
	
	
		
			
				|  | @@ -803,9 +889,18 @@
 | 
	
		
			
				|  |  |              this.saveSettlement()
 | 
	
		
			
				|  |  |            }).catch(()=>{
 | 
	
		
			
				|  |  |              this.$emit("goBack");
 | 
	
		
			
				|  |  | +          }).finally(()=>{
 | 
	
		
			
				|  |  | +            if(this.form.id){
 | 
	
		
			
				|  |  | +              this.unLock(this.detailData.lockData);
 | 
	
		
			
				|  |  | +              this.leaveDetailsKey(this.$route.name);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |            })
 | 
	
		
			
				|  |  |          }else{
 | 
	
		
			
				|  |  |            this.$emit("goBack");
 | 
	
		
			
				|  |  | +          if(this.form.id){
 | 
	
		
			
				|  |  | +            this.unLock(this.detailData.lockData);
 | 
	
		
			
				|  |  | +            this.leaveDetailsKey(this.$route.name);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |      }
 |